예제 #1
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    if (nicks) {
        win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role);
        GSList *curr_nick = nicks;
        while (curr_nick) {
            char *nick = curr_nick->data;
            Occupant *occupant = muc_roster_item(mucwin->roomjid, nick);
            if (occupant) {
                if (occupant->jid) {
                    win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s (%s)", nick, occupant->jid);
                } else {
                    win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", nick);
                }
            } else {
                win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", nick);
            }
            curr_nick = g_slist_next(curr_nick);
        }
        win_print(window, '!', 0, NULL, 0, 0, "", "");
    } else {
        win_vprint(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role);
        win_print(window, '!', 0, NULL, 0, 0, "", "");
    }
}
예제 #2
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_requires_config(ProfMucWin *mucwin)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    int num = wins_get_num(window);
    int ui_index = num;
    if (ui_index == 10) {
        ui_index = 0;
    }

    win_print(window, '-', 0, NULL, 0, 0, "", "");
    win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room locked, requires configuration.");
    win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room accept' to accept the defaults");
    win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room destroy' to cancel and destroy the room");
    win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room config' to edit the room configuration");
    win_print(window, '-', 0, NULL, 0, 0, "", "");

    // currently in groupchat window
    if (wins_is_current(window)) {
        status_bar_active(num);

    // not currently on groupchat window
    } else {
        status_bar_new(num);
    }
}
예제 #3
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    GSList *occupants = muc_occupants_by_role(mucwin->roomjid, role);

    if (!occupants) {
        switch (role) {
            case MUC_ROLE_MODERATOR:
                win_print(window, '!', 0, NULL, 0, 0, "", "No moderators found.");
                break;
            case MUC_ROLE_PARTICIPANT:
                win_print(window, '!', 0, NULL, 0, 0, "", "No participants found.");
                break;
            case MUC_ROLE_VISITOR:
                win_print(window, '!', 0, NULL, 0, 0, "", "No visitors found.");
                break;
            default:
                break;
        }
        win_print(window, '-', 0, NULL, 0, 0, "", "");
    } else {
        switch (role) {
            case MUC_ROLE_MODERATOR:
                win_print(window, '!', 0, NULL, 0, 0, "", "Moderators:");
                break;
            case MUC_ROLE_PARTICIPANT:
                win_print(window, '!', 0, NULL, 0, 0, "", "Participants:");
                break;
            case MUC_ROLE_VISITOR:
                win_print(window, '!', 0, NULL, 0, 0, "", "Visitors:");
                break;
            default:
                break;
        }

        GSList *curr_occupant = occupants;
        while(curr_occupant) {
            Occupant *occupant = curr_occupant->data;
            if (occupant->role == role) {
                if (occupant->jid) {
                    win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s (%s)", occupant->nick, occupant->jid);
                } else {
                    win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", occupant->nick);
                }
            }

            curr_occupant = g_slist_next(curr_occupant);
        }

        win_print(window, '-', 0, NULL, 0, 0, "", "");
    }
}
예제 #4
0
파일: core.c 프로젝트: sizeofvoid/profanity
void
ui_show_software_version(const char *const jid, const char *const  presence,
    const char *const name, const char *const version, const char *const os)
{
    Jid *jidp = jid_create(jid);
    ProfWin *window = NULL;
    ProfWin *chatwin = (ProfWin*)wins_get_chat(jidp->barejid);
    ProfWin *mucwin = (ProfWin*)wins_get_muc(jidp->barejid);
    ProfWin *privwin = (ProfWin*)wins_get_private(jidp->fulljid);
    ProfWin *console = wins_get_console();
    jid_destroy(jidp);

    if (chatwin) {
        if (wins_is_current(chatwin)) {
            window = chatwin;
        } else {
            window = console;
        }
    } else if (privwin) {
        if (wins_is_current(privwin)) {
            window = privwin;
        } else {
            window = console;
        }
    } else if (mucwin) {
        if (wins_is_current(mucwin)) {
            window = mucwin;
        } else {
            window = console;
        }
    } else {
        window = console;
    }

    if (name || version || os) {
        win_println(window, 0, "");
        theme_item_t presence_colour = theme_main_presence_attrs(presence);
        win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid);
        win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":");
    }
    if (name) {
        win_vprint(window, '-', 0, NULL, 0, 0, "", "Name    : %s", name);
    }
    if (version) {
        win_vprint(window, '-', 0, NULL, 0, 0, "", "Version : %s", version);
    }
    if (os) {
        win_vprint(window, '-', 0, NULL, 0, 0, "", "OS      : %s", os);
    }
}
예제 #5
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_info(ProfMucWin *mucwin)
{
    assert(mucwin != NULL);

    char *role = muc_role_str(mucwin->roomjid);
    char *affiliation = muc_affiliation_str(mucwin->roomjid);

    ProfWin *window = (ProfWin*) mucwin;
    win_vprint(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid);
    win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation);
    win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role);
    win_print(window, '-', 0, NULL, 0, 0, "", "");
}
예제 #6
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role);
    if (actor) {
        win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
    }
    if (reason) {
        win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
    }
    win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", "");
}
예제 #7
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *const nick, const char *const role,
    const char *const affiliation, const char *const actor, const char *const reason)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation);
    if (actor) {
        win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor);
    }
    if (reason) {
        win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason);
    }
    win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", "");
}
예제 #8
0
void
mucconfwin_show_form(ProfMucConfWin *confwin)
{
    ProfWin *window = (ProfWin*) confwin;
    if (confwin->form->title) {
        win_print(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: ");
        win_print(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title);
    } else {
        win_vprint(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid);
    }
    win_print(window, '-', 0, NULL, 0, 0, "", "");

    mucconfwin_form_help(confwin);

    GSList *fields = confwin->form->fields;
    GSList *curr_field = fields;
    while (curr_field) {
        FormField *field = curr_field->data;

        if ((g_strcmp0(field->type, "fixed") == 0) && field->values) {
            if (field->values) {
                char *value = field->values->data;
                win_print(window, '-', 0, NULL, 0, 0, "", value);
            }
        } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) {
            char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var);
            _mucconfwin_form_field(window, tag, field);
        }

        curr_field = g_slist_next(curr_field);
    }
}
예제 #9
0
void
win_show_occupant(ProfWin *window, Occupant *occupant)
{
    const char *presence_str = string_from_resource_presence(occupant->presence);

    theme_item_t presence_colour = theme_main_presence_attrs(presence_str);

    win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick);
    win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);

    if (occupant->status) {
        win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
    }

    win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
}
예제 #10
0
파일: core.c 프로젝트: sizeofvoid/profanity
void
ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (window == NULL) {
        log_error("Received ban, but no window open for %s.", roomjid);
    } else {
        int num = wins_get_num(window);
        ui_close_win(num);

        GString *message = g_string_new("Banned from ");
        g_string_append(message, roomjid);
        if (actor) {
            g_string_append(message, " by ");
            g_string_append(message, actor);
        }
        if (reason) {
            g_string_append(message, ", reason: ");
            g_string_append(message, reason);
        }

        ProfWin *console = wins_get_console();
        win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str);
        g_string_free(message, TRUE);
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_banned(privwin, actor, reason);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}
예제 #11
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s has left the room.", nick);
}
예제 #12
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_nick_change(ProfMucWin *mucwin, const char *const nick)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick);
}
예제 #13
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error kicking %s: %s", nick, error);
}
예제 #14
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", role, error);
}
예제 #15
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_THEM, "", "** %s is now known as %s", old_nick, nick);
}
예제 #16
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_room_info_error(ProfMucWin *mucwin, const char *const error)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error);
    win_print(window, '-', 0, NULL, 0, 0, "", "");
}
예제 #17
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *const role,
    const char *const affiliation, const char *const show, const char *const status)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ONLINE, "", "-> %s has joined the room", nick);
    if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
        if (role) {
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role);
        }
        if (affiliation) {
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation);
        }
    }
    win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", "");
}
예제 #18
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *const role,
    const char *const error)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s role for %s: %s", role, nick, error);
}
예제 #19
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const char *const affiliation,
    const char *const error)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error);
}
예제 #20
0
void
win_show_contact(ProfWin *window, PContact contact)
{
    const char *barejid = p_contact_barejid(contact);
    const char *name = p_contact_name(contact);
    const char *presence = p_contact_presence(contact);
    const char *status = p_contact_status(contact);
    GDateTime *last_activity = p_contact_last_activity(contact);

    theme_item_t presence_colour = theme_main_presence_attrs(presence);

    if (name) {
        win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", name);
    } else {
        win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid);
    }

    win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence);

    if (last_activity) {
        GDateTime *now = g_date_time_new_now_local();
        GTimeSpan span = g_date_time_difference(now, last_activity);
        g_date_time_unref(now);

        int hours = span / G_TIME_SPAN_HOUR;
        span = span - hours * G_TIME_SPAN_HOUR;
        int minutes = span / G_TIME_SPAN_MINUTE;
        span = span - minutes * G_TIME_SPAN_MINUTE;
        int seconds = span / G_TIME_SPAN_SECOND;

        if (hours > 0) {
          win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
        }
        else {
          win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds);
        }
    }

    if (status) {
        win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact));
    }

    win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
}
예제 #21
0
파일: privwin.c 프로젝트: 0xPoly/profanity
void
privwin_occupant_online(ProfPrivateWin *privwin)
{
    assert(privwin != NULL);

    privwin->occupant_offline = FALSE;
    Jid *jidp = jid_create(privwin->fulljid);
    win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ONLINE, NULL, "-- %s has joined the room.", jidp->resourcepart);
    jid_destroy(jidp);
}
예제 #22
0
파일: privwin.c 프로젝트: 0xPoly/profanity
void
privwin_room_left(ProfPrivateWin *privwin)
{
    assert(privwin != NULL);

    privwin->room_left = TRUE;
    Jid *jidp = jid_create(privwin->fulljid);
    win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have left %s.", jidp->barejid);
    jid_destroy(jidp);
}
예제 #23
0
파일: core.c 프로젝트: sizeofvoid/profanity
void
ui_room_join(const char *const roomjid, gboolean focus)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (!window) {
        window = wins_new_muc(roomjid);
    }

    char *nick = muc_nick(roomjid);
    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "-> You have joined the room as %s", nick);
    if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
        char *role = muc_role_str(roomjid);
        char *affiliation = muc_affiliation_str(roomjid);
        if (role) {
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role);
        }
        if (affiliation) {
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation);
        }
    }
    win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", "");


    if (focus) {
        ui_focus_win(window);
    } else {
        int num = wins_get_num(window);
        status_bar_active(num);
        ProfWin *console = wins_get_console();
        char *nick = muc_nick(roomjid);
        win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num);
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_joined(privwin);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}
예제 #24
0
void
win_show_status_string(ProfWin *window, const char *const from,
    const char *const show, const char *const status,
    GDateTime *last_activity, const char *const pre,
    const char *const default_show)
{
    theme_item_t presence_colour;

    if (show) {
        presence_colour = theme_main_presence_attrs(show);
    } else if (strcmp(default_show, "online") == 0) {
        presence_colour = THEME_ONLINE;
    } else {
        presence_colour = THEME_OFFLINE;
    }


    win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s %s", pre, from);

    if (show)
        win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show);
    else
        win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show);

    if (last_activity) {
        gchar *date_fmt = NULL;
        char *time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY);
        date_fmt = g_date_time_format(last_activity, time_pref);
        prefs_free_string(time_pref);
        assert(date_fmt != NULL);

        win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", last activity: %s", date_fmt);

        g_free(date_fmt);
    }

    if (status)
        win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status);

    win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");

}
예제 #25
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    if (jids) {
        win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation);
        GSList *curr_jid = jids;
        while (curr_jid) {
            char *jid = curr_jid->data;
            win_vprint(window, '!', 0, NULL, 0, 0, "", "  %s", jid);
            curr_jid = g_slist_next(curr_jid);
        }
        win_print(window, '!', 0, NULL, 0, 0, "", "");
    } else {
        win_vprint(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation);
        win_print(window, '!', 0, NULL, 0, 0, "", "");
    }
}
예제 #26
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_broadcast(ProfMucWin *mucwin, const char *const message)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    int num = wins_get_num(window);

    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: ");
    win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message);

    // currently in groupchat window
    if (wins_is_current(window)) {
        status_bar_active(num);

    // not currently on groupchat window
    } else {
        status_bar_new(num);
    }
}
예제 #27
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    int num = wins_get_num(window);

    if (subject) {
        if (nick) {
            win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "*%s has set the room subject: ", nick);
            win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject);
        } else {
            win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: ");
            win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject);
        }
    } else {
        if (nick) {
            win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "*%s has cleared the room subject.", nick);
        } else {
            win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room subject cleared");
        }
    }

    // currently in groupchat window
    if (wins_is_current(window)) {
        status_bar_active(num);

    // not currently on groupchat window
    } else {
        status_bar_active(num);
    }
}
예제 #28
0
파일: core.c 프로젝트: sizeofvoid/profanity
void
ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message)
{
    ProfWin *console = wins_get_console();
    if (roomjid) {
        ProfWin *muc_window = NULL;
        ProfWin *form_window = NULL;
        muc_window = (ProfWin*)wins_get_muc(roomjid);

        GString *form_recipient = g_string_new(roomjid);
        g_string_append(form_recipient, " config");
        form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str);
        g_string_free(form_recipient, TRUE);

        if (form_window) {
            if (message) {
                win_vprint(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message);
            } else {
                win_print(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error");
            }
        } else if (muc_window) {
            if (message) {
                win_vprint(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message);
            } else {
                win_print(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error");
            }
        } else {
            if (message) {
                win_vprint(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s: %s", roomjid, message);
            } else {
                win_vprint(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s", roomjid);
            }
        }
    } else {
        win_print(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error");
    }
}
예제 #29
0
파일: mucwin.c 프로젝트: nopslide/profanity
void
mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence)
{
    assert(mucwin != NULL);

    ProfWin *window = (ProfWin*)mucwin;
    if ((roster == NULL) || (g_list_length(roster) == 0)) {
        if (presence == NULL) {
            win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty.");
        } else {
            win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence);
        }
    } else {
        int length = g_list_length(roster);
        if (presence == NULL) {
            win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length);
        } else {
            win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence);
        }

        while (roster) {
            Occupant *occupant = roster->data;
            const char *presence_str = string_from_resource_presence(occupant->presence);

            theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick);

            if (roster->next) {
                win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", ");
            }

            roster = g_list_next(roster);
        }
        win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", "");

    }
}
예제 #30
0
파일: core.c 프로젝트: sizeofvoid/profanity
void
ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid,
    const char *const password)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (window == NULL) {
        log_error("Received room destroy, but no window open for %s.", roomjid);
    } else {
        int num = wins_get_num(window);
        ui_close_win(num);
        ProfWin *console = wins_get_console();

        if (reason) {
            win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s, reason: %s", roomjid, reason);
        } else {
            win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s", roomjid);
        }

        if (new_jid) {
            if (password) {
                win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s, password: %s", new_jid, password);
            } else {
                win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s", new_jid);
            }
        }
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_destroyed(privwin);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}