Tue, 17 Jan 2006 23:22:19 +0000
[gaim-migrate @ 15272]
Replace GaimBlistNodeAction with the more generic GaimMenuAction, this is in
preparation for letting the chat room user list have extensible menus like the
blist entries do. (I know it's not exactly the prettiest, and the callback
isn't exactly type-safe, when we eventually gobjectify everything we can get
some safety back by using (GObject, gpointer) but that's for later.)
I'm planning to look into merging GaimPluginActions into GaimMenuActions as
well.
| 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
85a5ebe9315f
[gaim-migrate @ 10696]
Christian Hammond <chipx86@chipx86.com>
parents:
9824
diff
changeset
|
21 | #include "internal.h" |
| 8089 | 22 | #include "gtkblist.h" |
|
9824
2fc5eef80af8
[gaim-migrate @ 10695]
Mark Doliner <markdoliner@pidgin.im>
parents:
9354
diff
changeset
|
23 | #include "gtkgaim.h" |
| 8089 | 24 | #include "gtkutils.h" |
| 25 | ||
|
9046
7892b6524178
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
26 | #include "gevolution.h" |
|
7892b6524178
[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 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11054
diff
changeset
|
36 | conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, screenname, account); |
| 8089 | 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); | |
|
11643
f04408721780
[gaim-migrate @ 13920]
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
11338
diff
changeset
|
46 | gaim_account_add_buddy(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 | { | |
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
58 | GList *list = NULL; |
| 8089 | 59 | GaimGroup *g; |
| 60 | GaimBlistNode *gnode; | |
| 61 | ||
| 62 | if (gaim_get_blist()->root == NULL) | |
| 63 | { | |
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
64 | list = g_list_append(list, _("Buddies")); |
| 8089 | 65 | } |
| 66 | else | |
| 67 | { | |
| 68 | for (gnode = gaim_get_blist()->root; | |
| 69 | gnode != NULL; | |
| 70 | gnode = gnode->next) | |
| 71 | { | |
| 72 | if (GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 73 | { | |
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
74 | g = (GaimGroup *)gnode; |
|
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
75 | list = g_list_append(list, g->name); |
| 8089 | 76 | } |
| 77 | } | |
| 78 | } | |
| 79 | ||
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
80 | return list; |
| 8089 | 81 | } |
| 82 | ||
| 83 | EContactField | |
| 84 | gevo_prpl_get_field(GaimAccount *account, GaimBuddy *buddy) | |
| 85 | { | |
| 86 | EContactField protocol_field = 0; | |
| 87 | const char *protocol_id; | |
| 88 | ||
| 89 | g_return_val_if_fail(account != NULL, 0); | |
| 90 | ||
| 91 | protocol_id = gaim_account_get_protocol_id(account); | |
| 92 | ||
| 93 | if (!strcmp(protocol_id, "prpl-oscar")) | |
| 94 | { | |
| 95 | GaimConnection *gc; | |
| 96 | GaimPluginProtocolInfo *prpl_info; | |
| 97 | ||
| 98 | gc = gaim_account_get_connection(account); | |
| 99 | ||
| 100 | prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 101 | ||
| 102 | if (!strcmp("aim", prpl_info->list_icon(account, buddy))) | |
| 103 | { | |
| 104 | protocol_field = E_CONTACT_IM_AIM; | |
| 105 | } | |
| 106 | else | |
| 107 | protocol_field = E_CONTACT_IM_ICQ; | |
| 108 | } | |
| 109 | else if (!strcmp(protocol_id, "prpl-msn")) | |
| 110 | protocol_field = E_CONTACT_IM_MSN; | |
| 111 | else if (!strcmp(protocol_id, "prpl-yahoo")) | |
| 112 | protocol_field = E_CONTACT_IM_YAHOO; | |
| 113 | else if (!strcmp(protocol_id, "prpl-jabber")) | |
| 114 | protocol_field = E_CONTACT_IM_JABBER; | |
|
11054
ba2440c5ee48
[gaim-migrate @ 12992]
Stanislav Brabec <sbrabec@suse.cz>
parents:
10246
diff
changeset
|
115 | else if (!strcmp(protocol_id, "prpl-novell")) |
|
ba2440c5ee48
[gaim-migrate @ 12992]
Stanislav Brabec <sbrabec@suse.cz>
parents:
10246
diff
changeset
|
116 | protocol_field = E_CONTACT_IM_GROUPWISE; |
| 8089 | 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 | |
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
128 | gevo_load_addressbook(const gchar* uri, EBook **book, GError **error) |
| 8089 | 129 | { |
|
9046
7892b6524178
[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 | ||
|
10081
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
134 | if (uri == NULL) |
|
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
135 | *book = e_book_new_system_addressbook(NULL); |
|
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
136 | else |
|
64e398f0eaa3
[gaim-migrate @ 11071]
Christian Hammond <chipx86@chipx86.com>
parents:
9825
diff
changeset
|
137 | *book = e_book_new_from_uri(uri, error); |
|
9046
7892b6524178
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
138 | |
|
9352
110bd952f273
[gaim-migrate @ 10160]
Christian Hammond <chipx86@chipx86.com>
parents:
9293
diff
changeset
|
139 | result = e_book_open(*book, FALSE, NULL); |
| 8089 | 140 | |
|
9046
7892b6524178
[gaim-migrate @ 9822]
Christian Hammond <chipx86@chipx86.com>
parents:
8474
diff
changeset
|
141 | if (!result && *book != NULL) |
| 8089 | 142 | { |
| 143 | g_object_unref(*book); | |
| 144 | *book = NULL; | |
| 145 | } | |
| 146 | ||
| 147 | return result; | |
| 148 | } |