comparison libpurple/protocols/msn/servconn.c @ 27644:f24885ec506b

Set the session error after disconnecting the servconn instead of before. The disconnect callback may try to do something that would set another error, thus hiding the original one.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 21 Jul 2009 03:56:44 +0000
parents aac28ab73e9e
children 97ba0d9e6e54
comparison
equal deleted inserted replaced
27643:577bf7ea0395 27644:f24885ec506b
123 **************************************************************************/ 123 **************************************************************************/
124 124
125 void 125 void
126 msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error) 126 msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error)
127 { 127 {
128 char *tmp; 128 MsnSession *session = servconn->session;
129 MsnServConnType type = servconn->type;
129 const char *reason; 130 const char *reason;
130 131
131 const char *names[] = { "Notification", "Switchboard" }; 132 const char *names[] = { "Notification", "Switchboard" };
132 const char *name; 133 const char *name;
133 134
134 name = names[servconn->type]; 135 name = names[type];
135 136
136 switch (error) 137 switch (error)
137 { 138 {
138 case MSN_SERVCONN_ERROR_CONNECT: 139 case MSN_SERVCONN_ERROR_CONNECT:
139 reason = _("Unable to connect"); break; 140 reason = _("Unable to connect"); break;
145 reason = _("Unknown error"); break; 146 reason = _("Unknown error"); break;
146 } 147 }
147 148
148 purple_debug_error("msn", "Connection error from %s server (%s): %s\n", 149 purple_debug_error("msn", "Connection error from %s server (%s): %s\n",
149 name, servconn->host, reason); 150 name, servconn->host, reason);
150 tmp = g_strdup_printf(_("Connection error from %s server:\n%s"), 151
151 name, reason); 152 if (type == MSN_SERVCONN_SB)
152
153 if (servconn->type == MSN_SERVCONN_NS)
154 {
155 msn_session_set_error(servconn->session, MSN_ERROR_SERVCONN, tmp);
156 }
157 else if (servconn->type == MSN_SERVCONN_SB)
158 { 153 {
159 MsnSwitchBoard *swboard; 154 MsnSwitchBoard *swboard;
160 swboard = servconn->cmdproc->data; 155 swboard = servconn->cmdproc->data;
161 if (swboard != NULL) 156 if (swboard != NULL)
162 swboard->error = MSN_SB_ERROR_CONNECTION; 157 swboard->error = MSN_SB_ERROR_CONNECTION;
163 } 158 }
164 159
160 /* servconn->disconnect_cb may destroy servconn, so don't use it again */
165 msn_servconn_disconnect(servconn); 161 msn_servconn_disconnect(servconn);
166 162
167 g_free(tmp); 163 if (type == MSN_SERVCONN_NS)
164 {
165 char *tmp = g_strdup_printf(_("Connection error from %s server:\n%s"),
166 name, reason);
167 msn_session_set_error(session, MSN_ERROR_SERVCONN, tmp);
168 g_free(tmp);
169 }
168 } 170 }
169 171
170 /************************************************************************** 172 /**************************************************************************
171 * Connect 173 * Connect
172 **************************************************************************/ 174 **************************************************************************/