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

« back to all changes in this revision

Viewing changes to libpurple/protocols/bonjour/bonjour.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:
41
41
#include "mdns_common.h"
42
42
#include "jabber.h"
43
43
#include "buddy.h"
44
 
 
45
 
/*
46
 
 * TODO: Should implement an add_buddy callback that removes the buddy
47
 
 *       from the local list.  Bonjour manages buddies for you, and
48
 
 *       adding someone locally by hand is stupid.  Or, maybe even better,
49
 
 *       if a PRPL does not have an add_buddy callback then do not allow
50
 
 *       users to add buddies.
51
 
 */
 
44
#include "bonjour_ft.h"
52
45
 
53
46
static char *default_firstname;
54
47
static char *default_lastname;
85
78
                                if (buddy->account != account)
86
79
                                        continue;
87
80
                                purple_prpl_got_user_status(account, buddy->name, "offline", NULL);
 
81
                                purple_account_remove_buddy(account, buddy, NULL);
88
82
                                purple_blist_remove_buddy(buddy);
89
83
                        }
90
84
                }
102
96
 
103
97
#ifdef _WIN32
104
98
        if (!dns_sd_available()) {
105
 
                gc->wants_to_die = TRUE;
106
 
                purple_connection_error(gc,
 
99
                purple_connection_error_reason(gc,
 
100
                        PURPLE_CONNECTION_ERROR_OTHER_ERROR,
107
101
                        _("The Apple Bonjour For Windows toolkit wasn't found, see the FAQ at: "
108
102
                          "http://developer.pidgin.im/wiki/Using%20Pidgin#CanIusePidginforBonjourLink-LocalMessaging"
109
103
                          " for more information."));
121
115
 
122
116
        if (bonjour_jabber_start(bd->jabber_data) == -1) {
123
117
                /* Send a message about the connection error */
124
 
                purple_connection_error(gc, _("Unable to listen for incoming IM connections\n"));
 
118
                purple_connection_error_reason (gc,
 
119
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
120
                        _("Unable to listen for incoming IM connections\n"));
125
121
                return;
126
122
        }
127
123
 
146
142
        bd->dns_sd_data->account = account;
147
143
        if (!bonjour_dns_sd_start(bd->dns_sd_data))
148
144
        {
149
 
                purple_connection_error(gc, _("Unable to establish connection with the local mDNS server.  Is it running?"));
 
145
                purple_connection_error_reason (gc,
 
146
                        PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
 
147
                        _("Unable to establish connection with the local mDNS server.  Is it running?"));
150
148
                return;
151
149
        }
152
150
 
166
164
        PurpleGroup *bonjour_group;
167
165
        BonjourData *bd = connection->proto_data;
168
166
 
 
167
        /* Remove all the bonjour buddies */
 
168
        bonjour_removeallfromlocal(connection);
 
169
 
169
170
        /* Stop looking for buddies in the LAN */
170
171
        if (bd != NULL && bd->dns_sd_data != NULL)
171
172
        {
180
181
                g_free(bd->jabber_data);
181
182
        }
182
183
 
183
 
        /* Remove all the bonjour buddies */
184
 
        bonjour_removeallfromlocal(connection);
185
 
 
186
184
        /* Delete the bonjour group */
187
185
        bonjour_group = purple_find_group(BONJOUR_GROUP_NAME);
188
186
        if (bonjour_group != NULL)
189
187
                purple_blist_remove_group(bonjour_group);
190
188
 
 
189
        /* Cancel any file transfers */
 
190
        while (bd != NULL && bd->xfer_lists) {
 
191
                purple_xfer_cancel_local(bd->xfer_lists->data);
 
192
        }
 
193
 
191
194
        g_free(bd);
192
195
        connection->proto_data = NULL;
193
196
}
249
252
        g_free(stripped);
250
253
}
251
254
 
 
255
/*
 
256
 * The add_buddy callback removes the buddy from the local list.
 
257
 * Bonjour manages buddies for you, and adding someone locally by
 
258
 * hand is stupid.  Perhaps we should change libpurple not to allow adding
 
259
 * if there is no add_buddy callback.
 
260
 */
 
261
static void
 
262
bonjour_fake_add_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group) {
 
263
        purple_debug_error("bonjour", "Buddy '%s' manually added; removing.  "
 
264
                                      "Bonjour buddies must be discovered and not manually added.\n",
 
265
                           purple_buddy_get_name(buddy));
 
266
 
 
267
        /* I suppose we could alert the user here, but it seems unnecessary. */
 
268
 
 
269
        /* If this causes problems, it can be moved to an idle callback */
 
270
        purple_blist_remove_buddy(buddy);
 
271
}
 
272
 
 
273
 
252
274
static void bonjour_remove_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group) {
253
275
        if (buddy->proto_data) {
254
276
                bonjour_buddy_delete(buddy->proto_data);
292
314
        PurpleBuddy *buddy = purple_find_buddy(connection->account, who);
293
315
        BonjourBuddy *bb;
294
316
 
295
 
        if (buddy == NULL)
 
317
        if (buddy == NULL || buddy->proto_data == NULL)
296
318
        {
297
319
                /*
298
320
                 * This buddy is not in our buddy list, and therefore does not really
359
381
        if (message != NULL)
360
382
                purple_notify_user_info_add_pair(user_info, _("Message"), message);
361
383
 
 
384
        if (bb == NULL) {
 
385
                purple_debug_error("bonjour", "Got tooltip request for a buddy without protocol data.\n");
 
386
                return;
 
387
        }
 
388
 
362
389
        /* Only show first/last name if there is a nickname set (to avoid duplication) */
363
390
        if (bb->nick != NULL) {
364
391
                if (bb->first != NULL)
414
441
        bonjour_set_status,                                      /* set_status */
415
442
        NULL,                                                    /* set_idle */
416
443
        NULL,                                                    /* change_passwd */
417
 
        NULL,                                                    /* add_buddy */
 
444
        bonjour_fake_add_buddy,                                  /* add_buddy */
418
445
        NULL,                                                    /* add_buddies */
419
446
        bonjour_remove_buddy,                                    /* remove_buddy */
420
447
        NULL,                                                    /* remove_buddies */
449
476
        NULL,                                                    /* roomlist_cancel */
450
477
        NULL,                                                    /* roomlist_expand_category */
451
478
        NULL,                                                    /* can_receive_file */
452
 
        NULL,                                                    /* send_file */
453
 
        NULL,                                                    /* new_xfer */
 
479
        bonjour_send_file,                                       /* send_file */
 
480
        bonjour_new_xfer,                                        /* new_xfer */
454
481
        NULL,                                                    /* offline_message */
455
482
        NULL,                                                    /* whiteboard_prpl_ops */
456
483
        NULL,                                                    /* send_raw */
476
503
 
477
504
        "prpl-bonjour",                                   /**< id             */
478
505
        "Bonjour",                                        /**< name           */
479
 
        VERSION,                                          /**< version        */
 
506
        DISPLAY_VERSION,                                  /**< version        */
480
507
                                                          /**  summary        */
481
508
        N_("Bonjour Protocol Plugin"),
482
509
                                                          /**  description    */
648
675
        /* TODO: Avoid 'localhost,' if possible */
649
676
        if (gethostname(hostname, 255) != 0) {
650
677
                purple_debug_warning("bonjour", "Error when getting host name: %s.  Using \"localhost.\"\n",
651
 
                                strerror(errno));
 
678
                                g_strerror(errno));
652
679
                strcpy(hostname, "localhost");
653
680
        }
654
681
        default_hostname = g_strdup(hostname);