Mercurial > pidgin
annotate plugins/gevolution/gevolution.c @ 11249:b4b1be482b4e
[gaim-migrate @ 13418]
sf patch #1235519, from Sadrul Habib Chowdhury
This is a pretty big patch that makes Gaim correctly save and restore
the current status (away/available, away message, available message,
invisible, etc).
The GaimGtkStatusBoxWidget thing I think defaults to "Available"
every time its created, which overrides the setting that was saved
to the XML file. So that still needs to be fixed before this will
really work.
Anyway, mad props to Sadrul for putting up with my requests on this patch
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sat, 13 Aug 2005 05:22:09 +0000 |
| parents | 5a8bc4b1f5b6 |
| children | bb0d7b719af2 |
| 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" | |
|
11117
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
27 #include "notify.h" |
| 8089 | 28 #include "signals.h" |
| 10831 | 29 #include "util.h" |
| 9954 | 30 #include "version.h" |
| 8089 | 31 |
| 9821 | 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 <libebook/e-book-listener.h> | |
| 42 #include <libedata-book/e-data-book-factory.h> | |
| 43 #include <bonobo/bonobo-main.h> | |
| 44 | |
|
11117
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
45 #include <glib.h> |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
46 |
| 8089 | 47 #define GEVOLUTION_PLUGIN_ID "gtk-x11-gevolution" |
| 48 | |
| 49 #define E_DATA_BOOK_FACTORY_OAF_ID \ | |
| 50 "OAFIID:GNOME_Evolution_DataServer_BookFactory" | |
| 51 | |
| 52 enum | |
| 53 { | |
| 54 COLUMN_AUTOADD, | |
| 55 COLUMN_ICON, | |
| 56 COLUMN_SCREENNAME, | |
| 57 COLUMN_DATA, | |
| 58 NUM_COLUMNS | |
| 59 }; | |
| 60 | |
| 61 static GaimBlistUiOps *backup_blist_ui_ops = NULL; | |
| 62 static GaimBlistUiOps *blist_ui_ops = NULL; | |
| 63 static EBook *book = NULL; | |
| 64 static gulong timer = 0; | |
| 65 static gulong book_view_tag = 0; | |
| 66 static EBookView *book_view = NULL; | |
| 67 | |
| 68 static void | |
| 69 update_ims_from_contact(EContact *contact, const char *name, | |
| 70 const char *prpl_id, EContactField field) | |
| 71 { | |
| 72 GList *ims = e_contact_get(contact, field); | |
| 73 GList *l, *l2; | |
| 74 | |
| 75 if (ims == NULL) | |
| 76 return; | |
| 77 | |
| 78 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
| 79 { | |
| 80 GaimConnection *gc = (GaimConnection *)l->data; | |
| 81 GaimAccount *account = gaim_connection_get_account(gc); | |
| 10831 | 82 char *me = g_strdup(gaim_normalize(account, gaim_account_get_username(account))); |
| 8089 | 83 |
| 84 if (strcmp(gaim_account_get_protocol_id(account), prpl_id)) | |
| 85 continue; | |
| 86 | |
| 87 if (!gaim_account_get_bool(account, "gevo-autoadd", FALSE)) | |
| 88 continue; | |
| 89 | |
| 90 for (l2 = ims; l2 != NULL; l2 = l2->next) | |
| 91 { | |
| 10831 | 92 if (gaim_find_buddy(account, l2->data) != NULL || |
| 93 !strcmp(me, gaim_normalize(account, l2->data))) | |
| 8089 | 94 continue; |
| 95 | |
| 96 gevo_add_buddy(account, _("Buddies"), l2->data, name); | |
| 97 } | |
| 10831 | 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
bc700cc98b82
[gaim-migrate @ 12992]
Richard Laager <rlaager@wiktel.com>
parents:
11033
diff
changeset
|
117 update_ims_from_contact(contact, name, "prpl-novell", E_CONTACT_IM_GROUPWISE); |
| 8089 | 118 } |
| 119 | |
| 120 static void | |
| 121 contacts_changed_cb(EBookView *book_view, const GList *contacts) | |
| 122 { | |
| 123 const GList *l; | |
| 124 | |
| 125 if (gaim_connections_get_all() == NULL) | |
| 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 | |
| 137 request_add_buddy(GaimAccount *account, const char *username, | |
| 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 { | |
| 159 gaim_debug_error("evolution", "Unable to retrieve book view! :(\n"); | |
| 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 | |
| 178 signed_on_cb(GaimConnection *gc) | |
| 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 | |
|
9055
a243d688c93c
[gaim-migrate @ 9831]
Christian Hammond <chipx86@chipx86.com>
parents:
9051
diff
changeset
|
210 menu_item_activate_cb(GaimBlistNode *node, gpointer user_data) |
| 8089 | 211 { |
| 9051 | 212 GaimBuddy *buddy = (GaimBuddy *)node; |
| 8089 | 213 gevo_associate_buddy_dialog_new(buddy); |
| 214 } | |
| 215 | |
| 216 static void | |
|
11117
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
217 menu_item_send_mail_activate_cb(GaimBlistNode *node, gpointer user_data) |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
218 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
219 GaimBuddy *buddy = (GaimBuddy *)node; |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
220 EContact *contact; |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
221 char *mail = NULL; |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
222 |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
223 contact = gevo_search_buddy_in_contacts(buddy, NULL); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
224 |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
225 if (contact != NULL) |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
226 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
227 mail = g_strdup(e_contact_get(contact, E_CONTACT_EMAIL_1)); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
228 g_object_unref(contact); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
229 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
230 else |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
231 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
232 GaimAccount *account = gaim_buddy_get_account(buddy); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
233 const char *prpl_id = gaim_account_get_protocol_id(account); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
234 |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
235 if (!strcmp(prpl_id, "prpl-msn")) |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
236 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
237 mail = g_strdup(gaim_normalize(account, |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
238 gaim_buddy_get_name(buddy))); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
239 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
240 else if (!strcmp(prpl_id, "prpl-yahoo")) |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
241 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
242 mail = g_strdup_printf("%s@yahoo.com", |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
243 gaim_normalize(account, |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
244 gaim_buddy_get_name(buddy))); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
245 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
246 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
247 |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
248 if (mail != NULL) |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
249 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
250 char *app = g_find_program_in_path("evolution"); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
251 if (app != NULL) |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
252 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
253 char *command_line = g_strdup_printf("%s mailto:%s", app, mail); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
254 g_free(app); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
255 g_free(mail); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
256 |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
257 g_spawn_command_line_async(command_line, NULL); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
258 g_free(command_line); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
259 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
260 else |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
261 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
262 gaim_notify_error(NULL, NULL, _("Unable to send e-mail"), |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
263 _("The evolution executable was not found in the PATH.")); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
264 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
265 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
266 else |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
267 { |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
268 gaim_notify_error(NULL, NULL, _("Unable to send e-mail"), |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
269 _("The specified buddy was not found in the Evolution Contacts.")); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
270 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
271 } |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
272 |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
273 static void |
| 9051 | 274 blist_node_extended_menu_cb(GaimBlistNode *node, GList **menu) |
| 8089 | 275 { |
| 9051 | 276 GaimBlistNodeAction *act; |
| 277 GaimBuddy *buddy; | |
| 8089 | 278 |
| 9051 | 279 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
| 280 return; | |
| 281 | |
| 282 buddy = (GaimBuddy *)node; | |
| 283 | |
| 8089 | 284 if (gevo_prpl_is_supported(buddy->account, buddy)) |
| 285 { | |
| 9051 | 286 act = gaim_blist_node_action_new(_("Add to Address Book"), |
|
10662
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10081
diff
changeset
|
287 menu_item_activate_cb, |
|
54ac161a876e
[gaim-migrate @ 12199]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10081
diff
changeset
|
288 NULL, NULL); |
| 9051 | 289 *menu = g_list_append(*menu, act); |
|
11117
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
290 act = gaim_blist_node_action_new(_("Send E-Mail"), |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
291 menu_item_send_mail_activate_cb, |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
292 NULL, NULL); |
|
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
293 *menu = g_list_append(*menu, act); |
| 8089 | 294 } |
| 295 } | |
| 296 | |
| 297 static gboolean | |
| 298 load_timeout(gpointer data) | |
| 299 { | |
| 300 GaimPlugin *plugin = (GaimPlugin *)data; | |
|
8127
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
301 EBookQuery *query; |
| 8089 | 302 |
| 303 timer = 0; | |
| 304 | |
|
10081
ff4be2d1401d
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
10055
diff
changeset
|
305 if (!gevo_load_addressbook(NULL, &book, NULL)) |
| 8089 | 306 return FALSE; |
| 307 | |
|
8127
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
308 query = e_book_query_any_field_contains(""); |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
309 |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
310 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
|
311 got_book_view_cb, NULL); |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
312 |
|
96ee7b21c1ae
[gaim-migrate @ 8832]
Christian Hammond <chipx86@chipx86.com>
parents:
8089
diff
changeset
|
313 e_book_query_unref(query); |
| 8089 | 314 |
| 9051 | 315 gaim_signal_connect(gaim_blist_get_handle(), "blist-node-extended-menu", |
| 316 plugin, GAIM_CALLBACK(blist_node_extended_menu_cb), NULL); | |
| 8089 | 317 |
| 318 return FALSE; | |
| 319 } | |
| 320 | |
| 321 static gboolean | |
| 322 plugin_load(GaimPlugin *plugin) | |
| 323 { | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
324 gaim_debug_register_category("evolution"); |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
325 |
| 8089 | 326 bonobo_activate(); |
| 327 | |
| 328 backup_blist_ui_ops = gaim_blist_get_ui_ops(); | |
| 329 | |
| 330 blist_ui_ops = g_memdup(backup_blist_ui_ops, sizeof(GaimBlistUiOps)); | |
| 331 blist_ui_ops->request_add_buddy = request_add_buddy; | |
| 332 | |
| 333 gaim_blist_set_ui_ops(blist_ui_ops); | |
| 334 | |
| 335 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", | |
| 336 plugin, GAIM_CALLBACK(signed_on_cb), NULL); | |
| 337 | |
| 338 timer = g_timeout_add(1, load_timeout, plugin); | |
| 339 | |
| 340 return TRUE; | |
| 341 } | |
| 342 | |
| 343 static gboolean | |
| 344 plugin_unload(GaimPlugin *plugin) | |
| 345 { | |
| 346 gaim_blist_set_ui_ops(backup_blist_ui_ops); | |
| 347 | |
| 348 g_free(blist_ui_ops); | |
| 349 | |
| 350 backup_blist_ui_ops = NULL; | |
| 351 blist_ui_ops = NULL; | |
| 352 | |
| 353 if (book_view != NULL) | |
| 354 { | |
| 355 e_book_view_stop(book_view); | |
| 356 g_object_unref(book_view); | |
| 357 book_view = NULL; | |
| 358 } | |
| 359 | |
| 360 if (book != NULL) | |
| 361 { | |
| 362 g_object_unref(book); | |
| 363 book = NULL; | |
| 364 } | |
| 365 | |
|
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
366 gaim_debug_unregister_category("evolution"); |
|
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10884
diff
changeset
|
367 |
| 8089 | 368 return TRUE; |
| 369 } | |
| 370 | |
| 371 static void | |
| 372 plugin_destroy(GaimPlugin *plugin) | |
| 373 { | |
|
10055
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
374 bonobo_debug_shutdown(); |
| 8089 | 375 } |
| 376 | |
| 377 static void | |
| 378 autoadd_toggled_cb(GtkCellRendererToggle *renderer, gchar *path_str, | |
| 379 gpointer data) | |
| 380 { | |
| 381 GaimAccount *account; | |
| 382 GtkTreeModel *model = (GtkTreeModel *)data; | |
| 383 GtkTreeIter iter; | |
| 384 gboolean autoadd; | |
| 385 | |
| 386 gtk_tree_model_get_iter_from_string(model, &iter, path_str); | |
| 387 gtk_tree_model_get(model, &iter, | |
| 388 COLUMN_DATA, &account, | |
| 389 COLUMN_AUTOADD, &autoadd, | |
| 390 -1); | |
| 391 | |
| 392 gaim_account_set_bool(account, "gevo-autoadd", !autoadd); | |
| 393 | |
| 394 gtk_list_store_set(GTK_LIST_STORE(model), &iter, | |
| 395 COLUMN_AUTOADD, !autoadd, | |
| 396 -1); | |
| 397 } | |
| 398 | |
| 399 static GtkWidget * | |
| 400 get_config_frame(GaimPlugin *plugin) | |
| 401 { | |
| 402 GtkWidget *ret; | |
| 403 GtkWidget *vbox; | |
| 404 GtkWidget *label; | |
| 405 GtkWidget *sw; | |
| 406 GtkWidget *treeview; | |
| 407 GtkTreeViewColumn *column; | |
| 408 GtkCellRenderer *renderer; | |
| 409 GdkPixbuf *pixbuf, *scale = NULL; | |
| 410 GtkListStore *model; | |
| 411 GList *l; | |
| 412 | |
| 413 /* Outside container */ | |
| 414 ret = gtk_vbox_new(FALSE, 18); | |
| 415 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 416 | |
| 417 /* Configuration frame */ | |
| 418 vbox = gaim_gtk_make_frame(ret, _("Evolution Integration Configuration")); | |
| 419 | |
| 420 /* Label */ | |
| 421 label = gtk_label_new(_("Select all accounts that buddies should be " | |
| 422 "auto-added to.")); | |
| 423 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 424 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 425 gtk_widget_show(label); | |
| 426 | |
| 427 /* Scrolled window */ | |
| 428 sw = gtk_scrolled_window_new(0, 0); | |
| 429 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 430 GTK_POLICY_AUTOMATIC, | |
| 431 GTK_POLICY_ALWAYS); | |
| 432 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
| 433 GTK_SHADOW_IN); | |
| 434 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 435 gtk_widget_set_size_request(sw, 300, 300); | |
| 436 gtk_widget_show(sw); | |
| 437 | |
| 438 /* Create the list model for the treeview. */ | |
| 439 model = gtk_list_store_new(NUM_COLUMNS, | |
| 440 G_TYPE_BOOLEAN, GDK_TYPE_PIXBUF, | |
| 441 G_TYPE_STRING, G_TYPE_POINTER); | |
| 442 | |
| 443 /* Setup the treeview */ | |
| 444 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 445 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | |
| 446 gtk_container_add(GTK_CONTAINER(sw), treeview); | |
| 447 gtk_widget_show(treeview); | |
| 448 | |
| 449 /* Setup the column */ | |
| 450 column = gtk_tree_view_column_new(); | |
| 451 gtk_tree_view_column_set_title(column, _("Account")); | |
| 452 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
| 453 | |
| 454 /* Checkbox */ | |
| 455 renderer = gtk_cell_renderer_toggle_new(); | |
| 456 | |
| 457 g_signal_connect(G_OBJECT(renderer), "toggled", | |
| 458 G_CALLBACK(autoadd_toggled_cb), model); | |
| 459 | |
| 460 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 461 gtk_tree_view_column_add_attribute(column, renderer, | |
| 462 "active", COLUMN_AUTOADD); | |
| 463 | |
| 464 /* Icon */ | |
| 465 renderer = gtk_cell_renderer_pixbuf_new(); | |
| 466 gtk_tree_view_column_pack_start(column, renderer, FALSE); | |
| 467 gtk_tree_view_column_add_attribute(column, renderer, | |
| 468 "pixbuf", COLUMN_ICON); | |
| 469 | |
| 470 /* Screenname */ | |
| 471 renderer = gtk_cell_renderer_text_new(); | |
| 472 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
| 473 gtk_tree_view_column_add_attribute(column, renderer, | |
| 474 "text", COLUMN_SCREENNAME); | |
| 475 | |
| 476 | |
| 477 /* Populate */ | |
| 478 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) | |
| 479 { | |
| 480 GaimAccount *account = (GaimAccount *)l->data; | |
| 481 GtkTreeIter iter; | |
| 482 | |
| 483 gaim_debug_info("evolution", "Adding account\n"); | |
| 484 | |
| 485 gtk_list_store_append(model, &iter); | |
| 486 | |
| 10884 | 487 pixbuf = gaim_gtk_create_prpl_icon(account); |
| 8089 | 488 |
| 489 if (pixbuf != NULL) | |
| 490 { | |
| 491 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
| 492 GDK_INTERP_BILINEAR); | |
| 493 | |
| 494 if (!gaim_account_is_connected(account)) | |
| 495 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); | |
| 496 } | |
| 497 | |
| 498 gtk_list_store_set(model, &iter, | |
| 499 COLUMN_AUTOADD, | |
| 500 gaim_account_get_bool(account, "gevo-autoadd", | |
| 501 FALSE), | |
| 502 COLUMN_ICON, scale, | |
| 503 COLUMN_SCREENNAME, | |
| 504 gaim_account_get_username(account), | |
| 505 COLUMN_DATA, account, | |
| 506 -1); | |
| 507 | |
| 508 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | |
| 509 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | |
| 510 } | |
| 511 | |
| 512 gtk_widget_show_all(ret); | |
| 513 | |
| 514 return ret; | |
| 515 } | |
| 516 | |
| 517 static GaimGtkPluginUiInfo ui_info = | |
| 518 { | |
| 519 get_config_frame | |
| 520 }; | |
| 521 | |
| 522 static GaimPluginInfo info = | |
| 523 { | |
| 9954 | 524 GAIM_PLUGIN_MAGIC, |
| 525 GAIM_MAJOR_VERSION, | |
| 526 GAIM_MINOR_VERSION, | |
| 8089 | 527 GAIM_PLUGIN_STANDARD, /**< type */ |
| 528 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ | |
| 529 0, /**< flags */ | |
| 530 NULL, /**< dependencies */ | |
| 531 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 532 | |
| 533 GEVOLUTION_PLUGIN_ID, /**< id */ | |
| 534 N_("Evolution Integration"), /**< name */ | |
| 535 VERSION, /**< version */ | |
| 536 /** summary */ | |
|
11117
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
537 N_("Provides integration with Evolution."), |
| 8089 | 538 /** description */ |
|
11117
5a8bc4b1f5b6
[gaim-migrate @ 13173]
Richard Laager <rlaager@wiktel.com>
parents:
11054
diff
changeset
|
539 N_("Provides integration with Evolution."), |
| 8089 | 540 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ |
| 541 GAIM_WEBSITE, /**< homepage */ | |
| 542 | |
| 543 plugin_load, /**< load */ | |
| 544 plugin_unload, /**< unload */ | |
| 545 plugin_destroy, /**< destroy */ | |
| 546 | |
| 547 &ui_info, /**< ui_info */ | |
| 8993 | 548 NULL, /**< extra_info */ |
| 549 NULL, | |
| 550 NULL | |
| 8089 | 551 }; |
| 552 | |
| 553 static void | |
| 554 init_plugin(GaimPlugin *plugin) | |
| 555 { | |
| 556 /* TODO: Change to core-remote when possible. */ | |
| 557 /* info.dependencies = g_list_append(info.dependencies, "gtk-remote"); */ | |
| 558 | |
| 559 /* | |
| 560 * I'm going to rant a little bit here... | |
| 561 * | |
| 562 * For some reason, when we init bonobo from inside a plugin, it will | |
| 563 * segfault when destroyed. The backtraces are within gmodule somewhere. | |
| 564 * There's not much I can do, and I'm not sure where the bug lies. | |
| 565 * However, plugins are only destroyed when Gaim is shutting down. After | |
| 566 * destroying the plugins, gaim ends, and anything else is of course | |
| 567 * freed. That includes this, if we make the module resident, which | |
| 568 * prevents us from being able to actually unload it. | |
| 569 * | |
| 570 * So, in conclusion, this is an evil hack, but it doesn't harm anything | |
| 571 * and it works. | |
| 572 */ | |
| 573 g_module_make_resident(plugin->handle); | |
|
10055
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
574 |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
575 if (!bonobo_init_full(NULL, NULL, bonobo_activation_orb_get(), |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
576 CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
577 { |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
578 gaim_debug_error("evolution", "Unable to initialize bonobo.\n"); |
|
0436734708fa
[gaim-migrate @ 11020]
Christian Hammond <chipx86@chipx86.com>
parents:
9954
diff
changeset
|
579 } |
| 8089 | 580 } |
| 581 | |
| 582 GAIM_INIT_PLUGIN(gevolution, init_plugin, info) |
