Beispiel #1
0
void
cons_show_account_list(gchar **accounts)
{
    int size = g_strv_length(accounts);
    if (size > 0) {
        cons_show("Accounts:");
        int i = 0;
        for (i = 0; i < size; i++) {
            if ((jabber_get_connection_status() == JABBER_CONNECTED) &&
                    (g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) {
                resource_presence_t presence = accounts_get_last_presence(accounts[i]);
                win_print_time(console, '-');
                win_presence_colour_on(console, string_from_resource_presence(presence));
                wprintw(console->win, "%s\n", accounts[i]);
                win_presence_colour_off(console, string_from_resource_presence(presence));
            } else {
                cons_show(accounts[i]);
            }
        }
        cons_show("");
    } else {
        cons_show("No accounts created yet.");
        cons_show("");
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #2
0
void
chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted)
{
    assert(chatwin != NULL);

    chatwin->is_otr = TRUE;
    chatwin->otr_is_trusted = trusted;

    ProfWin *window = (ProfWin*) chatwin;
    if (trusted) {
        win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted).");
    } else {
        win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted).");
    }

    if (wins_is_current(window)) {
         title_bar_switch();
    } else {
        int num = wins_get_num(window);
        status_bar_new(num);

        int ui_index = num;
        if (ui_index == 10) {
            ui_index = 0;
        }
        cons_show("%s started an OTR session (%d).", chatwin->barejid, ui_index);
        cons_alert();
    }
}
Beispiel #3
0
void
cons_check_version(gboolean not_available_msg)
{
    char *latest_release = release_get_latest();

    if (latest_release != NULL) {
        gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0);

        if (relase_valid) {
            if (release_is_new(latest_release)) {
                win_print_time(console, '-');
                wprintw(console->win, "A new version of Profanity is available: %s", latest_release);
                win_print_time(console, '-');
                wprintw(console->win, "Check <http://www.profanity.im> for details.\n");
                free(latest_release);
                win_print_time(console, '-');
                wprintw(console->win, "\n");
            } else {
                if (not_available_msg) {
                    cons_show("No new version available.");
                    cons_show("");
                }
            }

            ui_console_dirty();
            cons_alert();
        }
    }
}
Beispiel #4
0
void
cons_show_bookmarks(const GList *list)
{
    Bookmark *item;

    cons_show("");
    cons_show("Bookmarks:");

    /* TODO: show status (connected or not) and window number */
    while (list != NULL) {
        item = list->data;

        win_print_time(console, '-');
        wprintw(console->win, "  %s", item->jid);
        if (item->nick != NULL) {
            wprintw(console->win, "/%s", item->nick);
        }
        if (item->autojoin) {
            wprintw(console->win, " (autojoin)");
        }
        wprintw(console->win, "\n");
        list = g_list_next(list);
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #5
0
void
cons_show_software_version(const char * const jid, const char * const  presence,
    const char * const name, const char * const version, const char * const os)
{
    if ((name != NULL) || (version != NULL) || (os != NULL)) {
        cons_show("");
        win_print_time(console, '-');
        win_presence_colour_on(console, presence);
        wprintw(console->win, "%s", jid);
        win_presence_colour_off(console, presence);
        wprintw(console->win, ":\n");
    }
    if (name != NULL) {
        cons_show("Name    : %s", name);
    }
    if (version != NULL) {
        cons_show("Version : %s", version);
    }
    if (os != NULL) {
        cons_show("OS      : %s", os);
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #6
0
void
cons_show_roster(GSList *list)
{
    cons_show("");
    cons_show("Roster:");

    _show_roster_contacts(list, TRUE);
    ui_console_dirty();
    cons_alert();
}
Beispiel #7
0
void
cons_show_desktop_prefs(void)
{
    cons_show("Desktop notification preferences:");
    cons_show("");
    cons_notify_setting();

    ui_console_dirty();
    cons_alert();
}
Beispiel #8
0
void
cons_show_presence_prefs(void)
{
    cons_show("Presence preferences:");
    cons_show("");
    cons_autoaway_setting();

    ui_console_dirty();
    cons_alert();
}
Beispiel #9
0
void
cons_show_connection_prefs(void)
{
    cons_show("Connection preferences:");
    cons_show("");
    cons_reconnect_setting();
    cons_autoping_setting();

    ui_console_dirty();
    cons_alert();
}
Beispiel #10
0
void
cons_show_log_prefs(void)
{
    cons_show("Logging preferences:");
    cons_show("");
    cons_log_setting();
    cons_chlog_setting();
    cons_grlog_setting();

    ui_console_dirty();
    cons_alert();
}
Beispiel #11
0
void
cons_show_status(const char * const barejid)
{
    PContact pcontact = roster_get_contact(barejid);

    if (pcontact != NULL) {
        win_show_contact(console, pcontact);
    } else {
        cons_show("No such contact \"%s\" in roster.", barejid);
    }
    ui_console_dirty();
    cons_alert();
}
Beispiel #12
0
void
cons_show_chat_prefs(void)
{
    cons_show("Chat preferences:");
    cons_show("");
    cons_states_setting();
    cons_outtype_setting();
    cons_intype_setting();
    cons_gone_setting();
    cons_history_setting();

    ui_console_dirty();
    cons_alert();
}
Beispiel #13
0
void
cons_show_roster_group(const char * const group, GSList *list)
{
    cons_show("");

    if (list != NULL) {
        cons_show("%s:", group);
    } else {
        cons_show("No group named %s exists.", group);
    }

    _show_roster_contacts(list, FALSE);
    ui_console_dirty();
    cons_alert();
}
Beispiel #14
0
void
cons_show_incoming_message(const char * const short_from, const int win_index)
{
    int ui_index = win_index + 1;
    if (ui_index == 10) {
        ui_index = 0;
    }
    win_print_time(console, '-');
    wattron(console->win, COLOUR_INCOMING);
    wprintw(console->win, "<< incoming from %s (%d)\n", short_from, ui_index);
    wattroff(console->win, COLOUR_INCOMING);

    ui_console_dirty();
    cons_alert();
}
Beispiel #15
0
void
cons_show_ui_prefs(void)
{
    cons_show("UI preferences:");
    cons_show("");
    cons_theme_setting();
    cons_beep_setting();
    cons_flash_setting();
    cons_splash_setting();
    cons_vercheck_setting();
    cons_mouse_setting();
    cons_statuses_setting();
    cons_titlebar_setting();

    ui_console_dirty();
    cons_alert();
}
Beispiel #16
0
void
cons_show_contacts(GSList *list)
{
    GSList *curr = list;

    while(curr) {
        PContact contact = curr->data;
        if ((strcmp(p_contact_subscription(contact), "to") == 0) ||
            (strcmp(p_contact_subscription(contact), "both") == 0)) {
            win_show_contact(console, contact);
        }
        curr = g_slist_next(curr);
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #17
0
void
cons_show_error(const char * const msg, ...)
{
    va_list arg;
    va_start(arg, msg);
    GString *fmt_msg = g_string_new(NULL);
    g_string_vprintf(fmt_msg, msg, arg);
    win_print_time(console, '-');
    wattron(console->win, COLOUR_ERROR);
    wprintw(console->win, "%s\n", fmt_msg->str);
    wattroff(console->win, COLOUR_ERROR);
    g_string_free(fmt_msg, TRUE);
    va_end(arg);

    ui_console_dirty();
    cons_alert();
}
Beispiel #18
0
void
cons_show_room_invites(GSList *invites)
{
    cons_show("");
    if (invites == NULL) {
        cons_show("No outstanding chat room invites.");
    } else {
        cons_show("Chat room invites, use /join or /decline commands:");
        while (invites != NULL) {
            cons_show("  %s", invites->data);
            invites = g_slist_next(invites);
        }
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #19
0
void
cons_show_themes(GSList *themes)
{
    cons_show("");

    if (themes == NULL) {
        cons_show("No available themes.");
    } else {
        cons_show("Available themes:");
        while (themes != NULL) {
            cons_show(themes->data);
            themes = g_slist_next(themes);
        }
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #20
0
void
cons_show_login_success(ProfAccount *account)
{
    win_print_time(console, '-');
    wprintw(console->win, "%s logged in successfully, ", account->jid);

    resource_presence_t presence = accounts_get_login_presence(account->name);
    const char *presence_str = string_from_resource_presence(presence);

    win_presence_colour_on(console, presence_str);
    wprintw(console->win, "%s", presence_str);
    win_presence_colour_off(console, presence_str);
    wprintw(console->win, " (priority %d)",
        accounts_get_priority_for_presence_type(account->name, presence));
    wprintw(console->win, ".\n");
    ui_console_dirty();
    cons_alert();
}
Beispiel #21
0
void
cons_about(void)
{
    int rows, cols;
    getmaxyx(stdscr, rows, cols);

    if (prefs_get_boolean(PREF_SPLASH)) {
        _cons_splash_logo();
    } else {
        win_print_time(console, '-');

        if (strcmp(PACKAGE_STATUS, "development") == 0) {
            wprintw(console->win, "Welcome to Profanity, version %sdev\n", PACKAGE_VERSION);
        } else {
            wprintw(console->win, "Welcome to Profanity, version %s\n", PACKAGE_VERSION);
        }
    }

    win_print_time(console, '-');
    wprintw(console->win, "Copyright (C) 2012, 2013 James Booth <%s>.\n", PACKAGE_BUGREPORT);
    win_print_time(console, '-');
    wprintw(console->win, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
    win_print_time(console, '-');
    wprintw(console->win, "\n");
    win_print_time(console, '-');
    wprintw(console->win, "This is free software; you are free to change and redistribute it.\n");
    win_print_time(console, '-');
    wprintw(console->win, "There is NO WARRANTY, to the extent permitted by law.\n");
    win_print_time(console, '-');
    wprintw(console->win, "\n");
    win_print_time(console, '-');
    wprintw(console->win, "Type '/help' to show complete help.\n");
    win_print_time(console, '-');
    wprintw(console->win, "\n");

    if (prefs_get_boolean(PREF_VERCHECK)) {
        cons_check_version(FALSE);
    }

    prefresh(console->win, 0, 0, 1, 0, rows-3, cols-1);

    ui_console_dirty();
    cons_alert();
}
Beispiel #22
0
void
cons_show_typing(const char * const barejid)
{
    PContact contact = roster_get_contact(barejid);
    const char * display_usr = NULL;
    if (p_contact_name(contact) != NULL) {
        display_usr = p_contact_name(contact);
    } else {
        display_usr = barejid;
    }

    win_print_time(console, '-');
    wattron(console->win, COLOUR_TYPING);
    wprintw(console->win, "!! %s is typing a message...\n", display_usr);
    wattroff(console->win, COLOUR_TYPING);

    ui_console_dirty();
    cons_alert();
}
Beispiel #23
0
void
cons_show_disco_info(const char *jid, GSList *identities, GSList *features)
{
    if (((identities != NULL) && (g_slist_length(identities) > 0)) ||
        ((features != NULL) && (g_slist_length(features) > 0))) {
        cons_show("");
        cons_show("Service disovery info for %s", jid);

        if (identities != NULL) {
            cons_show("  Identities");
        }
        while (identities != NULL) {
            DiscoIdentity *identity = identities->data;  // anme trpe, cat
            GString *identity_str = g_string_new("    ");
            if (identity->name != NULL) {
                identity_str = g_string_append(identity_str, identity->name);
                identity_str = g_string_append(identity_str, " ");
            }
            if (identity->type != NULL) {
                identity_str = g_string_append(identity_str, identity->type);
                identity_str = g_string_append(identity_str, " ");
            }
            if (identity->category != NULL) {
                identity_str = g_string_append(identity_str, identity->category);
            }
            cons_show(identity_str->str);
            g_string_free(identity_str, FALSE);
            identities = g_slist_next(identities);
        }

        if (features != NULL) {
            cons_show("  Features:");
        }
        while (features != NULL) {
            cons_show("    %s", features->data);
            features = g_slist_next(features);
        }

        ui_console_dirty();
        cons_alert();
    }
}
Beispiel #24
0
void
cons_debug(const char * const msg, ...)
{
    if (strcmp(PACKAGE_STATUS, "development") == 0) {
        va_list arg;
        va_start(arg, msg);
        GString *fmt_msg = g_string_new(NULL);
        g_string_vprintf(fmt_msg, msg, arg);
        win_print_time(console, '-');
        wprintw(console->win, "%s\n", fmt_msg->str);
        g_string_free(fmt_msg, TRUE);
        va_end(arg);

        ui_console_dirty();
        cons_alert();

        ui_current_page_off();
        ui_refresh();
    }
}
Beispiel #25
0
void
cons_prefs(void)
{
    cons_show("");
    cons_show_ui_prefs();
    cons_show("");
    cons_show_desktop_prefs();
    cons_show("");
    cons_show_chat_prefs();
    cons_show("");
    cons_show_log_prefs();
    cons_show("");
    cons_show_presence_prefs();
    cons_show("");
    cons_show_connection_prefs();
    cons_show("");

    ui_console_dirty();
    cons_alert();
}
Beispiel #26
0
void
cons_navigation_help(void)
{
    cons_show("");
    cons_show("Navigation:");
    cons_show("");
    cons_show("Alt-1                    : This console window.");
    cons_show("Alt-2..Alt-0             : Chat windows.");
    cons_show("F1                       : This console window.");
    cons_show("F2..F10                  : Chat windows.");
    cons_show("UP, DOWN                 : Navigate input history.");
    cons_show("LEFT, RIGHT, HOME, END   : Edit current input.");
    cons_show("CTRL-LEFT, CTRL-RIGHT    : Jump word in input.");
    cons_show("ESC                      : Clear current input.");
    cons_show("TAB                      : Autocomplete.");
    cons_show("PAGE UP, PAGE DOWN       : Page the main window.");
    cons_show("");

    ui_console_dirty();
    cons_alert();
}
Beispiel #27
0
void
cons_show_room_list(GSList *rooms, const char * const conference_node)
{
    if ((rooms != NULL) && (g_slist_length(rooms) > 0)) {
        cons_show("Chat rooms at %s:", conference_node);
        while (rooms != NULL) {
            DiscoItem *room = rooms->data;
            win_print_time(console, '-');
            wprintw(console->win, "  %s", room->jid);
            if (room->name != NULL) {
                wprintw(console->win, ", (%s)", room->name);
            }
            wprintw(console->win, "\n");
            rooms = g_slist_next(rooms);
        }
    } else {
        cons_show("No chat rooms at %s", conference_node);
    }

    ui_console_dirty();
    cons_alert();
}
Beispiel #28
0
void
cons_help(void)
{
    cons_show("");
    cons_show("Choose a help option:");
    cons_show("");
    cons_show("/help commands   - List all commands.");
    cons_show("/help basic      - List basic commands for getting started.");
    cons_show("/help chatting   - List chat commands.");
    cons_show("/help groupchat  - List groupchat commands.");
    cons_show("/help presence   - List commands to change presence.");
    cons_show("/help roster     - List commands for manipulating your roster.");
    cons_show("/help service    - List service discovery commands");
    cons_show("/help settings   - List commands for changing settings.");
    cons_show("/help other      - Other commands.");
    cons_show("/help navigation - How to navigate around Profanity.");
    cons_show("/help [command]  - Detailed help on a specific command.");
    cons_show("");

    ui_console_dirty();
    cons_alert();
}
Beispiel #29
0
void
cons_show_disco_items(GSList *items, const char * const jid)
{
    if ((items != NULL) && (g_slist_length(items) > 0)) {
        cons_show("");
        cons_show("Service discovery items for %s:", jid);
        while (items != NULL) {
            DiscoItem *item = items->data;
            win_print_time(console, '-');
            wprintw(console->win, "  %s", item->jid);
            if (item->name != NULL) {
                wprintw(console->win, ", (%s)", item->name);
            }
            wprintw(console->win, "\n");
            items = g_slist_next(items);
        }
    } else {
        cons_show("");
        cons_show("No service discovery items for %s", jid);
    }
    ui_console_dirty();
    cons_alert();
}
Beispiel #30
0
void
cons_show_room_invite(const char * const invitor, const char * const room,
    const char * const reason)
{
    char *display_from = NULL;
    PContact contact = roster_get_contact(invitor);
    if (contact != NULL) {
        if (p_contact_name(contact) != NULL) {
            display_from = strdup(p_contact_name(contact));
        } else {
            display_from = strdup(invitor);
        }
    } else {
        display_from = strdup(invitor);
    }

    cons_show("");
    cons_show("Chat room invite received:");
    cons_show("  From   : %s", display_from);
    cons_show("  Room   : %s", room);

    if (reason != NULL) {
        cons_show("  Message: %s", reason);
    }

    cons_show("Use /join or /decline");

    if (prefs_get_boolean(PREF_NOTIFY_INVITE)) {
        notify_invite(display_from, room, reason);
    }

    free(display_from);

    ui_console_dirty();
    cons_alert();
}