Mercurial > pidgin
annotate src/protocols/gg/confer.c @ 13253:87a7c3077c19
[gaim-migrate @ 15619]
More cleaning up of oscar. Renamed some functions to be more clear.
Got rid of some stuff that wasn't used. Inlined some small things
in conn.c that were only used once.
The goals of all this are
1. Non-blocking I/O for all connections
2. p2p stuff won't use the same struct as oscar connections, because
that's stupid
3. The oscar PRPL should be less scary
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 12 Feb 2006 21:27:04 +0000 |
| parents | 4eae108efdde |
| children | 41747a38a1a8 |
| rev | line source |
|---|---|
| 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, | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
36 gaim_connection_get_account(gc)); |
| 11414 | 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, | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
42 const uin_t uin) |
| 11414 | 43 { |
| 44 GaimConversation *conv; | |
| 45 GGPInfo *info = gc->proto_data; | |
| 46 GGPChat *chat; | |
| 47 GList *l; | |
| 48 gchar *str_uin; | |
| 49 | |
| 50 for (l = info->chats; l != NULL; l = l->next) { | |
| 51 chat = l->data; | |
| 52 | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
53 if (g_utf8_collate(chat->name, chat_name) != 0) |
|
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
54 continue; |
|
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
55 |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
56 if (g_list_find(chat->participants, GINT_TO_POINTER(uin)) == NULL) { |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
57 chat->participants = g_list_append( |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
58 chat->participants, GINT_TO_POINTER(uin)); |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
59 |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
60 str_uin = g_strdup_printf("%lu", (unsigned long int)uin); |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
61 conv = ggp_confer_find_by_name(gc, chat_name); |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
62 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), str_uin, NULL, |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
63 GAIM_CBFLAGS_NONE, TRUE); |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
64 |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
65 g_free(str_uin); |
| 11414 | 66 } |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
67 break; |
| 11414 | 68 } |
| 69 } | |
| 70 /* }}} */ | |
| 71 | |
| 72 /* void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */ | |
| 73 void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
74 const uin_t *recipients, int count) |
| 11414 | 75 { |
| 76 GGPInfo *info = gc->proto_data; | |
| 77 GList *l; | |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
78 gchar *str_uin; |
| 11414 | 79 |
| 80 for (l = info->chats; l != NULL; l = l->next) { | |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
81 GGPChat *chat = l->data; |
|
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
82 int i; |
| 11414 | 83 |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
84 if (g_utf8_collate(chat->name, chat_name) != 0) |
|
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
85 continue; |
| 11414 | 86 |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
87 for (i = 0; i < count; i++) { |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
88 GaimConversation *conv; |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
89 |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
90 if (g_list_find(chat->participants, |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
91 GINT_TO_POINTER(recipients[i])) != NULL) { |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
92 continue; |
|
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
93 } |
| 11414 | 94 |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
95 chat->participants = g_list_append(chat->participants, |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
96 GINT_TO_POINTER(recipients[i])); |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
97 |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
98 str_uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
99 conv = ggp_confer_find_by_name(gc, chat_name); |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
100 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
101 str_uin, NULL, |
|
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
102 GAIM_CBFLAGS_NONE, TRUE); |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
103 g_free(str_uin); |
| 11414 | 104 } |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
105 break; |
| 11414 | 106 } |
| 107 } | |
| 108 /* }}} */ | |
| 109 | |
| 110 /* const char *ggp_confer_find_by_participants(GaimConnection *gc, const uin_t *recipients, int count) {{{ */ | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
111 const char *ggp_confer_find_by_participants(GaimConnection *gc, |
|
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
112 const uin_t *recipients, int count) |
| 11414 | 113 { |
| 114 GGPInfo *info = gc->proto_data; | |
| 115 GGPChat *chat = NULL; | |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
116 GList *l; |
|
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
117 int matches; |
| 11414 | 118 |
| 119 g_return_val_if_fail(info->chats != NULL, NULL); | |
| 120 | |
| 121 for (l = info->chats; l != NULL; l = l->next) { | |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
122 GList *m; |
|
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
123 |
| 11414 | 124 chat = l->data; |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
125 matches = 0; |
| 11414 | 126 |
| 127 for (m = chat->participants; m != NULL; m = m->next) { | |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
128 uin_t uin = GPOINTER_TO_INT(m->data); |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
129 int i; |
| 11414 | 130 |
| 131 for (i = 0; i < count; i++) | |
|
12961
4eae108efdde
[gaim-migrate @ 15314]
Richard Laager <rlaager@wiktel.com>
parents:
12373
diff
changeset
|
132 if (uin == recipients[i]) |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
133 matches++; |
| 11414 | 134 } |
| 135 | |
|
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
136 if (matches == count) |
| 11414 | 137 break; |
| 138 | |
| 139 chat = NULL; | |
| 140 } | |
| 141 | |
| 142 if (chat == NULL) | |
| 143 return NULL; | |
| 144 else | |
| 145 return chat->name; | |
| 146 } | |
| 147 /* }}} */ | |
| 148 | |
| 149 /* const char *ggp_confer_add_new(GaimConnection *gc, const char *name) {{{ */ | |
| 150 const char *ggp_confer_add_new(GaimConnection *gc, const char *name) | |
| 151 { | |
| 152 GGPInfo *info = gc->proto_data; | |
| 153 GGPChat *chat; | |
| 154 | |
| 155 chat = g_new0(GGPChat, 1); | |
| 156 | |
| 157 if (name == NULL) | |
| 158 chat->name = g_strdup_printf("conf#%d", info->chats_count++); | |
| 159 else | |
| 160 chat->name = g_strdup(name); | |
| 161 | |
| 162 chat->participants = NULL; | |
| 163 | |
| 164 info->chats = g_list_append(info->chats, chat); | |
| 165 | |
| 166 return chat->name; | |
| 167 } | |
| 168 /* }}} */ | |
| 169 | |
|
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
170 /* vim: set ts=8 sts=0 sw=8 noet: */ |
