comparison gtk/plugins/gevolution/gevo-util.c @ 14964:89ef5680f228

[gaim-migrate @ 17743] Split out the logic for finding a buddy's e-mail address into a separate function. Show the "Send E-mail" menu item only if an e-mail address was found. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 13 Nov 2006 04:16:49 +0000
parents 009db0b357b5
children
comparison
equal deleted inserted replaced
14963:1aa9839ca599 14964:89ef5680f228
144 *book = NULL; 144 *book = NULL;
145 } 145 }
146 146
147 return result; 147 return result;
148 } 148 }
149
150 char *
151 gevo_get_email_for_buddy(GaimBuddy *buddy)
152 {
153 EContact *contact;
154 char *mail = NULL;
155
156 contact = gevo_search_buddy_in_contacts(buddy, NULL);
157
158 if (contact != NULL)
159 {
160 mail = g_strdup(e_contact_get(contact, E_CONTACT_EMAIL_1));
161 g_object_unref(contact);
162 }
163
164 if (mail == NULL)
165 {
166 GaimAccount *account = gaim_buddy_get_account(buddy);
167 const char *prpl_id = gaim_account_get_protocol_id(account);
168
169 if (!strcmp(prpl_id, "prpl-msn"))
170 {
171 mail = g_strdup(gaim_normalize(account,
172 gaim_buddy_get_name(buddy)));
173 }
174 else if (!strcmp(prpl_id, "prpl-yahoo"))
175 {
176 mail = g_strdup_printf("%s@yahoo.com",
177 gaim_normalize(account,
178 gaim_buddy_get_name(buddy)));
179 }
180 }
181
182 return mail;
183 }