Mercurial > pidgin.yaz
annotate src/server.c @ 11955:e094639ab422
[gaim-migrate @ 14246]
this lets me compile without GMP
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 02 Nov 2005 13:43:50 +0000 |
parents | d2db6426c88a |
children | aadf61b30056 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6 * source distribution. | |
1 | 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 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
23 #include "internal.h" |
9944 | 24 #include "blist.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
25 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
26 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
27 #include "log.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
28 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
29 #include "prefs.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
30 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
31 #include "request.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
32 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
33 #include "server.h" |
9944 | 34 #include "status.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
35 #include "util.h" |
1 | 36 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
37 /* XXX UI Stuff */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
38 #include "gaim.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
39 #include "gtkutils.h" |
4687 | 40 |
8948 | 41 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600 |
9285 | 42 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married" |
8948 | 43 |
2993 | 44 /* This should return the elapsed time in seconds in which Gaim will not send |
45 * typing notifications. | |
8674
8c7da2e36136
[gaim-migrate @ 9426]
Christian Hammond <chipx86@chipx86.com>
parents:
8619
diff
changeset
|
46 * if it returns zero, it will not send any more typing notifications |
3001 | 47 * typing is a flag - TRUE for typing, FALSE for stopped typing */ |
6059 | 48 int serv_send_typing(GaimConnection *g, const char *name, int typing) { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
49 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
50 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
51 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
52 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
53 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
54 if (g && prpl_info && prpl_info->send_typing) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
55 return prpl_info->send_typing(g, name, typing); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
56 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
57 return 0; |
2993 | 58 } |
1 | 59 |
10871 | 60 static GSList *last_auto_responses = NULL; |
6479 | 61 struct last_auto_response { |
62 GaimConnection *gc; | |
3815 | 63 char name[80]; |
6479 | 64 time_t sent; |
3815 | 65 }; |
66 | |
10850 | 67 static gboolean |
68 expire_last_auto_responses(gpointer data) | |
6479 | 69 { |
70 GSList *tmp, *cur; | |
71 struct last_auto_response *lar; | |
72 | |
73 tmp = last_auto_responses; | |
74 | |
75 while (tmp) { | |
76 cur = tmp; | |
77 tmp = tmp->next; | |
78 lar = (struct last_auto_response *)cur->data; | |
79 | |
8948 | 80 if ((time(NULL) - lar->sent) > SECS_BEFORE_RESENDING_AUTORESPONSE) { |
6479 | 81 last_auto_responses = g_slist_remove(last_auto_responses, lar); |
82 g_free(lar); | |
83 } | |
84 } | |
85 | |
86 return FALSE; /* do not run again */ | |
87 } | |
88 | |
10850 | 89 static struct last_auto_response * |
90 get_last_auto_response(GaimConnection *gc, const char *name) | |
6479 | 91 { |
92 GSList *tmp; | |
93 struct last_auto_response *lar; | |
94 | |
95 /* because we're modifying or creating a lar, schedule the | |
96 * function to expire them as the pref dictates */ | |
8948 | 97 gaim_timeout_add((SECS_BEFORE_RESENDING_AUTORESPONSE + 1) * 1000, expire_last_auto_responses, NULL); |
6479 | 98 |
99 tmp = last_auto_responses; | |
100 | |
101 while (tmp) { | |
102 lar = (struct last_auto_response *)tmp->data; | |
103 | |
104 if (gc == lar->gc && !strncmp(name, lar->name, sizeof(lar->name))) | |
105 return lar; | |
106 | |
107 tmp = tmp->next; | |
108 } | |
109 | |
110 lar = (struct last_auto_response *)g_new0(struct last_auto_response, 1); | |
111 g_snprintf(lar->name, sizeof(lar->name), "%s", name); | |
112 lar->gc = gc; | |
113 lar->sent = 0; | |
114 last_auto_responses = g_slist_append(last_auto_responses, lar); | |
115 | |
116 return lar; | |
117 } | |
118 | |
6059 | 119 int serv_send_im(GaimConnection *gc, const char *name, const char *message, |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
120 GaimConvImFlags imflags) |
1 | 121 { |
9949 | 122 GaimConversation *conv; |
123 GaimAccount *account; | |
124 GaimPresence *presence; | |
125 GaimPluginProtocolInfo *prpl_info = NULL; | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
126 int val = -EINVAL; |
9594 | 127 const gchar *auto_reply_pref; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
128 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
129 if (gc != NULL && gc->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
130 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
131 |
9949 | 132 account = gaim_connection_get_account(gc); |
133 presence = gaim_account_get_presence(account); | |
134 | |
11338 | 135 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
136 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
137 if (prpl_info && prpl_info->send_im) |
6982 | 138 val = prpl_info->send_im(gc, name, message, imflags); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
139 |
11907 | 140 /* Only update the last_sent_time if the user actually sent the message */ |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
141 if (!(imflags & GAIM_CONV_IM_AUTO_RESP)) |
11907 | 142 time(&gc->last_sent_time); |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
143 |
9594 | 144 /* |
145 * XXX - If "only auto-reply when away & idle" is set, then shouldn't | |
146 * this only reset lar->sent if we're away AND idle? | |
147 */ | |
148 auto_reply_pref = gaim_prefs_get_string("/core/away/auto_reply"); | |
9949 | 149 if ((gc->flags & GAIM_CONNECTION_AUTO_RESP) && |
150 !gaim_presence_is_available(presence) && | |
151 strcmp(auto_reply_pref, "never")) { | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5539
diff
changeset
|
152 |
6479 | 153 struct last_auto_response *lar; |
154 lar = get_last_auto_response(gc, name); | |
155 lar->sent = time(NULL); | |
3815 | 156 } |
157 | |
9949 | 158 if (conv && gaim_conv_im_get_type_again_timeout(GAIM_CONV_IM(conv))) |
159 gaim_conv_im_stop_type_again_timeout(GAIM_CONV_IM(conv)); | |
3601 | 160 |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
161 return val; |
1 | 162 } |
163 | |
9285 | 164 void serv_get_info(GaimConnection *gc, const char *name) |
1 | 165 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
166 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
167 |
9285 | 168 if (gc != NULL && gc->prpl != NULL) |
169 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
170 |
9285 | 171 if (gc && prpl_info && prpl_info->get_info) |
172 prpl_info->get_info(gc, name); | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
173 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
174 |
9285 | 175 void serv_set_info(GaimConnection *gc, const char *info) |
1 | 176 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
177 GaimPluginProtocolInfo *prpl_info = NULL; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
178 GaimAccount *account; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
179 |
9285 | 180 if (gc != NULL && gc->prpl != NULL) |
181 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
182 |
9285 | 183 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
184 prpl_info->set_info) { |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
185 |
9285 | 186 account = gaim_connection_get_account(gc); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
187 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
188 if (gaim_signal_emit_return_1(gaim_accounts_get_handle(), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
189 "account-setting-info", account, info)) |
3456 | 190 return; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
191 |
9285 | 192 prpl_info->set_info(gc, info); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
193 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
194 gaim_signal_emit(gaim_accounts_get_handle(), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
195 "account-set-info", account, info); |
1749
5bfc58c20e82
[gaim-migrate @ 1759]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1734
diff
changeset
|
196 } |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
197 } |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
198 |
3136 | 199 /* |
200 * Set buddy's alias on server roster/list | |
201 */ | |
6695 | 202 void serv_alias_buddy(GaimBuddy *b) |
3136 | 203 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
204 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
205 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
206 if (b != NULL && b->account->gc->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
207 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(b->account->gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
208 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
209 if (b && prpl_info && prpl_info->alias_buddy) { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
210 prpl_info->alias_buddy(b->account->gc, b->name, b->alias); |
3136 | 211 } |
212 } | |
213 | |
9135
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
214 void |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
215 serv_got_alias(GaimConnection *gc, const char *who, const char *alias) |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
216 { |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
217 GaimAccount *account = gaim_connection_get_account(gc); |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
218 GSList *buds, *buddies = gaim_find_buddies(account, who); |
8870 | 219 GaimBuddy *b; |
9135
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
220 GaimConversation *conv; |
6058 | 221 |
9135
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
222 for (buds = buddies; buds; buds = buds->next) |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
223 { |
8870 | 224 b = buds->data; |
225 gaim_blist_server_alias_buddy(b, alias); | |
9135
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
226 |
11338 | 227 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, account); |
9135
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
228 |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
229 if (conv != NULL && b->server_alias != NULL && |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
230 strcmp(b->server_alias, alias)) |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
231 { |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
232 char *tmp = g_strdup_printf(_("%s is now known as %s.\n"), |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
233 who, alias); |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
234 |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
235 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
236 time(NULL)); |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
237 |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
238 g_free(tmp); |
6038664a67fe
[gaim-migrate @ 9919]
Christian Hammond <chipx86@chipx86.com>
parents:
9109
diff
changeset
|
239 } |
8870 | 240 } |
8894 | 241 g_slist_free(buddies); |
4227 | 242 } |
243 | |
3136 | 244 /* |
245 * Move a buddy from one group to another on server. | |
246 * | |
247 * Note: For now we'll not deal with changing gc's at the same time, but | |
9285 | 248 * it should be possible. Probably needs to be done, someday. Although, |
249 * the UI for that would be difficult, because groups are Gaim-wide. | |
3136 | 250 */ |
6695 | 251 void serv_move_buddy(GaimBuddy *b, GaimGroup *og, GaimGroup *ng) |
3136 | 252 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
253 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
254 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
255 if (b->account->gc != NULL && b->account->gc->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
256 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(b->account->gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
257 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
258 if (b && b->account->gc && og && ng) { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
259 if (prpl_info && prpl_info->group_buddy) { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
260 prpl_info->group_buddy(b->account->gc, b->name, og->name, ng->name); |
3136 | 261 } |
262 } | |
263 } | |
264 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
265 void serv_add_permit(GaimConnection *g, const char *name) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
266 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
267 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
268 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
269 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
270 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
271 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
272 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->add_permit) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
273 prpl_info->add_permit(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
274 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
275 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
276 void serv_add_deny(GaimConnection *g, const char *name) |
1 | 277 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
278 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
279 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
280 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
281 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
282 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
283 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->add_deny) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
284 prpl_info->add_deny(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
285 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
286 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
287 void serv_rem_permit(GaimConnection *g, const char *name) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
288 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
289 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
290 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
291 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
292 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
293 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
294 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->rem_permit) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
295 prpl_info->rem_permit(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
296 } |
1 | 297 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
298 void serv_rem_deny(GaimConnection *g, const char *name) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
299 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
300 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
301 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
302 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
303 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
304 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
305 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->rem_deny) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
306 prpl_info->rem_deny(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
307 } |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
660
diff
changeset
|
308 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
309 void serv_set_permit_deny(GaimConnection *g) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
310 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
311 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
312 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
313 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
314 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
315 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
316 /* |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
317 * this is called when either you import a buddy list, and make lots |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
318 * of changes that way, or when the user toggles the permit/deny mode |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
319 * in the prefs. In either case you should probably be resetting and |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
320 * resending the permit/deny info when you get this. |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
321 */ |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
322 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->set_permit_deny) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
323 prpl_info->set_permit_deny(g); |
1 | 324 } |
325 | |
1026 | 326 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
327 void serv_set_idle(GaimConnection *g, int time) |
1 | 328 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
329 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
330 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
331 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
332 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
333 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
334 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->set_idle) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
335 prpl_info->set_idle(g, time); |
1 | 336 } |
337 | |
338 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
339 void serv_join_chat(GaimConnection *g, GHashTable *data) |
1 | 340 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
341 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
342 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
343 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
344 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
345 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
346 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->join_chat) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
347 prpl_info->join_chat(g, data); |
1 | 348 } |
349 | |
8562 | 350 |
351 void serv_reject_chat(GaimConnection *g, GHashTable *data) | |
352 { | |
353 GaimPluginProtocolInfo *prpl_info = NULL; | |
354 | |
355 if (g != NULL && g->prpl != NULL) | |
356 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); | |
357 | |
358 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->reject_chat) | |
359 prpl_info->reject_chat(g, data); | |
360 } | |
361 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
362 void serv_chat_invite(GaimConnection *g, int id, const char *message, const char *name) |
1 | 363 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
364 GaimPluginProtocolInfo *prpl_info = NULL; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
365 GaimConversation *conv; |
2359
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
366 char *buffy = message && *message ? g_strdup(message) : NULL; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
367 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
368 conv = gaim_find_chat(g, id); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
369 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
370 if (conv == NULL) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
371 return; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
372 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
373 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
374 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
375 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
376 gaim_signal_emit(gaim_conversations_get_handle(), "chat-inviting-user", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
377 conv, name, &buffy); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
378 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
379 if (prpl_info && g_list_find(gaim_connections_get_all(), g) && prpl_info->chat_invite) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
380 prpl_info->chat_invite(g, id, buffy, name); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
381 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
382 gaim_signal_emit(gaim_conversations_get_handle(), "chat-invited-user", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
383 conv, name, buffy); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
384 |
2359
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
385 if (buffy) |
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
386 g_free(buffy); |
1 | 387 } |
388 | |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
389 /* Ya know, nothing uses this except gaim_conversation_destroy(), |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
390 * I think I'll just merge it into that later... |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
391 * Then again, something might want to use this, from outside prpl-land |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
392 * to leave a chat without destroying the conversation. |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
393 */ |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
394 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
395 void serv_chat_leave(GaimConnection *g, int id) |
1 | 396 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
397 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
398 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
399 if (!g_list_find(gaim_connections_get_all(), g)) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
400 return; |
1015
c3579d03a0c1
[gaim-migrate @ 1025]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1013
diff
changeset
|
401 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
402 if (g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
403 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
404 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
405 if (prpl_info && prpl_info->chat_leave) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
406 prpl_info->chat_leave(g, id); |
1 | 407 } |
408 | |
6059 | 409 void serv_chat_whisper(GaimConnection *g, int id, const char *who, const char *message) |
1 | 410 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
411 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
412 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
413 if (g != NULL && g->prpl != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
414 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(g->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
415 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
416 if (prpl_info && prpl_info->chat_whisper) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
417 prpl_info->chat_whisper(g, id, who, message); |
1 | 418 } |
419 | |
11907 | 420 int serv_chat_send(GaimConnection *gc, int id, const char *message) |
1 | 421 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
422 int val = -EINVAL; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
423 GaimPluginProtocolInfo *prpl_info = NULL; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
424 |
11907 | 425 if (gc->prpl != NULL) |
426 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
427 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
428 if (prpl_info && prpl_info->chat_send) |
11907 | 429 val = prpl_info->chat_send(gc, id, message); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
430 |
11907 | 431 time(&gc->last_sent_time); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5170
diff
changeset
|
432 |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
433 return val; |
1 | 434 } |
435 | |
5842 | 436 void serv_set_buddyicon(GaimConnection *gc, const char *filename) |
437 { | |
438 GaimPluginProtocolInfo *prpl_info = NULL; | |
8674
8c7da2e36136
[gaim-migrate @ 9426]
Christian Hammond <chipx86@chipx86.com>
parents:
8619
diff
changeset
|
439 |
5842 | 440 if (gc->prpl != NULL) |
441 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
442 | |
443 if (prpl_info && prpl_info->set_buddy_icon) | |
444 prpl_info->set_buddy_icon(gc, filename); | |
8674
8c7da2e36136
[gaim-migrate @ 9426]
Christian Hammond <chipx86@chipx86.com>
parents:
8619
diff
changeset
|
445 |
8c7da2e36136
[gaim-migrate @ 9426]
Christian Hammond <chipx86@chipx86.com>
parents:
8619
diff
changeset
|
446 } |
5842 | 447 |
9944 | 448 #if 0 |
1773 | 449 int find_queue_row_by_name(char *name) |
450 { | |
4412 | 451 gchar *temp; |
452 gint i = 0; | |
453 gboolean valid; | |
454 GtkTreeIter iter; | |
1773 | 455 |
4412 | 456 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), &iter); |
457 while(valid) { | |
458 gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), &iter, 0, &temp, -1); | |
459 if(!strcmp(name, temp)) | |
1773 | 460 return i; |
4412 | 461 g_free(temp); |
8674
8c7da2e36136
[gaim-migrate @ 9426]
Christian Hammond <chipx86@chipx86.com>
parents:
8619
diff
changeset
|
462 |
4412 | 463 i++; |
464 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(awayqueuestore), &iter); | |
1773 | 465 } |
466 | |
467 return -1; | |
468 } | |
469 | |
470 int find_queue_total_by_name(char *name) | |
471 { | |
472 GSList *templist; | |
473 int i = 0; | |
474 | |
475 templist = message_queue; | |
476 | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
477 while (templist) { |
1773 | 478 struct queued_message *qm = (struct queued_message *)templist->data; |
6621 | 479 if ((qm->flags & GAIM_MESSAGE_RECV) && !strcmp(name, qm->name)) |
1773 | 480 i++; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
481 |
1773 | 482 templist = templist->next; |
483 } | |
484 | |
485 return i; | |
486 } | |
9944 | 487 #endif |
1773 | 488 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
489 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
490 * woo. i'm actually going to comment this function. isn't that fun. make |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
491 * sure to follow along, kids |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
492 */ |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
493 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
494 GaimConvImFlags imflags, time_t mtime) |
1 | 495 { |
9944 | 496 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5630
diff
changeset
|
497 GaimConversation *cnv; |
9944 | 498 GaimPresence *presence; |
499 GaimStatus *status; | |
6982 | 500 GaimMessageFlags msgflags; |
5136 | 501 char *message, *name; |
6622 | 502 char *angel, *buffy; |
503 int plugin_return; | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
504 |
11903 | 505 g_return_if_fail(msg != NULL); |
506 | |
9944 | 507 account = gaim_connection_get_account(gc); |
508 presence = gaim_account_get_presence(account); | |
509 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
510 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
511 * We should update the conversation window buttons and menu, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
512 * if it exists. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
513 */ |
11338 | 514 cnv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, gc->account); |
2106
efb39c151cf7
[gaim-migrate @ 2116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2104
diff
changeset
|
515 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
516 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
517 * Plugin stuff. we pass a char ** but we don't want to pass what's |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
518 * been given us by the prpls. So we create temp holders and pass |
6982 | 519 * those instead. It's basically just to avoid segfaults. |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
520 */ |
6982 | 521 buffy = g_malloc(MAX(strlen(msg) + 1, BUF_LONG)); |
522 strcpy(buffy, msg); | |
523 angel = g_strdup(who); | |
1339 | 524 |
6982 | 525 plugin_return = GPOINTER_TO_INT( |
526 gaim_signal_emit_return_1(gaim_conversations_get_handle(), | |
8999 | 527 "receiving-im-msg", gc->account, |
10104 | 528 &angel, &buffy, cnv, &imflags)); |
6982 | 529 |
530 if (!buffy || !angel || plugin_return) { | |
531 if (buffy) | |
532 g_free(buffy); | |
533 if (angel) | |
534 g_free(angel); | |
535 return; | |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
536 } |
8619 | 537 |
8999 | 538 name = angel; |
6982 | 539 message = buffy; |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
540 |
8999 | 541 gaim_signal_emit(gaim_conversations_get_handle(), "received-im-msg", gc->account, |
10104 | 542 name, message, cnv, imflags); |
8999 | 543 |
8882 | 544 /* Make sure URLs are clickable */ |
545 buffy = gaim_markup_linkify(message); | |
546 g_free(message); | |
547 message = buffy; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
548 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
549 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
550 * Um. When we call gaim_conversation_write with the message we received, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
551 * it's nice to pass whether or not it was an auto-response. So if it |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
552 * was an auto-response, we set the appropriate flag. This is just so |
6982 | 553 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway). |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
554 */ |
6982 | 555 msgflags = GAIM_MESSAGE_RECV; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
556 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
6982 | 557 msgflags |= GAIM_MESSAGE_AUTO_RESP; |
1 | 558 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
559 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
560 * Alright. Two cases for how to handle this. Either we're away or |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
561 * we're not. If we're not, then it's easy. If we are, then there |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
562 * are three or four different ways of handling it and different |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
563 * things we have to do for each. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
564 */ |
9949 | 565 if (!gaim_presence_is_available(presence)) |
566 { | |
6479 | 567 time_t t = time(NULL); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
568 char *tmpmsg; |
6695 | 569 GaimBuddy *b = gaim_find_buddy(gc->account, name); |
9620 | 570 const char *alias = b ? gaim_buddy_get_alias(b) : name; |
6479 | 571 struct last_auto_response *lar; |
9594 | 572 const gchar *auto_reply_pref; |
9949 | 573 const char *away_msg; |
574 #if 0 | |
575 int row; | |
576 #endif | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
577 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
578 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
579 * Either we're going to queue it or not. Because of the way |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
580 * awayness currently works, this is fucked up. It's possible |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
581 * for an account to be away without the imaway dialog being |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
582 * shown. In fact, it's possible for *all* the accounts to be |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
583 * away without the imaway dialog being shown. So in order for |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
584 * this to be queued properly, we have to make sure that the |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
585 * imaway dialog actually exists, first. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
586 */ |
9944 | 587 #if 0 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5539
diff
changeset
|
588 if (!cnv && awayqueue && |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
589 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
8674
8c7da2e36136
[gaim-migrate @ 9426]
Christian Hammond <chipx86@chipx86.com>
parents:
8619
diff
changeset
|
590 /* |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
591 * Alright, so we're going to queue it. Neat, eh? :) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
592 * So first we create something to store the message, and add |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
593 * it to our queue. Then we update the away dialog to indicate |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
594 * that we've queued something. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
595 */ |
1769
68eddf56f419
[gaim-migrate @ 1779]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1768
diff
changeset
|
596 struct queued_message *qm; |
4412 | 597 GtkTreeIter iter; |
598 gchar path[10]; | |
4167 | 599 |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
600 qm = g_new0(struct queued_message, 1); |
5136 | 601 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
8413
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
602 if(strcmp(alias, name) != 0) |
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
603 g_snprintf(qm->alias, sizeof(qm->alias), "(%s)", alias); |
6982 | 604 qm->message = g_strdup(message); |
4608 | 605 qm->account = gc->account; |
1769
68eddf56f419
[gaim-migrate @ 1779]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1768
diff
changeset
|
606 qm->tm = mtime; |
6982 | 607 qm->flags = msgflags; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
608 message_queue = g_slist_append(message_queue, qm); |
1768 | 609 |
1773 | 610 row = find_queue_row_by_name(qm->name); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
611 if (row >= 0) { |
1773 | 612 char number[32]; |
613 int qtotal; | |
614 | |
615 qtotal = find_queue_total_by_name(qm->name); | |
6308 | 616 g_snprintf(number, 32, ngettext("(%d message)", |
617 "(%d messages)", qtotal), qtotal); | |
4412 | 618 g_snprintf(path, 10, "%d", row); |
619 gtk_tree_model_get_iter_from_string( | |
620 GTK_TREE_MODEL(awayqueuestore), &iter, path); | |
621 gtk_list_store_set(awayqueuestore, &iter, | |
8413
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
622 2, number, -1); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
623 } else { |
8413
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
624 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), |
4412 | 625 &iter); |
626 gtk_list_store_append(awayqueuestore, &iter); | |
627 gtk_list_store_set(awayqueuestore, &iter, | |
628 0, qm->name, | |
8413
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
629 1, qm->alias, |
f5b0e1a4b0c7
[gaim-migrate @ 9143]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
630 2, _("(1 message)"), |
4412 | 631 -1); |
1773 | 632 } |
9944 | 633 } |
634 else | |
635 #endif | |
636 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
637 /* |
4985 | 638 * Make sure the conversation |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
639 * exists and is updated (partly handled above already), play |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
640 * the receive sound (sound.c will take care of not playing |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
641 * while away), and then write it to the convo window. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
642 */ |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4440
diff
changeset
|
643 if (cnv == NULL) |
11338 | 644 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
645 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
646 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); |
1 | 647 } |
648 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
649 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
650 * Regardless of whether we queue it or not, we should send an |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
651 * auto-response. That is, of course, unless the horse.... no wait. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
652 * Don't autorespond if: |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
653 * |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
654 * - it's not supported on this connection |
9594 | 655 * - or the away message is empty |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
656 * - or it's disabled |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
657 * - or we're not idle and the 'only auto respond if idle' pref |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
658 * is set |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
659 */ |
9594 | 660 auto_reply_pref = gaim_prefs_get_string("/core/away/auto_reply"); |
10052 | 661 |
6622 | 662 if (!(gc->flags & GAIM_CONNECTION_AUTO_RESP) || |
10052 | 663 gaim_presence_is_available(presence) || |
9949 | 664 !strcmp(auto_reply_pref, "never") || |
665 (!gaim_presence_is_idle(presence) && | |
666 !strcmp(auto_reply_pref, "awayidle"))) { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
667 |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
668 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
669 g_free(message); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
670 return; |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
671 } |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
672 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
673 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
674 * This used to be based on the conversation window. But um, if |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
675 * you went away, and someone sent you a message and got your |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
676 * auto-response, and then you closed the window, and then the |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
677 * sent you another one, they'd get the auto-response back too |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
678 * soon. Besides that, we need to keep track of this even if we've |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
679 * got a queue. So the rest of this block is just the auto-response, |
6479 | 680 * if necessary. |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
681 */ |
6479 | 682 lar = get_last_auto_response(gc, name); |
8948 | 683 if ((t - lar->sent) < SECS_BEFORE_RESENDING_AUTORESPONSE) { |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
684 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
685 g_free(message); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
686 return; |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
687 } |
6479 | 688 lar->sent = t; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
689 |
10052 | 690 status = gaim_presence_get_active_status(presence); |
691 if (status == NULL) | |
692 return; | |
693 | |
694 away_msg = gaim_value_get_string( | |
695 gaim_status_get_attr_value(status, "message")); | |
696 | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
697 /* apply default fonts and colors */ |
11632 | 698 /* TODO: Do we even need this? */ |
9944 | 699 tmpmsg = stylize(away_msg, MSG_LEN); |
8700 | 700 |
701 /* Move this to oscar.c! */ | |
702 buffy = gaim_str_sub_away_formatters(tmpmsg, alias); | |
703 serv_send_im(gc, name, buffy, GAIM_CONV_IM_AUTO_RESP); | |
704 g_free(buffy); | |
705 | |
9944 | 706 #if 0 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5539
diff
changeset
|
707 if (!cnv && awayqueue && |
5573
5e7de337a053
[gaim-migrate @ 5976]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
708 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5539
diff
changeset
|
709 |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
710 struct queued_message *qm; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5539
diff
changeset
|
711 |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
712 qm = g_new0(struct queued_message, 1); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
713 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
714 qm->message = g_strdup(gaim_str_sub_away_formatters(tmpmsg, alias)); |
4608 | 715 qm->account = gc->account; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
716 qm->tm = mtime; |
6621 | 717 qm->flags = GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
718 message_queue = g_slist_append(message_queue, qm); |
9944 | 719 } |
720 else if (cnv != NULL) | |
721 #endif | |
722 { | |
723 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, | |
724 gaim_str_sub_away_formatters(tmpmsg, alias), | |
725 GAIM_MESSAGE_SEND | GAIM_MESSAGE_AUTO_RESP, | |
726 mtime); | |
727 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
728 |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
729 g_free(tmpmsg); |
9944 | 730 } |
731 else | |
732 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
733 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
734 * We're not away. This is easy. If the convo window doesn't |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
735 * exist, create and update it (if it does exist it was updated |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
736 * earlier), then play a sound indicating we've received it and |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
737 * then display it. Easy. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
738 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
739 |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11706
diff
changeset
|
740 if (cnv == NULL) |
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11706
diff
changeset
|
741 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gc->account, name); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
742 |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11706
diff
changeset
|
743 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); |
1 | 744 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
745 |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
746 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
747 g_free(message); |
1 | 748 } |
749 | |
5630 | 750 void serv_got_typing(GaimConnection *gc, const char *name, int timeout, |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5842
diff
changeset
|
751 GaimTypingState state) { |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
752 GaimConversation *conv; |
11709
cae2fb7e8594
[gaim-migrate @ 14000]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11706
diff
changeset
|
753 GaimConvIm *im = NULL; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
754 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
755 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
756 if (conv != NULL) { |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
757 im = GAIM_CONV_IM(conv); |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
758 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
759 gaim_conv_im_set_typing_state(im, state); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
760 gaim_conv_im_update_typing(im); |
6456
ccfdf9f2cdd1
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6444
diff
changeset
|
761 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
762 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
763 if (state == GAIM_TYPING) |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
764 { |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
765 gaim_signal_emit(gaim_conversations_get_handle(), |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
766 "buddy-typing", gc->account, name); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
767 } |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
768 else |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
769 { |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
770 gaim_signal_emit(gaim_conversations_get_handle(), |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
771 "buddy-typing-stopped", gc->account, name); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
772 } |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
773 |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
774 if (conv != NULL && timeout > 0) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
775 gaim_conv_im_start_typing_timeout(im, timeout); |
2993 | 776 } |
1 | 777 |
5630 | 778 void serv_got_typing_stopped(GaimConnection *gc, const char *name) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
779 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
780 GaimConversation *conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
781 GaimConvIm *im; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
782 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
783 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
784 if (conv != NULL) |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
785 { |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
786 im = GAIM_CONV_IM(conv); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
787 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
788 if (im->typing_state == GAIM_NOT_TYPING) |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
789 return; |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
790 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
791 gaim_conv_im_stop_typing_timeout(im); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
792 gaim_conv_im_set_typing_state(im, GAIM_NOT_TYPING); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
793 gaim_conv_im_update_typing(im); |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
794 } |
5032
cb700c07ee07
[gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents:
5024
diff
changeset
|
795 |
11706
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
796 gaim_signal_emit(gaim_conversations_get_handle(), |
bcc49c25ef90
[gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents:
11643
diff
changeset
|
797 "buddy-typing-stopped", gc->account, name); |
2993 | 798 } |
1 | 799 |
4487 | 800 struct chat_invite_data { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
801 GaimConnection *gc; |
5234 | 802 GHashTable *components; |
4487 | 803 }; |
1723
76e601b77099
[gaim-migrate @ 1733]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1722
diff
changeset
|
804 |
4487 | 805 static void chat_invite_data_free(struct chat_invite_data *cid) |
1 | 806 { |
5234 | 807 if (cid->components) |
808 g_hash_table_destroy(cid->components); | |
4487 | 809 g_free(cid); |
810 } | |
1723
76e601b77099
[gaim-migrate @ 1733]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1722
diff
changeset
|
811 |
8562 | 812 |
813 static void chat_invite_reject(struct chat_invite_data *cid) | |
814 { | |
815 serv_reject_chat(cid->gc, cid->components); | |
816 chat_invite_data_free(cid); | |
817 } | |
818 | |
819 | |
4487 | 820 static void chat_invite_accept(struct chat_invite_data *cid) |
821 { | |
5234 | 822 serv_join_chat(cid->gc, cid->components); |
4487 | 823 chat_invite_data_free(cid); |
1 | 824 } |
825 | |
826 | |
827 | |
5630 | 828 void serv_got_chat_invite(GaimConnection *gc, const char *name, |
829 const char *who, const char *message, GHashTable *data) | |
1 | 830 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
831 GaimAccount *account; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
832 char buf2[BUF_LONG]; |
4487 | 833 struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1); |
11064
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
834 int plugin_return; |
1 | 835 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
836 account = gaim_connection_get_account(gc); |
1 | 837 |
11064
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
838 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
839 gaim_conversations_get_handle(), |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
840 "chat-invited", account, who, name, message, data)); |
1 | 841 |
4487 | 842 cid->gc = gc; |
5234 | 843 cid->components = data; |
1 | 844 |
11064
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
845 if (plugin_return == 0) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
846 { |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
847 if (message != NULL) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
848 { |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
849 g_snprintf(buf2, sizeof(buf2), |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
850 _("%s has invited %s to the chat room %s:\n%s"), |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
851 who, gaim_account_get_username(account), name, message); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
852 } |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
853 else |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
854 g_snprintf(buf2, sizeof(buf2), |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
855 _("%s has invited %s to the chat room %s\n"), |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
856 who, gaim_account_get_username(account), name); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
857 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
858 |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
859 gaim_request_accept_cancel(gc, NULL, _("Accept chat invitation?"), buf2, |
9976 | 860 GAIM_DEFAULT_ACTION_NONE, cid, |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5461
diff
changeset
|
861 G_CALLBACK(chat_invite_accept), |
8562 | 862 G_CALLBACK(chat_invite_reject)); |
11064
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
863 } |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
864 else if (plugin_return > 0) |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
865 chat_invite_accept(cid); |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
866 else |
e4459e8ccfb5
[gaim-migrate @ 13035]
Richard Laager <rlaager@wiktel.com>
parents:
11003
diff
changeset
|
867 chat_invite_reject(cid); |
1 | 868 } |
869 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5630
diff
changeset
|
870 GaimConversation *serv_got_joined_chat(GaimConnection *gc, |
5630 | 871 int id, const char *name) |
1 | 872 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
873 GaimConversation *conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
874 GaimConvChat *chat; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
875 GaimAccount *account; |
1 | 876 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
877 account = gaim_connection_get_account(gc); |
1 | 878 |
11338 | 879 conv = gaim_conversation_new(GAIM_CONV_TYPE_CHAT, account, name); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
880 chat = GAIM_CONV_CHAT(conv); |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
881 |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
882 if (!g_slist_find(gc->buddy_chats, conv)) |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
883 gc->buddy_chats = g_slist_append(gc->buddy_chats, conv); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
884 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
885 gaim_conv_chat_set_id(chat, id); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4440
diff
changeset
|
886 |
1785
f4ae086c746b
[gaim-migrate @ 1795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1775
diff
changeset
|
887 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
888 gaim_signal_emit(gaim_conversations_get_handle(), "chat-joined", conv); |
3710 | 889 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
890 return conv; |
1 | 891 } |
892 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5560
diff
changeset
|
893 void serv_got_chat_left(GaimConnection *g, int id) |
1 | 894 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
895 GSList *bcs; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5630
diff
changeset
|
896 GaimConversation *conv = NULL; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
897 GaimConvChat *chat = NULL; |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
898 GaimAccount *account; |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
899 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
900 account = gaim_connection_get_account(g); |
1 | 901 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
902 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5630
diff
changeset
|
903 conv = (GaimConversation *)bcs->data; |
1 | 904 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
905 chat = GAIM_CONV_CHAT(conv); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
906 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
907 if (gaim_conv_chat_get_id(chat) == id) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
908 break; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
909 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
910 conv = NULL; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
911 } |
1 | 912 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
913 if (!conv) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
914 return; |
1 | 915 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
916 gaim_signal_emit(gaim_conversations_get_handle(), "chat-left", conv); |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
917 |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
918 gaim_debug(GAIM_DEBUG_INFO, "server", "Leaving room: %s\n", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
919 gaim_conversation_get_name(conv)); |
1 | 920 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
921 g->buddy_chats = g_slist_remove(g->buddy_chats, conv); |
1 | 922 |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
923 gaim_conv_chat_left(GAIM_CONV_CHAT(conv)); |
1 | 924 } |
925 | |
6059 | 926 void serv_got_chat_in(GaimConnection *g, int id, const char *who, |
9584 | 927 GaimConvChatFlags chatflags, const char *message, time_t mtime) |
1 | 928 { |
9584 | 929 GaimMessageFlags msgflags = 0; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
930 GSList *bcs; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5630
diff
changeset
|
931 GaimConversation *conv = NULL; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
932 GaimConvChat *chat = NULL; |
2296
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
933 char *buf; |
3163 | 934 char *buffy, *angel; |
935 int plugin_return; | |
1 | 936 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
937 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5630
diff
changeset
|
938 conv = (GaimConversation *)bcs->data; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
939 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
940 chat = GAIM_CONV_CHAT(conv); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
941 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
942 if (gaim_conv_chat_get_id(chat) == id) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
943 break; |
1 | 944 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
945 conv = NULL; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
946 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
947 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
948 if (!conv) |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
949 return; |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
950 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
951 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
952 * Plugin stuff. We pass a char ** but we don't want to pass what's |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
953 * been given us by the prpls. so we create temp holders and pass those |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
954 * instead. It's basically just to avoid segfaults. Of course, if the |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
955 * data is binary, plugins don't see it. Bitch all you want; i really |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
956 * don't want you to be dealing with it. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
957 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
958 |
3163 | 959 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); |
960 strcpy(buffy, message); | |
961 angel = g_strdup(who); | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
962 |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
963 plugin_return = GPOINTER_TO_INT( |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6479
diff
changeset
|
964 gaim_signal_emit_return_1(gaim_conversations_get_handle(), |
8999 | 965 "receiving-chat-msg", g->account, |
10104 | 966 &angel, &buffy, conv, &chatflags)); |
3163 | 967 |
968 if (!buffy || !angel || plugin_return) { | |
969 if (buffy) | |
970 g_free(buffy); | |
971 if (angel) | |
972 g_free(angel); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
973 return; |
3163 | 974 } |
975 who = angel; | |
976 message = buffy; | |
1 | 977 |
8999 | 978 gaim_signal_emit(gaim_conversations_get_handle(), "received-chat-msg", g->account, |
10104 | 979 who, message, conv, chatflags); |
8999 | 980 |
8882 | 981 /* Make sure URLs are clickable */ |
982 buf = gaim_markup_linkify(message); | |
1643
d7e380618fd5
[gaim-migrate @ 1653]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1587
diff
changeset
|
983 |
9584 | 984 if (chatflags & GAIM_CONV_CHAT_WHISPER) |
985 msgflags |= GAIM_MESSAGE_WHISPER; | |
986 if (chatflags & GAIM_CONV_CHAT_DELAYED) | |
987 msgflags |= GAIM_MESSAGE_DELAYED; | |
10104 | 988 if (chatflags & GAIM_CONV_CHAT_ALERT) |
989 msgflags |= GAIM_MESSAGE_NICK; | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
990 |
9584 | 991 gaim_conv_chat_write(chat, who, buf, msgflags, mtime); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
992 |
6350 | 993 g_free(angel); |
2296
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
994 g_free(buf); |
6062 | 995 g_free(buffy); |
1 | 996 } |
9466 | 997 |
998 void serv_send_file(GaimConnection *gc, const char *who, const char *file) | |
999 { | |
1000 GaimPluginProtocolInfo *prpl_info = NULL; | |
10751 | 1001 |
9466 | 1002 if (gc != NULL && gc->prpl != NULL) |
1003 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1004 | |
9647 | 1005 if (prpl_info && prpl_info->send_file) { |
1006 if (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who)) { | |
1007 prpl_info->send_file(gc, who, file); | |
1008 } | |
1009 } | |
9466 | 1010 } |