Fri, 27 Jul 2007 08:34:40 +0000
- tls_peers certmgr now responds to certificate-stored,
certificate-deleted signals
| 8089 | 1 | /* |
| 15884 | 2 | * Evolution integration plugin for Purple |
| 8089 | 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" | |
| 15577 | 22 | #include "pidgin.h" |
| 8089 | 23 | |
| 24 | #include "connection.h" | |
| 25 | #include "debug.h" | |
| 26 | #include "prefs.h" | |
| 11117 | 27 | #include "notify.h" |
| 8089 | 28 | #include "signals.h" |
|
10831
fbe1ff83d5a9
[gaim-migrate @ 12499]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10662
diff
changeset
|
29 | #include "util.h" |
| 9954 | 30 | #include "version.h" |
| 8089 | 31 | |
|
9821
d02520c59822
[gaim-migrate @ 10692]
Mark Doliner <markdoliner@pidgin.im>
parents:
9354
diff
changeset
|
32 | #include "gtkblist.h" |
| 8089 | 33 | #include "gtkconv.h" |
| 34 | #include "gtkplugin.h" | |
| 35 | #include "gtkutils.h" | |
| 36 | ||
| 37 | #include "gevolution.h" | |
| 38 | ||
| 39 | #include <libedata-book/Evolution-DataServer-Addressbook.h> | |
| 40 | ||
| 41 | #include <libedata-book/e-data-book-factory.h> | |
| 42 | #include <bonobo/bonobo-main.h> | |
| 43 | ||
| 11117 | 44 | #include <glib.h> |
| 45 | ||
| 8089 | 46 | #define GEVOLUTION_PLUGIN_ID "gtk-x11-gevolution" |
| 47 | ||
| 48 | #define E_DATA_BOOK_FACTORY_OAF_ID \ | |
| 49 | "OAFIID:GNOME_Evolution_DataServer_BookFactory" | |
| 50 | ||
| 51 | enum | |
| 52 | { | |
| 53 | COLUMN_AUTOADD, | |
| 54 | COLUMN_ICON, | |
| 55 | COLUMN_SCREENNAME, | |
| 56 | COLUMN_DATA, | |
| 57 | NUM_COLUMNS | |
| 58 | }; | |
| 59 | ||
| 15884 | 60 | static PurpleBlistUiOps *backup_blist_ui_ops = NULL; |
| 61 | static PurpleBlistUiOps *blist_ui_ops = NULL; | |
| 8089 | 62 | static EBook *book = NULL; |
| 63 | static gulong timer = 0; | |
| 64 | static gulong book_view_tag = 0; | |
| 65 | static EBookView *book_view = NULL; | |
| 66 | ||
| 67 | static void | |
| 68 | update_ims_from_contact(EContact *contact, const char *name, | |
| 69 | const char *prpl_id, EContactField field) | |
| 70 | { | |
| 71 | GList *ims = e_contact_get(contact, field); | |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
72 | GList *l, *l2; |
| 8089 | 73 | |
| 74 | if (ims == NULL) | |
| 75 | return; | |
| 76 | ||
| 15884 | 77 | for (l = purple_connections_get_all(); l != NULL; l = l->next) |
| 8089 | 78 | { |
| 15884 | 79 | PurpleConnection *gc = (PurpleConnection *)l->data; |
| 80 | PurpleAccount *account = purple_connection_get_account(gc); | |
|
14848
0cbce2b9b92d
[gaim-migrate @ 17550]
Henning Norén <henning.noren@gmail.com>
parents:
14253
diff
changeset
|
81 | char *me; |
| 8089 | 82 | |
| 15884 | 83 | if (strcmp(purple_account_get_protocol_id(account), prpl_id)) |
| 8089 | 84 | continue; |
| 85 | ||
| 15884 | 86 | if (!purple_account_get_bool(account, "gevo-autoadd", FALSE)) |
| 8089 | 87 | continue; |
| 88 | ||
| 15884 | 89 | me = g_strdup(purple_normalize(account, purple_account_get_username(account))); |
| 8089 | 90 | for (l2 = ims; l2 != NULL; l2 = l2->next) |
| 91 | { | |
| 15884 | 92 | if (purple_find_buddy(account, l2->data) != NULL || |
| 93 | !strcmp(me, purple_normalize(account, l2->data))) | |
| 8089 | 94 | continue; |
| 95 | ||
| 96 | gevo_add_buddy(account, _("Buddies"), l2->data, name); | |
| 97 | } | |
|
10831
fbe1ff83d5a9
[gaim-migrate @ 12499]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10662
diff
changeset
|
98 | g_free(me); |
| 8089 | 99 | } |
| 100 | ||
| 101 | g_list_foreach(ims, (GFunc)g_free, NULL); | |
| 102 | g_list_free(ims); | |
| 103 | } | |
| 104 | ||
| 105 | static void | |
| 106 | update_buddies_from_contact(EContact *contact) | |
| 107 | { | |
| 108 | const char *name; | |
| 109 | ||
| 110 | name = e_contact_get_const(contact, E_CONTACT_FULL_NAME); | |
| 111 | ||
| 112 | update_ims_from_contact(contact, name, "prpl-oscar", E_CONTACT_IM_AIM); | |
| 113 | update_ims_from_contact(contact, name, "prpl-jabber", E_CONTACT_IM_JABBER); | |
| 114 | update_ims_from_contact(contact, name, "prpl-yahoo", E_CONTACT_IM_YAHOO); | |
| 115 | update_ims_from_contact(contact, name, "prpl-msn", E_CONTACT_IM_MSN); | |
| 116 | update_ims_from_contact(contact, name, "prpl-oscar", E_CONTACT_IM_ICQ); | |
|
11054
ba2440c5ee48
[gaim-migrate @ 12992]
Stanislav Brabec <sbrabec@suse.cz>
parents:
11033
diff
changeset
|
117 | update_ims_from_contact(contact, name, "prpl-novell", E_CONTACT_IM_GROUPWISE); |
| 8089 | 118 | } |
| 119 | ||
| 120 | static void | |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
18186
diff
changeset
|
121 | contacts_changed_cb(EBookView *book_view, GList *contacts) |
| 8089 | 122 | { |
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
18186
diff
changeset
|
123 | GList *l; |
| 8089 | 124 | |
| 15884 | 125 | if (purple_connections_get_all() == NULL) |
| 8089 | 126 | return; |
| 127 | ||
| 128 | for (l = contacts; l != NULL; l = l->next) | |
| 129 | { | |
| 130 | EContact *contact = (EContact *)l->data; | |
| 131 | ||
| 132 | update_buddies_from_contact(contact); | |
| 133 | } | |
| 134 | } | |
| 135 | ||
| 136 | static void | |
| 15884 | 137 | request_add_buddy(PurpleAccount *account, const char *username, |
| 8089 | 138 | const char *group, const char *alias) |
| 139 | { | |
| 140 | if (book == NULL) | |
| 141 | { | |
| 142 | backup_blist_ui_ops->request_add_buddy(account, username, group, | |
| 143 | alias); | |
| 144 | } | |
| 145 | else | |
| 146 | { | |
| 147 | gevo_add_buddy_dialog_show(account, username, group, alias); | |
| 148 | } | |
| 149 | } | |
| 150 | ||
| 151 | static void | |
| 152 | got_book_view_cb(EBook *book, EBookStatus status, EBookView *view, | |
| 153 | gpointer user_data) | |
| 154 | { | |
| 155 | book_view_tag = 0; | |
| 156 | ||
| 157 | if (status != E_BOOK_ERROR_OK) | |
| 158 | { | |
| 15884 | 159 | purple_debug_error("evolution", "Unable to retrieve book view! :(\n"); |
| 8089 | 160 | |
| 161 | return; | |
| 162 | } | |
| 163 | ||
| 164 | book_view = view; | |
| 165 | ||
| 166 | g_object_ref(book_view); | |
| 167 | ||
| 168 | g_signal_connect(G_OBJECT(book_view), "contacts_changed", | |
| 169 | G_CALLBACK(contacts_changed_cb), book); | |
| 170 | ||
| 171 | g_signal_connect(G_OBJECT(book_view), "contacts_added", | |
| 172 | G_CALLBACK(contacts_changed_cb), book); | |
| 173 | ||
| 174 | e_book_view_start(view); | |
| 175 | } | |
| 176 | ||
| 177 | static void | |
| 15884 | 178 | signed_on_cb(PurpleConnection *gc) |
| 8089 | 179 | { |
| 180 | EBookQuery *query; | |
| 181 | gboolean status; | |
| 182 | GList *contacts; | |
| 183 | GList *l; | |
| 184 | ||
| 185 | if (book == NULL) | |
| 186 | return; | |
| 187 | ||
| 188 | query = e_book_query_any_field_contains(""); | |
| 189 | ||
| 190 | status = e_book_get_contacts(book, query, &contacts, NULL); | |
| 191 | ||
| 192 | e_book_query_unref(query); | |
| 193 | ||
| 194 | if (!status) | |
| 195 | return; | |
| 196 | ||
| 197 | for (l = contacts; l != NULL; l = l->next) | |
| 198 | { | |
| 199 | EContact *contact = E_CONTACT(l->data); | |
| 200 | ||
| 201 | update_buddies_from_contact(contact); | |
| 202 | ||
| 203 | g_object_unref(contact); | |
| 204 | } | |
| 205 | ||
| 206 | g_list_free(contacts); | |
| 207 | } | |
| 208 | ||
| 209 | static void | |
| 15884 | 210 | menu_item_activate_cb(PurpleBlistNode *node, gpointer user_data) |
| 8089 | 211 | { |
| 15884 | 212 | PurpleBuddy *buddy = (PurpleBuddy *)node; |
| 8089 | 213 | gevo_associate_buddy_dialog_new(buddy); |
| 214 | } | |
| 215 | ||
| 216 | static void | |
| 15884 | 217 | menu_item_send_mail_activate_cb(PurpleBlistNode *node, gpointer user_data) |
| 11117 | 218 | { |
| 15884 | 219 | PurpleBuddy *buddy = (PurpleBuddy *)node; |
| 11117 | 220 | char *mail = NULL; |
| 221 | ||
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
222 | mail = gevo_get_email_for_buddy(buddy); |
| 11117 | 223 | |
| 224 | if (mail != NULL) | |
| 225 | { | |
| 226 | char *app = g_find_program_in_path("evolution"); | |
| 227 | if (app != NULL) | |
| 228 | { | |
| 229 | char *command_line = g_strdup_printf("%s mailto:%s", app, mail); | |
|
18860
3d47d8b63f6a
quote e-mail address before sending it to evolution
Sean Egan <seanegan@pidgin.im>
parents:
18190
diff
changeset
|
230 | char *quoted = g_shell_quote(command_line); |
| 11117 | 231 | g_free(app); |
| 232 | g_free(mail); | |
| 233 | ||
|
18860
3d47d8b63f6a
quote e-mail address before sending it to evolution
Sean Egan <seanegan@pidgin.im>
parents:
18190
diff
changeset
|
234 | g_spawn_command_line_async(quoted, NULL); |
| 11117 | 235 | g_free(command_line); |
|
18860
3d47d8b63f6a
quote e-mail address before sending it to evolution
Sean Egan <seanegan@pidgin.im>
parents:
18190
diff
changeset
|
236 | g_free(quoted); |
| 11117 | 237 | } |
| 238 | else | |
| 239 | { | |
| 15884 | 240 | purple_notify_error(NULL, NULL, _("Unable to send e-mail"), |
| 11117 | 241 | _("The evolution executable was not found in the PATH.")); |
| 242 | } | |
| 243 | } | |
| 244 | else | |
| 245 | { | |
| 15884 | 246 | purple_notify_error(NULL, NULL, _("Unable to send e-mail"), |
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
247 | _("An e-mail address was not found for this buddy.")); |
| 11117 | 248 | } |
| 249 | } | |
| 250 | ||
| 251 | static void | |
| 15884 | 252 | blist_node_extended_menu_cb(PurpleBlistNode *node, GList **menu) |
| 8089 | 253 | { |
| 15884 | 254 | PurpleMenuAction *act; |
| 255 | PurpleBuddy *buddy; | |
| 256 | PurpleAccount *account; | |
|
15025
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
257 | EContact *contact; |
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
258 | char *mail; |
| 8089 | 259 | |
| 15884 | 260 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
| 9051 | 261 | return; |
| 262 | ||
| 15884 | 263 | buddy = (PurpleBuddy *)node; |
| 264 | account = purple_buddy_get_account(buddy); | |
| 9051 | 265 | |
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
266 | if (!gevo_prpl_is_supported(account, buddy)) |
|
15025
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
267 | return; |
|
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
268 | |
|
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
269 | contact = gevo_search_buddy_in_contacts(buddy, NULL); |
|
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
270 | |
|
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
271 | if (contact == NULL) |
| 8089 | 272 | { |
| 15884 | 273 | act = purple_menu_action_new(_("Add to Address Book"), |
| 274 | PURPLE_CALLBACK(menu_item_activate_cb), | |
| 12919 | 275 | NULL, NULL); |
| 9051 | 276 | *menu = g_list_append(*menu, act); |
| 8089 | 277 | } |
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
278 | else |
|
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
279 | g_object_unref(contact); |
|
15025
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
280 | |
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
281 | mail = gevo_get_email_for_buddy(buddy); |
|
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
282 | |
|
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
283 | if (mail != NULL) |
|
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
284 | { |
| 15884 | 285 | act = purple_menu_action_new(_("Send E-Mail"), |
| 286 | PURPLE_CALLBACK(menu_item_send_mail_activate_cb), NULL, NULL); | |
|
15026
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
287 | *menu = g_list_append(*menu, act); |
|
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
288 | g_free(mail); |
|
be82a893c65e
[gaim-migrate @ 17743]
Christian Hammond <chipx86@chipx86.com>
parents:
15025
diff
changeset
|
289 | } |
| 8089 | 290 | } |
| 291 | ||
|
11919
64764637df2a
[gaim-migrate @ 14210]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
292 | /* TODO: Something in here leaks 1 reference to a bonobo object! */ |
| 8089 | 293 | static gboolean |
| 294 | load_timeout(gpointer data) | |
| 295 | { | |
| 15884 | 296 | PurplePlugin *plugin = (PurplePlugin *)data; |
|
8127
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
297 | EBookQuery *query; |
| 8089 | 298 | |
| 299 | timer = 0; | |
| 300 | ||
|
11919
64764637df2a
[gaim-migrate @ 14210]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
301 | /* Maybe this is it? */ |
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
10055
diff
changeset
|
302 | if (!gevo_load_addressbook(NULL, &book, NULL)) |
| 8089 | 303 | return FALSE; |
| 304 | ||
|
8127
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
305 | query = e_book_query_any_field_contains(""); |
|
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
306 | |
|
11919
64764637df2a
[gaim-migrate @ 14210]
Mark Doliner <markdoliner@pidgin.im>
parents:
11256
diff
changeset
|
307 | /* Is it this? */ |
|
8127
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
308 | book_view_tag = e_book_async_get_book_view(book, query, NULL, -1, |
|
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
309 | got_book_view_cb, NULL); |
|
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
310 | |
|
da683b4a5dc0
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
311 | e_book_query_unref(query); |
| 8089 | 312 | |
| 15884 | 313 | purple_signal_connect(purple_blist_get_handle(), "blist-node-extended-menu", |
| 314 | plugin, PURPLE_CALLBACK(blist_node_extended_menu_cb), NULL); | |
| 8089 | 315 | |
| 316 | return FALSE; | |
| 317 | } | |
| 318 | ||
| 319 | static gboolean | |
| 15884 | 320 | plugin_load(PurplePlugin *plugin) |
| 8089 | 321 | { |
| 322 | bonobo_activate(); | |
| 323 | ||
| 15884 | 324 | backup_blist_ui_ops = purple_blist_get_ui_ops(); |
| 8089 | 325 | |
| 15884 | 326 | blist_ui_ops = g_memdup(backup_blist_ui_ops, sizeof(PurpleBlistUiOps)); |
| 8089 | 327 | blist_ui_ops->request_add_buddy = request_add_buddy; |
| 328 | ||
| 15884 | 329 | purple_blist_set_ui_ops(blist_ui_ops); |
| 8089 | 330 | |
| 15884 | 331 | purple_signal_connect(purple_connections_get_handle(), "signed-on", |
| 332 | plugin, PURPLE_CALLBACK(signed_on_cb), NULL); | |
| 8089 | 333 | |
| 334 | timer = g_timeout_add(1, load_timeout, plugin); | |
| 335 | ||
| 336 | return TRUE; | |
| 337 | } | |
| 338 | ||
| 339 | static gboolean | |
| 15884 | 340 | plugin_unload(PurplePlugin *plugin) |
| 8089 | 341 | { |
| 15884 | 342 | purple_blist_set_ui_ops(backup_blist_ui_ops); |
| 8089 | 343 | |
| 344 | g_free(blist_ui_ops); | |
| 345 | ||
| 346 | backup_blist_ui_ops = NULL; | |
| 347 | blist_ui_ops = NULL; | |
| 348 | ||
| 349 | if (book_view != NULL) | |
| 350 | { | |
| 351 | e_book_view_stop(book_view); | |
| 352 | g_object_unref(book_view); | |
| 353 | book_view = NULL; | |
| 354 | } | |
| 355 | ||
| 356 | if (book != NULL) | |
| 357 | { | |
| 358 | g_object_unref(book); | |
| 359 | book = NULL; | |
| 360 | } | |
| 361 | ||
| 362 | return TRUE; | |
| 363 | } | |
| 364 | ||
| 365 | static void | |
| 15884 | 366 | plugin_destroy(PurplePlugin *plugin) |
| 8089 | 367 | { |
| 10055 | 368 | bonobo_debug_shutdown(); |
| 8089 | 369 | } |
| 370 | ||
| 371 | static void | |
| 372 | autoadd_toggled_cb(GtkCellRendererToggle *renderer, gchar *path_str, | |
| 373 | gpointer data) | |
| 374 | { | |
| 15884 | 375 | PurpleAccount *account; |
| 8089 | 376 | GtkTreeModel *model = (GtkTreeModel *)data; |
| 377 | GtkTreeIter iter; | |
| 378 | gboolean autoadd; | |
| 379 | ||
| 380 | gtk_tree_model_get_iter_from_string(model, &iter, path_str); | |
| 381 | gtk_tree_model_get(model, &iter, | |
| 382 | COLUMN_DATA, &account, | |
| 383 | COLUMN_AUTOADD, &autoadd, | |
| 384 | -1); | |
| 385 | ||
| 15884 | 386 | purple_account_set_bool(account, "gevo-autoadd", !autoadd); |
| 8089 | 387 | |
| 388 | gtk_list_store_set(GTK_LIST_STORE(model), &iter, | |
| 389 | COLUMN_AUTOADD, !autoadd, | |
| 390 | -1); | |
| 391 | } | |
| 392 | ||
| 393 | static GtkWidget * | |
| 15884 | 394 | get_config_frame(PurplePlugin *plugin) |
| 8089 | 395 | { |
| 396 | GtkWidget *ret; | |
| 397 | GtkWidget *vbox; | |
| 398 | GtkWidget *label; | |
| 399 | GtkWidget *sw; | |
| 400 | GtkWidget *treeview; | |
| 401 | GtkTreeViewColumn *column; | |
| 402 | GtkCellRenderer *renderer; | |
|
13091
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
12919
diff
changeset
|
403 | GdkPixbuf *pixbuf; |
| 8089 | 404 | GtkListStore *model; |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
405 | GList *l; |
| 8089 | 406 | |
| 407 | /* Outside container */ | |
| 408 | ret = gtk_vbox_new(FALSE, 18); | |
| 409 | gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 410 | ||
| 411 | /* Configuration frame */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
412 | vbox = pidgin_make_frame(ret, _("Evolution Integration Configuration")); |
| 8089 | 413 | |
| 414 | /* Label */ | |
| 415 | label = gtk_label_new(_("Select all accounts that buddies should be " | |
| 416 | "auto-added to.")); | |
| 417 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 418 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 419 | gtk_widget_show(label); | |
| 420 | ||
| 421 | /* Scrolled window */ | |
| 422 | sw = gtk_scrolled_window_new(0, 0); | |
| 423 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 424 | GTK_POLICY_AUTOMATIC, | |
| 425 | GTK_POLICY_ALWAYS); | |
| 426 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
| 427 | GTK_SHADOW_IN); | |
| 428 | gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 429 | gtk_widget_set_size_request(sw, 300, 300); | |
| 430 | gtk_widget_show(sw); | |
| 431 | ||
| 432 | /* Create the list model for the treeview. */ | |
| 433 | model = gtk_list_store_new(NUM_COLUMNS, | |
| 434 | G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, | |
| 435 | G_TYPE_STRING, G_TYPE_POINTER); | |
| 436 | ||
| 437 | /* Setup the treeview */ | |
| 438 | treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 439 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
| 440 | gtk_container_add(GTK_CONTAINER(sw), treeview); | |
| 441 | gtk_widget_show(treeview); | |
| 442 | ||
| 443 | /* Setup the column */ | |
| 444 | column = gtk_tree_view_column_new(); | |
| 445 | gtk_tree_view_column_set_title(column, _("Account")); | |
| 446 | gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
| 447 | ||
| 448 | /* Checkbox */ | |
| 449 | renderer = gtk_cell_renderer_toggle_new(); | |
| 450 | ||
| 451 | g_signal_connect(G_OBJECT(renderer), "toggled", | |
| 452 | G_CALLBACK(autoadd_toggled_cb), model); | |
| 453 | ||
| 454 | gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 455 | gtk_tree_view_column_add_attribute(column, renderer, | |
| 456 | "active", COLUMN_AUTOADD); | |
| 457 | ||
| 458 | /* Icon */ | |
| 459 | renderer = gtk_cell_renderer_pixbuf_new(); | |
| 460 | gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 461 | gtk_tree_view_column_add_attribute(column, renderer, | |
| 462 | "pixbuf", COLUMN_ICON); | |
| 463 | ||
| 464 | /* Screenname */ | |
| 465 | renderer = gtk_cell_renderer_text_new(); | |
| 466 | gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
| 467 | gtk_tree_view_column_add_attribute(column, renderer, | |
| 468 | "text", COLUMN_SCREENNAME); | |
| 469 | ||
| 470 | ||
| 471 | /* Populate */ | |
| 15884 | 472 | for (l = purple_accounts_get_all(); l != NULL; l = l->next) |
| 8089 | 473 | { |
| 15884 | 474 | PurpleAccount *account = (PurpleAccount *)l->data; |
| 8089 | 475 | GtkTreeIter iter; |
| 476 | ||
| 15884 | 477 | purple_debug_info("evolution", "Adding account\n"); |
| 8089 | 478 | |
| 479 | gtk_list_store_append(model, &iter); | |
| 480 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
481 | pixbuf = pidgin_create_prpl_icon(account, 0.5); |
| 15884 | 482 | if ((pixbuf != NULL) && (!purple_account_is_connected(account))) |
|
13091
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
12919
diff
changeset
|
483 | gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE); |
| 8089 | 484 | |
| 485 | gtk_list_store_set(model, &iter, | |
| 486 | COLUMN_AUTOADD, | |
| 15884 | 487 | purple_account_get_bool(account, "gevo-autoadd", |
| 8089 | 488 | FALSE), |
|
13091
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
12919
diff
changeset
|
489 | COLUMN_ICON, pixbuf, |
| 8089 | 490 | COLUMN_SCREENNAME, |
| 15884 | 491 | purple_account_get_username(account), |
| 8089 | 492 | COLUMN_DATA, account, |
| 493 | -1); | |
| 494 | ||
|
13091
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
12919
diff
changeset
|
495 | if (pixbuf != NULL) |
|
b5ed878998dd
[gaim-migrate @ 15452]
Mark Doliner <markdoliner@pidgin.im>
parents:
12919
diff
changeset
|
496 | g_object_unref(G_OBJECT(pixbuf)); |
| 8089 | 497 | } |
| 498 | ||
| 499 | gtk_widget_show_all(ret); | |
| 500 | ||
| 501 | return ret; | |
| 502 | } | |
| 503 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
504 | static PidginPluginUiInfo ui_info = |
| 8089 | 505 | { |
|
12219
2265c26be232
[gaim-migrate @ 14521]
Richard Laager <rlaager@pidgin.im>
parents:
11919
diff
changeset
|
506 | get_config_frame, /**< get_config_frame */ |
|
16788
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
507 | 0, /**< page_num */ |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
508 | /* Padding */ |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
509 | NULL, |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
510 | NULL, |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
511 | NULL, |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
512 | NULL |
| 8089 | 513 | }; |
| 514 | ||
| 15884 | 515 | static PurplePluginInfo info = |
| 8089 | 516 | { |
| 15884 | 517 | PURPLE_PLUGIN_MAGIC, |
| 518 | PURPLE_MAJOR_VERSION, | |
| 519 | PURPLE_MINOR_VERSION, | |
| 520 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
521 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 8089 | 522 | 0, /**< flags */ |
| 523 | NULL, /**< dependencies */ | |
| 15884 | 524 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 8089 | 525 | |
| 526 | GEVOLUTION_PLUGIN_ID, /**< id */ | |
| 527 | N_("Evolution Integration"), /**< name */ | |
| 528 | VERSION, /**< version */ | |
| 529 | /** summary */ | |
| 11117 | 530 | N_("Provides integration with Evolution."), |
| 8089 | 531 | /** description */ |
| 11117 | 532 | N_("Provides integration with Evolution."), |
|
15025
4bb4a1b56c14
[gaim-migrate @ 17742]
Christian Hammond <chipx86@chipx86.com>
parents:
14848
diff
changeset
|
533 | "Christian Hammond <chipx86@chipx86.com>", /**< author */ |
| 15884 | 534 | PURPLE_WEBSITE, /**< homepage */ |
| 8089 | 535 | |
| 536 | plugin_load, /**< load */ | |
| 537 | plugin_unload, /**< unload */ | |
| 538 | plugin_destroy, /**< destroy */ | |
| 539 | ||
| 540 | &ui_info, /**< ui_info */ | |
| 8993 | 541 | NULL, /**< extra_info */ |
| 542 | NULL, | |
|
16788
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
543 | NULL, |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
544 | |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
545 | /* Padding */ |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
546 | NULL, |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
547 | NULL, |
|
417d0e8d6f3f
Add padding to structs to fix compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
548 | NULL, |
| 8993 | 549 | NULL |
| 8089 | 550 | }; |
| 551 | ||
| 552 | static void | |
| 15884 | 553 | init_plugin(PurplePlugin *plugin) |
| 8089 | 554 | { |
| 555 | /* TODO: Change to core-remote when possible. */ | |
| 556 | /* info.dependencies = g_list_append(info.dependencies, "gtk-remote"); */ | |
| 557 | ||
| 558 | /* | |
| 559 | * I'm going to rant a little bit here... | |
| 560 | * | |
| 561 | * For some reason, when we init bonobo from inside a plugin, it will | |
| 562 | * segfault when destroyed. The backtraces are within gmodule somewhere. | |
| 563 | * There's not much I can do, and I'm not sure where the bug lies. | |
| 15884 | 564 | * However, plugins are only destroyed when Purple is shutting down. After |
| 565 | * destroying the plugins, purple ends, and anything else is of course | |
| 8089 | 566 | * freed. That includes this, if we make the module resident, which |
| 567 | * prevents us from being able to actually unload it. | |
| 568 | * | |
| 569 | * So, in conclusion, this is an evil hack, but it doesn't harm anything | |
| 570 | * and it works. | |
| 571 | */ | |
| 572 | g_module_make_resident(plugin->handle); | |
| 10055 | 573 | |
| 574 | if (!bonobo_init_full(NULL, NULL, bonobo_activation_orb_get(), | |
| 575 | CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) | |
| 576 | { | |
| 15884 | 577 | purple_debug_error("evolution", "Unable to initialize bonobo.\n"); |
| 10055 | 578 | } |
| 8089 | 579 | } |
| 580 | ||
| 15884 | 581 | PURPLE_INIT_PLUGIN(gevolution, init_plugin, info) |