| 54 return g_strdup(strchr(mask, '!') + 1); |
54 return g_strdup(strchr(mask, '!') + 1); |
| 55 } |
55 } |
| 56 |
56 |
| 57 static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]) |
57 static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]) |
| 58 { |
58 { |
| 59 GList *users = gaim_conv_chat_get_users(GAIM_CONV_CHAT(convo)); |
|
| 60 char *message = g_strdup_printf("quit: %s", data[1]); |
59 char *message = g_strdup_printf("quit: %s", data[1]); |
| 61 |
60 |
| 62 if (g_list_find_custom(users, data[0], (GCompareFunc)(strcmp))) |
61 if (gaim_conv_chat_find_user(GAIM_CONV_CHAT(convo), data[0])) |
| 63 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), data[0], message); |
62 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), data[0], message); |
| 64 |
63 |
| 65 g_free(message); |
64 g_free(message); |
| 66 } |
65 } |
| 67 |
66 |
| 330 g_free(msg); |
329 g_free(msg); |
| 331 g_free(irc->nameconv); |
330 g_free(irc->nameconv); |
| 332 irc->nameconv = NULL; |
331 irc->nameconv = NULL; |
| 333 } else { |
332 } else { |
| 334 GList *users = NULL; |
333 GList *users = NULL; |
| |
334 GList *flags = NULL; |
| 335 |
335 |
| 336 while (*cur) { |
336 while (*cur) { |
| |
337 GaimConvChatBuddyFlags f = GAIM_CBFLAGS_NONE; |
| 337 end = strchr(cur, ' '); |
338 end = strchr(cur, ' '); |
| 338 if (!end) |
339 if (!end) |
| 339 end = cur + strlen(cur); |
340 end = cur + strlen(cur); |
| 340 if (*cur == '@' || *cur == '%' || *cur == '+') |
341 if (*cur == '@') { |
| |
342 f = GAIM_CBFLAGS_OP; |
| 341 cur++; |
343 cur++; |
| |
344 } else if (*cur == '%') { |
| |
345 f = GAIM_CBFLAGS_HALFOP; |
| |
346 cur++; |
| |
347 } else if(*cur == '+') { |
| |
348 f = GAIM_CBFLAGS_VOICE; |
| |
349 cur++; |
| |
350 } |
| 342 tmp = g_strndup(cur, end - cur); |
351 tmp = g_strndup(cur, end - cur); |
| 343 users = g_list_append(users, tmp); |
352 users = g_list_append(users, tmp); |
| |
353 flags = g_list_append(flags, GINT_TO_POINTER(f)); |
| 344 cur = end; |
354 cur = end; |
| 345 if (*cur) |
355 if (*cur) |
| 346 cur++; |
356 cur++; |
| 347 } |
357 } |
| 348 |
358 |
| 349 if (users != NULL) { |
359 if (users != NULL) { |
| 350 GList *l; |
360 GList *l; |
| 351 |
361 |
| 352 gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users); |
362 gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users, flags); |
| 353 |
363 |
| 354 for (l = users; l != NULL; l = l->next) |
364 for (l = users; l != NULL; l = l->next) |
| 355 g_free(l->data); |
365 g_free(l->data); |
| 356 |
366 |
| 357 g_list_free(users); |
367 g_list_free(users); |
| |
368 g_list_free(flags); |
| 358 } |
369 } |
| 359 } |
370 } |
| 360 g_free(names); |
371 g_free(names); |
| 361 } else { |
372 } else { |
| 362 if (!irc->names) |
373 if (!irc->names) |
| 572 g_free(nick); |
583 g_free(nick); |
| 573 return; |
584 return; |
| 574 } |
585 } |
| 575 |
586 |
| 576 userhost = irc_mask_userhost(from); |
587 userhost = irc_mask_userhost(from); |
| 577 gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost); |
588 gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost, GAIM_CBFLAGS_NONE); |
| 578 |
589 |
| 579 if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { |
590 if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { |
| 580 ib->flag = TRUE; |
591 ib->flag = TRUE; |
| 581 irc_buddy_status(nick, ib, irc); |
592 irc_buddy_status(nick, ib, irc); |
| 582 } |
593 } |
| 630 return; |
641 return; |
| 631 } |
642 } |
| 632 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], args[2] ? args[2] : "", nick); |
643 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], args[2] ? args[2] : "", nick); |
| 633 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
644 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 634 g_free(buf); |
645 g_free(buf); |
| |
646 if(args[2]) { |
| |
647 GaimConvChatBuddyFlags newflag, flags; |
| |
648 char *mcur, *cur, *end, *user; |
| |
649 gboolean add = FALSE; |
| |
650 mcur = args[1]; |
| |
651 cur = args[2]; |
| |
652 while (*cur && *mcur) { |
| |
653 if ((*mcur == '+') || (*mcur == '-')) { |
| |
654 add = (*mcur == '+') ? TRUE : FALSE; |
| |
655 mcur++; |
| |
656 continue; |
| |
657 } |
| |
658 end = strchr(cur, ' '); |
| |
659 if (!end) |
| |
660 end = cur + strlen(cur); |
| |
661 user = g_strndup(cur, end - cur); |
| |
662 flags = gaim_conv_chat_user_get_flags(GAIM_CONV_CHAT(convo), user); |
| |
663 newflag = GAIM_CBFLAGS_NONE; |
| |
664 if (*mcur == 'o') |
| |
665 newflag = GAIM_CBFLAGS_OP; |
| |
666 else if (*mcur =='h') |
| |
667 newflag = GAIM_CBFLAGS_HALFOP; |
| |
668 else if (*mcur == 'v') |
| |
669 newflag = GAIM_CBFLAGS_VOICE; |
| |
670 if (newflag) { |
| |
671 if (add) |
| |
672 flags |= newflag; |
| |
673 else |
| |
674 flags &= ~newflag; |
| |
675 gaim_conv_chat_user_set_flags(GAIM_CONV_CHAT(convo), user, flags); |
| |
676 } |
| |
677 g_free(user); |
| |
678 cur = end; |
| |
679 if (*cur) |
| |
680 cur++; |
| |
681 if (*mcur) |
| |
682 mcur++; |
| |
683 } |
| |
684 } |
| 635 } else { /* User */ |
685 } else { /* User */ |
| 636 } |
686 } |
| 637 g_free(nick); |
687 g_free(nick); |
| 638 } |
688 } |
| 639 |
689 |
| 653 gaim_connection_set_display_name(gc, args[0]); |
703 gaim_connection_set_display_name(gc, args[0]); |
| 654 } |
704 } |
| 655 |
705 |
| 656 while (chats) { |
706 while (chats) { |
| 657 GaimConvChat *chat = GAIM_CONV_CHAT(chats->data); |
707 GaimConvChat *chat = GAIM_CONV_CHAT(chats->data); |
| 658 GList *users = gaim_conv_chat_get_users(chat); |
708 gaim_conv_chat_rename_user(chat, nick, args[0]); |
| 659 |
|
| 660 while (users) { |
|
| 661 char *user = users->data; |
|
| 662 |
|
| 663 if (!strcmp(nick, user)) { |
|
| 664 gaim_conv_chat_rename_user(chat, user, args[0]); |
|
| 665 users = gaim_conv_chat_get_users(chat); |
|
| 666 break; |
|
| 667 } |
|
| 668 users = users->next; |
|
| 669 } |
|
| 670 chats = chats->next; |
709 chats = chats->next; |
| 671 } |
710 } |
| 672 g_free(nick); |
711 g_free(nick); |
| 673 } |
712 } |
| 674 |
713 |