Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/session.c @ 20418:0f6747c5dcc2
propagate from branch 'im.pidgin.pidgin' (head b0fb787915db137be9b01af88d1fb0c107f66cd6)
to branch 'im.pidgin.cpw.khc.msnp14' (head b26eeab8d7655cb97d30c814bd37041707f692df)
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 20 May 2007 15:48:51 +0000 |
parents | d92776c252b8 7c0a2ef88018 |
children | 703fc3437ab5 |
comparison
equal
deleted
inserted
replaced
17197:c2ecc135867d | 20418:0f6747c5dcc2 |
---|---|
40 session->notification = msn_notification_new(session); | 40 session->notification = msn_notification_new(session); |
41 session->userlist = msn_userlist_new(session); | 41 session->userlist = msn_userlist_new(session); |
42 | 42 |
43 session->user = msn_user_new(session->userlist, | 43 session->user = msn_user_new(session->userlist, |
44 purple_account_get_username(account), NULL); | 44 purple_account_get_username(account), NULL); |
45 | 45 session->bnode = NULL; |
46 session->protocol_ver = 9; | 46 |
47 /*if you want to chat with Yahoo Messenger*/ | |
48 //session->protocol_ver = WLM_YAHOO_PROT_VER; | |
49 session->protocol_ver = WLM_PROT_VER; | |
47 session->conv_seq = 1; | 50 session->conv_seq = 1; |
48 | 51 |
49 return session; | 52 return session; |
50 } | 53 } |
51 | 54 |
68 while (session->slplinks != NULL) | 71 while (session->slplinks != NULL) |
69 msn_slplink_destroy(session->slplinks->data); | 72 msn_slplink_destroy(session->slplinks->data); |
70 | 73 |
71 msn_userlist_destroy(session->userlist); | 74 msn_userlist_destroy(session->userlist); |
72 | 75 |
76 g_free(session->passport_info.t); | |
77 g_free(session->passport_info.p); | |
73 g_free(session->passport_info.kv); | 78 g_free(session->passport_info.kv); |
74 g_free(session->passport_info.sid); | 79 g_free(session->passport_info.sid); |
75 g_free(session->passport_info.mspauth); | 80 g_free(session->passport_info.mspauth); |
76 g_free(session->passport_info.client_ip); | 81 g_free(session->passport_info.client_ip); |
77 | 82 |
85 msn_sync_destroy(session->sync); | 90 msn_sync_destroy(session->sync); |
86 | 91 |
87 if (session->nexus != NULL) | 92 if (session->nexus != NULL) |
88 msn_nexus_destroy(session->nexus); | 93 msn_nexus_destroy(session->nexus); |
89 | 94 |
95 if (session->contact != NULL) | |
96 msn_contact_destroy(session->contact); | |
97 if (session->oim != NULL) | |
98 msn_oim_destroy(session->oim); | |
99 | |
90 if (session->user != NULL) | 100 if (session->user != NULL) |
91 msn_user_destroy(session->user); | 101 msn_user_destroy(session->user); |
92 | 102 |
93 g_free(session); | 103 g_free(session); |
94 } | 104 } |
150 if ((swboard->im_user != NULL) && !strcmp(username, swboard->im_user)) | 160 if ((swboard->im_user != NULL) && !strcmp(username, swboard->im_user)) |
151 return swboard; | 161 return swboard; |
152 } | 162 } |
153 | 163 |
154 return NULL; | 164 return NULL; |
165 } | |
166 | |
167 /*get the conversation*/ | |
168 PurpleConversation * | |
169 msn_session_get_conv(MsnSession *session,const char *passport) | |
170 { | |
171 PurpleAccount *account; | |
172 PurpleConversation * conv; | |
173 | |
174 g_return_val_if_fail(session != NULL, NULL); | |
175 account = session->account; | |
176 | |
177 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, | |
178 passport, account); | |
179 if(conv == NULL){ | |
180 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, passport); | |
181 } | |
182 return conv; | |
183 } | |
184 | |
185 /* put Message to User Conversation | |
186 * | |
187 * passport - the one want to talk to you | |
188 */ | |
189 void | |
190 msn_session_report_user(MsnSession *session,const char *passport,char *msg,PurpleMessageFlags flags) | |
191 { | |
192 PurpleConversation * conv; | |
193 | |
194 if ((conv = msn_session_get_conv(session,passport)) != NULL){ | |
195 purple_conversation_write(conv, NULL, msg, flags, time(NULL)); | |
196 } | |
155 } | 197 } |
156 | 198 |
157 MsnSwitchBoard * | 199 MsnSwitchBoard * |
158 msn_session_find_swboard_with_conv(MsnSession *session, PurpleConversation *conv) | 200 msn_session_find_swboard_with_conv(MsnSession *session, PurpleConversation *conv) |
159 { | 201 { |
217 swboard->flag |= flag; | 259 swboard->flag |= flag; |
218 | 260 |
219 return swboard; | 261 return swboard; |
220 } | 262 } |
221 | 263 |
222 static void | 264 /*setup the bnode, for MSN SOAP contact/address book op*/ |
223 msn_session_sync_users(MsnSession *session) | 265 void |
266 msn_session_set_bnode(MsnSession *session) | |
224 { | 267 { |
225 PurpleBlistNode *gnode, *cnode, *bnode; | 268 PurpleBlistNode *gnode, *cnode, *bnode; |
226 PurpleConnection *gc = purple_account_get_connection(session->account); | 269 PurpleConnection *gc = purple_account_get_connection(session->account); |
227 | 270 |
228 g_return_if_fail(gc != NULL); | 271 g_return_if_fail(gc != NULL); |
229 | 272 |
230 /* The core used to use msn_add_buddy to add all buddies before | 273 /* The core used to use msn_add_buddy to add all buddies before |
231 * being logged in. This no longer happens, so we manually iterate | 274 * being logged in. This no longer happens, so we manually iterate |
232 * over the whole buddy list to identify sync issues. */ | 275 * over the whole buddy list to identify sync issues. */ |
233 | 276 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) |
234 for (gnode = purple_blist_get_root(); gnode; gnode = gnode->next) { | 277 { |
278 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) | |
279 continue; | |
280 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
281 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) | |
282 continue; | |
283 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
284 PurpleBuddy *b; | |
285 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | |
286 continue; | |
287 b = (PurpleBuddy *)bnode; | |
288 if(b->account == gc->account){ | |
289 session->bnode = bnode; | |
290 return; | |
291 } | |
292 } | |
293 } | |
294 } | |
295 session->bnode = NULL; | |
296 } | |
297 | |
298 /*get bnode*/ | |
299 PurpleBlistNode * | |
300 msn_session_get_bnode(MsnSession *session) | |
301 { | |
302 #if 1 | |
303 return session->bnode; | |
304 #else | |
305 return purple_get_blist()->root; | |
306 #endif | |
307 } | |
308 | |
309 static void | |
310 msn_session_sync_users(MsnSession *session) | |
311 { | |
312 PurpleBlistNode *gnode, *cnode, *bnode; | |
313 PurpleConnection *gc = purple_account_get_connection(session->account); | |
314 | |
315 g_return_if_fail(gc != NULL); | |
316 | |
317 /* The core used to use msn_add_buddy to add all buddies before | |
318 * being logged in. This no longer happens, so we manually iterate | |
319 * over the whole buddy list to identify sync issues. | |
320 */ | |
321 for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { | |
235 PurpleGroup *group = (PurpleGroup *)gnode; | 322 PurpleGroup *group = (PurpleGroup *)gnode; |
236 const char *group_name = group->name; | 323 const char *group_name = group->name; |
237 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) | 324 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
238 continue; | 325 continue; |
326 if(!g_strcasecmp(group_name, MSN_INDIVIDUALS_GROUP_NAME) | |
327 || !g_strcasecmp(group_name,MSN_NON_IM_GROUP_NAME)){ | |
328 continue; | |
329 } | |
239 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 330 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
240 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) | 331 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
241 continue; | 332 continue; |
242 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 333 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
243 PurpleBuddy *b; | 334 PurpleBuddy *b; |
250 | 341 |
251 remote_user = msn_userlist_find_user(session->userlist, purple_buddy_get_name(b)); | 342 remote_user = msn_userlist_find_user(session->userlist, purple_buddy_get_name(b)); |
252 | 343 |
253 if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) | 344 if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) |
254 { | 345 { |
255 int group_id; | 346 const char *group_id; |
256 GList *l; | 347 GList *l; |
257 | 348 |
349 purple_debug_info("MaYuan","remote user:{%s}\n",b->name); | |
258 group_id = msn_userlist_find_group_id(remote_user->userlist, | 350 group_id = msn_userlist_find_group_id(remote_user->userlist, |
259 group_name); | 351 group_name); |
352 if(group_id == NULL){ | |
353 continue; | |
354 } | |
355 purple_debug_info("MaYuan","group_id:{%s}\n",group_id); | |
260 | 356 |
261 for (l = remote_user->group_ids; l != NULL; l = l->next) | 357 for (l = remote_user->group_ids; l != NULL; l = l->next) |
262 { | 358 { |
263 if (group_id == GPOINTER_TO_INT(l->data)) | 359 purple_debug_info("MaYuan","l->data:{%s}\n",l->data); |
360 if (!g_strcasecmp(group_id ,l->data)) | |
264 { | 361 { |
265 found = TRUE; | 362 found = TRUE; |
266 break; | 363 break; |
267 } | 364 } |
268 } | 365 } |
269 | |
270 } | 366 } |
271 | 367 |
272 if (!found) | 368 if (!found) |
273 { | 369 { |
274 /* The user was not on the server list or not in that group | 370 /* The user was not on the server list or not in that group |
275 * on the server list */ | 371 * on the server list */ |
276 msn_show_sync_issue(session, purple_buddy_get_name(b), group_name); | 372 msn_show_sync_issue(session, b->name, group_name); |
277 } | 373 } |
278 } | 374 } |
279 } | 375 } |
280 } | 376 } |
281 } | 377 } |
408 * and @msn.com accounts don't automatically get the initial email | 504 * and @msn.com accounts don't automatically get the initial email |
409 * notification so we always request it on login | 505 * notification so we always request it on login |
410 */ | 506 */ |
411 msn_cmdproc_send(session->notification->cmdproc, "URL", "%s", "INBOX"); | 507 msn_cmdproc_send(session->notification->cmdproc, "URL", "%s", "INBOX"); |
412 } | 508 } |
509 |