Mercurial > pidgin
annotate plugins/gevolution/gevo-util.c @ 9299:635f88dc9adf
[gaim-migrate @ 10102]
Someone who knows this code better than I may want to double check this,
but this seems to fix the issues I was having with buddy icons not updating
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Wed, 16 Jun 2004 06:51:24 +0000 |
parents | d92ee4b0e44b |
children | cc2baf349805 |
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 "gtkinternal.h" | |
22 #include "gtkblist.h" | |
23 #include "gtkutils.h" | |
24 | |
25 #include <libebook/e-book.h> | |
26 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
27 #include "gevolution.h" |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
28 |
8089 | 29 void |
30 gevo_add_buddy(GaimAccount *account, const char *group_name, | |
31 const char *screenname, const char *alias) | |
32 { | |
33 GaimConversation *conv = NULL; | |
34 GaimBuddy *buddy; | |
35 GaimGroup *group; | |
36 | |
37 conv = gaim_find_conversation_with_account(screenname, account); | |
38 | |
39 if ((group = gaim_find_group(group_name)) == NULL) | |
40 { | |
41 group = gaim_group_new(group_name); | |
42 gaim_blist_add_group(group, NULL); | |
43 } | |
44 | |
45 buddy = gaim_buddy_new(account, screenname, alias); | |
46 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
9293
d92ee4b0e44b
[gaim-migrate @ 10096]
Christian Hammond <chipx86@chipx86.com>
parents:
9095
diff
changeset
|
47 serv_add_buddy(gaim_account_get_connection(account), buddy); |
8089 | 48 |
49 if (conv != NULL) | |
50 { | |
51 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); | |
52 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ADD); | |
53 } | |
54 } | |
55 | |
56 GList * | |
57 gevo_get_groups(void) | |
58 { | |
59 GList *tmp = NULL; | |
60 char *tmp2; | |
61 GaimGroup *g; | |
62 GaimBlistNode *gnode; | |
63 | |
64 if (gaim_get_blist()->root == NULL) | |
65 { | |
66 tmp2 = g_strdup(_("Buddies")); | |
67 tmp = g_list_append(tmp, tmp2); | |
68 } | |
69 else | |
70 { | |
71 for (gnode = gaim_get_blist()->root; | |
72 gnode != NULL; | |
73 gnode = gnode->next) | |
74 { | |
75 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
76 { | |
77 g = (GaimGroup *)gnode; | |
78 tmp2 = g->name; | |
79 tmp = g_list_append(tmp, tmp2); | |
80 } | |
81 } | |
82 } | |
83 | |
84 return tmp; | |
85 } | |
86 | |
87 EContactField | |
88 gevo_prpl_get_field(GaimAccount *account, GaimBuddy *buddy) | |
89 { | |
90 EContactField protocol_field = 0; | |
91 const char *protocol_id; | |
92 | |
93 g_return_val_if_fail(account != NULL, 0); | |
94 | |
95 protocol_id = gaim_account_get_protocol_id(account); | |
96 | |
97 if (!strcmp(protocol_id, "prpl-oscar")) | |
98 { | |
99 GaimConnection *gc; | |
100 GaimPluginProtocolInfo *prpl_info; | |
101 | |
102 gc = gaim_account_get_connection(account); | |
103 | |
104 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
105 | |
106 if (!strcmp("aim", prpl_info->list_icon(account, buddy))) | |
107 { | |
108 protocol_field = E_CONTACT_IM_AIM; | |
109 } | |
110 else | |
111 protocol_field = E_CONTACT_IM_ICQ; | |
112 } | |
113 else if (!strcmp(protocol_id, "prpl-msn")) | |
114 protocol_field = E_CONTACT_IM_MSN; | |
115 else if (!strcmp(protocol_id, "prpl-yahoo")) | |
116 protocol_field = E_CONTACT_IM_YAHOO; | |
117 else if (!strcmp(protocol_id, "prpl-jabber")) | |
118 protocol_field = E_CONTACT_IM_JABBER; | |
119 | |
120 return protocol_field; | |
121 } | |
122 | |
123 gboolean | |
124 gevo_prpl_is_supported(GaimAccount *account, GaimBuddy *buddy) | |
125 { | |
126 return (gevo_prpl_get_field(account, buddy) != 0); | |
127 } | |
128 | |
129 gboolean | |
130 gevo_load_addressbook(EBook **book, GError **error) | |
131 { | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
132 gboolean result = FALSE; |
8089 | 133 |
134 g_return_val_if_fail(book != NULL, FALSE); | |
135 | |
9095
61b33ac58669
[gaim-migrate @ 9872]
Christian Hammond <chipx86@chipx86.com>
parents:
9046
diff
changeset
|
136 /* #if EBOOK_CHECK_VERSION(0, 0, 94) */ |
61b33ac58669
[gaim-migrate @ 9872]
Christian Hammond <chipx86@chipx86.com>
parents:
9046
diff
changeset
|
137 #ifdef LIBEBOOK_NEW_API |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
138 *book = e_book_new_system_addressbook(NULL); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
139 |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
140 if (book != NULL) |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
141 result = e_book_open(*book, FALSE, NULL); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
142 #else |
8089 | 143 *book = e_book_new(); |
144 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
145 result = e_book_load_local_addressbook(*book, error); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
146 #endif |
8089 | 147 |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
148 if (!result && *book != NULL) |
8089 | 149 { |
150 g_object_unref(*book); | |
151 *book = NULL; | |
152 } | |
153 | |
154 return result; | |
155 } |