2 * Evolution integration plugin for Purple
4 * Copyright (C) 2003 Christian Hammond.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "gevolution.h"
29 gevo_add_buddy(PurpleAccount
*account
, const char *group_name
,
30 const char *buddy_name
, const char *alias
)
32 PurpleIMConversation
*im
= NULL
;
36 im
= purple_conversations_find_im_with_account(buddy_name
, account
);
38 group
= purple_blist_find_group(group_name
);
41 group
= purple_group_new(group_name
);
42 purple_blist_add_group(group
, NULL
);
45 buddy
= purple_blist_find_buddy_in_group(account
, buddy_name
, group
);
48 buddy
= purple_buddy_new(account
, buddy_name
, alias
);
49 purple_blist_add_buddy(buddy
, NULL
, group
, NULL
);
52 purple_account_add_buddy(account
, buddy
, NULL
);
56 purple_buddy_icon_update(purple_im_conversation_get_icon(im
));
57 purple_conversation_update(PURPLE_CONVERSATION(im
),
58 PURPLE_CONVERSATION_UPDATE_ADD
);
65 static GList
*list
= NULL
;
67 PurpleBlistNode
*gnode
;
72 if (purple_blist_get_buddy_list()->root
== NULL
) {
73 list
= g_list_append(list
,
74 (gpointer
)PURPLE_BLIST_DEFAULT_GROUP_NAME
);
76 for (gnode
= purple_blist_get_buddy_list()->root
;
80 if (PURPLE_IS_GROUP(gnode
))
82 g
= PURPLE_GROUP(gnode
);
83 list
= g_list_append(list
,
84 (gpointer
)purple_group_get_name(g
));
93 gevo_protocol_get_field(PurpleAccount
*account
, PurpleBuddy
*buddy
)
95 EContactField protocol_field
= 0;
96 const char *protocol_id
;
98 g_return_val_if_fail(account
!= NULL
, 0);
100 protocol_id
= purple_account_get_protocol_id(account
);
102 if (!strcmp(protocol_id
, "prpl-aim"))
103 protocol_field
= E_CONTACT_IM_AIM
;
104 else if (!strcmp(protocol_id
, "prpl-icq"))
105 protocol_field
= E_CONTACT_IM_ICQ
;
106 else if (!strcmp(protocol_id
, "prpl-msn"))
107 protocol_field
= E_CONTACT_IM_MSN
;
108 else if (!strcmp(protocol_id
, "prpl-yahoo"))
109 protocol_field
= E_CONTACT_IM_YAHOO
;
110 else if (!strcmp(protocol_id
, "prpl-jabber"))
111 protocol_field
= E_CONTACT_IM_JABBER
;
112 else if (!strcmp(protocol_id
, "prpl-novell"))
113 protocol_field
= E_CONTACT_IM_GROUPWISE
;
114 else if (!strcmp(protocol_id
, "prpl-gg"))
115 protocol_field
= E_CONTACT_IM_GADUGADU
;
117 return protocol_field
;
121 gevo_protocol_is_supported(PurpleAccount
*account
, PurpleBuddy
*buddy
)
123 return (gevo_protocol_get_field(account
, buddy
) != 0);
127 gevo_load_addressbook(const gchar
* uid
, EBook
**book
, GError
**error
)
129 gboolean result
= FALSE
;
130 ESourceRegistry
*registry
;
133 g_return_val_if_fail(book
!= NULL
, FALSE
);
135 registry
= e_source_registry_new_sync(NULL
, error
);
141 source
= e_source_registry_ref_default_address_book(registry
);
143 source
= e_source_registry_ref_source(registry
, uid
);
145 g_object_unref(registry
);
147 result
= gevo_load_addressbook_from_source(source
, book
, error
);
149 g_object_unref(source
);
155 gevo_load_addressbook_from_source(ESource
*source
, EBook
**book
, GError
**error
)
157 gboolean result
= FALSE
;
159 *book
= e_book_new(source
, error
);
166 result
= e_book_open(*book
, FALSE
, error
);
168 if (!result
&& *book
!= NULL
)
170 g_object_unref(*book
);
178 gevo_get_email_for_buddy(PurpleBuddy
*buddy
)
183 contact
= gevo_search_buddy_in_contacts(buddy
, NULL
);
187 mail
= g_strdup(e_contact_get(contact
, E_CONTACT_EMAIL_1
));
188 g_object_unref(contact
);
193 PurpleAccount
*account
= purple_buddy_get_account(buddy
);
194 const char *protocol_id
= purple_account_get_protocol_id(account
);
196 if (!strcmp(protocol_id
, "prpl-msn"))
198 mail
= g_strdup(purple_normalize(account
,
199 purple_buddy_get_name(buddy
)));
201 else if (!strcmp(protocol_id
, "prpl-yahoo"))
203 mail
= g_strdup_printf("%s@yahoo.com",
204 purple_normalize(account
,
205 purple_buddy_get_name(buddy
)));