Changeset 341ab62ab03143302fa354d392ba2f8e585d5300
- Timestamp:
- 12/02/10 15:56:26 (2 years ago)
- Author:
- Armin Burgmeier <armin@…>
- git-author:
- Benjamin Herr <ben@0x539.de> / 2010-02-09T19:50:58Z+0100
- Parents:
- bc626ac1b9062e23d8e3c0f757e7f0ca0199db4b
- Children:
- 61cce2ce9c8b06819912a01dad14af78444f3b64
- git-committer:
- Armin Burgmeier <armin@arbur.net> / 2010-02-12T15:56:26Z+0100
- Message:
-
auth-commands: Handle _TRY_AGAIN auth errors, etc.
2010-02-09 Benjamin Herr <ben@…>
- code/commands/auth-commands.hpp:
- code/commands/auth-commands.cpp: Handle _TRY_AGAIN errors, do
the whole retrying thing properly.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rbc626ac
|
r341ab62
|
|
| | 1 | 2010-02-09 Benjamin Herr <ben@0x539.de> |
| | 2 | |
| | 3 | * code/commands/auth-commands.hpp: |
| | 4 | * code/commands/auth-commands.cpp: Handle _TRY_AGAIN errors, do |
| | 5 | the whole retrying thing properly. |
| | 6 | |
| 1 | 7 | 2010-01-31 Benjamin Herr <ben@0x539.de>, Armin Burgmeier <armin@arbur.net> |
| 2 | 8 | |
-
|
rbc626ac
|
r341ab62
|
|
| 141 | 141 | RetryMap::iterator i = m_retries.find(xmpp); |
| 142 | 142 | if(i == m_retries.end()) |
| | 143 | i = insert_retry_info(xmpp); |
| | 144 | RetryInfo& info(i->second); |
| | 145 | |
| | 146 | if(info.last_password.empty()) |
| 143 | 147 | { |
| 144 | | i = m_retries.insert( |
| 145 | | std::make_pair(xmpp, |
| 146 | | RetryInfo())).first; |
| 147 | | i->second.retries = 0; |
| 148 | | i->second.handle = g_signal_connect( |
| 149 | | G_OBJECT(xmpp), |
| 150 | | "notify::status", |
| 151 | | G_CALLBACK(on_notify_status_static), |
| 152 | | this); |
| | 148 | info.last_password = |
| | 149 | prompt_password(m_parent, xmpp, |
| | 150 | info.retries); |
| | 151 | ++info.retries; |
| | 152 | |
| | 153 | if(info.last_password.empty()) |
| | 154 | return GSASL_NO_PASSWORD; |
| 153 | 155 | } |
| 154 | | RetryInfo& info(i->second); |
| 155 | | |
| 156 | | Glib::ustring password = |
| 157 | | prompt_password(m_parent, xmpp, info.retries); |
| 158 | | ++info.retries; |
| 159 | | |
| 160 | | if(password.empty()) |
| 161 | | return GSASL_NO_PASSWORD; |
| | 156 | |
| 162 | 157 | gsasl_property_set(session, |
| 163 | 158 | GSASL_PASSWORD, |
| 164 | | password.c_str()); |
| | 159 | info.last_password.c_str()); |
| 165 | 160 | return GSASL_OK; |
| 166 | 161 | } |
| … |
… |
|
| 188 | 183 | g_assert(INF_IS_XMPP_CONNECTION(connection)); |
| 189 | 184 | |
| | 185 | InfXmppConnection* xmpp = INF_XMPP_CONNECTION(connection); |
| | 186 | RetryMap::iterator iter = m_retries.find(xmpp); |
| | 187 | if(iter == m_retries.end()) |
| | 188 | iter = insert_retry_info(xmpp); |
| | 189 | Glib::ustring& last_password(iter->second.last_password); |
| | 190 | Glib::ustring old_password; |
| | 191 | |
| | 192 | old_password.swap(last_password); |
| | 193 | |
| 190 | 194 | if(error->domain == |
| 191 | 195 | g_quark_from_static_string("INF_XMPP_CONNECTION_AUTH_ERROR")) |
| 192 | 196 | { |
| 193 | | InfXmppConnection* xmpp = INF_XMPP_CONNECTION(connection); |
| 194 | 197 | const GError* sasl_error = |
| 195 | 198 | inf_xmpp_connection_get_sasl_error(xmpp); |
| 196 | 199 | if(sasl_error != NULL && |
| 197 | 200 | sasl_error->domain == |
| 198 | | inf_authentication_detail_error_quark() && |
| 199 | | sasl_error->code == |
| 200 | | INF_AUTHENTICATION_DETAIL_ERROR_AUTHENTICATION_FAILED) |
| 201 | | { |
| 202 | | GError* my_error = NULL; |
| 203 | | inf_xmpp_connection_retry_sasl_authentication( |
| 204 | | INF_XMPP_CONNECTION(connection), &my_error); |
| 205 | | if(my_error) |
| 206 | | { |
| 207 | | show_error(my_error, m_statusbar, connection); |
| 208 | | g_error_free(my_error); |
| 209 | | } |
| | 201 | inf_authentication_detail_error_quark()) |
| | 202 | { |
| | 203 | handle_error_detail(xmpp, sasl_error, |
| | 204 | old_password, |
| | 205 | last_password); |
| 210 | 206 | } |
| 211 | 207 | else if(sasl_error != NULL) |
| … |
… |
|
| 218 | 214 | } |
| 219 | 215 | } |
| 220 | | else if(error->domain == inf_gsasl_error_quark() || |
| 221 | | error->domain == inf_authentication_detail_error_quark()) |
| | 216 | else if(error->domain == inf_gsasl_error_quark()) |
| 222 | 217 | { |
| 223 | 218 | show_error(error, m_statusbar, connection); |
| 224 | 219 | } |
| | 220 | } |
| | 221 | |
| | 222 | void Gobby::AuthCommands::handle_error_detail(InfXmppConnection* xmpp, |
| | 223 | const GError* detail_error, |
| | 224 | Glib::ustring& old_password, |
| | 225 | Glib::ustring& last_password) |
| | 226 | { |
| | 227 | GError* error = NULL; |
| | 228 | switch(detail_error->code) |
| | 229 | { |
| | 230 | case INF_AUTHENTICATION_DETAIL_ERROR_AUTHENTICATION_FAILED: |
| | 231 | inf_xmpp_connection_retry_sasl_authentication(xmpp, &error); |
| | 232 | break; |
| | 233 | case INF_AUTHENTICATION_DETAIL_ERROR_TRY_AGAIN: |
| | 234 | old_password.swap(last_password); |
| | 235 | inf_xmpp_connection_retry_sasl_authentication(xmpp, &error); |
| | 236 | |
| | 237 | break; |
| | 238 | default: |
| | 239 | show_error(detail_error, m_statusbar, |
| | 240 | INF_XML_CONNECTION(xmpp)); |
| | 241 | break; |
| | 242 | } |
| | 243 | |
| | 244 | if(error) |
| | 245 | { |
| | 246 | show_error(error, m_statusbar, |
| | 247 | INF_XML_CONNECTION(xmpp)); |
| | 248 | g_error_free(error); |
| | 249 | } |
| | 250 | } |
| | 251 | |
| | 252 | Gobby::AuthCommands::RetryMap::iterator |
| | 253 | Gobby::AuthCommands::insert_retry_info(InfXmppConnection* xmpp) |
| | 254 | { |
| | 255 | RetryMap::iterator iter = m_retries.insert( |
| | 256 | std::make_pair(xmpp, |
| | 257 | RetryInfo())).first; |
| | 258 | iter->second.retries = 0; |
| | 259 | iter->second.handle = g_signal_connect( |
| | 260 | G_OBJECT(xmpp), |
| | 261 | "notify::status", |
| | 262 | G_CALLBACK(on_notify_status_static), |
| | 263 | this); |
| | 264 | |
| | 265 | return iter; |
| 225 | 266 | } |
| 226 | 267 | |
-
|
r6942859
|
r341ab62
|
|
| 87 | 87 | void browser_error_callback(InfcBrowser* browser, GError* error); |
| 88 | 88 | |
| | 89 | void handle_error_detail(InfXmppConnection* xmpp, |
| | 90 | const GError* detail_error, |
| | 91 | Glib::ustring& old_password, |
| | 92 | Glib::ustring& last_password); |
| | 93 | |
| | 94 | struct RetryInfo { |
| | 95 | unsigned int retries; |
| | 96 | Glib::ustring last_password; |
| | 97 | gulong handle; |
| | 98 | }; |
| | 99 | |
| | 100 | typedef std::map<InfXmppConnection*, RetryInfo> RetryMap; |
| | 101 | |
| | 102 | RetryMap::iterator insert_retry_info(InfXmppConnection* xmpp); |
| | 103 | |
| 89 | 104 | void on_notify_status(InfXmppConnection* connection); |
| 90 | 105 | |
| … |
… |
|
| 95 | 110 | Gsasl* m_gsasl; |
| 96 | 111 | |
| 97 | | struct RetryInfo { |
| 98 | | unsigned int retries; |
| 99 | | gulong handle; |
| 100 | | }; |
| 101 | | |
| 102 | | typedef std::map<InfXmppConnection*, RetryInfo> RetryMap; |
| 103 | 112 | RetryMap m_retries; |
| 104 | 113 | }; |