Changes in irc_channel.c [a9b1e0e:5ebff60]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_channel.c
ra9b1e0e r5ebff60 556 556 } 557 557 558 gboolean irc_channel_is_unused(irc_t *irc, 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(irc, 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 looks578 like it's not in use yet. Most likely the IRC client579 rejoined the channel after a reconnect. Remove it so580 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(irc_t *irc, 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(&irc->b->set, "lcnicks")) {608 nick_lc(irc, name + 1);609 }610 611 while (!irc_channel_is_unused(irc, 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, name))) {629 return FALSE;630 }631 632 g_free(ic->name);633 ic->name = full_name;634 635 return TRUE;636 }637 638 558 static gint irc_channel_user_cmp(gconstpointer a_, gconstpointer b_) 639 559 {
Note: See TracChangeset
for help on using the changeset viewer.