Mercurial > pidgin
annotate plugins/gevolution/gevolution.c @ 11038:aedd557f46dd
[gaim-migrate @ 12935]
Patch #1223447 from Richard Laager
"This patch sets the sensitivity to FALSE (i.e. it greys out the menu option) of any buddy node action where callback is NULL. This is so that plugins can put an item in the right-click menu and grey it out selectively instead of being forced to either offer the option or not."
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Thu, 30 Jun 2005 04:16:15 +0000 |
| parents | 50224ac8184d |
| children | bc700cc98b82 |
| rev | line source |
|---|---|
| 8089 | 1 /* |
| 2 * Evolution integration plugin for Gaim | |
| 3 * | |
| 4 * Copyright (C) 2003 Christian Hammond. | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or | |
| 7 * modify it under the terms of the GNU General Public License as | |
| 8 * published by the Free Software Foundation; either version 2 of the | |
| 9 * License, or (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, but | |
| 12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 * General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 19 * 02111-1307, USA. | |
| 20 */ | |
| 21 #include "internal.h" | |
| 9821 | 22 #include "gtkgaim.h" |
| 8089 | 23 |
| 24 #include "connection.h" | |
| 25 #include "debug.h" | |
| 26 #include "prefs.h" | |
| 27 #include "signals.h" | |
| 10831 | 28 #include "util.h" |
| 9954 | 29 #include "version.h" |
| 8089 | 30 |
| 9821 | 31 #include "gtkblist.h" |
| 8089 | 32 #include "gtkconv.h" |
| 33 #include "gtkplugin.h" | |
| 34 #include "gtkutils.h" | |
| 35 | |
| 36 #include "gevolution.h" | |
| 37 | |
| 38 #include <libedata-book/Evolution-DataServer-Addressbook.h> | |
| 39 | |
| 40 #include <libebook/e-book-listener.h> | |
| 41 #include <libedata-book/e-data-book-factory.h> | |
| 42 #include <bonobo/bonobo-main.h> | |
| 43 | |
| 44 #define GEVOLUTION_PLUGIN_ID "gtk-x11-gevolution" | |
| 45 | |
| 46 #define E_DATA_BOOK_FACTORY_OAF_ID \ | |
| 47 "OAFIID:GNOME_Evolution_DataServer_BookFactory" | |
| 48 | |
| 49 enum | |
| 50 { | |
| 51 COLUMN_AUTOADD, | |
| 52 COLUMN_ICON, | |
| 53 COLUMN_SCREENNAME, | |
| 54 COLUMN_DATA, | |
| 55 NUM_COLUMNS | |
| 56 }; | |
| 57 | |
| 58 static GaimBlistUiOps *backup_blist_ui_ops = NULL; | |
| 59 static GaimBlistUiOps *blist_ui_ops = NULL; | |
| 60 static EBook *book = NULL; | |
| 61 static gulong timer = 0; | |
| 62 static gulong book_view_tag = 0; | |
| 63 static EBookView *book_view = NULL; | |
| 64 | |
| 65 static void | |
| 66 update_ims_from_contact(EContact *contact, const char *name, | |
| 67 const char *prpl_id, EContactField field) | |
| 68 { | |
| 69 GList *ims = e_contact_get(contact, field); | |
| 70 GList *l, *l2; | |
| 71 | |
| 72 if (ims == NULL) | |
| 73 return; | |
| 74 | |
| 75 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
| 76 { | |
| 77 GaimConnection *gc = (GaimConnection *)l->data; | |
| 78 GaimAccount *account = gaim_connection_get_account(gc); | |
| 10831 | 79 char *me = g_strdup(gaim_normalize(account, gaim_account_get_username(account))); |
| 8089 | 80 |
| 81 if (strcmp(gaim_account_get_protocol_id(account), prpl_id)) | |
| 82 continue; | |
| 83 | |
| 84 if (!gaim_account_get_bool(account, "gevo-autoadd", FALSE)) | |
| 85 continue; | |
| 86 | |
| 87 for (l2 = ims; l2 != NULL; l2 = l2->next) | |
| 88 { | |
| 10831 | 89 if (gaim_find_buddy(account, l2->data) != NULL || |
| 90 !strcmp(me, gaim_normalize(account, l2->data))) | |
| 8089 | 91 continue; |
| 92 | |
| 93 gevo_add_buddy(account, _("Buddies"), l2->data, name); | |
| 94 } | |
| 10831 | 95 g_free(me); |
| 8089 | 96 } |
| 97 | |
| 98 g_list_foreach(ims, (GFunc)g_free, NULL); | |
| 99 g_list_free(ims); | |
| 100 } | |
| 101 | |
| 102 static void | |
| 103 update_buddies_from_contact(EContact *contact) | |
| 104 { | |
| 105 const char *name; | |
| 106 | |
| 107 name = e_contact_get_const(contact, E_CONTACT_FULL_NAME); | |
| 108 | |
| 109 update_ims_from_contact(contact, name, "prpl-oscar", E_CONTACT_IM_AIM); | |
| 110 update_ims_from_contact(contact, name, "prpl-jabber", E_CONTACT_IM_JABBER); | |
| 111 update_ims_from_contact(contact, name, "prpl-yahoo", E_CONTACT_IM_YAHOO); | |
| 112 update_ims_from_contact(contact, name, "prpl-msn", E_CONTACT_IM_MSN); | |
| 113 update_ims_from_contact(contact, name, "prpl-oscar", E_CONTACT_IM_ICQ); | |
| 114 } | |
| 115 | |
| 116 static void | |
| 117 contacts_changed_cb(EBookView *book_view, const GList *contacts) | |
| 118 { | |
| 119 const GList *l; | |
| 120 | |
| 121 if (gaim_connections_get_all() == NULL) | |
| 122 return; | |
| 123 | |
| 124 for (l = contacts; l != NULL; l = l->next) | |
| 125 { | |
| 126 EContact *contact = (EContact *)l->data; | |
| 127 | |
| 128 update_buddies_from_contact(contact); | |
| 129 } | |
| 130 } | |
| 131 | |
| 132 static void | |
| 133 request_add_buddy(GaimAccount *account, const char *username, | |
| 134 const char *group, const char *alias) | |
| 135 { | |
| 136 if (book == NULL) | |
| 137 { | |
| 138 backup_blist_ui_ops->request_add_buddy(account, username, group, | |
| 139 alias); | |
| 140 } | |
| 141 else | |
| 142 { | |
| 143 gevo_add_buddy_dialog_show(account, username, group, alias); | |
| 144 } | |
| 145 } | |
| 146 | |
| 147 static void | |
| 148 got_book_view_cb(EBook *book, EBookStatus status, EBookView *view, | |
| 149 gpointer user_data) | |
| 150 { | |
| 151 book_view_tag = 0; | |
| 152 | |
| 153 if (status != E_BOOK_ERROR_OK) | |
| 154 { | |
| 155 gaim_debug_error("evolution", "Unable to retrieve book view! :(\n"); | |
| 156 | |
| 157 return; | |
| 158 } | |
| 159 | |
| 160 book_view = view; | |
| 161 | |
| 162 g_object_ref(book_view); | |
| 163 | |
| 164 g_signal_connect(G_OBJECT(book_view), "contacts_changed", | |
| 165 G_CALLBACK(contacts_changed_cb), book); | |
| 166 | |
| 167 g_signal_connect(G_OBJECT(book_view), "contacts_added", | |
| 168 G_CALLBACK(contacts_changed_cb), book); | |
| 169 | |
| 170 e_book_view_start(view); | |
| 171 } | |
| 172 | |
| 173 static void | |
| 174 signed_on_cb(GaimConnection *gc) | |
| 175 { | |
| 176 EBookQuery *query; | |
| 177 gboolean status; | |
| 178 GList *contacts; | |
| 179 GList *l; | |
| 180 | |
| 181 if (book == NULL) | |
| 182 return; | |
| 183 | |
| 184 query = e_book_query_any_field_contains(""); | |
| 185 | |
| 186 status = e_book_get_contacts(book, query, &contacts, NULL); | |
| 187 | |
| 188 e_book_query_unref(query); | |
| 189 | |
| 190 if (!status) | |
| 191 return; | |
| 192 | |
| 193 for (l = contacts; l != NULL; l = l->next) | |
| 194 { | |
| 195 EContact *contact = E_CONTACT(l->data); | |
| 196 | |
| 197 update_buddies_from_contact(contact); | |
| 198 | |
| 199 g_object_unref(contact); | |
| 200 } | |
| 201 | |
| 202 g_list_free(contacts); | |
| 203 } | |
| 204 | |
| 205 static void | |
|
9055
a243d688c93c
[gaim-migrate @ 9831]
Christian Hammond <chipx86@chipx86.com>
parents:
9051
diff
changeset
|
206 menu_item_activate_cb(GaimBlistNode *node, gpointer user_data) |
| 8089 | 207 { |
| 9051 | 208 GaimBuddy *buddy = (GaimBuddy *)node; |
| 8089 | 209 gevo_associate_buddy_dialog_new(buddy); |
| 210 } | |
| 211 | |
| 212 static void | |
| 9051 | 213 blist_node_extended_menu_cb(GaimBlistNode *node, GList **menu) |
| 8089 | 214 { |
| 9051 | 215 GaimBlistNodeAction *act; |
| 216 GaimBuddy *buddy; | |
| 8089 | 217 |
| 9051 | 218 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 219 return; | |
| 220 | |
| 221 buddy = (GaimBuddy *)node; | |
| 222 | |
| 8089 | 223 if (gevo_prpl_is_supported(buddy->account, buddy)) |
| 224 { | |
| 9051 | 225 act = gaim_blist_node_action_new(_("Add to Address Book"), |
|
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10081
diff
changeset
|
226 menu_item_activate_cb, |
|
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10081
diff
changeset
|
227 NULL, NULL); |
| 9051 | 228 *menu = g_list_append(*menu, act); |
| 8089 | 229 } |
| 230 } | |
| 231 | |
| 232 static gboolean | |
| 233 load_timeout(gpointer data) | |
| 234 { | |
| 235 GaimPlugin *plugin = (GaimPlugin *)data; | |
|
8127
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
236 EBookQuery *query; |
| 8089 | 237 |
| 238 timer = 0; | |
| 239 | |
|
10081
ff4be2d1401d
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
10055
diff
changeset
|
240 if (!gevo_load_addressbook(NULL, &book, NULL)) |
| 8089 | 241 return FALSE; |
| 242 | |
|
8127
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
243 query = e_book_query_any_field_contains(""); |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
244 |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
245 book_view_tag = e_book_async_get_book_view(book, query, NULL, -1, |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
246 got_book_view_cb, NULL); |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
247 |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
248 e_book_query_unref(query); |
| 8089 | 249 |
| 9051 | 250 gaim_signal_connect(gaim_blist_get_handle(), "blist-node-extended-menu", |
| 251 plugin, GAIM_CALLBACK(blist_node_extended_menu_cb), NULL); | |
| 8089 | 252 |
| 253 return FALSE; | |
| 254 } | |
| 255 | |
| 256 static gboolean | |
| 257 plugin_load(GaimPlugin *plugin) | |
| 258 { | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
259 gaim_debug_register_category("evolution"); |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
260 |
| 8089 | 261 bonobo_activate(); |
| 262 | |
| 263 backup_blist_ui_ops = gaim_blist_get_ui_ops(); | |
| 264 | |
| 265 blist_ui_ops = g_memdup(backup_blist_ui_ops, sizeof(GaimBlistUiOps)); | |
| 266 blist_ui_ops->request_add_buddy = request_add_buddy; | |
| 267 | |
| 268 gaim_blist_set_ui_ops(blist_ui_ops); | |
| 269 | |
| 270 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
| 271 plugin, GAIM_CALLBACK(signed_on_cb), NULL); | |
| 272 | |
| 273 timer = g_timeout_add(1, load_timeout, plugin); | |
| 274 | |
| 275 return TRUE; | |
| 276 } | |
| 277 | |
| 278 static gboolean | |
| 279 plugin_unload(GaimPlugin *plugin) | |
| 280 { | |
| 281 gaim_blist_set_ui_ops(backup_blist_ui_ops); | |
| 282 | |
| 283 g_free(blist_ui_ops); | |
| 284 | |
| 285 backup_blist_ui_ops = NULL; | |
| 286 blist_ui_ops = NULL; | |
| 287 | |
| 288 if (book_view != NULL) | |
| 289 { | |
| 290 e_book_view_stop(book_view); | |
| 291 g_object_unref(book_view); | |
| 292 book_view = NULL; | |
| 293 } | |
| 294 | |
| 295 if (book != NULL) | |
| 296 { | |
| 297 g_object_unref(book); | |
| 298 book = NULL; | |
| 299 } | |
| 300 | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
301 gaim_debug_unregister_category("evolution"); |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
302 |
| 8089 | 303 return TRUE; |
| 304 } | |
| 305 | |
| 306 static void | |
| 307 plugin_destroy(GaimPlugin *plugin) | |
| 308 { | |
|
10055
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
309 bonobo_debug_shutdown(); |
| 8089 | 310 } |
| 311 | |
| 312 static void | |
| 313 autoadd_toggled_cb(GtkCellRendererToggle *renderer, gchar *path_str, | |
| 314 gpointer data) | |
| 315 { | |
| 316 GaimAccount *account; | |
| 317 GtkTreeModel *model = (GtkTreeModel *)data; | |
| 318 GtkTreeIter iter; | |
| 319 gboolean autoadd; | |
| 320 | |
| 321 gtk_tree_model_get_iter_from_string(model, &iter, path_str); | |
| 322 gtk_tree_model_get(model, &iter, | |
| 323 COLUMN_DATA, &account, | |
| 324 COLUMN_AUTOADD, &autoadd, | |
| 325 -1); | |
| 326 | |
| 327 gaim_account_set_bool(account, "gevo-autoadd", !autoadd); | |
| 328 | |
| 329 gtk_list_store_set(GTK_LIST_STORE(model), &iter, | |
| 330 COLUMN_AUTOADD, !autoadd, | |
| 331 -1); | |
| 332 } | |
| 333 | |
| 334 static GtkWidget * | |
| 335 get_config_frame(GaimPlugin *plugin) | |
| 336 { | |
| 337 GtkWidget *ret; | |
| 338 GtkWidget *vbox; | |
| 339 GtkWidget *label; | |
| 340 GtkWidget *sw; | |
| 341 GtkWidget *treeview; | |
| 342 GtkTreeViewColumn *column; | |
| 343 GtkCellRenderer *renderer; | |
| 344 GdkPixbuf *pixbuf, *scale = NULL; | |
| 345 GtkListStore *model; | |
| 346 GList *l; | |
| 347 | |
| 348 /* Outside container */ | |
| 349 ret = gtk_vbox_new(FALSE, 18); | |
| 350 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 351 | |
| 352 /* Configuration frame */ | |
| 353 vbox = gaim_gtk_make_frame(ret, _("Evolution Integration Configuration")); | |
| 354 | |
| 355 /* Label */ | |
| 356 label = gtk_label_new(_("Select all accounts that buddies should be " | |
| 357 "auto-added to.")); | |
| 358 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 359 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 360 gtk_widget_show(label); | |
| 361 | |
| 362 /* Scrolled window */ | |
| 363 sw = gtk_scrolled_window_new(0, 0); | |
| 364 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 365 GTK_POLICY_AUTOMATIC, | |
| 366 GTK_POLICY_ALWAYS); | |
| 367 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
| 368 GTK_SHADOW_IN); | |
| 369 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 370 gtk_widget_set_size_request(sw, 300, 300); | |
| 371 gtk_widget_show(sw); | |
| 372 | |
| 373 /* Create the list model for the treeview. */ | |
| 374 model = gtk_list_store_new(NUM_COLUMNS, | |
| 375 G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, | |
| 376 G_TYPE_STRING, G_TYPE_POINTER); | |
| 377 | |
| 378 /* Setup the treeview */ | |
| 379 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 380 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
| 381 gtk_container_add(GTK_CONTAINER(sw), treeview); | |
| 382 gtk_widget_show(treeview); | |
| 383 | |
| 384 /* Setup the column */ | |
| 385 column = gtk_tree_view_column_new(); | |
| 386 gtk_tree_view_column_set_title(column, _("Account")); | |
| 387 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
| 388 | |
| 389 /* Checkbox */ | |
| 390 renderer = gtk_cell_renderer_toggle_new(); | |
| 391 | |
| 392 g_signal_connect(G_OBJECT(renderer), "toggled", | |
| 393 G_CALLBACK(autoadd_toggled_cb), model); | |
| 394 | |
| 395 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 396 gtk_tree_view_column_add_attribute(column, renderer, | |
| 397 "active", COLUMN_AUTOADD); | |
| 398 | |
| 399 /* Icon */ | |
| 400 renderer = gtk_cell_renderer_pixbuf_new(); | |
| 401 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 402 gtk_tree_view_column_add_attribute(column, renderer, | |
| 403 "pixbuf", COLUMN_ICON); | |
| 404 | |
| 405 /* Screenname */ | |
| 406 renderer = gtk_cell_renderer_text_new(); | |
| 407 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
| 408 gtk_tree_view_column_add_attribute(column, renderer, | |
| 409 "text", COLUMN_SCREENNAME); | |
| 410 | |
| 411 | |
| 412 /* Populate */ | |
| 413 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) | |
| 414 { | |
| 415 GaimAccount *account = (GaimAccount *)l->data; | |
| 416 GtkTreeIter iter; | |
| 417 | |
| 418 gaim_debug_info("evolution", "Adding account\n"); | |
| 419 | |
| 420 gtk_list_store_append(model, &iter); | |
| 421 | |
| 10884 | 422 pixbuf = gaim_gtk_create_prpl_icon(account); |
| 8089 | 423 |
| 424 if (pixbuf != NULL) | |
| 425 { | |
| 426 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
| 427 GDK_INTERP_BILINEAR); | |
| 428 | |
| 429 if (!gaim_account_is_connected(account)) | |
| 430 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
| 431 } | |
| 432 | |
| 433 gtk_list_store_set(model, &iter, | |
| 434 COLUMN_AUTOADD, | |
| 435 gaim_account_get_bool(account, "gevo-autoadd", | |
| 436 FALSE), | |
| 437 COLUMN_ICON, scale, | |
| 438 COLUMN_SCREENNAME, | |
| 439 gaim_account_get_username(account), | |
| 440 COLUMN_DATA, account, | |
| 441 -1); | |
| 442 | |
| 443 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
| 444 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | |
| 445 } | |
| 446 | |
| 447 gtk_widget_show_all(ret); | |
| 448 | |
| 449 return ret; | |
| 450 } | |
| 451 | |
| 452 static GaimGtkPluginUiInfo ui_info = | |
| 453 { | |
| 454 get_config_frame | |
| 455 }; | |
| 456 | |
| 457 static GaimPluginInfo info = | |
| 458 { | |
| 9954 | 459 GAIM_PLUGIN_MAGIC, |
| 460 GAIM_MAJOR_VERSION, | |
| 461 GAIM_MINOR_VERSION, | |
| 8089 | 462 GAIM_PLUGIN_STANDARD, /**< type */ |
| 463 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ | |
| 464 0, /**< flags */ | |
| 465 NULL, /**< dependencies */ | |
| 466 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 467 | |
| 468 GEVOLUTION_PLUGIN_ID, /**< id */ | |
| 469 N_("Evolution Integration"), /**< name */ | |
| 470 VERSION, /**< version */ | |
| 471 /** summary */ | |
| 472 N_("Provides integration with Ximian Evolution."), | |
| 473 /** description */ | |
| 474 N_("Provides integration with Ximian Evolution."), | |
| 475 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
| 476 GAIM_WEBSITE, /**< homepage */ | |
| 477 | |
| 478 plugin_load, /**< load */ | |
| 479 plugin_unload, /**< unload */ | |
| 480 plugin_destroy, /**< destroy */ | |
| 481 | |
| 482 &ui_info, /**< ui_info */ | |
| 8993 | 483 NULL, /**< extra_info */ |
| 484 NULL, | |
| 485 NULL | |
| 8089 | 486 }; |
| 487 | |
| 488 static void | |
| 489 init_plugin(GaimPlugin *plugin) | |
| 490 { | |
| 491 /* TODO: Change to core-remote when possible. */ | |
| 492 /* info.dependencies = g_list_append(info.dependencies, "gtk-remote"); */ | |
| 493 | |
| 494 /* | |
| 495 * I'm going to rant a little bit here... | |
| 496 * | |
| 497 * For some reason, when we init bonobo from inside a plugin, it will | |
| 498 * segfault when destroyed. The backtraces are within gmodule somewhere. | |
| 499 * There's not much I can do, and I'm not sure where the bug lies. | |
| 500 * However, plugins are only destroyed when Gaim is shutting down. After | |
| 501 * destroying the plugins, gaim ends, and anything else is of course | |
| 502 * freed. That includes this, if we make the module resident, which | |
| 503 * prevents us from being able to actually unload it. | |
| 504 * | |
| 505 * So, in conclusion, this is an evil hack, but it doesn't harm anything | |
| 506 * and it works. | |
| 507 */ | |
| 508 g_module_make_resident(plugin->handle); | |
|
10055
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
509 |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
510 if (!bonobo_init_full(NULL, NULL, bonobo_activation_orb_get(), |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
511 CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
512 { |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
513 gaim_debug_error("evolution", "Unable to initialize bonobo.\n"); |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
514 } |
| 8089 | 515 } |
| 516 | |
| 517 GAIM_INIT_PLUGIN(gevolution, init_plugin, info) |
