Mercurial > pidgin.yaz
annotate src/server.c @ 4989:0f8189301213
[gaim-migrate @ 5324]
fix a file descriptor leak
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 03 Apr 2003 23:15:00 +0000 |
parents | 088566495617 |
children | 73aef6d0f497 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2048
diff
changeset
|
23 #include <config.h> |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
338
diff
changeset
|
24 #endif |
1 | 25 #include <time.h> |
26 #include <stdio.h> | |
1057
d50d3abb9eb7
[gaim-migrate @ 1067]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1056
diff
changeset
|
27 #include <stdlib.h> |
1 | 28 #include <string.h> |
29 #include <sys/types.h> | |
30 #include <sys/stat.h> | |
31 #include <sys/time.h> | |
32 #include <unistd.h> | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
33 #include <errno.h> |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
34 #include "gtkimhtml.h" |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
35 #include "prpl.h" |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
36 #include "multi.h" |
1 | 37 #include "gaim.h" |
4767 | 38 #include "sound.h" |
1 | 39 |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
962
diff
changeset
|
40 #include "pixmaps/cancel.xpm" |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
41 #include "pixmaps/tb_search.xpm" |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
962
diff
changeset
|
42 |
4687 | 43 #include "pounce.h" |
44 | |
4491 | 45 void serv_login(struct gaim_account *account) |
1 | 46 { |
4491 | 47 struct prpl *p = find_prpl(account->protocol); |
4040 | 48 |
4491 | 49 if (account->gc != NULL || p == NULL) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
50 return; |
2531 | 51 |
4040 | 52 if(!ref_protocol(p)) |
53 return; | |
3572 | 54 |
3606 | 55 if (p->login) { |
4491 | 56 if (!strlen(account->password) && !(p->options & OPT_PROTO_NO_PASSWORD) && |
3789 | 57 !(p->options & OPT_PROTO_PASSWORD_OPTIONAL)) { |
3427 | 58 do_error_dialog(_("Please enter your password"), NULL, GAIM_ERROR); |
2531 | 59 return; |
60 } | |
61 | |
4491 | 62 debug_printf(PACKAGE " " VERSION " logging in %s using %s\n", account->username, p->name); |
63 account->connecting = TRUE; | |
3517 | 64 connecting_count++; |
3570 | 65 debug_printf("connecting_count: %d\n", connecting_count); |
4491 | 66 plugin_event(event_connecting, account); |
67 p->login(account); | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
414
diff
changeset
|
68 } |
1 | 69 } |
70 | |
2382
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
71 static gboolean send_keepalive(gpointer d) |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
72 { |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
73 struct gaim_connection *gc = d; |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
74 if (gc->prpl && gc->prpl->keepalive) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
75 gc->prpl->keepalive(gc); |
2382
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
76 return TRUE; |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
77 } |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
78 |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
79 static void update_keepalive(struct gaim_connection *gc, gboolean on) |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
80 { |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
81 if (on && !gc->keepalive) { |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
82 debug_printf("allowing NOP\n"); |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
83 gc->keepalive = g_timeout_add(60000, send_keepalive, gc); |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
84 } else if (!on && gc->keepalive > 0) { |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
85 debug_printf("removing NOP\n"); |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
86 g_source_remove(gc->keepalive); |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
87 gc->keepalive = 0; |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
88 } |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
89 } |
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
90 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
91 void serv_close(struct gaim_connection *gc) |
1 | 92 { |
3572 | 93 struct prpl *prpl; |
2017
eee309c0de93
[gaim-migrate @ 2027]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2001
diff
changeset
|
94 while (gc->buddy_chats) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
95 struct gaim_conversation *b = gc->buddy_chats->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
96 |
1063
e1408fb04c36
[gaim-migrate @ 1073]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
97 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
98 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
99 /* TODO: Nuke the UI-specific code here. */ |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
100 if (GAIM_IS_GTK_CONVERSATION(b)) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
101 gaim_gtkconv_update_buttons_by_protocol(b); |
1063
e1408fb04c36
[gaim-migrate @ 1073]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
102 } |
e1408fb04c36
[gaim-migrate @ 1073]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1057
diff
changeset
|
103 |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
104 if (gc->idle_timer > 0) |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
105 g_source_remove(gc->idle_timer); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
106 gc->idle_timer = 0; |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
107 |
2382
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2381
diff
changeset
|
108 update_keepalive(gc, FALSE); |
1050
c4baa5509558
[gaim-migrate @ 1060]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1038
diff
changeset
|
109 |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
110 if (gc->prpl && gc->prpl->close) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
111 gc->prpl->close(gc); |
4040 | 112 |
3572 | 113 prpl = gc->prpl; |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
114 account_offline(gc); |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
115 destroy_gaim_conn(gc); |
3572 | 116 |
4040 | 117 unref_protocol(prpl); |
1 | 118 } |
119 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
120 void serv_touch_idle(struct gaim_connection *gc) |
1 | 121 { |
122 /* Are we idle? If so, not anymore */ | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
123 if (gc->is_idle > 0) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
124 gc->is_idle = 0; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
125 serv_set_idle(gc, 0); |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
126 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
127 time(&gc->lastsent); |
1834
0695f52c06da
[gaim-migrate @ 1844]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
128 if (gc->is_auto_away) |
0695f52c06da
[gaim-migrate @ 1844]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1815
diff
changeset
|
129 check_idle(gc); |
1 | 130 } |
131 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
132 void serv_finish_login(struct gaim_connection *gc) |
1 | 133 { |
4491 | 134 if (strlen(gc->account->user_info)) { |
1976 | 135 /* g_malloc(strlen(gc->user->user_info) * 4); |
136 strncpy_withhtml(buf, gc->user->user_info, strlen(gc->user->user_info) * 4); */ | |
4491 | 137 serv_set_info(gc, gc->account->user_info); |
1976 | 138 /* g_free(buf); */ |
1 | 139 } |
140 | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
141 if (gc->idle_timer > 0) |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
142 g_source_remove(gc->idle_timer); |
1 | 143 |
2381
427ccd7dfdd2
[gaim-migrate @ 2394]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2372
diff
changeset
|
144 gc->idle_timer = g_timeout_add(20000, check_idle, gc); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
145 serv_touch_idle(gc); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
146 |
1995
815997c7d4f1
[gaim-migrate @ 2005]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1981
diff
changeset
|
147 if (gc->prpl->options & OPT_PROTO_CORRECT_TIME) |
815997c7d4f1
[gaim-migrate @ 2005]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1981
diff
changeset
|
148 serv_add_buddy(gc, gc->username); |
815997c7d4f1
[gaim-migrate @ 2005]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1981
diff
changeset
|
149 |
1772
896432d66303
[gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1771
diff
changeset
|
150 update_keepalive(gc, TRUE); |
1 | 151 } |
152 | |
2993 | 153 /* This should return the elapsed time in seconds in which Gaim will not send |
154 * typing notifications. | |
3001 | 155 * if it returns zero, it will not send any more typing notifications |
156 * typing is a flag - TRUE for typing, FALSE for stopped typing */ | |
157 int serv_send_typing(struct gaim_connection *g, char *name, int typing) { | |
2993 | 158 if (g && g->prpl && g->prpl->send_typing) |
3001 | 159 return g->prpl->send_typing(g, name, typing); |
2993 | 160 else return 0; |
161 } | |
1 | 162 |
3815 | 163 struct queued_away_response { |
164 char name[80]; | |
165 time_t sent_away; | |
166 }; | |
167 | |
168 struct queued_away_response *find_queued_away_response_by_name(char *name); | |
169 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
170 int serv_send_im(struct gaim_connection *gc, char *name, char *message, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
171 int len, int flags) |
1 | 172 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
173 struct gaim_conversation *c; |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
174 int val = -EINVAL; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
175 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
176 c = gaim_find_conversation(name); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
177 |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
178 if (gc->prpl && gc->prpl->send_im) |
3033 | 179 val = gc->prpl->send_im(gc, name, message, len, flags); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
180 |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2205
diff
changeset
|
181 if (!(flags & IM_FLAG_AWAY)) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
182 serv_touch_idle(gc); |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
183 |
3815 | 184 if (gc->away && away_options & OPT_AWAY_DELAY_IN_USE && |
185 !(away_options & OPT_AWAY_NO_AUTO_RESP)) { | |
186 time_t t; | |
187 struct queued_away_response *qar; | |
188 time(&t); | |
189 qar = find_queued_away_response_by_name(name); | |
190 if (!qar) { | |
191 qar = (struct queued_away_response *)g_new0(struct queued_away_response, 1); | |
192 g_snprintf(qar->name, sizeof(qar->name), "%s", name); | |
193 qar->sent_away = 0; | |
194 away_time_queue = g_slist_append(away_time_queue, qar); | |
195 } | |
196 qar->sent_away = t; | |
197 } | |
198 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
199 if (c && gaim_im_get_type_again_timeout(GAIM_IM(c))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
200 gaim_im_stop_type_again_timeout(GAIM_IM(c)); |
3601 | 201 |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2108
diff
changeset
|
202 return val; |
1 | 203 } |
204 | |
1032
643a4d81c18a
[gaim-migrate @ 1042]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
205 void serv_get_info(struct gaim_connection *g, char *name) |
1 | 206 { |
1006
0a4d0ed65e17
[gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1002
diff
changeset
|
207 if (g && g->prpl && g->prpl->get_info) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
208 g->prpl->get_info(g, name); |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
209 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
210 |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
211 void serv_get_away(struct gaim_connection *g, char *name) |
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
212 { |
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
213 if (g && g->prpl && g->prpl->get_away) |
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
214 g->prpl->get_away(g, name); |
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
215 } |
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
216 |
1032
643a4d81c18a
[gaim-migrate @ 1042]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
217 void serv_get_dir(struct gaim_connection *g, char *name) |
1 | 218 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
219 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->get_dir) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
220 g->prpl->get_dir(g, name); |
1 | 221 } |
222 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
223 void serv_set_dir(struct gaim_connection *g, const char *first, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
224 const char *middle, const char *last, const char *maiden, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
225 const char *city, const char *state, const char *country, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
226 int web) |
1 | 227 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
228 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_dir) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
229 g->prpl->set_dir(g, first, middle, last, maiden, city, state, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
230 country, web); |
1 | 231 } |
232 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
233 void serv_dir_search(struct gaim_connection *g, const char *first, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
234 const char *middle, const char *last, const char *maiden, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
235 const char *city, const char *state, const char *country, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
236 const char *email) |
1 | 237 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
238 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->dir_search) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
239 g->prpl->dir_search(g, first, middle, last, maiden, city, state, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
240 country, email); |
1 | 241 } |
242 | |
243 | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
244 void serv_set_away(struct gaim_connection *gc, char *state, char *message) |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
245 { |
1938
c9db54d8d8dc
[gaim-migrate @ 1948]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1937
diff
changeset
|
246 if (gc && gc->prpl && gc->prpl->set_away) { |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
247 char *buf = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
248 |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
249 if (gc->away_state) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
250 g_free(gc->away_state); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
251 gc->away_state = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
252 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
253 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
254 if (message) { |
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
255 buf = g_malloc(strlen(message) + 1); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
256 if (gc->flags & OPT_CONN_HTML) |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
257 strncpy(buf, message, strlen(message) + 1); |
1938
c9db54d8d8dc
[gaim-migrate @ 1948]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1937
diff
changeset
|
258 else |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
259 strncpy_nohtml(buf, message, strlen(message) + 1); |
1937 | 260 } |
1938
c9db54d8d8dc
[gaim-migrate @ 1948]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1937
diff
changeset
|
261 |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
262 gc->prpl->set_away(gc, state, buf); |
2000 | 263 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
264 if (gc->away && state) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
265 gc->away_state = g_strdup(state); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
266 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
267 |
3517 | 268 plugin_event(event_away, gc, state, buf); |
1938
c9db54d8d8dc
[gaim-migrate @ 1948]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1937
diff
changeset
|
269 |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
270 if (buf) |
1938
c9db54d8d8dc
[gaim-migrate @ 1948]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1937
diff
changeset
|
271 g_free(buf); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
272 } |
1937 | 273 |
1938
c9db54d8d8dc
[gaim-migrate @ 1948]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1937
diff
changeset
|
274 system_log(log_away, gc, NULL, OPT_LOG_BUDDY_AWAY | OPT_LOG_MY_SIGNON); |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
275 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
276 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1376
diff
changeset
|
277 void serv_set_away_all(char *message) |
1 | 278 { |
976
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
279 GSList *c = connections; |
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
280 struct gaim_connection *g; |
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
281 |
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
282 while (c) { |
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
283 g = (struct gaim_connection *)c->data; |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
284 serv_set_away(g, GAIM_AWAY_CUSTOM, message); |
976
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
285 c = c->next; |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
414
diff
changeset
|
286 } |
1 | 287 } |
288 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
289 void serv_set_info(struct gaim_connection *g, char *info) |
1 | 290 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
291 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_info) { |
3517 | 292 if (plugin_event(event_set_info, g, info)) |
3456 | 293 return; |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
294 g->prpl->set_info(g, info); |
1749
5bfc58c20e82
[gaim-migrate @ 1759]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1734
diff
changeset
|
295 } |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
296 } |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
297 |
3466 | 298 void serv_change_passwd(struct gaim_connection *g, const char *orig, const char *new) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
299 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
300 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->change_passwd) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
301 g->prpl->change_passwd(g, orig, new); |
1 | 302 } |
303 | |
3466 | 304 void serv_add_buddy(struct gaim_connection *g, const char *name) |
1 | 305 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
306 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->add_buddy) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
307 g->prpl->add_buddy(g, name); |
1 | 308 } |
309 | |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
310 void serv_add_buddies(struct gaim_connection *g, GList *buddies) |
1 | 311 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
312 if (g && g_slist_find(connections, g) && g->prpl) { |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
313 if (g->prpl->add_buddies) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
314 g->prpl->add_buddies(g, buddies); |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
315 else if (g->prpl->add_buddy) |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
316 while (buddies) { |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
317 g->prpl->add_buddy(g, buddies->data); |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
318 buddies = buddies->next; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
319 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1303
diff
changeset
|
320 } |
1 | 321 } |
322 | |
323 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2662
diff
changeset
|
324 void serv_remove_buddy(struct gaim_connection *g, char *name, char *group) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
325 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
326 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->remove_buddy) |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2662
diff
changeset
|
327 g->prpl->remove_buddy(g, name, group); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
328 } |
1 | 329 |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2662
diff
changeset
|
330 void serv_remove_buddies(struct gaim_connection *gc, GList *g, char *group) |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
331 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
332 if (!g_slist_find(connections, gc)) |
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
333 return; |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
334 if (!gc->prpl) |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
335 return; /* how the hell did that happen? */ |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
336 if (gc->prpl->remove_buddies) |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2662
diff
changeset
|
337 gc->prpl->remove_buddies(gc, g, group); |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
338 else { |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
339 while (g) { |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2662
diff
changeset
|
340 serv_remove_buddy(gc, g->data, group); |
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
341 g = g->next; |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
342 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
343 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
344 } |
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2313
diff
changeset
|
345 |
3136 | 346 /* |
347 * Set buddy's alias on server roster/list | |
348 */ | |
349 void serv_alias_buddy(struct buddy *b) | |
350 { | |
4491 | 351 if(b && b->account->gc && b->account->gc->prpl && b->account->gc->prpl->alias_buddy) { |
352 b->account->gc->prpl->alias_buddy(b->account->gc, b->name, b->alias); | |
3136 | 353 } |
354 } | |
355 | |
4227 | 356 void serv_got_alias(struct gaim_connection *gc, char *who, char *alias) { |
4687 | 357 struct buddy *b = gaim_find_buddy(gc->account, who); |
4227 | 358 if(!b) |
359 return; | |
360 | |
4687 | 361 if (b->server_alias) |
362 g_free(b->server_alias); | |
363 | |
4227 | 364 if(alias) |
4687 | 365 b->server_alias = g_strdup(alias); |
4227 | 366 else |
4687 | 367 b->server_alias = NULL; |
4227 | 368 |
4760 | 369 gaim_blist_update_buddy_status(b, b->uc); |
4227 | 370 } |
371 | |
3136 | 372 /* |
373 * Move a buddy from one group to another on server. | |
374 * | |
375 * Note: For now we'll not deal with changing gc's at the same time, but | |
376 * it should be possible. Probably needs to be done, someday. | |
377 */ | |
378 void serv_move_buddy(struct buddy *b, struct group *og, struct group *ng) | |
379 { | |
4491 | 380 if(b && b->account->gc && og && ng) { |
381 if(b->account->gc->prpl && b->account->gc->prpl->group_buddy) { | |
382 b->account->gc->prpl->group_buddy(b->account->gc, b->name, og->name, ng->name); | |
3136 | 383 } |
384 } | |
385 } | |
386 | |
3348 | 387 /* |
388 * Rename a group on server roster/list. | |
389 */ | |
3466 | 390 void serv_rename_group(struct gaim_connection *g, struct group *old_group, const char *new_name) |
3348 | 391 { |
392 if (g && g->prpl && old_group && new_name) { | |
393 GList *tobemoved = NULL; | |
4969 | 394 GaimBlistNode *b = ((GaimBlistNode*)old_group)->child; |
3348 | 395 |
4969 | 396 while (b) { |
397 struct buddy *bd = (struct buddy *)b; | |
398 if (bd->account = g->account) | |
399 tobemoved = g_list_append(tobemoved, bd->name); | |
400 b = b->next; | |
401 } | |
3348 | 402 |
403 if (g->prpl->rename_group) { | |
404 /* prpl's might need to check if the group already | |
405 * exists or not, and handle that differently */ | |
406 g->prpl->rename_group(g, old_group->name, new_name, tobemoved); | |
407 } else { | |
408 serv_remove_buddies(g, tobemoved, old_group->name); | |
409 serv_add_buddies(g, tobemoved); | |
410 } | |
411 | |
412 g_list_free(tobemoved); | |
413 } | |
414 } | |
415 | |
4349 | 416 void serv_add_permit(struct gaim_connection *g, const char *name) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
417 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
418 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->add_permit) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
419 g->prpl->add_permit(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
420 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
421 |
4349 | 422 void serv_add_deny(struct gaim_connection *g, const char *name) |
1 | 423 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
424 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->add_deny) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
425 g->prpl->add_deny(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
426 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
427 |
4349 | 428 void serv_rem_permit(struct gaim_connection *g, const char *name) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
429 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
430 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->rem_permit) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
431 g->prpl->rem_permit(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
432 } |
1 | 433 |
4349 | 434 void serv_rem_deny(struct gaim_connection *g, const char *name) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
435 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
436 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->rem_deny) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
437 g->prpl->rem_deny(g, name); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
438 } |
678
c72f58814e9f
[gaim-migrate @ 688]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
660
diff
changeset
|
439 |
1038
daad2440a642
[gaim-migrate @ 1048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1032
diff
changeset
|
440 void serv_set_permit_deny(struct gaim_connection *g) |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1026
diff
changeset
|
441 { |
1145
cd96ca1aed02
[gaim-migrate @ 1155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1140
diff
changeset
|
442 /* this is called when either you import a buddy list, and make lots of changes that way, |
cd96ca1aed02
[gaim-migrate @ 1155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1140
diff
changeset
|
443 * or when the user toggles the permit/deny mode in the prefs. In either case you should |
cd96ca1aed02
[gaim-migrate @ 1155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1140
diff
changeset
|
444 * probably be resetting and resending the permit/deny info when you get this. */ |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
445 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_permit_deny) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
446 g->prpl->set_permit_deny(g); |
1 | 447 } |
448 | |
1026 | 449 |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
450 void serv_set_idle(struct gaim_connection *g, int time) |
1 | 451 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
452 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->set_idle) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
453 g->prpl->set_idle(g, time); |
1 | 454 } |
455 | |
976
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
973
diff
changeset
|
456 void serv_warn(struct gaim_connection *g, char *name, int anon) |
1 | 457 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
458 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->warn) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
459 g->prpl->warn(g, name, anon); |
1 | 460 } |
461 | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
462 void serv_join_chat(struct gaim_connection *g, GList *data) |
1 | 463 { |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
464 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->join_chat) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
465 g->prpl->join_chat(g, data); |
1 | 466 } |
467 | |
3466 | 468 void serv_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) |
1 | 469 { |
2359
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
470 char *buffy = message && *message ? g_strdup(message) : NULL; |
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
471 plugin_event(event_chat_send_invite, g, (void *)id, name, &buffy); |
2586
0f5390176949
[gaim-migrate @ 2599]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2546
diff
changeset
|
472 if (g && g_slist_find(connections, g) && g->prpl && g->prpl->chat_invite) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
473 g->prpl->chat_invite(g, id, buffy, name); |
2359
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
474 if (buffy) |
ad56a93661fc
[gaim-migrate @ 2372]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2345
diff
changeset
|
475 g_free(buffy); |
1 | 476 } |
477 | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
962
diff
changeset
|
478 void serv_chat_leave(struct gaim_connection *g, int id) |
1 | 479 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
480 if (!g_slist_find(connections, g)) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
481 return; |
1015
c3579d03a0c1
[gaim-migrate @ 1025]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1013
diff
changeset
|
482 |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
483 if (g->prpl && g->prpl->chat_leave) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
484 g->prpl->chat_leave(g, id); |
1 | 485 } |
486 | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
962
diff
changeset
|
487 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) |
1 | 488 { |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
489 if (g->prpl && g->prpl->chat_whisper) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
490 g->prpl->chat_whisper(g, id, who, message); |
1 | 491 } |
492 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
493 int serv_chat_send(struct gaim_connection *g, int id, char *message) |
1 | 494 { |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
495 int val = -EINVAL; |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
496 if (g->prpl && g->prpl->chat_send) |
2662
b0c5770156e1
[gaim-migrate @ 2675]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2646
diff
changeset
|
497 val = g->prpl->chat_send(g, id, message); |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
931
diff
changeset
|
498 serv_touch_idle(g); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
499 return val; |
1 | 500 } |
501 | |
1773 | 502 int find_queue_row_by_name(char *name) |
503 { | |
4412 | 504 gchar *temp; |
505 gint i = 0; | |
506 gboolean valid; | |
507 GtkTreeIter iter; | |
1773 | 508 |
4412 | 509 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), &iter); |
510 while(valid) { | |
511 gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), &iter, 0, &temp, -1); | |
512 if(!strcmp(name, temp)) | |
1773 | 513 return i; |
4412 | 514 g_free(temp); |
515 | |
516 i++; | |
517 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(awayqueuestore), &iter); | |
1773 | 518 } |
519 | |
520 return -1; | |
521 } | |
522 | |
523 int find_queue_total_by_name(char *name) | |
524 { | |
525 GSList *templist; | |
526 int i = 0; | |
527 | |
528 templist = message_queue; | |
529 | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
530 while (templist) { |
1773 | 531 struct queued_message *qm = (struct queued_message *)templist->data; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
532 if ((qm->flags & WFLAG_RECV) && !strcmp(name, qm->name)) |
1773 | 533 i++; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
534 |
1773 | 535 templist = templist->next; |
536 } | |
537 | |
538 return i; | |
539 } | |
540 | |
1774 | 541 struct queued_away_response *find_queued_away_response_by_name(char *name) |
542 { | |
543 GSList *templist; | |
544 struct queued_away_response *qar; | |
545 | |
546 templist = away_time_queue; | |
547 | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
548 while (templist) { |
1774 | 549 qar = (struct queued_away_response *)templist->data; |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
550 |
1774 | 551 if (!strcmp(name, qar->name)) |
552 return qar; | |
553 | |
554 templist = templist->next; | |
555 } | |
556 | |
557 return NULL; | |
558 } | |
559 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
560 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
561 * 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
|
562 * sure to follow along, kids |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
563 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
564 void serv_got_im(struct gaim_connection *gc, char *name, char *message, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
565 guint32 flags, time_t mtime, gint len) |
1 | 566 { |
1981
7739e648a28a
[gaim-migrate @ 1991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
567 char *buffy; |
7739e648a28a
[gaim-migrate @ 1991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
568 char *angel; |
7739e648a28a
[gaim-migrate @ 1991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
569 int plugin_return; |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
570 int away = 0; |
1981
7739e648a28a
[gaim-migrate @ 1991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1976
diff
changeset
|
571 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
572 struct gaim_conversation *cnv; |
1 | 573 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
574 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
575 * Pay no attention to the man behind the curtain. |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
576 * |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
577 * The reason i feel okay with this is because it's useful to some |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
578 * plugins. Gaim doesn't ever use it itself. Besides, it's not entirely |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
579 * accurate; it's possible to have false negatives with most protocols. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
580 * Also with some it's easy to have false positives as well. So if you're |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
581 * a plugin author, don't rely on this, still do your own checks. But uh. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
582 * It's a start. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
583 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
584 |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
585 if (flags & IM_FLAG_GAIMUSER) |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
586 debug_printf("%s is a gaim user.\n", name); |
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
587 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
588 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
589 * We should update the conversation window buttons and menu, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
590 * if it exists. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
591 */ |
4491 | 592 cnv = gaim_find_conversation_with_account(name, gc->account); |
2106
efb39c151cf7
[gaim-migrate @ 2116]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2104
diff
changeset
|
593 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
594 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
595 * 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
|
596 * been given us by the prpls. So we create temp holders and pass |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
597 * those instead. It's basically just to avoid segfaults. Of course, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
598 * if the data is binary, plugins don't see it. Bitch all you want; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
599 * I really don't want you to be dealing with it. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
600 */ |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
601 if (len < 0) { |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
602 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
603 strcpy(buffy, message); |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
604 angel = g_strdup(name); |
3517 | 605 plugin_return = plugin_event(event_im_recv, gc, &angel, &buffy, &flags); |
1339 | 606 |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
607 if (!buffy || !angel || plugin_return) { |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
608 if (buffy) |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
609 g_free(buffy); |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
610 if (angel) |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
611 g_free(angel); |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
612 return; |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
613 } |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
614 name = angel; |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
615 message = buffy; |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
616 } else { |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
617 name = g_strdup(name); |
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
618 message = g_memdup(message, len); |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
619 } |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
620 |
3792 | 621 #if 0 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
622 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
623 * TiK, using TOC, sends an automated message in order to get your |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
624 * away message. Now, this is one of the biggest hacks I think I've |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
625 * seen. But, in order to be nice to TiK, we're going to give users |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
626 * the option to ignore it. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
627 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
628 if ((away_options & OPT_AWAY_TIK_HACK) && gc->away && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
629 strlen(gc->away) && (len < 0) && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
630 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
631 !strcmp(message, ">>>Automated Message: Getting Away Message<<<")) { |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
809
diff
changeset
|
632 char *tmpmsg = stylize(awaymessage->message, MSG_LEN); |
3033 | 633 serv_send_im(gc, name, tmpmsg, -1, IM_FLAG_AWAY); |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
809
diff
changeset
|
634 g_free(tmpmsg); |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
635 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
636 g_free(message); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
637 return; |
736
d05d746384a7
[gaim-migrate @ 746]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
710
diff
changeset
|
638 } |
3792 | 639 #endif |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
640 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
641 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
642 * If you can't figure this out, stop reading right now. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
643 * "We're not worthy! We're not worthy!" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
644 */ |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
645 if ((len < 0) && (convo_options & OPT_CONVO_SEND_LINKS)) |
616 | 646 linkify_text(message); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
647 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
648 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
649 * 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
|
650 * 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
|
651 * was an auto-response, we set the appropriate flag. This is just so |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
652 * prpls don't have to know about WFLAG_* (though some do anyway) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
653 */ |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
654 if (flags & IM_FLAG_AWAY) |
764 | 655 away = WFLAG_AUTO; |
1 | 656 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
657 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
658 * 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
|
659 * 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
|
660 * are three or four different ways of handling it and different |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
661 * things we have to do for each. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
662 */ |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
663 if (gc->away) { |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
664 time_t t; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
665 char *tmpmsg; |
4687 | 666 struct buddy *b = gaim_find_buddy(gc->account, name); |
667 char *alias = b ? gaim_get_buddy_alias(b) : name; | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
668 int row; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
669 struct queued_away_response *qar; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
670 |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
671 time(&t); |
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 * 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
|
675 * awayness currently works, this is fucked up. It's possible |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
676 * for an account to be away without the imaway dialog being |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
677 * 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
|
678 * away without the imaway dialog being shown. So in order for |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
679 * 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
|
680 * imaway dialog actually exists, first. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
681 */ |
4412 | 682 if (!cnv && awayqueue && (away_options & OPT_AWAY_QUEUE)) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
683 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
684 * Alright, so we're going to queue it. Neat, eh? :) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
685 * So first we create something to store the message, and add |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
686 * 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
|
687 * that we've queued something. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
688 */ |
1769
68eddf56f419
[gaim-migrate @ 1779]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1768
diff
changeset
|
689 struct queued_message *qm; |
4412 | 690 GtkTreeIter iter; |
691 gchar path[10]; | |
4167 | 692 |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
693 qm = g_new0(struct queued_message, 1); |
3985 | 694 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
695 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); |
4608 | 696 qm->account = gc->account; |
1769
68eddf56f419
[gaim-migrate @ 1779]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1768
diff
changeset
|
697 qm->tm = mtime; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
698 qm->flags = WFLAG_RECV | away; |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
699 qm->len = len; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
700 message_queue = g_slist_append(message_queue, qm); |
1768 | 701 |
1773 | 702 row = find_queue_row_by_name(qm->name); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
703 if (row >= 0) { |
1773 | 704 char number[32]; |
705 int qtotal; | |
706 | |
707 qtotal = find_queue_total_by_name(qm->name); | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
708 g_snprintf(number, 32, _("(%d messages)"), qtotal); |
4412 | 709 g_snprintf(path, 10, "%d", row); |
710 gtk_tree_model_get_iter_from_string( | |
711 GTK_TREE_MODEL(awayqueuestore), &iter, path); | |
712 gtk_list_store_set(awayqueuestore, &iter, | |
713 1, number, -1); | |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
714 } else { |
4412 | 715 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), |
716 &iter); | |
717 gtk_list_store_append(awayqueuestore, &iter); | |
718 gtk_list_store_set(awayqueuestore, &iter, | |
719 0, qm->name, | |
720 1, _("(1 message)"), | |
721 -1); | |
1773 | 722 } |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
723 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
724 /* |
4985 | 725 * Make sure the conversation |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
726 * exists and is updated (partly handled above already), play |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
727 * the receive sound (sound.c will take care of not playing |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
728 * while away), and then write it to the convo window. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
729 */ |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4440
diff
changeset
|
730 if (cnv == NULL) |
4491 | 731 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
732 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
733 gaim_im_write(GAIM_IM(cnv), NULL, message, len, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
734 away | WFLAG_RECV, mtime); |
1 | 735 } |
736 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
737 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
738 * 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
|
739 * auto-response. That is, of course, unless the horse.... no wait. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
740 * Don't autorespond if: |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
741 * |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
742 * - it's not supported on this connection |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
743 * - or it's disabled |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
744 * - or the away message is empty |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
745 * - 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
|
746 * is set |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4074
diff
changeset
|
747 */ |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
748 if (!(gc->flags & OPT_CONN_AUTO_RESP) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
749 (away_options & OPT_AWAY_NO_AUTO_RESP) || !strlen(gc->away) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
750 ((away_options & OPT_AWAY_IDLE_RESP) && !gc->is_idle)) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
751 |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
752 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
753 g_free(message); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
754 return; |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
755 } |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
756 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
757 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
758 * 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
|
759 * 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
|
760 * auto-response, and then you closed the window, and then the |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
761 * 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
|
762 * 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
|
763 * got a queue. So the rest of this block is just the auto-response, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
764 * if necessary |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
765 */ |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
766 qar = find_queued_away_response_by_name(name); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
767 if (!qar) { |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
768 qar = (struct queued_away_response *)g_new0(struct queued_away_response, 1); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
769 g_snprintf(qar->name, sizeof(qar->name), "%s", name); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
770 qar->sent_away = 0; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
771 away_time_queue = g_slist_append(away_time_queue, qar); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
772 } |
2906
538c58b43eff
[gaim-migrate @ 2919]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2856
diff
changeset
|
773 if ((t - qar->sent_away) < away_resend) { |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
774 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
775 g_free(message); |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
776 return; |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
777 } |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
778 qar->sent_away = t; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
779 |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
780 /* apply default fonts and colors */ |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
781 tmpmsg = stylize(gc->away, MSG_LEN); |
3033 | 782 serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, IM_FLAG_AWAY); |
4412 | 783 if (!cnv && awayqueue && (away_options & OPT_AWAY_QUEUE)) { |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
784 struct queued_message *qm; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
785 qm = g_new0(struct queued_message, 1); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
786 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
1785
f4ae086c746b
[gaim-migrate @ 1795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1775
diff
changeset
|
787 qm->message = g_strdup(away_subs(tmpmsg, alias)); |
4608 | 788 qm->account = gc->account; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
789 qm->tm = mtime; |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
790 qm->flags = WFLAG_SEND | WFLAG_AUTO; |
2979 | 791 qm->len = -1; |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
792 message_queue = g_slist_append(message_queue, qm); |
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
793 } else if (cnv != NULL) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
794 gaim_im_write(GAIM_IM(cnv), NULL, away_subs(tmpmsg, alias), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
795 len, WFLAG_SEND | WFLAG_AUTO, mtime); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
796 |
1775
9ca22174da76
[gaim-migrate @ 1785]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1774
diff
changeset
|
797 g_free(tmpmsg); |
1 | 798 } else { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
799 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
800 * 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
|
801 * 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
|
802 * earlier), then play a sound indicating we've received it and |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
803 * then display it. Easy. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
804 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
805 if (away_options & OPT_AWAY_QUEUE_UNREAD && |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
806 !gaim_find_conversation(name) && docklet_count) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
807 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
808 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
809 * We're gonna queue it up and wait for the user to ask for |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
810 * it... probably by clicking the docklet or windows tray icon. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
811 */ |
3517 | 812 struct queued_message *qm; |
813 qm = g_new0(struct queued_message, 1); | |
814 g_snprintf(qm->name, sizeof(qm->name), "%s", name); | |
815 qm->message = g_strdup(message); | |
4608 | 816 qm->account = gc->account; |
3517 | 817 qm->tm = mtime; |
818 qm->flags = away | WFLAG_RECV; | |
819 qm->len = len; | |
820 unread_message_queue = g_slist_append(unread_message_queue, qm); | |
821 } else { | |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4440
diff
changeset
|
822 if (cnv == NULL) |
4491 | 823 cnv = gaim_conversation_new(GAIM_CONV_IM, gc->account, name); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
824 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
825 /* CONV XXX gaim_conversation_set_name(cnv, name); */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
826 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
827 gaim_im_write(GAIM_IM(cnv), NULL, message, len, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
828 away | WFLAG_RECV, mtime); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
829 gaim_window_flash(gaim_conversation_get_window(cnv)); |
1 | 830 } |
831 } | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
832 |
3517 | 833 plugin_event(event_im_displayed_rcvd, gc, name, message, flags, mtime); |
2104
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
834 g_free(name); |
0b81421021fd
[gaim-migrate @ 2114]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
835 g_free(message); |
1 | 836 } |
837 | |
838 | |
839 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
840 void serv_got_update(struct gaim_connection *gc, char *name, int loggedin, |
4732 | 841 int evil, time_t signon, time_t idle, int type) |
1 | 842 { |
4687 | 843 struct buddy *b = gaim_find_buddy(gc->account, name); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
844 |
2993 | 845 if (signon && (gc->prpl->options & OPT_PROTO_CORRECT_TIME)) { |
1435
f16e17d42b43
[gaim-migrate @ 1445]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1434
diff
changeset
|
846 char *tmp = g_strdup(normalize(name)); |
4793 | 847 if (!gaim_utf8_strcasecmp(tmp, normalize(gc->username))) { |
2506
072f253d5939
[gaim-migrate @ 2519]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2505
diff
changeset
|
848 gc->evil = evil; |
4841 | 849 gc->login_time_official = signon; |
4687 | 850 /*update_idle_times();*/ |
1995
815997c7d4f1
[gaim-migrate @ 2005]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1981
diff
changeset
|
851 } |
1435
f16e17d42b43
[gaim-migrate @ 1445]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1434
diff
changeset
|
852 g_free(tmp); |
f16e17d42b43
[gaim-migrate @ 1445]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1434
diff
changeset
|
853 } |
f16e17d42b43
[gaim-migrate @ 1445]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1434
diff
changeset
|
854 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
855 if (!b) { |
1376
730a1a19b4cc
[gaim-migrate @ 1386]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1371
diff
changeset
|
856 debug_printf("Error, no such buddy %s\n", name); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
857 return; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
858 } |
1 | 859 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
860 /* This code will 'align' the name from the TOC */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
861 /* server with what's in our record. We want to */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
862 /* store things how THEY want it... */ |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
863 if (strcmp(name, b->name)) { |
4687 | 864 gaim_blist_rename_buddy(b, name); |
4349 | 865 gaim_blist_save(); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
866 } |
1 | 867 |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
868 if (!b->idle && idle) { |
3517 | 869 plugin_event(event_buddy_idle, gc, b->name); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
870 system_log(log_idle, gc, b, OPT_LOG_BUDDY_IDLE); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
871 } |
1140 | 872 if (b->idle && !idle) { |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
873 do_pounce(gc, b->name, OPT_POUNCE_UNIDLE); |
3517 | 874 plugin_event(event_buddy_unidle, gc, b->name); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
875 system_log(log_unidle, gc, b, OPT_LOG_BUDDY_IDLE); |
1140 | 876 } |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
990
diff
changeset
|
877 |
4687 | 878 gaim_blist_update_buddy_idle(b, idle); |
879 gaim_blist_update_buddy_evil(b, evil); | |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
880 |
136
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
881 if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) { |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
882 do_pounce(gc, b->name, OPT_POUNCE_UNAWAY); |
3517 | 883 plugin_event(event_buddy_back, gc, b->name); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
884 system_log(log_back, gc, b, OPT_LOG_BUDDY_AWAY); |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
885 } else if (!(b->uc & UC_UNAVAILABLE) && (type & UC_UNAVAILABLE)) { |
3517 | 886 plugin_event(event_buddy_away, gc, b->name); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
887 system_log(log_away, gc, b, OPT_LOG_BUDDY_AWAY); |
136
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
888 } |
780
c714def9cebb
[gaim-migrate @ 790]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
771
diff
changeset
|
889 |
4687 | 890 gaim_blist_update_buddy_status(b, type); |
891 | |
1 | 892 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
893 if (loggedin) { |
4767 | 894 if (!b->present == 1) { |
895 struct gaim_conversation *c = gaim_find_conversation(b->name); | |
4873 | 896 if (c && (im_options & OPT_IM_LOGON)) { |
4767 | 897 char *tmp = g_strdup_printf(_("%s logged in."), gaim_get_buddy_alias(b)); |
898 gaim_conversation_write(c, NULL, tmp, -1, | |
899 WFLAG_SYSTEM, time(NULL)); | |
900 g_free(tmp); | |
901 } else if (awayqueue && find_queue_total_by_name(b->name)) { | |
902 struct queued_message *qm = g_new0(struct queued_message, 1); | |
903 g_snprintf(qm->name, sizeof(qm->name), "%s", b->name); | |
904 qm->message = g_strdup_printf(_("%s logged in."), | |
905 gaim_get_buddy_alias(b)); | |
906 qm->account = gc->account; | |
907 qm->tm = time(NULL); | |
908 qm->flags = WFLAG_SYSTEM; | |
909 qm->len = -1; | |
910 message_queue = g_slist_append(message_queue, qm); | |
911 } | |
912 gaim_sound_play_event(GAIM_SOUND_BUDDY_ARRIVE); | |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
913 do_pounce(gc, b->name, OPT_POUNCE_SIGNON); |
3517 | 914 plugin_event(event_buddy_signon, gc, b->name); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
915 system_log(log_signon, gc, b, OPT_LOG_BUDDY_SIGNON); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
916 } |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
917 } else { |
4767 | 918 if (b->present == 1) { |
919 struct gaim_conversation *c = gaim_find_conversation(b->name); | |
4873 | 920 if (c && (im_options & OPT_IM_LOGON)) { |
4767 | 921 char *tmp = g_strdup_printf(_("%s logged out."), gaim_get_buddy_alias(b)); |
922 gaim_conversation_write(c, NULL, tmp, -1, | |
923 WFLAG_SYSTEM, time(NULL)); | |
924 g_free(tmp); | |
925 } else if (awayqueue && find_queue_total_by_name(b->name)) { | |
926 struct queued_message *qm = g_new0(struct queued_message, 1); | |
927 g_snprintf(qm->name, sizeof(qm->name), "%s", b->name); | |
928 qm->message = g_strdup_printf(_("%s logged out."), | |
929 gaim_get_buddy_alias(b)); | |
930 qm->account = gc->account; | |
931 qm->tm = time(NULL); | |
932 qm->flags = WFLAG_SYSTEM; | |
933 qm->len = -1; | |
934 message_queue = g_slist_append(message_queue, qm); | |
935 } | |
936 gaim_sound_play_event(GAIM_SOUND_BUDDY_LEAVE); | |
3517 | 937 plugin_event(event_buddy_signoff, gc, b->name); |
1575
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
938 system_log(log_signoff, gc, b, OPT_LOG_BUDDY_SIGNON); |
427e1409917c
[gaim-migrate @ 1585]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1555
diff
changeset
|
939 } |
4767 | 940 } |
941 | |
942 gaim_blist_update_buddy_presence(b, loggedin); | |
943 | |
1 | 944 } |
945 | |
946 | |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
947 void serv_got_eviled(struct gaim_connection *gc, char *name, int lev) |
1 | 948 { |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
949 char buf2[1024]; |
1 | 950 |
3517 | 951 plugin_event(event_warned, gc, name, lev); |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
952 |
2646
2555683e8dc8
[gaim-migrate @ 2659]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2607
diff
changeset
|
953 if (gc->evil >= lev) { |
1771
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
954 gc->evil = lev; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
955 return; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
956 } |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
957 |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
958 gc->evil = lev; |
213607e89598
[gaim-migrate @ 1781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1769
diff
changeset
|
959 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
960 g_snprintf(buf2, sizeof(buf2), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
961 _("%s has just been warned by %s.\n" |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
962 "Your new warning level is %d%%"), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
963 gc->username, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
964 ((name == NULL)? _("an anonymous person") : name), lev); |
1 | 965 |
3427 | 966 do_error_dialog(buf2, NULL, GAIM_INFO); |
1 | 967 } |
968 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
969 void serv_got_typing(struct gaim_connection *gc, char *name, int timeout, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
970 int state) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
971 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
972 struct gaim_conversation *cnv = gaim_find_conversation(name); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
973 struct gaim_im *im; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
974 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
975 if (!cnv) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
976 return; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
977 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
978 im = GAIM_IM(cnv); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
979 |
4491 | 980 gaim_conversation_set_account(cnv, gc->account); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
981 gaim_im_set_typing_state(im, state); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
982 gaim_im_update_typing(im); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
983 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
984 plugin_event(event_got_typing, gc, name); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
985 do_pounce(gc, name, OPT_POUNCE_TYPING); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
986 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
987 if (timeout > 0) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
988 gaim_im_start_typing_timeout(im, timeout); |
2993 | 989 } |
1 | 990 |
2993 | 991 void serv_got_typing_stopped(struct gaim_connection *gc, char *name) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
992 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
993 struct gaim_conversation *c = gaim_find_conversation(name); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
994 struct gaim_im *im; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
995 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
996 if (!c) |
3787 | 997 return; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
998 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
999 im = GAIM_IM(c); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1000 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1001 gaim_im_stop_typing_timeout(im); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1002 gaim_im_set_typing_state(im, NOT_TYPING); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1003 gaim_im_update_typing(im); |
2993 | 1004 } |
1 | 1005 |
4487 | 1006 struct chat_invite_data { |
1007 struct gaim_connection *gc; | |
1008 GList *str; | |
1009 }; | |
1723
76e601b77099
[gaim-migrate @ 1733]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1722
diff
changeset
|
1010 |
4487 | 1011 static void chat_invite_data_free(struct chat_invite_data *cid) |
1 | 1012 { |
4487 | 1013 GList *tmp = cid->str; |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1014 while (tmp) { |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1015 /* this is either a g_malloc'd char* or g_malloc'd int* */ |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1016 g_free(tmp->data); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1017 tmp = tmp->next; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1018 } |
4487 | 1019 if (cid->str) |
1020 g_list_free(cid->str); | |
1021 g_free(cid); | |
1022 } | |
1723
76e601b77099
[gaim-migrate @ 1733]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1722
diff
changeset
|
1023 |
4487 | 1024 static void chat_invite_accept(struct chat_invite_data *cid) |
1025 { | |
1026 serv_join_chat(cid->gc, cid->str); | |
1027 | |
1028 chat_invite_data_free(cid); | |
1 | 1029 } |
1030 | |
1031 | |
1032 | |
4487 | 1033 void serv_got_chat_invite(struct gaim_connection *gc, char *name, |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1034 char *who, char *message, GList *data) |
1 | 1035 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1036 char buf2[BUF_LONG]; |
4487 | 1037 struct chat_invite_data *cid = g_new0(struct chat_invite_data, 1); |
1 | 1038 |
1039 | |
4487 | 1040 plugin_event(event_chat_invited, gc, who, name, message); |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
1041 |
414
f9dc74875833
[gaim-migrate @ 424]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1042 if (message) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1043 g_snprintf(buf2, sizeof(buf2), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1044 _("User '%s' invites %s to buddy chat room: '%s'\n%s"), |
4487 | 1045 who, gc->username, name, message); |
414
f9dc74875833
[gaim-migrate @ 424]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
411
diff
changeset
|
1046 else |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1047 g_snprintf(buf2, sizeof(buf2), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1048 _("User '%s' invites %s to buddy chat room: '%s'\n"), |
4487 | 1049 who, gc->username, name); |
1 | 1050 |
4487 | 1051 cid->gc = gc; |
1052 cid->str = data; | |
1 | 1053 |
4487 | 1054 do_ask_dialog(_("Buddy Chat Invite"), buf2, cid, _("Accept"), chat_invite_accept, _("Cancel"), chat_invite_data_free, NULL, FALSE); |
1 | 1055 } |
1056 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1057 struct gaim_conversation *serv_got_joined_chat(struct gaim_connection *gc, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1058 int id, char *name) |
1 | 1059 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1060 struct gaim_conversation *b; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1061 struct gaim_chat *chat; |
1 | 1062 |
4491 | 1063 b = gaim_conversation_new(GAIM_CONV_CHAT, gc->account, name); |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1064 chat = GAIM_CHAT(b); |
1 | 1065 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1066 gc->buddy_chats = g_slist_append(gc->buddy_chats, b); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1067 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1068 gaim_chat_set_id(chat, id); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4440
diff
changeset
|
1069 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1070 if ((logging_options & OPT_LOG_CHATS) || |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1071 find_log_info(gaim_conversation_get_name(b))) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1072 |
888 | 1073 FILE *fd; |
1074 char *filename; | |
1075 | |
1076 filename = (char *)malloc(100); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1077 g_snprintf(filename, 100, "%s.chat", gaim_conversation_get_name(b)); |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1078 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1079 fd = open_log_file(filename, TRUE); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1080 |
1722
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1081 if (fd) { |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1082 if (!(logging_options & OPT_LOG_STRIP_HTML)) |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1083 fprintf(fd, |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1084 "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1085 full_date()); |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1086 else |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1087 fprintf(fd, "---- New Conversation @ %s ----\n", full_date()); |
1437
1f0660a2c893
[gaim-migrate @ 1447]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1435
diff
changeset
|
1088 |
1722
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1089 fclose(fd); |
1edc8b545d6f
[gaim-migrate @ 1732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1721
diff
changeset
|
1090 } |
888 | 1091 free(filename); |
1092 } | |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1093 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1094 gaim_window_show(gaim_conversation_get_window(b)); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1095 gaim_window_switch_conversation(gaim_conversation_get_window(b), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1096 gaim_conversation_get_index(b)); |
1785
f4ae086c746b
[gaim-migrate @ 1795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1775
diff
changeset
|
1097 |
3710 | 1098 plugin_event(event_chat_join, gc, id, name); |
1099 | |
1785
f4ae086c746b
[gaim-migrate @ 1795]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1775
diff
changeset
|
1100 return b; |
1 | 1101 } |
1102 | |
964
2cd7b73e2c9a
[gaim-migrate @ 974]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
962
diff
changeset
|
1103 void serv_got_chat_left(struct gaim_connection *g, int id) |
1 | 1104 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1105 GSList *bcs; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1106 struct gaim_conversation *conv = NULL; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1107 struct gaim_chat *chat = NULL; |
1 | 1108 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1109 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1110 conv = (struct gaim_conversation *)bcs->data; |
1 | 1111 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1112 chat = GAIM_CHAT(conv); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1113 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1114 if (gaim_chat_get_id(chat) == id) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1115 break; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1116 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1117 conv = NULL; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1118 } |
1 | 1119 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1120 if (!conv) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1121 return; |
1 | 1122 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1123 plugin_event(event_chat_leave, g, gaim_chat_get_id(chat)); |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
1124 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1125 debug_printf("Leaving room %s.\n", gaim_conversation_get_name(conv)); |
1 | 1126 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1127 g->buddy_chats = g_slist_remove(g->buddy_chats, conv); |
1 | 1128 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1129 gaim_conversation_destroy(conv); |
1 | 1130 } |
1131 | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1132 void serv_got_chat_in(struct gaim_connection *g, int id, char *who, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1133 int whisper, char *message, time_t mtime) |
1 | 1134 { |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1135 int w; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1136 GSList *bcs; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1137 struct gaim_conversation *conv = NULL; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1138 struct gaim_chat *chat = NULL; |
2296
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
1139 char *buf; |
3163 | 1140 char *buffy, *angel; |
1141 int plugin_return; | |
1 | 1142 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1143 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1144 conv = (struct gaim_conversation *)bcs->data; |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1145 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1146 chat = GAIM_CHAT(conv); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1147 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1148 if (gaim_chat_get_id(chat) == id) |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1149 break; |
1 | 1150 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1151 conv = NULL; |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1152 } |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1153 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1154 if (!conv) |
1100
f168625b63fe
[gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1089
diff
changeset
|
1155 return; |
391
be408b41c172
[gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
368
diff
changeset
|
1156 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1157 /* |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1158 * 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
|
1159 * 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
|
1160 * 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
|
1161 * 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
|
1162 * don't want you to be dealing with it. |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1163 */ |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1164 |
3163 | 1165 buffy = g_malloc(MAX(strlen(message) + 1, BUF_LONG)); |
1166 strcpy(buffy, message); | |
1167 angel = g_strdup(who); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1168 plugin_return = plugin_event(event_chat_recv, g, gaim_chat_get_id(chat), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1169 &angel, &buffy); |
3163 | 1170 |
1171 if (!buffy || !angel || plugin_return) { | |
1172 if (buffy) | |
1173 g_free(buffy); | |
1174 if (angel) | |
1175 g_free(angel); | |
2372
2927c2c26fe6
[gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2359
diff
changeset
|
1176 return; |
3163 | 1177 } |
1178 who = angel; | |
1179 message = buffy; | |
1 | 1180 |
2296
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
1181 buf = g_malloc(MAX(strlen(message) * 2, 8192)); |
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
1182 strcpy(buf, message); |
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
1183 |
2313
bd9d403fb15b
[gaim-migrate @ 2323]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1184 if (convo_options & OPT_CONVO_SEND_LINKS) |
2296
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
1185 linkify_text(buf); |
1643
d7e380618fd5
[gaim-migrate @ 1653]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1587
diff
changeset
|
1186 |
1252
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1187 if (whisper) |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1188 w = WFLAG_WHISPER; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1189 else |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1190 w = 0; |
46c09828e929
[gaim-migrate @ 1262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1250
diff
changeset
|
1191 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1192 gaim_chat_write(chat, who, buf, w, mtime); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1193 |
3163 | 1194 g_free(who); |
1195 g_free(message); | |
2296
878503b60006
[gaim-migrate @ 2306]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
1196 g_free(buf); |
1 | 1197 } |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1198 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1199 static void des_popup(GtkWidget *w, GtkWidget *window) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1200 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1201 if (w == window) { |
4635 | 1202 char *u = g_object_get_data(G_OBJECT(window), "url"); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1203 g_free(u); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1204 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1205 gtk_widget_destroy(window); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1206 } |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1207 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1208 void serv_got_popup(char *msg, char *u, int wid, int hei) |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1209 { |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1210 GtkWidget *window; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1211 GtkWidget *vbox; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1212 GtkWidget *sw; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1213 GtkWidget *text; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1214 GtkWidget *hbox; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1215 GtkWidget *button; |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1216 char *url = g_strdup(u); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1217 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1218 GAIM_DIALOG(window); |
4074 | 1219 gtk_window_set_role(GTK_WINDOW(window), "popup"); |
4635 | 1220 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1221 gtk_window_set_title(GTK_WINDOW(window), "Gaim - Popup"); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1222 gtk_container_set_border_width(GTK_CONTAINER(window), 5); |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
1223 g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(des_popup), window); |
4635 | 1224 g_object_set_data(G_OBJECT(window), "url", url); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1225 gtk_widget_realize(window); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1226 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1227 vbox = gtk_vbox_new(FALSE, 5); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1228 gtk_container_add(GTK_CONTAINER(window), vbox); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1229 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1230 sw = gtk_scrolled_window_new(NULL, NULL); |
4635 | 1231 gtk_widget_set_size_request(sw, wid, hei); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1232 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1233 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 5); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1234 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1235 text = gtk_imhtml_new(NULL, NULL); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1236 gtk_container_add(GTK_CONTAINER(sw), text); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1237 gaim_setup_imhtml(text); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1238 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1239 hbox = gtk_hbox_new(FALSE, 5); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1240 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1241 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1242 button = picture_button(window, _("Close"), cancel_xpm); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1243 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5); |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
1244 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(des_popup), window); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1245 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1246 button = picture_button(window, _("More Info"), tb_search_xpm); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1247 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5); |
4162
d3c8d2b40494
[gaim-migrate @ 4391]
Christian Hammond <chipx86@chipx86.com>
parents:
4124
diff
changeset
|
1248 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(open_url), url); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1249 |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1250 gtk_widget_show_all(window); |
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1251 |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2827
diff
changeset
|
1252 gtk_imhtml_append_text(GTK_IMHTML(text), msg, -1, GTK_IMHTML_NO_NEWLINE); |
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
1253 } |