1 | /********************************************************************\ |
---|
2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
3 | * * |
---|
4 | * Copyright 2002-2010 Wilmer van der Gaast and others * |
---|
5 | \********************************************************************/ |
---|
6 | |
---|
7 | /* Some glue to put the IRC and the IM stuff together. */ |
---|
8 | |
---|
9 | /* |
---|
10 | This program is free software; you can redistribute it and/or modify |
---|
11 | it under the terms of the GNU General Public License as published by |
---|
12 | the Free Software Foundation; either version 2 of the License, or |
---|
13 | (at your option) any later version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License with |
---|
21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
22 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
23 | Suite 330, Boston, MA 02111-1307 USA |
---|
24 | */ |
---|
25 | |
---|
26 | #include "bitlbee.h" |
---|
27 | #include "dcc.h" |
---|
28 | |
---|
29 | /* IM->IRC callbacks: Simple IM/buddy-related stuff. */ |
---|
30 | |
---|
31 | static const struct irc_user_funcs irc_user_im_funcs; |
---|
32 | |
---|
33 | static gboolean bee_irc_user_new( bee_t *bee, bee_user_t *bu ) |
---|
34 | { |
---|
35 | irc_user_t *iu; |
---|
36 | char nick[MAX_NICK_LENGTH+1], *s; |
---|
37 | |
---|
38 | memset( nick, 0, MAX_NICK_LENGTH + 1 ); |
---|
39 | strcpy( nick, nick_get( bu->ic->acc, bu->handle ) ); |
---|
40 | |
---|
41 | bu->ui_data = iu = irc_user_new( (irc_t*) bee->ui_data, nick ); |
---|
42 | iu->bu = bu; |
---|
43 | |
---|
44 | if( ( s = strchr( bu->handle, '@' ) ) ) |
---|
45 | { |
---|
46 | iu->host = g_strdup( s + 1 ); |
---|
47 | iu->user = g_strndup( bu->handle, s - bu->handle ); |
---|
48 | } |
---|
49 | else if( bu->ic->acc->server ) |
---|
50 | { |
---|
51 | iu->host = g_strdup( bu->ic->acc->server ); |
---|
52 | iu->user = g_strdup( bu->handle ); |
---|
53 | |
---|
54 | /* s/ /_/ ... important for AOL screennames */ |
---|
55 | for( s = iu->user; *s; s ++ ) |
---|
56 | if( *s == ' ' ) |
---|
57 | *s = '_'; |
---|
58 | } |
---|
59 | else |
---|
60 | { |
---|
61 | iu->host = g_strdup( bu->ic->acc->prpl->name ); |
---|
62 | iu->user = g_strdup( bu->handle ); |
---|
63 | } |
---|
64 | |
---|
65 | if( set_getbool( &bee->set, "private" ) ) |
---|
66 | iu->flags |= IRC_USER_PRIVATE; |
---|
67 | |
---|
68 | if( bu->flags & BEE_USER_LOCAL ) |
---|
69 | { |
---|
70 | char *s = set_getstr( &bee->set, "handle_unknown" ); |
---|
71 | |
---|
72 | if( strcmp( s, "add_private" ) == 0 ) |
---|
73 | iu->flags |= IRC_USER_PRIVATE; |
---|
74 | else if( strcmp( s, "add_channel" ) == 0 ) |
---|
75 | iu->flags &= ~IRC_USER_PRIVATE; |
---|
76 | } |
---|
77 | |
---|
78 | iu->f = &irc_user_im_funcs; |
---|
79 | //iu->last_typing_notice = 0; |
---|
80 | |
---|
81 | return TRUE; |
---|
82 | } |
---|
83 | |
---|
84 | static gboolean bee_irc_user_free( bee_t *bee, bee_user_t *bu ) |
---|
85 | { |
---|
86 | return irc_user_free( bee->ui_data, (irc_user_t *) bu->ui_data ); |
---|
87 | } |
---|
88 | |
---|
89 | static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old ) |
---|
90 | { |
---|
91 | irc_t *irc = bee->ui_data; |
---|
92 | irc_user_t *iu = bu->ui_data; |
---|
93 | |
---|
94 | /* Do this outside the if below since away state can change without |
---|
95 | the online state changing. */ |
---|
96 | iu->flags &= ~IRC_USER_AWAY; |
---|
97 | if( bu->flags & BEE_USER_AWAY || !( bu->flags & BEE_USER_ONLINE ) ) |
---|
98 | iu->flags |= IRC_USER_AWAY; |
---|
99 | |
---|
100 | if( ( bu->flags & BEE_USER_ONLINE ) != ( old->flags & BEE_USER_ONLINE ) ) |
---|
101 | { |
---|
102 | if( bu->flags & BEE_USER_ONLINE ) |
---|
103 | { |
---|
104 | if( g_hash_table_lookup( irc->watches, iu->key ) ) |
---|
105 | irc_send_num( irc, 600, "%s %s %s %d :%s", iu->nick, iu->user, |
---|
106 | iu->host, (int) time( NULL ), "logged online" ); |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | if( g_hash_table_lookup( irc->watches, iu->key ) ) |
---|
111 | irc_send_num( irc, 601, "%s %s %s %d :%s", iu->nick, iu->user, |
---|
112 | iu->host, (int) time( NULL ), "logged offline" ); |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | bee_irc_channel_update( irc, NULL, iu ); |
---|
117 | |
---|
118 | return TRUE; |
---|
119 | } |
---|
120 | |
---|
121 | void bee_irc_channel_update( irc_t *irc, irc_channel_t *ic, irc_user_t *iu ) |
---|
122 | { |
---|
123 | struct irc_control_channel *icc; |
---|
124 | GSList *l; |
---|
125 | gboolean show; |
---|
126 | |
---|
127 | if( ic == NULL ) |
---|
128 | { |
---|
129 | for( l = irc->channels; l; l = l->next ) |
---|
130 | { |
---|
131 | ic = l->data; |
---|
132 | /* TODO: Just add a type flag or so.. */ |
---|
133 | if( ic->f == irc->default_channel->f ) |
---|
134 | bee_irc_channel_update( irc, ic, iu ); |
---|
135 | } |
---|
136 | return; |
---|
137 | } |
---|
138 | if( iu == NULL ) |
---|
139 | { |
---|
140 | for( l = irc->users; l; l = l->next ) |
---|
141 | { |
---|
142 | iu = l->data; |
---|
143 | if( iu->bu ) |
---|
144 | bee_irc_channel_update( irc, ic, l->data ); |
---|
145 | } |
---|
146 | return; |
---|
147 | } |
---|
148 | |
---|
149 | icc = ic->data; |
---|
150 | |
---|
151 | if( !( iu->bu->flags & BEE_USER_ONLINE ) ) |
---|
152 | show = FALSE; |
---|
153 | else if( icc->type == IRC_CC_TYPE_DEFAULT ) |
---|
154 | show = TRUE; |
---|
155 | else if( icc->type == IRC_CC_TYPE_GROUP ) |
---|
156 | show = iu->bu->group == icc->group; |
---|
157 | else if( icc->type == IRC_CC_TYPE_ACCOUNT ) |
---|
158 | show = iu->bu->ic->acc == icc->account; |
---|
159 | |
---|
160 | if( !show ) |
---|
161 | { |
---|
162 | irc_channel_del_user( ic, iu ); |
---|
163 | } |
---|
164 | else |
---|
165 | { |
---|
166 | irc_channel_add_user( ic, iu ); |
---|
167 | |
---|
168 | if( set_getbool( &irc->b->set, "away_devoice" ) ) |
---|
169 | irc_channel_user_set_mode( ic, iu, ( iu->bu->flags & BEE_USER_AWAY ) ? |
---|
170 | 0 : IRC_CHANNEL_USER_VOICE ); |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at ) |
---|
175 | { |
---|
176 | irc_t *irc = bee->ui_data; |
---|
177 | irc_channel_t *ic = irc->default_channel; |
---|
178 | irc_user_t *iu = (irc_user_t *) bu->ui_data; |
---|
179 | char *dst, *prefix = NULL; |
---|
180 | char *wrapped, *ts = NULL; |
---|
181 | |
---|
182 | if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) ) |
---|
183 | ts = irc_format_timestamp( irc, sent_at ); |
---|
184 | |
---|
185 | if( iu->flags & IRC_USER_PRIVATE ) |
---|
186 | { |
---|
187 | dst = irc->user->nick; |
---|
188 | prefix = ts; |
---|
189 | ts = NULL; |
---|
190 | } |
---|
191 | else |
---|
192 | { |
---|
193 | dst = ic->name; |
---|
194 | prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" ); |
---|
195 | } |
---|
196 | |
---|
197 | wrapped = word_wrap( msg, 425 ); |
---|
198 | irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix ); |
---|
199 | |
---|
200 | g_free( wrapped ); |
---|
201 | g_free( prefix ); |
---|
202 | g_free( ts ); |
---|
203 | |
---|
204 | return TRUE; |
---|
205 | } |
---|
206 | |
---|
207 | static gboolean bee_irc_user_typing( bee_t *bee, bee_user_t *bu, uint32_t flags ) |
---|
208 | { |
---|
209 | irc_t *irc = (irc_t *) bee->ui_data; |
---|
210 | |
---|
211 | if( set_getbool( &bee->set, "typing_notice" ) ) |
---|
212 | irc_send_msg_f( (irc_user_t *) bu->ui_data, "PRIVMSG", irc->user->nick, |
---|
213 | "\001TYPING %d\001", ( flags >> 8 ) & 3 ); |
---|
214 | else |
---|
215 | return FALSE; |
---|
216 | |
---|
217 | return TRUE; |
---|
218 | } |
---|
219 | |
---|
220 | static gboolean bee_irc_user_fullname( bee_t *bee, bee_user_t *bu ) |
---|
221 | { |
---|
222 | irc_user_t *iu = (irc_user_t *) bu->ui_data; |
---|
223 | irc_t *irc = (irc_t *) bee->ui_data; |
---|
224 | char *s; |
---|
225 | |
---|
226 | if( iu->fullname != iu->nick ) |
---|
227 | g_free( iu->fullname ); |
---|
228 | iu->fullname = g_strdup( bu->fullname ); |
---|
229 | |
---|
230 | /* Strip newlines (unlikely, but IRC-unfriendly so they must go) |
---|
231 | TODO(wilmer): Do the same with away msgs again! */ |
---|
232 | for( s = iu->fullname; *s; s ++ ) |
---|
233 | if( isspace( *s ) ) *s = ' '; |
---|
234 | |
---|
235 | if( ( bu->ic->flags & OPT_LOGGED_IN ) && set_getbool( &bee->set, "display_namechanges" ) ) |
---|
236 | { |
---|
237 | char *msg = g_strdup_printf( "<< \002BitlBee\002 - Changed name to `%s' >>", iu->fullname ); |
---|
238 | irc_send_msg( iu, "NOTICE", irc->user->nick, msg, NULL ); |
---|
239 | } |
---|
240 | |
---|
241 | s = set_getstr( &bu->ic->acc->set, "nick_source" ); |
---|
242 | if( strcmp( s, "handle" ) != 0 ) |
---|
243 | { |
---|
244 | char *name = g_strdup( bu->fullname ); |
---|
245 | |
---|
246 | if( strcmp( s, "first_name" ) == 0 ) |
---|
247 | { |
---|
248 | int i; |
---|
249 | for( i = 0; name[i] && !isspace( name[i] ); i ++ ) {} |
---|
250 | name[i] = '\0'; |
---|
251 | } |
---|
252 | |
---|
253 | imcb_buddy_nick_hint( bu->ic, bu->handle, name ); |
---|
254 | |
---|
255 | g_free( name ); |
---|
256 | } |
---|
257 | |
---|
258 | return TRUE; |
---|
259 | } |
---|
260 | |
---|
261 | /* IRC->IM calls */ |
---|
262 | |
---|
263 | static gboolean bee_irc_user_privmsg( irc_user_t *iu, const char *msg ) |
---|
264 | { |
---|
265 | if( iu->bu ) |
---|
266 | return bee_user_msg( iu->irc->b, iu->bu, msg, 0 ); |
---|
267 | else |
---|
268 | return FALSE; |
---|
269 | } |
---|
270 | |
---|
271 | static gboolean bee_irc_user_ctcp( irc_user_t *iu, char *const *ctcp ) |
---|
272 | { |
---|
273 | if( ctcp[1] && g_strcasecmp( ctcp[0], "DCC" ) == 0 |
---|
274 | && g_strcasecmp( ctcp[1], "SEND" ) == 0 ) |
---|
275 | { |
---|
276 | if( iu->bu && iu->bu->ic && iu->bu->ic->acc->prpl->transfer_request ) |
---|
277 | { |
---|
278 | file_transfer_t *ft = dcc_request( iu->bu->ic, ctcp ); |
---|
279 | if ( ft ) |
---|
280 | iu->bu->ic->acc->prpl->transfer_request( iu->bu->ic, ft, iu->bu->handle ); |
---|
281 | |
---|
282 | return TRUE; |
---|
283 | } |
---|
284 | } |
---|
285 | else if( g_strcasecmp( ctcp[0], "TYPING" ) == 0 ) |
---|
286 | { |
---|
287 | if( iu->bu && iu->bu->ic && iu->bu->ic->acc->prpl->send_typing && ctcp[1] ) |
---|
288 | { |
---|
289 | int st = ctcp[1][0]; |
---|
290 | if( st >= '0' && st <= '2' ) |
---|
291 | { |
---|
292 | st <<= 8; |
---|
293 | iu->bu->ic->acc->prpl->send_typing( iu->bu->ic, iu->bu->handle, st ); |
---|
294 | } |
---|
295 | |
---|
296 | return TRUE; |
---|
297 | } |
---|
298 | } |
---|
299 | |
---|
300 | return FALSE; |
---|
301 | } |
---|
302 | |
---|
303 | static const struct irc_user_funcs irc_user_im_funcs = { |
---|
304 | bee_irc_user_privmsg, |
---|
305 | bee_irc_user_ctcp, |
---|
306 | }; |
---|
307 | |
---|
308 | |
---|
309 | /* IM->IRC: Groupchats */ |
---|
310 | static const struct irc_channel_funcs irc_channel_im_chat_funcs; |
---|
311 | |
---|
312 | static gboolean bee_irc_chat_new( bee_t *bee, struct groupchat *c ) |
---|
313 | { |
---|
314 | irc_t *irc = bee->ui_data; |
---|
315 | irc_channel_t *ic; |
---|
316 | char *topic; |
---|
317 | GSList *l; |
---|
318 | int i; |
---|
319 | |
---|
320 | /* Try to find a channel that expects to receive a groupchat. |
---|
321 | This flag is set by groupchat_stub_invite(). */ |
---|
322 | for( l = irc->channels; l; l = l->next ) |
---|
323 | { |
---|
324 | ic = l->data; |
---|
325 | if( ic->flags & IRC_CHANNEL_CHAT_PICKME ) |
---|
326 | break; |
---|
327 | } |
---|
328 | |
---|
329 | /* If we found none, just generate some stupid name. */ |
---|
330 | if( l == NULL ) for( i = 0; i <= 999; i ++ ) |
---|
331 | { |
---|
332 | char name[16]; |
---|
333 | sprintf( name, "&chat_%03d", i ); |
---|
334 | if( ( ic = irc_channel_new( irc, name ) ) ) |
---|
335 | break; |
---|
336 | } |
---|
337 | |
---|
338 | if( ic == NULL ) |
---|
339 | return FALSE; |
---|
340 | |
---|
341 | c->ui_data = ic; |
---|
342 | ic->data = c; |
---|
343 | ic->f = &irc_channel_im_chat_funcs; |
---|
344 | |
---|
345 | topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); |
---|
346 | irc_channel_set_topic( ic, topic, irc->root ); |
---|
347 | g_free( topic ); |
---|
348 | |
---|
349 | return TRUE; |
---|
350 | } |
---|
351 | |
---|
352 | static gboolean bee_irc_chat_free( bee_t *bee, struct groupchat *c ) |
---|
353 | { |
---|
354 | irc_channel_t *ic = c->ui_data; |
---|
355 | |
---|
356 | if( ic->flags & IRC_CHANNEL_JOINED ) |
---|
357 | irc_channel_printf( ic, "Cleaning up channel, bye!" ); |
---|
358 | |
---|
359 | irc_channel_free( ic ); |
---|
360 | |
---|
361 | return TRUE; |
---|
362 | } |
---|
363 | |
---|
364 | static gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *text ) |
---|
365 | { |
---|
366 | irc_channel_t *ic = c->ui_data; |
---|
367 | |
---|
368 | irc_channel_printf( ic, "%s", text ); |
---|
369 | |
---|
370 | return TRUE; |
---|
371 | } |
---|
372 | |
---|
373 | static gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at ) |
---|
374 | { |
---|
375 | irc_t *irc = bee->ui_data; |
---|
376 | irc_user_t *iu = bu->ui_data; |
---|
377 | irc_channel_t *ic = c->ui_data; |
---|
378 | char *ts = NULL; |
---|
379 | |
---|
380 | if( sent_at > 0 && set_getbool( &bee->set, "display_timestamps" ) ) |
---|
381 | ts = irc_format_timestamp( irc, sent_at ); |
---|
382 | |
---|
383 | irc_send_msg( iu, "PRIVMSG", ic->name, msg, ts ); |
---|
384 | g_free( ts ); |
---|
385 | |
---|
386 | return TRUE; |
---|
387 | } |
---|
388 | |
---|
389 | static gboolean bee_irc_chat_add_user( bee_t *bee, struct groupchat *c, bee_user_t *bu ) |
---|
390 | { |
---|
391 | irc_t *irc = bee->ui_data; |
---|
392 | |
---|
393 | irc_channel_add_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data ); |
---|
394 | |
---|
395 | return TRUE; |
---|
396 | } |
---|
397 | |
---|
398 | static gboolean bee_irc_chat_remove_user( bee_t *bee, struct groupchat *c, bee_user_t *bu ) |
---|
399 | { |
---|
400 | irc_t *irc = bee->ui_data; |
---|
401 | |
---|
402 | irc_channel_del_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data ); |
---|
403 | |
---|
404 | return TRUE; |
---|
405 | } |
---|
406 | |
---|
407 | static gboolean bee_irc_chat_topic( bee_t *bee, struct groupchat *c, const char *new, bee_user_t *bu ) |
---|
408 | { |
---|
409 | irc_t *irc = bee->ui_data; |
---|
410 | irc_user_t *iu; |
---|
411 | |
---|
412 | if( bu == NULL ) |
---|
413 | iu = irc->root; |
---|
414 | else if( bu == bee->user ) |
---|
415 | iu = irc->user; |
---|
416 | else |
---|
417 | iu = bu->ui_data; |
---|
418 | |
---|
419 | irc_channel_set_topic( c->ui_data, new, iu ); |
---|
420 | |
---|
421 | return TRUE; |
---|
422 | } |
---|
423 | |
---|
424 | static gboolean bee_irc_chat_name_hint( bee_t *bee, struct groupchat *c, const char *name ) |
---|
425 | { |
---|
426 | irc_t *irc = bee->ui_data; |
---|
427 | irc_channel_t *ic = c->ui_data; |
---|
428 | char stripped[MAX_NICK_LENGTH+1], *full_name; |
---|
429 | |
---|
430 | /* Don't rename a channel if the user's in it already. */ |
---|
431 | if( ic->flags & IRC_CHANNEL_JOINED ) |
---|
432 | return FALSE; |
---|
433 | |
---|
434 | strncpy( stripped, name, MAX_NICK_LENGTH ); |
---|
435 | stripped[MAX_NICK_LENGTH] = '\0'; |
---|
436 | nick_strip( stripped ); |
---|
437 | if( set_getbool( &bee->set, "lcnicks" ) ) |
---|
438 | nick_lc( stripped ); |
---|
439 | |
---|
440 | full_name = g_strdup_printf( "&%s", stripped ); |
---|
441 | |
---|
442 | if( stripped[0] && irc_channel_by_name( irc, full_name ) == NULL ) |
---|
443 | { |
---|
444 | g_free( ic->name ); |
---|
445 | ic->name = full_name; |
---|
446 | } |
---|
447 | else |
---|
448 | { |
---|
449 | g_free( full_name ); |
---|
450 | } |
---|
451 | |
---|
452 | return TRUE; |
---|
453 | } |
---|
454 | |
---|
455 | /* IRC->IM */ |
---|
456 | static gboolean bee_irc_channel_chat_privmsg( irc_channel_t *ic, const char *msg ) |
---|
457 | { |
---|
458 | struct groupchat *c = ic->data; |
---|
459 | |
---|
460 | bee_chat_msg( ic->irc->b, c, msg, 0 ); |
---|
461 | |
---|
462 | return TRUE; |
---|
463 | |
---|
464 | } |
---|
465 | |
---|
466 | static gboolean bee_irc_channel_chat_part( irc_channel_t *ic, const char *msg ) |
---|
467 | { |
---|
468 | struct groupchat *c = ic->data; |
---|
469 | |
---|
470 | if( c->ic->acc->prpl->chat_leave ) |
---|
471 | c->ic->acc->prpl->chat_leave( c ); |
---|
472 | |
---|
473 | return TRUE; |
---|
474 | |
---|
475 | } |
---|
476 | |
---|
477 | static gboolean bee_irc_channel_chat_topic( irc_channel_t *ic, const char *new ) |
---|
478 | { |
---|
479 | return TRUE; |
---|
480 | } |
---|
481 | |
---|
482 | static gboolean bee_irc_channel_chat_invite( irc_channel_t *ic, irc_user_t *iu ) |
---|
483 | { |
---|
484 | struct groupchat *c = ic->data; |
---|
485 | |
---|
486 | if( iu->bu->ic != c->ic ) |
---|
487 | irc_send_num( ic->irc, 482, "%s :Can't mix different IM networks in one groupchat", ic->name ); |
---|
488 | else if( c->ic->acc->prpl->chat_invite ) |
---|
489 | c->ic->acc->prpl->chat_invite( c, iu->bu->handle, NULL ); |
---|
490 | else |
---|
491 | irc_send_num( ic->irc, 482, "%s :IM protocol does not support room invitations", ic->name ); |
---|
492 | |
---|
493 | return TRUE; |
---|
494 | } |
---|
495 | |
---|
496 | static const struct irc_channel_funcs irc_channel_im_chat_funcs = { |
---|
497 | bee_irc_channel_chat_privmsg, |
---|
498 | NULL, /* join */ |
---|
499 | bee_irc_channel_chat_part, |
---|
500 | bee_irc_channel_chat_topic, |
---|
501 | bee_irc_channel_chat_invite, |
---|
502 | }; |
---|
503 | |
---|
504 | |
---|
505 | /* IM->IRC: File transfers */ |
---|
506 | static file_transfer_t *bee_irc_ft_in_start( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size ) |
---|
507 | { |
---|
508 | return dccs_send_start( bu->ic, (irc_user_t *) bu->ui_data, file_name, file_size ); |
---|
509 | } |
---|
510 | |
---|
511 | static gboolean bee_irc_ft_out_start( struct im_connection *ic, file_transfer_t *ft ) |
---|
512 | { |
---|
513 | return dccs_recv_start( ft ); |
---|
514 | } |
---|
515 | |
---|
516 | static void bee_irc_ft_close( struct im_connection *ic, file_transfer_t *ft ) |
---|
517 | { |
---|
518 | return dcc_close( ft ); |
---|
519 | } |
---|
520 | |
---|
521 | static void bee_irc_ft_finished( struct im_connection *ic, file_transfer_t *file ) |
---|
522 | { |
---|
523 | dcc_file_transfer_t *df = file->priv; |
---|
524 | |
---|
525 | if( file->bytes_transferred >= file->file_size ) |
---|
526 | dcc_finish( file ); |
---|
527 | else |
---|
528 | df->proto_finished = TRUE; |
---|
529 | } |
---|
530 | |
---|
531 | const struct bee_ui_funcs irc_ui_funcs = { |
---|
532 | bee_irc_user_new, |
---|
533 | bee_irc_user_free, |
---|
534 | bee_irc_user_fullname, |
---|
535 | bee_irc_user_status, |
---|
536 | bee_irc_user_msg, |
---|
537 | bee_irc_user_typing, |
---|
538 | |
---|
539 | bee_irc_chat_new, |
---|
540 | bee_irc_chat_free, |
---|
541 | bee_irc_chat_log, |
---|
542 | bee_irc_chat_msg, |
---|
543 | bee_irc_chat_add_user, |
---|
544 | bee_irc_chat_remove_user, |
---|
545 | bee_irc_chat_topic, |
---|
546 | bee_irc_chat_name_hint, |
---|
547 | |
---|
548 | bee_irc_ft_in_start, |
---|
549 | bee_irc_ft_out_start, |
---|
550 | bee_irc_ft_close, |
---|
551 | bee_irc_ft_finished, |
---|
552 | }; |
---|