Mercurial > pidgin
annotate plugins/gevolution/gevo-util.c @ 9046:c307cf4c84d2
[gaim-migrate @ 9822]
The gevolution plugin should now compile with both the previous release of
Evolution/e-d-s and with e-d-s CVS.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 23 May 2004 22:43:37 +0000 |
parents | 8b62cc40069b |
children | 61b33ac58669 |
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); | |
47 serv_add_buddy(gaim_account_get_connection(account), screenname, group); | |
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 gaim_blist_save(); | |
55 } | |
56 } | |
57 | |
58 GList * | |
59 gevo_get_groups(void) | |
60 { | |
61 GList *tmp = NULL; | |
62 char *tmp2; | |
63 GaimGroup *g; | |
64 GaimBlistNode *gnode; | |
65 | |
66 if (gaim_get_blist()->root == NULL) | |
67 { | |
68 tmp2 = g_strdup(_("Buddies")); | |
69 tmp = g_list_append(tmp, tmp2); | |
70 } | |
71 else | |
72 { | |
73 for (gnode = gaim_get_blist()->root; | |
74 gnode != NULL; | |
75 gnode = gnode->next) | |
76 { | |
77 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
78 { | |
79 g = (GaimGroup *)gnode; | |
80 tmp2 = g->name; | |
81 tmp = g_list_append(tmp, tmp2); | |
82 } | |
83 } | |
84 } | |
85 | |
86 return tmp; | |
87 } | |
88 | |
89 EContactField | |
90 gevo_prpl_get_field(GaimAccount *account, GaimBuddy *buddy) | |
91 { | |
92 EContactField protocol_field = 0; | |
93 const char *protocol_id; | |
94 | |
95 g_return_val_if_fail(account != NULL, 0); | |
96 | |
97 protocol_id = gaim_account_get_protocol_id(account); | |
98 | |
99 if (!strcmp(protocol_id, "prpl-oscar")) | |
100 { | |
101 GaimConnection *gc; | |
102 GaimPluginProtocolInfo *prpl_info; | |
103 | |
104 gc = gaim_account_get_connection(account); | |
105 | |
106 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
107 | |
108 if (!strcmp("aim", prpl_info->list_icon(account, buddy))) | |
109 { | |
110 protocol_field = E_CONTACT_IM_AIM; | |
111 } | |
112 else | |
113 protocol_field = E_CONTACT_IM_ICQ; | |
114 } | |
115 else if (!strcmp(protocol_id, "prpl-msn")) | |
116 protocol_field = E_CONTACT_IM_MSN; | |
117 else if (!strcmp(protocol_id, "prpl-yahoo")) | |
118 protocol_field = E_CONTACT_IM_YAHOO; | |
119 else if (!strcmp(protocol_id, "prpl-jabber")) | |
120 protocol_field = E_CONTACT_IM_JABBER; | |
121 | |
122 return protocol_field; | |
123 } | |
124 | |
125 gboolean | |
126 gevo_prpl_is_supported(GaimAccount *account, GaimBuddy *buddy) | |
127 { | |
128 return (gevo_prpl_get_field(account, buddy) != 0); | |
129 } | |
130 | |
131 gboolean | |
132 gevo_load_addressbook(EBook **book, GError **error) | |
133 { | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
134 gboolean result = FALSE; |
8089 | 135 |
136 g_return_val_if_fail(book != NULL, FALSE); | |
137 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
138 #if EBOOK_CHECK_VERSION(0, 0, 93) |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
139 *book = e_book_new_system_addressbook(NULL); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
140 |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
141 if (book != NULL) |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
142 result = e_book_open(*book, FALSE, NULL); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
143 #else |
8089 | 144 *book = e_book_new(); |
145 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
146 result = e_book_load_local_addressbook(*book, error); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
147 #endif |
8089 | 148 |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
149 if (!result && *book != NULL) |
8089 | 150 { |
151 g_object_unref(*book); | |
152 *book = NULL; | |
153 } | |
154 | |
155 return result; | |
156 } |