Mercurial > pidgin.yaz
annotate plugins/gevolution/gevo-util.c @ 10044:86a6d78b070b
[gaim-migrate @ 11003]
this is the msn buddy list sync code from the 1.0.0 tree, also from shx. in
this patch, i changed one instance of "b" to "buddy" to make it compile.
this introduces code to ask the user about discrepances between the local
and server lists on msn.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sun, 19 Sep 2004 03:02:28 +0000 |
parents | c00def44d76a |
children | ff4be2d1401d |
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 */ | |
9825
c00def44d76a
[gaim-migrate @ 10696]
Christian Hammond <chipx86@chipx86.com>
parents:
9824
diff
changeset
|
21 #include "internal.h" |
8089 | 22 #include "gtkblist.h" |
9824 | 23 #include "gtkgaim.h" |
8089 | 24 #include "gtkutils.h" |
25 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
26 #include "gevolution.h" |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
27 |
8089 | 28 void |
29 gevo_add_buddy(GaimAccount *account, const char *group_name, | |
30 const char *screenname, const char *alias) | |
31 { | |
32 GaimConversation *conv = NULL; | |
33 GaimBuddy *buddy; | |
34 GaimGroup *group; | |
35 | |
36 conv = gaim_find_conversation_with_account(screenname, account); | |
37 | |
38 if ((group = gaim_find_group(group_name)) == NULL) | |
39 { | |
40 group = gaim_group_new(group_name); | |
41 gaim_blist_add_group(group, NULL); | |
42 } | |
43 | |
44 buddy = gaim_buddy_new(account, screenname, alias); | |
45 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
9293
d92ee4b0e44b
[gaim-migrate @ 10096]
Christian Hammond <chipx86@chipx86.com>
parents:
9095
diff
changeset
|
46 serv_add_buddy(gaim_account_get_connection(account), buddy); |
8089 | 47 |
48 if (conv != NULL) | |
49 { | |
50 gaim_buddy_icon_update(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); | |
51 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ADD); | |
52 } | |
53 } | |
54 | |
55 GList * | |
56 gevo_get_groups(void) | |
57 { | |
58 GList *tmp = NULL; | |
59 char *tmp2; | |
60 GaimGroup *g; | |
61 GaimBlistNode *gnode; | |
62 | |
63 if (gaim_get_blist()->root == NULL) | |
64 { | |
65 tmp2 = g_strdup(_("Buddies")); | |
66 tmp = g_list_append(tmp, tmp2); | |
67 } | |
68 else | |
69 { | |
70 for (gnode = gaim_get_blist()->root; | |
71 gnode != NULL; | |
72 gnode = gnode->next) | |
73 { | |
74 if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
75 { | |
76 g = (GaimGroup *)gnode; | |
77 tmp2 = g->name; | |
78 tmp = g_list_append(tmp, tmp2); | |
79 } | |
80 } | |
81 } | |
82 | |
83 return tmp; | |
84 } | |
85 | |
86 EContactField | |
87 gevo_prpl_get_field(GaimAccount *account, GaimBuddy *buddy) | |
88 { | |
89 EContactField protocol_field = 0; | |
90 const char *protocol_id; | |
91 | |
92 g_return_val_if_fail(account != NULL, 0); | |
93 | |
94 protocol_id = gaim_account_get_protocol_id(account); | |
95 | |
96 if (!strcmp(protocol_id, "prpl-oscar")) | |
97 { | |
98 GaimConnection *gc; | |
99 GaimPluginProtocolInfo *prpl_info; | |
100 | |
101 gc = gaim_account_get_connection(account); | |
102 | |
103 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
104 | |
105 if (!strcmp("aim", prpl_info->list_icon(account, buddy))) | |
106 { | |
107 protocol_field = E_CONTACT_IM_AIM; | |
108 } | |
109 else | |
110 protocol_field = E_CONTACT_IM_ICQ; | |
111 } | |
112 else if (!strcmp(protocol_id, "prpl-msn")) | |
113 protocol_field = E_CONTACT_IM_MSN; | |
114 else if (!strcmp(protocol_id, "prpl-yahoo")) | |
115 protocol_field = E_CONTACT_IM_YAHOO; | |
116 else if (!strcmp(protocol_id, "prpl-jabber")) | |
117 protocol_field = E_CONTACT_IM_JABBER; | |
118 | |
119 return protocol_field; | |
120 } | |
121 | |
122 gboolean | |
123 gevo_prpl_is_supported(GaimAccount *account, GaimBuddy *buddy) | |
124 { | |
125 return (gevo_prpl_get_field(account, buddy) != 0); | |
126 } | |
127 | |
128 gboolean | |
129 gevo_load_addressbook(EBook **book, GError **error) | |
130 { | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
131 gboolean result = FALSE; |
8089 | 132 |
133 g_return_val_if_fail(book != NULL, FALSE); | |
134 | |
9352
cc2baf349805
[gaim-migrate @ 10160]
Christian Hammond <chipx86@chipx86.com>
parents:
9293
diff
changeset
|
135 #if EBOOK_CHECK_VERSION(0, 0, 94) |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
136 *book = e_book_new_system_addressbook(NULL); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
137 |
9352
cc2baf349805
[gaim-migrate @ 10160]
Christian Hammond <chipx86@chipx86.com>
parents:
9293
diff
changeset
|
138 result = e_book_open(*book, FALSE, NULL); |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
139 #else |
8089 | 140 *book = e_book_new(); |
141 | |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
142 result = e_book_load_local_addressbook(*book, error); |
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
143 #endif |
8089 | 144 |
9046
c307cf4c84d2
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
145 if (!result && *book != NULL) |
8089 | 146 { |
147 g_object_unref(*book); | |
148 *book = NULL; | |
149 } | |
150 | |
151 return result; | |
152 } |