Merge branch 'master' into windows

This commit is contained in:
James Booth
2013-08-25 23:27:42 +01:00
29 changed files with 861 additions and 279 deletions

View File

@@ -38,6 +38,7 @@
#include "ui/windows.h"
#include "ui/ui.h"
#include "xmpp/xmpp.h"
#include "xmpp/bookmark.h"
#define CONS_WIN_TITLE "_cons"
@@ -598,6 +599,34 @@ cons_show_room_list(GSList *rooms, const char * const conference_node)
cons_alert();
}
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();
}
void
cons_show_disco_info(const char *jid, GSList *identities, GSList *features)
{
@@ -613,15 +642,15 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features)
DiscoIdentity *identity = identities->data; // anme trpe, cat
GString *identity_str = g_string_new(" ");
if (identity->name != NULL) {
identity_str = g_string_append(identity_str, strdup(identity->name));
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, strdup(identity->type));
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, strdup(identity->category));
identity_str = g_string_append(identity_str, identity->category);
}
cons_show(identity_str->str);
g_string_free(identity_str, FALSE);
@@ -712,7 +741,7 @@ cons_show_room_invite(const char * const invitor, const char * const room,
notify_invite(display_from, room, reason);
}
FREE_SET_NULL(display_from);
free(display_from);
wins_refresh_console();
cons_alert();
@@ -1278,7 +1307,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
title = g_string_append(title, p_contact_barejid(contact));
if (p_contact_name(contact) != NULL) {
title = g_string_append(title, " (");
title = g_string_append(title, strdup(p_contact_name(contact)));
title = g_string_append(title, p_contact_name(contact));
title = g_string_append(title, ")");
}
@@ -1325,7 +1354,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
if (groups != NULL) {
GString *groups_str = g_string_new(" Groups : ");
while (groups != NULL) {
g_string_append(groups_str, strdup(groups->data));
g_string_append(groups_str, groups->data);
if (g_slist_next(groups) != NULL) {
g_string_append(groups_str, ", ");
}

View File

@@ -249,8 +249,9 @@ ui_incoming_msg(const char * const from, const char * const message,
GTimeVal *tv_stamp, gboolean priv)
{
gboolean win_created = FALSE;
char *display_from;
char *display_from = NULL;
win_type_t win_type;
if (priv) {
win_type = WIN_PRIVATE;
display_from = get_nick_from_full_jid(from);
@@ -394,7 +395,7 @@ ui_incoming_msg(const char * const from, const char * const message,
if (prefs_get_boolean(PREF_NOTIFY_MESSAGE))
notify_message(display_from, ui_index);
FREE_SET_NULL(display_from);
free(display_from);
}
void
@@ -447,15 +448,15 @@ ui_contact_online(const char * const barejid, const char * const resource,
// use nickname if exists
if (p_contact_name(contact) != NULL) {
g_string_append(display_str, strdup(p_contact_name(contact)));
g_string_append(display_str, p_contact_name(contact));
} else {
g_string_append(display_str, strdup(barejid));
g_string_append(display_str, barejid);
}
// add resource if not default provided by profanity
if (strcmp(jid->resourcepart, "__prof_default") != 0) {
g_string_append(display_str, " (");
g_string_append(display_str, strdup(jid->resourcepart));
g_string_append(display_str, jid->resourcepart);
g_string_append(display_str, ")");
}
@@ -489,15 +490,15 @@ ui_contact_offline(const char * const from, const char * const show,
// use nickname if exists
if (p_contact_name(contact) != NULL) {
g_string_append(display_str, strdup(p_contact_name(contact)));
g_string_append(display_str, p_contact_name(contact));
} else {
g_string_append(display_str, strdup(jidp->barejid));
g_string_append(display_str, jidp->barejid);
}
// add resource if not default provided by profanity
if (strcmp(jidp->resourcepart, "__prof_default") != 0) {
g_string_append(display_str, " (");
g_string_append(display_str, strdup(jidp->resourcepart));
g_string_append(display_str, jidp->resourcepart);
g_string_append(display_str, ")");
}

View File

@@ -80,7 +80,7 @@ notify_invite(const char * const from, const char * const room,
_notify(message->str, 10000, "Incoming message");
g_string_free(message, FALSE);
g_string_free(message, TRUE);
}
void
@@ -102,7 +102,7 @@ notify_room_message(const char * const handle, const char * const room, int win)
_notify(text->str, 10000, "incoming message");
g_string_free(text, FALSE);
g_string_free(text, TRUE);
}
void
@@ -111,7 +111,7 @@ notify_subscription(const char * const from)
GString *message = g_string_new("Subscription request: \n");
g_string_append(message, from);
_notify(message->str, 10000, "Incomming message");
g_string_free(message, FALSE);
g_string_free(message, TRUE);
}
void

View File

@@ -22,6 +22,7 @@
#include "config.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@@ -63,6 +64,8 @@ create_status_bar(void)
mvwprintw(status_bar, 0, cols - 31, _active);
wattroff(status_bar, COLOUR_STATUS_BRACKET);
if (last_time != NULL)
g_date_time_unref(last_time);
last_time = g_date_time_new_now_local();
dirty = TRUE;
@@ -76,6 +79,8 @@ status_bar_refresh(void)
if (elapsed >= 60000000) {
dirty = TRUE;
if (last_time != NULL)
g_date_time_unref(last_time);
last_time = g_date_time_new_now_local();
}
@@ -113,6 +118,8 @@ status_bar_resize(void)
if (message != NULL)
mvwprintw(status_bar, 0, 10, message);
if (last_time != NULL)
g_date_time_unref(last_time);
last_time = g_date_time_new_now_local();
dirty = TRUE;
}
@@ -184,14 +191,12 @@ status_bar_get_password(void)
void
status_bar_print_message(const char * const msg)
{
if (message != NULL) {
free(message);
message = NULL;
}
werase(status_bar);
message = (char *) malloc((strlen(msg) + 1) * sizeof(char));
if (message != NULL) {
free(message);
}
message = (char *) malloc(strlen(msg) + 1);
strcpy(message, msg);
mvwprintw(status_bar, 0, 10, message);
@@ -270,6 +275,7 @@ static void
_status_bar_update_time(void)
{
gchar *date_fmt = g_date_time_format(last_time, "%H:%M");
assert(date_fmt != NULL);
wattron(status_bar, COLOUR_STATUS_BRACKET);
mvwaddch(status_bar, 0, 1, '[');
@@ -279,7 +285,7 @@ _status_bar_update_time(void)
mvwaddch(status_bar, 0, 7, ']');
wattroff(status_bar, COLOUR_STATUS_BRACKET);
free(date_fmt);
g_free(date_fmt);
dirty = TRUE;
}

View File

@@ -87,7 +87,7 @@ title_bar_refresh(void)
free(current_title);
}
current_title = (char *) malloc((strlen(recipient) + 1) * sizeof(char));
current_title = (char *) malloc(strlen(recipient) + 1);
strcpy(current_title, recipient);
title_bar_draw();
@@ -113,7 +113,7 @@ title_bar_show(const char * const title)
if (current_title != NULL)
free(current_title);
current_title = (char *) malloc((strlen(title) + 1) * sizeof(char));
current_title = (char *) malloc(strlen(title) + 1);
strcpy(current_title, title);
_title_bar_draw_title();
}
@@ -138,7 +138,7 @@ title_bar_set_recipient(const char * const from)
free(current_title);
}
current_title = (char *) malloc((strlen(from) + 1) * sizeof(char));
current_title = (char *) malloc(strlen(from) + 1);
strcpy(current_title, from);
dirty = TRUE;
@@ -160,10 +160,10 @@ title_bar_set_typing(gboolean is_typing)
}
if (is_typing) {
current_title = (char *) malloc((strlen(recipient) + 13) * sizeof(char));
current_title = (char *) malloc(strlen(recipient) + 13);
sprintf(current_title, "%s (typing...)", recipient);
} else {
current_title = (char *) malloc((strlen(recipient) + 1) * sizeof(char));
current_title = (char *) malloc(strlen(recipient) + 1);
strcpy(current_title, recipient);
}

View File

@@ -179,6 +179,7 @@ void cons_show_software_version(const char * const jid,
const char * const version, const char * const os);
void cons_show_account_list(gchar **accounts);
void cons_show_room_list(GSList *room, const char * const conference_node);
void cons_show_bookmarks(const GList *list);
void cons_show_disco_items(GSList *items, const char * const jid);
void cons_show_disco_info(const char *from, GSList *identities, GSList *features);
void cons_show_room_invite(const char * const invitor, const char * const room,