comparison src/protocols/msn/session.c @ 8808:bbd8cdaf0ad5

[gaim-migrate @ 9570] A massive patch by shx to reorganize MSN some more and add command processor support. This allows us to do cool things like produce more detailed error messages. For example, the Invalid Username dialog now shows the username of the invalid user. I modified the aforementioned dialog so it'll look a little nicer looking, and also mention the account this happened on. It also removes the user from your blist, as there's no point to keeping the user on there. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 25 Apr 2004 22:02:06 +0000
parents 060171053a32
children ffecda0c1f45
comparison
equal deleted inserted replaced
8807:482fc53c969d 8808:bbd8cdaf0ad5
156 156
157 MsnSwitchBoard * 157 MsnSwitchBoard *
158 msn_session_open_switchboard(MsnSession *session) 158 msn_session_open_switchboard(MsnSession *session)
159 { 159 {
160 MsnSwitchBoard *swboard; 160 MsnSwitchBoard *swboard;
161 161 MsnCmdProc *cmdproc;
162 g_return_val_if_fail(session != NULL, NULL); 162
163 163 g_return_val_if_fail(session != NULL, NULL);
164 if (msn_servconn_send_command(session->notification_conn, "XFR", "SB") < 0) 164
165 { 165 cmdproc = session->notification_conn->cmdproc;
166
167 msn_cmdproc_send(cmdproc, "XFR", "%s", "SB");
168
169 if (cmdproc->error)
166 return NULL; 170 return NULL;
167 }
168 171
169 swboard = msn_switchboard_new(session); 172 swboard = msn_switchboard_new(session);
170 173
171 return swboard; 174 return swboard;
172 } 175 }
173 176
174 gboolean 177 gboolean
175 msn_session_change_status(MsnSession *session, const char *state) 178 msn_session_change_status(MsnSession *session, const char *state)
176 { 179 {
177 MsnUser *user = session->user; 180 MsnCmdProc *cmdproc;
181 MsnUser *user;
178 MsnObject *msnobj; 182 MsnObject *msnobj;
179 char buf[MSN_BUF_LEN];
180 183
181 g_return_val_if_fail(session != NULL, FALSE); 184 g_return_val_if_fail(session != NULL, FALSE);
182 g_return_val_if_fail(state != NULL, FALSE); 185 g_return_val_if_fail(state != NULL, FALSE);
183 186
187 user = session->user;
184 msnobj = msn_user_get_object(user); 188 msnobj = msn_user_get_object(user);
185 189
186 if (state != session->away_state) 190 if (state != session->away_state)
187 { 191 {
188 if (session->away_state != NULL) 192 if (session->away_state != NULL)
189 g_free(session->away_state); 193 g_free(session->away_state);
190 194
191 session->away_state = g_strdup(state); 195 session->away_state = g_strdup(state);
192 } 196 }
193 197
198 cmdproc = session->notification_conn->cmdproc;
199
194 if (msnobj == NULL) 200 if (msnobj == NULL)
195 g_snprintf(buf, sizeof(buf), "%s %d", state, MSN_CLIENT_ID); 201 {
202 msn_cmdproc_send(cmdproc, "CHG", "%s %d", state, MSN_CLIENT_ID);
203 }
196 else 204 else
197 { 205 {
198 char *msnobj_str = msn_object_to_string(msnobj); 206 char *msnobj_str = msn_object_to_string(msnobj);
199 207
200 g_snprintf(buf, sizeof(buf), "%s %d %s", state, MSN_CLIENT_ID, 208 msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state, MSN_CLIENT_ID,
201 gaim_url_encode(msnobj_str)); 209 gaim_url_encode(msnobj_str));
202 210
203 g_free(msnobj_str); 211 g_free(msnobj_str);
204 }
205
206 if (!msn_servconn_send_command(session->notification_conn, "CHG", buf))
207 {
208 gaim_connection_error(gaim_account_get_connection(session->account),
209 _("Write error"));
210
211 return FALSE;
212 } 212 }
213 213
214 return TRUE; 214 return TRUE;
215 } 215 }
216 216