Mercurial > pidgin.yaz
annotate plugins/gevolution/gevo-util.c @ 9567:111394c5fe2a
[gaim-migrate @ 10410]
Fix a check. I didn't mean to commit that.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Tue, 20 Jul 2004 01:08:18 +0000 |
parents | a5ec9e73f46d |
children | 94910b9520cf |
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 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
25 #include "gevolution.h" |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
26 |
8089 | 27 void |
28 gevo_add_buddy(GaimAccount *account, const char *group_name, | |
29 const char *screenname, const char *alias) | |
30 { | |
31 GaimConversation *conv = NULL; | |
32 GaimBuddy *buddy; | |
33 GaimGroup *group; | |
34 | |
35 conv = gaim_find_conversation_with_account(screenname, account); | |
36 | |
37 if ((group = gaim_find_group(group_name)) == NULL) | |
38 { | |
39 group = gaim_group_new(group_name); | |
40 gaim_blist_add_group(group, NULL); | |
41 } | |
42 | |
43 buddy = gaim_buddy_new(account, screenname, alias); | |
44 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
9293
d92ee4b0e44b
[gaim-migrate @ 10096]
Christian Hammond <chipx86@chipx86.com>
parents:
9095
diff
changeset
|
45 serv_add_buddy(gaim_account_get_connection(account), buddy); |
8089 | 46 |
47 if (conv != NULL) | |
48 { | |
49 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); | |
50 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ADD); | |
51 } | |
52 } | |
53 | |
54 GList * | |
55 gevo_get_groups(void) | |
56 { | |
57 GList *tmp = NULL; | |
58 char *tmp2; | |
59 GaimGroup *g; | |
60 GaimBlistNode *gnode; | |
61 | |
62 if (gaim_get_blist()->root == NULL) | |
63 { | |
64 tmp2 = g_strdup(_("Buddies")); | |
65 tmp = g_list_append(tmp, tmp2); | |
66 } | |
67 else | |
68 { | |
69 for (gnode = gaim_get_blist()->root; | |
70 gnode != NULL; | |
71 gnode = gnode->next) | |
72 { | |
73 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
74 { | |
75 g = (GaimGroup *)gnode; | |
76 tmp2 = g->name; | |
77 tmp = g_list_append(tmp, tmp2); | |
78 } | |
79 } | |
80 } | |
81 | |
82 return tmp; | |
83 } | |
84 | |
85 EContactField | |
86 gevo_prpl_get_field(GaimAccount *account, GaimBuddy *buddy) | |
87 { | |
88 EContactField protocol_field = 0; | |
89 const char *protocol_id; | |
90 | |
91 g_return_val_if_fail(account != NULL, 0); | |
92 | |
93 protocol_id = gaim_account_get_protocol_id(account); | |
94 | |
95 if (!strcmp(protocol_id, "prpl-oscar")) | |
96 { | |
97 GaimConnection *gc; | |
98 GaimPluginProtocolInfo *prpl_info; | |
99 | |
100 gc = gaim_account_get_connection(account); | |
101 | |
102 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
103 | |
104 if (!strcmp("aim", prpl_info->list_icon(account, buddy))) | |
105 { | |
106 protocol_field = E_CONTACT_IM_AIM; | |
107 } | |
108 else | |
109 protocol_field = E_CONTACT_IM_ICQ; | |
110 } | |
111 else if (!strcmp(protocol_id, "prpl-msn")) | |
112 protocol_field = E_CONTACT_IM_MSN; | |
113 else if (!strcmp(protocol_id, "prpl-yahoo")) | |
114 protocol_field = E_CONTACT_IM_YAHOO; | |
115 else if (!strcmp(protocol_id, "prpl-jabber")) | |
116 protocol_field = E_CONTACT_IM_JABBER; | |
117 | |
118 return protocol_field; | |
119 } | |
120 | |
121 gboolean | |
122 gevo_prpl_is_supported(GaimAccount *account, GaimBuddy *buddy) | |
123 { | |
124 return (gevo_prpl_get_field(account, buddy) != 0); | |
125 } | |
126 | |
127 gboolean | |
128 gevo_load_addressbook(EBook **book, GError **error) | |
129 { | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
130 gboolean result = FALSE; |
8089 | 131 |
132 g_return_val_if_fail(book != NULL, FALSE); | |
133 | |
9352
cc2baf349805
[gaim-migrate @ 10160]
Christian Hammond <chipx86@chipx86.com>
parents:
9293
diff
changeset
|
134 #if EBOOK_CHECK_VERSION(0, 0, 94) |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
135 *book = e_book_new_system_addressbook(NULL); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
136 |
9352
cc2baf349805
[gaim-migrate @ 10160]
Christian Hammond <chipx86@chipx86.com>
parents:
9293
diff
changeset
|
137 result = e_book_open(*book, FALSE, NULL); |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
138 #else |
8089 | 139 *book = e_book_new(); |
140 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
141 result = e_book_load_local_addressbook(*book, error); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
142 #endif |
8089 | 143 |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
144 if (!result && *book != NULL) |
8089 | 145 { |
146 g_object_unref(*book); | |
147 *book = NULL; | |
148 } | |
149 | |
150 return result; | |
151 } |