Changeset e3e2059 for irc_channel.c
- Timestamp:
- 2015-04-06T12:35:57Z (9 years ago)
- Branches:
- master
- Children:
- 8bcd160
- Parents:
- 69982f8
- git-author:
- dequis <dx@…> (06-04-15 12:30:30)
- git-committer:
- dequis <dx@…> (06-04-15 12:35:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_channel.c
r69982f8 re3e2059 556 556 } 557 557 558 gboolean irc_channel_is_unused(bee_t *bee, char *name) 559 { 560 char *type, *chat_type; 561 irc_channel_t *oic; 562 563 if (!irc_channel_name_ok(name)) { 564 return FALSE; 565 } 566 567 if (!(oic = irc_channel_by_name(bee->ui_data, name))) { 568 return TRUE; 569 } 570 571 type = set_getstr(&oic->set, "type"); 572 chat_type = set_getstr(&oic->set, "chat_type"); 573 574 if (type && chat_type && oic->data == FALSE && 575 strcmp(type, "chat") == 0 && 576 strcmp(chat_type, "groupchat") == 0) { 577 /* There's a channel with this name already, but it looks 578 like it's not in use yet. Most likely the IRC client 579 rejoined the channel after a reconnect. Remove it so 580 we can reuse its name. */ 581 irc_channel_free(oic); 582 return TRUE; 583 } 584 585 return FALSE; 586 } 587 588 char *irc_channel_name_gen(bee_t *bee, const char *hint) 589 { 590 char name[MAX_NICK_LENGTH + 1] = { 0 }; 591 char *translit_name; 592 gsize bytes_written; 593 594 translit_name = g_convert_with_fallback(hint, -1, "ASCII//TRANSLIT", "UTF-8", "", NULL, &bytes_written, NULL); 595 if (bytes_written > MAX_NICK_LENGTH) { 596 translit_name[MAX_NICK_LENGTH] = '\0'; 597 } 598 599 name[0] = '#'; 600 strncpy(name + 1, translit_name, MAX_NICK_LENGTH - 1); 601 name[MAX_NICK_LENGTH] = '\0'; 602 603 g_free(translit_name); 604 605 irc_channel_name_strip(name); 606 607 if (set_getbool(&bee->set, "lcnicks")) { 608 nick_lc(bee->ui_data, name + 1); 609 } 610 611 while (!irc_channel_is_unused(bee, name)) { 612 underscore_dedupe(name); 613 } 614 615 return g_strdup(name); 616 } 617 618 gboolean irc_channel_name_hint(irc_channel_t *ic, const char *name) 619 { 620 irc_t *irc = ic->irc; 621 char *full_name; 622 623 /* Don't rename a channel if the user's in it already. */ 624 if (ic->flags & IRC_CHANNEL_JOINED) { 625 return FALSE; 626 } 627 628 if (!(full_name = irc_channel_name_gen(irc->b, name))) { 629 return FALSE; 630 } 631 632 g_free(ic->name); 633 ic->name = full_name; 634 635 return TRUE; 636 } 637 558 638 static gint irc_channel_user_cmp(gconstpointer a_, gconstpointer b_) 559 639 {
Note: See TracChangeset
for help on using the changeset viewer.