~ubuntu-branches/ubuntu/hardy/pidgin/hardy

« back to all changes in this revision

Viewing changes to libpurple/protocols/msn/session.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-21 02:48:06 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20071221024806-pd44a5k9tiyh12mp
Tags: 1:2.3.1-2ubuntu1
* Sync with Debian, remaining Ubuntu changes; (LP: #177811)
  - Set Maintainer to Ubuntu Core Developers.
  - Add build-deps on liblaunchpad-integration-dev, intltool,
    libnm-glib-dev (for --enable-nm) (Ubuntu #112720).
  - Drop build-deps on libsilc-1.1-2-dev | libsilc-dev (>= 1.1.1) as 
    this library is in universe.
  - Drop the libpurple0 recommends on libpurple-bin.
  - Add a gaim transitionnal package for upgrades.
  - Ship compatibility symlinks via debian/gaim.links.
  - Pass --enable-nm to configure to enable NetworkManager support.
  - Pass --disable-silc to configure to disable silc support even if 
    it's installed in the build environment.
  - Add X-Ubuntu-Gettext-Domain to the desktop file and update the
    translation templates in common-install-impl::.
   - Update debian/prefs.xml to set the notify plugin prefs
    /plugins/gtk/X11/notify/* and set /pidgin/plugins/loaded to load 
    the notify plugin; Ubuntu: #13389.
  - Add LPI integration patch, 02_lpi.
  - Add patch 04_let_crasher_for_apport to stop catching the SIGSEGV signal
    and let apport handle it.
  - Add patch 05_default_to_irc_ubuntu_com to set the default IRC 
    server to irc.ubuntu.com.
  - Add autoconf patch, 70_autoconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "msn.h"
25
25
#include "session.h"
26
26
#include "notification.h"
 
27
#include "oim.h"
27
28
 
28
29
#include "dialog.h"
29
30
 
42
43
 
43
44
        session->user = msn_user_new(session->userlist,
44
45
                                                                 purple_account_get_username(account), NULL);
 
46
        session->oim = msn_oim_new(session);
45
47
 
46
 
        session->protocol_ver = 9;
 
48
        /*if you want to chat with Yahoo Messenger*/
 
49
        //session->protocol_ver = WLM_YAHOO_PROT_VER;
 
50
        session->protocol_ver = WLM_PROT_VER;
47
51
        session->conv_seq = 1;
48
52
 
49
53
        return session;
70
74
 
71
75
        msn_userlist_destroy(session->userlist);
72
76
 
 
77
        g_free(session->passport_info.t);
 
78
        g_free(session->passport_info.p);
73
79
        g_free(session->passport_info.kv);
74
80
        g_free(session->passport_info.sid);
75
81
        g_free(session->passport_info.mspauth);
87
93
        if (session->nexus != NULL)
88
94
                msn_nexus_destroy(session->nexus);
89
95
 
 
96
        if (session->contact != NULL)
 
97
                msn_contact_destroy(session->contact);
 
98
        if (session->oim != NULL)
 
99
                msn_oim_destroy(session->oim);
 
100
 
90
101
        if (session->user != NULL)
91
102
                msn_user_destroy(session->user);
92
103
 
 
104
        if (session->soap_table)
 
105
                g_hash_table_destroy(session->soap_table);
 
106
 
 
107
        if (session->soap_cleanup_handle)
 
108
                purple_timeout_remove(session->soap_cleanup_handle);
 
109
 
93
110
        g_free(session);
94
111
}
95
112
 
121
138
msn_session_disconnect(MsnSession *session)
122
139
{
123
140
        g_return_if_fail(session != NULL);
124
 
        g_return_if_fail(session->connected);
 
141
 
 
142
        if (!session->connected)
 
143
                return;
125
144
 
126
145
        session->connected = FALSE;
127
146
 
154
173
        return NULL;
155
174
}
156
175
 
 
176
static PurpleConversation *
 
177
msn_session_get_conv(MsnSession *session,const char *passport)
 
178
{
 
179
        PurpleAccount *account;
 
180
        PurpleConversation * conv;
 
181
 
 
182
        g_return_val_if_fail(session != NULL, NULL);
 
183
        account = session->account;
 
184
 
 
185
        conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
 
186
                                                                        passport, account);
 
187
        if(conv == NULL){
 
188
                conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, passport);
 
189
        }
 
190
        return conv;
 
191
}
 
192
 
 
193
/* put Message to User Conversation
 
194
 *
 
195
 *      passport - the one want to talk to you
 
196
 */
 
197
void
 
198
msn_session_report_user(MsnSession *session,const char *passport,char *msg,PurpleMessageFlags flags)
 
199
{
 
200
        PurpleConversation * conv;
 
201
 
 
202
        if ((conv = msn_session_get_conv(session,passport)) != NULL){
 
203
                purple_conversation_write(conv, NULL, msg, flags, time(NULL));
 
204
        }
 
205
}
 
206
 
157
207
MsnSwitchBoard *
158
208
msn_session_find_swboard_with_conv(MsnSession *session, PurpleConversation *conv)
159
209
{
229
279
 
230
280
        /* The core used to use msn_add_buddy to add all buddies before
231
281
         * being logged in. This no longer happens, so we manually iterate
232
 
         * over the whole buddy list to identify sync issues. */
233
 
 
234
 
        for (gnode = purple_blist_get_root(); gnode; gnode = gnode->next) {
 
282
         * over the whole buddy list to identify sync issues.
 
283
         */
 
284
        for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
235
285
                PurpleGroup *group = (PurpleGroup *)gnode;
236
 
                const char *group_name = group->name;
 
286
                const char *group_name;
237
287
                if(!PURPLE_BLIST_NODE_IS_GROUP(gnode))
238
288
                        continue;
 
289
                group_name = group->name;
239
290
                for(cnode = gnode->child; cnode; cnode = cnode->next) {
240
291
                        if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
241
292
                                continue;
252
303
 
253
304
                                        if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP))
254
305
                                        {
255
 
                                                int group_id;
256
306
                                                GList *l;
257
307
 
258
 
                                                group_id = msn_userlist_find_group_id(remote_user->userlist,
259
 
                                                                group_name);
260
 
 
261
308
                                                for (l = remote_user->group_ids; l != NULL; l = l->next)
262
309
                                                {
263
 
                                                        if (group_id == GPOINTER_TO_INT(l->data))
 
310
                                                        const char *name = msn_userlist_find_group_name(remote_user->userlist, l->data);
 
311
                                                        if (name && !g_strcasecmp(group_name, name))
264
312
                                                        {
265
313
                                                                found = TRUE;
266
314
                                                                break;
267
315
                                                        }
268
316
                                                }
269
 
 
270
317
                                        }
271
318
 
272
319
                                        if (!found)
286
333
                                          const char *info)
287
334
{
288
335
        PurpleConnection *gc;
 
336
        PurpleConnectionError reason;
289
337
        char *msg;
290
338
 
291
339
        gc = purple_account_get_connection(session->account);
293
341
        switch (error)
294
342
        {
295
343
                case MSN_ERROR_SERVCONN:
 
344
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
296
345
                        msg = g_strdup(info);
297
346
                        break;
298
347
                case MSN_ERROR_UNSUPPORTED_PROTOCOL:
 
348
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
299
349
                        msg = g_strdup(_("Our protocol is not supported by the "
300
350
                                                         "server."));
301
351
                        break;
302
352
                case MSN_ERROR_HTTP_MALFORMED:
 
353
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
303
354
                        msg = g_strdup(_("Error parsing HTTP."));
304
355
                        break;
305
356
                case MSN_ERROR_SIGN_OTHER:
306
 
                        gc->wants_to_die = TRUE;
 
357
                        reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE;
307
358
                        msg = g_strdup(_("You have signed on from another location."));
 
359
                        if (!purple_account_get_remember_password(session->account))
 
360
                                purple_account_set_password(session->account, NULL);
308
361
                        break;
309
362
                case MSN_ERROR_SERV_UNAVAILABLE:
 
363
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
310
364
                        msg = g_strdup(_("The MSN servers are temporarily "
311
365
                                                         "unavailable. Please wait and try "
312
366
                                                         "again."));
313
367
                        break;
314
368
                case MSN_ERROR_SERV_DOWN:
 
369
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
315
370
                        msg = g_strdup(_("The MSN servers are going down "
316
371
                                                         "temporarily."));
317
372
                        break;
318
373
                case MSN_ERROR_AUTH:
319
 
                        gc->wants_to_die = TRUE;
 
374
                        reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
320
375
                        msg = g_strdup_printf(_("Unable to authenticate: %s"),
321
376
                                                                  (info == NULL ) ?
322
377
                                                                  _("Unknown error") : info);
323
378
                        break;
324
379
                case MSN_ERROR_BAD_BLIST:
 
380
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
325
381
                        msg = g_strdup(_("Your MSN buddy list is temporarily "
326
382
                                                         "unavailable. Please wait and try "
327
383
                                                         "again."));
328
384
                        break;
329
385
                default:
 
386
                        reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
330
387
                        msg = g_strdup(_("Unknown error."));
331
388
                        break;
332
389
        }
333
390
 
334
391
        msn_session_disconnect(session);
335
392
 
336
 
        purple_connection_error(gc, msg);
 
393
        purple_connection_error_reason (gc, reason, msg);
337
394
 
338
395
        g_free(msg);
339
396
}
419
476
                msn_cmdproc_send(session->notification->cmdproc, "URL", "%s", "INBOX");
420
477
        }
421
478
}
 
479