11414
|
1 /**
|
|
2 * @file confer.c
|
|
3 *
|
|
4 * gaim
|
|
5 *
|
|
6 * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us>
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 */
|
|
22
|
|
23
|
|
24 #include "lib/libgadu.h"
|
|
25 #include "gg.h"
|
|
26 #include "utils.h"
|
|
27 #include "confer.h"
|
|
28
|
|
29 /* GaimConversation *ggp_confer_find_by_name(GaimConnection *gc, const gchar *name) {{{ */
|
|
30 GaimConversation *ggp_confer_find_by_name(GaimConnection *gc, const gchar *name)
|
|
31 {
|
|
32 g_return_val_if_fail(gc != NULL, NULL);
|
|
33 g_return_val_if_fail(name != NULL, NULL);
|
|
34
|
|
35 return gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, name,
|
|
36 gaim_connection_get_account(gc));
|
|
37 }
|
|
38 /* }}} */
|
|
39
|
|
40 /* void ggp_confer_participants_add_uin(GaimConnection *gc, const gchar *chat_name, const uin_t uin) {{{ */
|
|
41 void ggp_confer_participants_add_uin(GaimConnection *gc, const gchar *chat_name,
|
|
42 const uin_t uin)
|
|
43 {
|
|
44 GaimConversation *conv;
|
|
45 GGPInfo *info = gc->proto_data;
|
|
46 GGPChat *chat;
|
|
47 GList *l;
|
|
48 gchar *str_uin;
|
|
49
|
|
50 str_uin = g_strdup_printf("%lu", (unsigned long int)uin);
|
|
51
|
|
52 for (l = info->chats; l != NULL; l = l->next) {
|
|
53 chat = l->data;
|
|
54
|
|
55 if (g_utf8_collate(chat->name, chat_name) == 0) {
|
|
56 if (g_list_find(chat->participants, str_uin) == NULL) {
|
|
57 chat->participants = g_list_append(chat->participants, str_uin);
|
|
58 conv = ggp_confer_find_by_name(gc, chat_name);
|
|
59
|
|
60 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv),
|
|
61 ggp_buddy_get_name(gc, uin), NULL, GAIM_CBFLAGS_NONE, TRUE);
|
|
62 }
|
|
63 break;
|
|
64 }
|
|
65 }
|
|
66 }
|
|
67 /* }}} */
|
|
68
|
|
69 /* void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */
|
|
70 void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name,
|
|
71 const uin_t *recipients, int count)
|
|
72 {
|
|
73 GaimConversation *conv;
|
|
74 GGPInfo *info = gc->proto_data;
|
|
75 GGPChat *chat;
|
|
76 GList *l;
|
|
77 int i;
|
|
78 gchar *uin;
|
|
79
|
|
80 for (l = info->chats; l != NULL; l = l->next) {
|
|
81 chat = l->data;
|
|
82
|
|
83 if (g_utf8_collate(chat->name, chat_name) == 0) {
|
|
84
|
|
85 for (i = 0; i < count; i++) {
|
|
86 uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]);
|
|
87 if (g_list_find(chat->participants, uin) == NULL) {
|
|
88 chat->participants = g_list_append(chat->participants, uin);
|
|
89 conv = ggp_confer_find_by_name(gc, chat_name);
|
|
90
|
|
91 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv),
|
|
92 ggp_buddy_get_name(gc, recipients[i]),
|
|
93 NULL, GAIM_CBFLAGS_NONE, TRUE);
|
|
94 }
|
|
95 g_free(uin);
|
|
96 }
|
|
97 break;
|
|
98 }
|
|
99 }
|
|
100 }
|
|
101 /* }}} */
|
|
102
|
|
103 /* const char *ggp_confer_find_by_participants(GaimConnection *gc, const uin_t *recipients, int count) {{{ */
|
|
104 const char *ggp_confer_find_by_participants(GaimConnection *gc, const uin_t *recipients, int count)
|
|
105 {
|
|
106 GGPInfo *info = gc->proto_data;
|
|
107 GGPChat *chat = NULL;
|
|
108 GList *l, *m;
|
|
109 int i;
|
|
110 int maches;
|
|
111
|
|
112 g_return_val_if_fail(info->chats != NULL, NULL);
|
|
113
|
|
114 for (l = info->chats; l != NULL; l = l->next) {
|
|
115 chat = l->data;
|
|
116 maches = 0;
|
|
117
|
|
118 for (m = chat->participants; m != NULL; m = m->next) {
|
|
119 uin_t p = ggp_str_to_uin(m->data);
|
|
120
|
|
121 for (i = 0; i < count; i++)
|
|
122 if (p == recipients[i])
|
|
123 maches++;
|
|
124 }
|
|
125
|
|
126 if (maches == count)
|
|
127 break;
|
|
128
|
|
129 chat = NULL;
|
|
130 }
|
|
131
|
|
132 if (chat == NULL)
|
|
133 return NULL;
|
|
134 else
|
|
135 return chat->name;
|
|
136 }
|
|
137 /* }}} */
|
|
138
|
|
139 /* const char *ggp_confer_add_new(GaimConnection *gc, const char *name) {{{ */
|
|
140 const char *ggp_confer_add_new(GaimConnection *gc, const char *name)
|
|
141 {
|
|
142 GGPInfo *info = gc->proto_data;
|
|
143 GGPChat *chat;
|
|
144
|
|
145 chat = g_new0(GGPChat, 1);
|
|
146
|
|
147 if (name == NULL)
|
|
148 chat->name = g_strdup_printf("conf#%d", info->chats_count++);
|
|
149 else
|
|
150 chat->name = g_strdup(name);
|
|
151
|
|
152 chat->participants = NULL;
|
|
153
|
|
154 info->chats = g_list_append(info->chats, chat);
|
|
155
|
|
156 return chat->name;
|
|
157 }
|
|
158 /* }}} */
|
|
159
|
|
160 /* vim: set ts=4 sts=0 sw=4 noet: */
|