~ubuntu-branches/ubuntu/wily/weechat/wily

« back to all changes in this revision

Viewing changes to src/plugins/irc/irc-channel.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2015-08-19 18:34:17 UTC
  • mfrom: (29.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20150819183417-u026z5wo8knpcdqd
Tags: 1.3-1
* New upstream release
  - Remove backported patch to fix FTBFS with ruby 2.2
* Use dh-exec to build javascript plugin only on architectures which v8
  engine supports. Thanks to Mateusz Łukasik for the patch
  (Closes: #794584)

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
    struct t_gui_buffer *ptr_buffer, *ptr_buffer_for_merge;
237
237
    int buffer_created, current_buffer_number, buffer_position;
238
238
    int manual_join, noswitch;
239
 
    char *buffer_name, str_number[32], *channel_name_lower;
240
 
    const char *short_name, *localvar_channel;
 
239
    char str_number[32], *channel_name_lower;
 
240
    const char *buffer_name, *short_name, *localvar_channel;
241
241
 
242
242
    buffer_created = 0;
243
243
 
351
351
            weechat_buffer_set (ptr_buffer, "nicklist_display_groups", "0");
352
352
            weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback",
353
353
                                        &irc_buffer_nickcmp_cb);
 
354
            weechat_buffer_set_pointer (ptr_buffer, "nickcmp_callback_data",
 
355
                                        server);
354
356
        }
355
357
 
356
358
        /* set highlights settings on channel buffer */
463
465
        WEECHAT_HASHTABLE_STRING,
464
466
        NULL,
465
467
        NULL);
466
 
    new_channel->checking_away = 0;
 
468
    new_channel->checking_whox = 0;
467
469
    new_channel->away_message = NULL;
468
470
    new_channel->has_quit_server = 0;
469
471
    new_channel->cycle = 0;
501
503
}
502
504
 
503
505
/*
504
 
 * Renames a channel.
505
 
 */
506
 
 
507
 
void
508
 
irc_channel_rename (struct t_irc_server *server,
509
 
                    struct t_irc_channel *channel,
510
 
                    const char *new_name)
511
 
{
512
 
    struct t_irc_channel *ptr_channel;
513
 
    char *buffer_name;
514
 
    const char *short_name;
515
 
 
516
 
    /* check if another channel exists with this exact name */
517
 
    for (ptr_channel = server->channels; ptr_channel;
518
 
         ptr_channel = ptr_channel->next_channel)
519
 
    {
520
 
        if ((ptr_channel != channel)
521
 
            && (strcmp (ptr_channel->name, new_name) == 0))
522
 
        {
523
 
            return;
524
 
        }
525
 
    }
526
 
 
527
 
    /* rename the channel in buffer */
528
 
    if (channel->buffer)
529
 
    {
530
 
        short_name = weechat_buffer_get_string (channel->buffer, "short_name");
531
 
        if (!short_name || (strcmp (short_name, channel->name) == 0))
532
 
        {
533
 
            /* update the short_name only if it was not changed by the user */
534
 
            weechat_buffer_set (channel->buffer, "short_name", new_name);
535
 
        }
536
 
        buffer_name = irc_buffer_build_name (server->name,
537
 
                                             new_name);
538
 
        weechat_buffer_set (channel->buffer, "name", buffer_name);
539
 
        weechat_buffer_set (channel->buffer, "localvar_set_channel", new_name);
540
 
    }
541
 
 
542
 
    /* rename the irc channel */
543
 
    if (channel->name)
544
 
        free (channel->name);
545
 
    channel->name = strdup (new_name);
546
 
}
547
 
 
548
 
/*
549
506
 * Adds groups in nicklist for a channel.
550
507
 */
551
508
 
679
636
}
680
637
 
681
638
/*
 
639
 * Removes account for all nicks on a channel.
 
640
 */
 
641
 
 
642
void
 
643
irc_channel_remove_account (struct t_irc_server *server,
 
644
                            struct t_irc_channel *channel)
 
645
{
 
646
    struct t_irc_nick *ptr_nick;
 
647
 
 
648
    /* make C compiler happy */
 
649
    (void) server;
 
650
 
 
651
    if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
 
652
    {
 
653
        for (ptr_nick = channel->nicks; ptr_nick;
 
654
             ptr_nick = ptr_nick->next_nick)
 
655
        {
 
656
            if (ptr_nick->account)
 
657
                free (ptr_nick->account);
 
658
            ptr_nick->account = strdup ("*");
 
659
        }
 
660
    }
 
661
}
 
662
 
 
663
/*
682
664
 * Removes away for all nicks on a channel.
683
665
 */
684
666
 
690
672
 
691
673
    if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
692
674
    {
693
 
        for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
 
675
        for (ptr_nick = channel->nicks; ptr_nick;
 
676
             ptr_nick = ptr_nick->next_nick)
694
677
        {
695
678
            irc_nick_set_away (server, channel, ptr_nick, 0);
696
679
        }
698
681
}
699
682
 
700
683
/*
701
 
 * Checks for away on a channel.
 
684
 * Checks for WHOX information on a channel.
702
685
 */
703
686
 
704
687
void
705
 
irc_channel_check_away (struct t_irc_server *server,
 
688
irc_channel_check_whox (struct t_irc_server *server,
706
689
                        struct t_irc_channel *channel)
707
690
{
708
691
    if ((channel->type == IRC_CHANNEL_TYPE_CHANNEL) && channel->nicks)
709
692
    {
710
693
        if (server->cap_away_notify
 
694
            || server->cap_account_notify
711
695
            || ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK) > 0)
712
696
                && ((IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS) == 0)
713
697
                    || (channel->nicks_count <= IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_AWAY_CHECK_MAX_NICKS)))))
714
698
        {
715
 
            channel->checking_away++;
716
 
            irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
717
 
                              "WHO %s", channel->name);
 
699
            channel->checking_whox++;
 
700
            if (irc_server_get_isupport_value (server, "WHOX"))
 
701
            {
 
702
                /* WHOX is supported */
 
703
                irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
 
704
                                  "WHO %s %%cuhsnfdar", channel->name);
 
705
            }
 
706
            else
 
707
            {
 
708
                /* WHOX is NOT supported */
 
709
                irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
 
710
                                  "WHO %s", channel->name);
 
711
            }
718
712
        }
719
713
        else
720
 
            irc_channel_remove_away (server, channel);
 
714
        {
 
715
            irc_channel_remove_account(server, channel);
 
716
            irc_channel_remove_away(server, channel);
 
717
        }
721
718
    }
722
719
}
723
720
 
1456
1453
        WEECHAT_HDATA_VAR(struct t_irc_channel, limit, INTEGER, 0, NULL, NULL);
1457
1454
        WEECHAT_HDATA_VAR(struct t_irc_channel, key, STRING, 0, NULL, NULL);
1458
1455
        WEECHAT_HDATA_VAR(struct t_irc_channel, join_msg_received, HASHTABLE, 0, NULL, NULL);
1459
 
        WEECHAT_HDATA_VAR(struct t_irc_channel, checking_away, INTEGER, 0, NULL, NULL);
 
1456
        WEECHAT_HDATA_VAR(struct t_irc_channel, checking_whox, INTEGER, 0, NULL, NULL);
1460
1457
        WEECHAT_HDATA_VAR(struct t_irc_channel, away_message, STRING, 0, NULL, NULL);
1461
1458
        WEECHAT_HDATA_VAR(struct t_irc_channel, has_quit_server, INTEGER, 0, NULL, NULL);
1462
1459
        WEECHAT_HDATA_VAR(struct t_irc_channel, cycle, INTEGER, 0, NULL, NULL);
1553
1550
    if (!weechat_infolist_new_var_string (ptr_item, "join_msg_received",
1554
1551
                                          weechat_hashtable_get_string (channel->join_msg_received, "keys")))
1555
1552
        return 0;
1556
 
    if (!weechat_infolist_new_var_integer (ptr_item, "checking_away", channel->checking_away))
 
1553
    if (!weechat_infolist_new_var_integer (ptr_item, "checking_whox", channel->checking_whox))
1557
1554
        return 0;
1558
1555
    if (!weechat_infolist_new_var_string (ptr_item, "away_message", channel->away_message))
1559
1556
        return 0;
1637
1634
                        channel->join_msg_received,
1638
1635
                        weechat_hashtable_get_string (channel->join_msg_received,
1639
1636
                                                      "keys_values"));
1640
 
    weechat_log_printf ("       checking_away. . . . . . : %d",    channel->checking_away);
 
1637
    weechat_log_printf ("       checking_whox. . . . . . : %d",    channel->checking_whox);
1641
1638
    weechat_log_printf ("       away_message . . . . . . : '%s'",  channel->away_message);
1642
1639
    weechat_log_printf ("       has_quit_server. . . . . : %d",    channel->has_quit_server);
1643
1640
    weechat_log_printf ("       cycle. . . . . . . . . . : %d",    channel->cycle);