Beispiel #1
0
struct t_gui_nick *
gui_nicklist_search_nick (struct t_gui_buffer *buffer,
                          struct t_gui_nick_group *from_group,
                          const char *name)
{
    struct t_gui_nick *ptr_nick;
    struct t_gui_nick_group *ptr_group;

    if (!buffer && !from_group)
        return NULL;

    if (!from_group && !buffer->nicklist_root)
        return NULL;

    for (ptr_nick = (from_group) ? from_group->nicks : buffer->nicklist_root->nicks;
         ptr_nick; ptr_nick = ptr_nick->next_nick)
    {
        if (buffer->nickcmp_callback)
        {
            if ((buffer->nickcmp_callback) (buffer->nickcmp_callback_pointer,
                                            buffer->nickcmp_callback_data,
                                            buffer,
                                            ptr_nick->name,
                                            name) == 0)
                return ptr_nick;
        }
        else
        {
            if (strcmp (ptr_nick->name, name) == 0)
                return ptr_nick;
        }
    }

    /* search nick in child groups */
    for (ptr_group = (from_group) ? from_group->children : buffer->nicklist_root->children;
         ptr_group; ptr_group = ptr_group->next_group)
    {
        ptr_nick = gui_nicklist_search_nick (buffer, ptr_group, name);
        if (ptr_nick)
            return ptr_nick;
    }

    /* nick not found */
    return NULL;
}
Beispiel #2
0
int
gui_nicklist_add_to_infolist (struct t_infolist *infolist,
                              struct t_gui_buffer *buffer,
                              const char *name)
{
    struct t_gui_nick_group *ptr_group;
    struct t_gui_nick *ptr_nick;

    if (!infolist || !buffer)
        return 0;

    /* add only one nick if asked */
    if (name && (strncmp (name, "nick_", 5) == 0))
    {
        ptr_nick = gui_nicklist_search_nick (buffer, NULL, name + 5);
        if (!ptr_nick)
            return 0;
        return gui_nicklist_add_nick_to_infolist (infolist, ptr_nick);
    }

    /* add only one group if asked */
    if (name && (strncmp (name, "group_", 6) == 0))
    {
        ptr_group = gui_nicklist_search_group (buffer, NULL, name + 6);
        if (!ptr_group)
            return 0;
        return gui_nicklist_add_group_to_infolist (infolist, ptr_group);
    }

    ptr_group = NULL;
    ptr_nick = NULL;
    gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
    while (ptr_group || ptr_nick)
    {
        if (ptr_nick)
            gui_nicklist_add_nick_to_infolist (infolist, ptr_nick);
        else
            gui_nicklist_add_group_to_infolist (infolist, ptr_group);

        gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
    }

    return 1;
}
Beispiel #3
0
int
gui_line_has_offline_nick (struct t_gui_line *line)
{
    const char *nick;

    if (line && gui_line_search_tag_starting_with (line, "prefix_nick"))
    {
        nick = gui_line_get_nick_tag (line);
        if (nick
            && (line->data->buffer->nicklist_root
                && (line->data->buffer->nicklist_root->nicks
                    || line->data->buffer->nicklist_root->children))
            && !gui_nicklist_search_nick (line->data->buffer, NULL, nick))
        {
            return 1;
        }
    }

    return 0;
}
Beispiel #4
0
struct t_gui_nick *
gui_nicklist_add_nick (struct t_gui_buffer *buffer,
                       struct t_gui_nick_group *group,
                       const char *name, const char *color,
                       const char *prefix, const char *prefix_color,
                       int visible)
{
    struct t_gui_nick *new_nick;

    if (!buffer || !name || gui_nicklist_search_nick (buffer, NULL, name))
        return NULL;

    new_nick = malloc (sizeof (*new_nick));
    if (!new_nick)
        return NULL;

    new_nick->group = (group) ? group : buffer->nicklist_root;
    new_nick->name = (char *)string_shared_get (name);
    new_nick->color = (color) ? (char *)string_shared_get (color) : NULL;
    new_nick->prefix = (prefix) ? (char *)string_shared_get (prefix) : NULL;
    new_nick->prefix_color = (prefix_color) ? (char *)string_shared_get (prefix_color) : NULL;
    new_nick->visible = visible;

    gui_nicklist_insert_nick_sorted (new_nick->group, new_nick);

    buffer->nicklist_count++;
    buffer->nicklist_nicks_count++;

    if (visible)
        buffer->nicklist_visible_count++;

    if (CONFIG_BOOLEAN(config_look_color_nick_offline))
        gui_buffer_ask_chat_refresh (buffer, 1);

    gui_nicklist_send_signal ("nicklist_nick_added", buffer, name);
    gui_nicklist_send_hsignal ("nicklist_nick_added", buffer, NULL, new_nick);

    return new_nick;
}