1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Function signatures across lines

This commit is contained in:
James Booth 2012-07-24 23:19:48 +01:00
parent 6bbad269db
commit 279737bada
18 changed files with 393 additions and 203 deletions

View File

@ -34,13 +34,15 @@ static GTimeZone *tz;
static void _close_file(gpointer key, gpointer value, gpointer user_data); static void _close_file(gpointer key, gpointer value, gpointer user_data);
void chat_log_init(void) void
chat_log_init(void)
{ {
tz = g_time_zone_new_local(); tz = g_time_zone_new_local();
logs = g_hash_table_new(NULL, (GEqualFunc) g_strcmp0); logs = g_hash_table_new(NULL, (GEqualFunc) g_strcmp0);
} }
void chat_log_chat(const char * const login, char *other, void
chat_log_chat(const char * const login, char *other,
const char * const msg, chat_log_direction_t direction) const char * const msg, chat_log_direction_t direction)
{ {
gpointer logpp = g_hash_table_lookup(logs, other); gpointer logpp = g_hash_table_lookup(logs, other);
@ -81,13 +83,15 @@ void chat_log_chat(const char * const login, char *other,
g_date_time_unref(dt); g_date_time_unref(dt);
} }
void chat_log_close(void) void
chat_log_close(void)
{ {
g_hash_table_foreach(logs, (GHFunc) _close_file, NULL); g_hash_table_foreach(logs, (GHFunc) _close_file, NULL);
g_time_zone_unref(tz); g_time_zone_unref(tz);
} }
static void _close_file(gpointer key, gpointer value, gpointer user_data) static void
_close_file(gpointer key, gpointer value, gpointer user_data)
{ {
fclose(value); fclose(value);
} }

View File

@ -88,7 +88,8 @@ static struct cmd_t commands[] = {
static const int num_cmds = 17; static const int num_cmds = 17;
gboolean process_input(char *inp) gboolean
process_input(char *inp)
{ {
gboolean result = FALSE; gboolean result = FALSE;
@ -115,7 +116,8 @@ gboolean process_input(char *inp)
return result; return result;
} }
void command_init(void) void
command_init(void)
{ {
commands_ac = p_autocomplete_new(); commands_ac = p_autocomplete_new();
@ -128,17 +130,20 @@ void command_init(void)
history_init(); history_init();
} }
char * cmd_complete(char *inp) char *
cmd_complete(char *inp)
{ {
return p_autocomplete_complete(commands_ac, inp); return p_autocomplete_complete(commands_ac, inp);
} }
void reset_command_completer(void) void
reset_command_completer(void)
{ {
p_autocomplete_reset(commands_ac); p_autocomplete_reset(commands_ac);
} }
static gboolean _handle_command(const char * const command, const char * const inp) static gboolean
_handle_command(const char * const command, const char * const inp)
{ {
int i; int i;
for (i = 0; i < num_cmds; i++) { for (i = 0; i < num_cmds; i++) {
@ -151,7 +156,8 @@ static gboolean _handle_command(const char * const command, const char * const i
return _cmd_default(inp); return _cmd_default(inp);
} }
static gboolean _cmd_connect(const char * const inp) static gboolean
_cmd_connect(const char * const inp)
{ {
gboolean result = FALSE; gboolean result = FALSE;
jabber_conn_status_t conn_status = jabber_connection_status(); jabber_conn_status_t conn_status = jabber_connection_status();
@ -186,26 +192,30 @@ static gboolean _cmd_connect(const char * const inp)
return result; return result;
} }
static gboolean _cmd_quit(const char * const inp) static gboolean
_cmd_quit(const char * const inp)
{ {
return FALSE; return FALSE;
} }
static gboolean _cmd_help(const char * const inp) static gboolean
_cmd_help(const char * const inp)
{ {
cons_help(); cons_help();
return TRUE; return TRUE;
} }
static gboolean _cmd_prefs(const char * const inp) static gboolean
_cmd_prefs(const char * const inp)
{ {
cons_prefs(); cons_prefs();
return TRUE; return TRUE;
} }
static gboolean _cmd_ros(const char * const inp) static gboolean
_cmd_ros(const char * const inp)
{ {
jabber_conn_status_t conn_status = jabber_connection_status(); jabber_conn_status_t conn_status = jabber_connection_status();
@ -217,7 +227,8 @@ static gboolean _cmd_ros(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_who(const char * const inp) static gboolean
_cmd_who(const char * const inp)
{ {
jabber_conn_status_t conn_status = jabber_connection_status(); jabber_conn_status_t conn_status = jabber_connection_status();
@ -231,7 +242,8 @@ static gboolean _cmd_who(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_msg(const char * const inp) static gboolean
_cmd_msg(const char * const inp)
{ {
char *usr = NULL; char *usr = NULL;
char *msg = NULL; char *msg = NULL;
@ -265,7 +277,8 @@ static gboolean _cmd_msg(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_close(const char * const inp) static gboolean
_cmd_close(const char * const inp)
{ {
if (!win_close_win()) if (!win_close_win())
cons_bad_command(inp); cons_bad_command(inp);
@ -273,7 +286,8 @@ static gboolean _cmd_close(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_set_beep(const char * const inp) static gboolean
_cmd_set_beep(const char * const inp)
{ {
if (strcmp(inp, "/beep on") == 0) { if (strcmp(inp, "/beep on") == 0) {
cons_show("Sound enabled."); cons_show("Sound enabled.");
@ -288,7 +302,8 @@ static gboolean _cmd_set_beep(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_set_notify(const char * const inp) static gboolean
_cmd_set_notify(const char * const inp)
{ {
if (strcmp(inp, "/notify on") == 0) { if (strcmp(inp, "/notify on") == 0) {
cons_show("Desktop notifications enabled."); cons_show("Desktop notifications enabled.");
@ -303,7 +318,8 @@ static gboolean _cmd_set_notify(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_set_flash(const char * const inp) static gboolean
_cmd_set_flash(const char * const inp)
{ {
if (strcmp(inp, "/flash on") == 0) { if (strcmp(inp, "/flash on") == 0) {
cons_show("Screen flash enabled."); cons_show("Screen flash enabled.");
@ -318,7 +334,8 @@ static gboolean _cmd_set_flash(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_set_showsplash(const char * const inp) static gboolean
_cmd_set_showsplash(const char * const inp)
{ {
if (strcmp(inp, "/showsplash on") == 0) { if (strcmp(inp, "/showsplash on") == 0) {
cons_show("Splash screen enabled."); cons_show("Splash screen enabled.");
@ -333,7 +350,8 @@ static gboolean _cmd_set_showsplash(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_set_chlog(const char * const inp) static gboolean
_cmd_set_chlog(const char * const inp)
{ {
if (strcmp(inp, "/chlog on") == 0) { if (strcmp(inp, "/chlog on") == 0) {
cons_show("Chat logging enabled."); cons_show("Chat logging enabled.");
@ -348,37 +366,43 @@ static gboolean _cmd_set_chlog(const char * const inp)
return TRUE; return TRUE;
} }
static gboolean _cmd_away(const char * const inp) static gboolean
_cmd_away(const char * const inp)
{ {
_update_presence(PRESENCE_AWAY, "away", inp); _update_presence(PRESENCE_AWAY, "away", inp);
return TRUE; return TRUE;
} }
static gboolean _cmd_online(const char * const inp) static gboolean
_cmd_online(const char * const inp)
{ {
_update_presence(PRESENCE_ONLINE, "online", inp); _update_presence(PRESENCE_ONLINE, "online", inp);
return TRUE; return TRUE;
} }
static gboolean _cmd_dnd(const char * const inp) static gboolean
_cmd_dnd(const char * const inp)
{ {
_update_presence(PRESENCE_DND, "dnd", inp); _update_presence(PRESENCE_DND, "dnd", inp);
return TRUE; return TRUE;
} }
static gboolean _cmd_chat(const char * const inp) static gboolean
_cmd_chat(const char * const inp)
{ {
_update_presence(PRESENCE_CHAT, "chat", inp); _update_presence(PRESENCE_CHAT, "chat", inp);
return TRUE; return TRUE;
} }
static gboolean _cmd_xa(const char * const inp) static gboolean
_cmd_xa(const char * const inp)
{ {
_update_presence(PRESENCE_XA, "xa", inp); _update_presence(PRESENCE_XA, "xa", inp);
return TRUE; return TRUE;
} }
static gboolean _cmd_default(const char * const inp) static gboolean
_cmd_default(const char * const inp)
{ {
if (win_in_chat()) { if (win_in_chat()) {
char *recipient = win_get_recipient(); char *recipient = win_get_recipient();
@ -392,7 +416,8 @@ static gboolean _cmd_default(const char * const inp)
return TRUE; return TRUE;
} }
static void _update_presence(const jabber_presence_t presence, static void
_update_presence(const jabber_presence_t presence,
const char * const show, const char * const inp) const char * const show, const char * const inp)
{ {
char *msg; char *msg;

View File

@ -30,13 +30,15 @@
#include "common.h" #include "common.h"
void p_slist_free_full(GSList *items, GDestroyNotify free_func) void
p_slist_free_full(GSList *items, GDestroyNotify free_func)
{ {
g_slist_foreach (items, (GFunc) free_func, NULL); g_slist_foreach (items, (GFunc) free_func, NULL);
g_slist_free (items); g_slist_free (items);
} }
void create_config_directory() void
create_config_directory()
{ {
GString *dir = g_string_new(getenv("HOME")); GString *dir = g_string_new(getenv("HOME"));
g_string_append(dir, "/.profanity"); g_string_append(dir, "/.profanity");
@ -44,7 +46,8 @@ void create_config_directory()
g_string_free(dir, TRUE); g_string_free(dir, TRUE);
} }
void create_dir(char *name) void
create_dir(char *name)
{ {
int e; int e;
struct stat sb; struct stat sb;

View File

@ -33,7 +33,8 @@ struct p_contact_t {
char *status; char *status;
}; };
PContact p_contact_new(const char * const name, const char * const show, PContact
p_contact_new(const char * const name, const char * const show,
const char * const status) const char * const status)
{ {
PContact contact = malloc(sizeof(struct p_contact_t)); PContact contact = malloc(sizeof(struct p_contact_t));
@ -52,7 +53,8 @@ PContact p_contact_new(const char * const name, const char * const show,
return contact; return contact;
} }
PContact p_contact_copy(PContact contact) PContact
p_contact_copy(PContact contact)
{ {
PContact copy = malloc(sizeof(struct p_contact_t)); PContact copy = malloc(sizeof(struct p_contact_t));
copy->name = strdup(contact->name); copy->name = strdup(contact->name);
@ -66,7 +68,8 @@ PContact p_contact_copy(PContact contact)
return copy; return copy;
} }
void p_contact_free(PContact contact) void
p_contact_free(PContact contact)
{ {
free(contact->name); free(contact->name);
@ -83,22 +86,26 @@ void p_contact_free(PContact contact)
contact = NULL; contact = NULL;
} }
const char * p_contact_name(const PContact contact) const char *
p_contact_name(const PContact contact)
{ {
return contact->name; return contact->name;
} }
const char * p_contact_show(const PContact contact) const char *
p_contact_show(const PContact contact)
{ {
return contact->show; return contact->show;
} }
const char * p_contact_status(const PContact contact) const char *
p_contact_status(const PContact contact)
{ {
return contact->status; return contact->status;
} }
int p_contacts_equal_deep(const PContact c1, const PContact c2) int
p_contacts_equal_deep(const PContact c1, const PContact c2)
{ {
int name_eq = (g_strcmp0(c1->name, c2->name) == 0); int name_eq = (g_strcmp0(c1->name, c2->name) == 0);
int show_eq = (g_strcmp0(c1->show, c2->show) == 0); int show_eq = (g_strcmp0(c1->show, c2->show) == 0);

View File

@ -32,7 +32,8 @@
static PAutocomplete ac; static PAutocomplete ac;
void contact_list_init(void) void
contact_list_init(void)
{ {
ac = p_obj_autocomplete_new((PStrFunc)p_contact_name, ac = p_obj_autocomplete_new((PStrFunc)p_contact_name,
(PCopyFunc)p_contact_copy, (PCopyFunc)p_contact_copy,
@ -40,33 +41,39 @@ void contact_list_init(void)
(GDestroyNotify)p_contact_free); (GDestroyNotify)p_contact_free);
} }
void contact_list_clear(void) void
contact_list_clear(void)
{ {
p_autocomplete_clear(ac); p_autocomplete_clear(ac);
} }
void reset_search_attempts(void) void
reset_search_attempts(void)
{ {
p_autocomplete_reset(ac); p_autocomplete_reset(ac);
} }
gboolean contact_list_remove(const char * const name) gboolean
contact_list_remove(const char * const name)
{ {
return p_autocomplete_remove(ac, name); return p_autocomplete_remove(ac, name);
} }
gboolean contact_list_add(const char * const name, const char * const show, gboolean
contact_list_add(const char * const name, const char * const show,
const char * const status) const char * const status)
{ {
return p_autocomplete_add(ac, p_contact_new(name, show, status)); return p_autocomplete_add(ac, p_contact_new(name, show, status));
} }
GSList * get_contact_list(void) GSList *
get_contact_list(void)
{ {
return p_autocomplete_get_list(ac); return p_autocomplete_get_list(ac);
} }
char * find_contact(char *search_str) char *
find_contact(char *search_str)
{ {
return p_autocomplete_complete(ac, search_str); return p_autocomplete_complete(ac, search_str);
} }

View File

@ -31,17 +31,20 @@ static PHistory history;
void _stringify_input(char *inp, int size, char *string); void _stringify_input(char *inp, int size, char *string);
void history_init(void) void
history_init(void)
{ {
history = p_history_new(MAX_HISTORY); history = p_history_new(MAX_HISTORY);
} }
void history_append(char *inp) void
history_append(char *inp)
{ {
p_history_append(history, inp); p_history_append(history, inp);
} }
char * history_previous(char *inp, int *size) char *
history_previous(char *inp, int *size)
{ {
char inp_str[*size + 1]; char inp_str[*size + 1];
_stringify_input(inp, *size, inp_str); _stringify_input(inp, *size, inp_str);
@ -49,7 +52,8 @@ char * history_previous(char *inp, int *size)
return p_history_previous(history, inp_str); return p_history_previous(history, inp_str);
} }
char *history_next(char *inp, int *size) char *
history_next(char *inp, int *size)
{ {
char inp_str[*size + 1]; char inp_str[*size + 1];
_stringify_input(inp, *size, inp_str); _stringify_input(inp, *size, inp_str);
@ -57,7 +61,8 @@ char *history_next(char *inp, int *size)
return p_history_next(history, inp_str); return p_history_next(history, inp_str);
} }
void _stringify_input(char *inp, int size, char *string) void
_stringify_input(char *inp, int size, char *string)
{ {
int i; int i;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
@ -65,5 +70,3 @@ void _stringify_input(char *inp, int size, char *string)
} }
string[size] = '\0'; string[size] = '\0';
} }

View File

@ -57,7 +57,8 @@ static int _handle_edit(const int ch, char *input, int *size);
static int _printable(const int ch); static int _printable(const int ch);
static void _replace_input(char *input, const char * const new_input, int *size); static void _replace_input(char *input, const char * const new_input, int *size);
void create_input_window(void) void
create_input_window(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -69,7 +70,8 @@ void create_input_window(void)
prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1); prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
} }
void inp_win_resize(const char * const input, const int size) void
inp_win_resize(const char * const input, const int size)
{ {
int rows, cols, inp_x, inp_y; int rows, cols, inp_x, inp_y;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -86,7 +88,8 @@ void inp_win_resize(const char * const input, const int size)
prefresh(inp_win, pad_start, 0, rows-1, 0, rows-1, cols-1); prefresh(inp_win, pad_start, 0, rows-1, 0, rows-1, cols-1);
} }
void inp_clear(void) void
inp_clear(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -96,17 +99,20 @@ void inp_clear(void)
prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1); prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
} }
void inp_non_block(void) void
inp_non_block(void)
{ {
wtimeout(inp_win, 500); wtimeout(inp_win, 500);
} }
void inp_block(void) void
inp_block(void)
{ {
wtimeout(inp_win, -1); wtimeout(inp_win, -1);
} }
void inp_get_char(int *ch, char *input, int *size) void
inp_get_char(int *ch, char *input, int *size)
{ {
int inp_y = 0; int inp_y = 0;
int inp_x = 0; int inp_x = 0;
@ -155,7 +161,8 @@ void inp_get_char(int *ch, char *input, int *size)
echo(); echo();
} }
void inp_get_password(char *passwd) void
inp_get_password(char *passwd)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -169,7 +176,8 @@ void inp_get_password(char *passwd)
status_bar_clear(); status_bar_clear();
} }
void inp_put_back(void) void
inp_put_back(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -181,7 +189,8 @@ void inp_put_back(void)
* key press: up, down, left, right or backspace * key press: up, down, left, right or backspace
* return 0 if it wasnt * return 0 if it wasnt
*/ */
static int _handle_edit(const int ch, char *input, int *size) static int
_handle_edit(const int ch, char *input, int *size)
{ {
int i, rows, cols; int i, rows, cols;
char *prev = NULL; char *prev = NULL;
@ -356,7 +365,8 @@ static int _handle_edit(const int ch, char *input, int *size)
} }
} }
static int _printable(const int ch) static int
_printable(const int ch)
{ {
return (ch != ERR && ch != '\n' && return (ch != ERR && ch != '\n' &&
ch != KEY_PPAGE && ch != KEY_NPAGE && ch != KEY_PPAGE && ch != KEY_NPAGE &&
@ -367,7 +377,8 @@ static int _printable(const int ch)
ch != KEY_IC && ch != KEY_EIC && ch != KEY_RESIZE); ch != KEY_IC && ch != KEY_EIC && ch != KEY_RESIZE);
} }
static void _replace_input(char *input, const char * const new_input, int *size) static void
_replace_input(char *input, const char * const new_input, int *size)
{ {
int i; int i;

View File

@ -52,12 +52,14 @@ void xmpp_file_logger(void * const userdata, const xmpp_log_level_t level,
static const xmpp_log_t file_log = { &xmpp_file_logger, XMPP_LEVEL_DEBUG }; static const xmpp_log_t file_log = { &xmpp_file_logger, XMPP_LEVEL_DEBUG };
xmpp_log_t *xmpp_get_file_logger() xmpp_log_t *
xmpp_get_file_logger()
{ {
return (xmpp_log_t*) &file_log; return (xmpp_log_t*) &file_log;
} }
void xmpp_file_logger(void * const userdata, const xmpp_log_level_t level, void
xmpp_file_logger(void * const userdata, const xmpp_log_level_t level,
const char * const area, const char * const msg) const char * const area, const char * const msg)
{ {
log_msg(area, msg); log_msg(area, msg);
@ -79,19 +81,22 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata); static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata);
void jabber_init(const int disable_tls) void
jabber_init(const int disable_tls)
{ {
jabber_conn.conn_status = JABBER_STARTED; jabber_conn.conn_status = JABBER_STARTED;
jabber_conn.presence = PRESENCE_OFFLINE; jabber_conn.presence = PRESENCE_OFFLINE;
jabber_conn.tls_disabled = disable_tls; jabber_conn.tls_disabled = disable_tls;
} }
jabber_conn_status_t jabber_connection_status(void) jabber_conn_status_t
jabber_connection_status(void)
{ {
return (jabber_conn.conn_status); return (jabber_conn.conn_status);
} }
jabber_conn_status_t jabber_connect(const char * const user, jabber_conn_status_t
jabber_connect(const char * const user,
const char * const passwd) const char * const passwd)
{ {
xmpp_initialize(); xmpp_initialize();
@ -117,12 +122,14 @@ jabber_conn_status_t jabber_connect(const char * const user,
return jabber_conn.conn_status; return jabber_conn.conn_status;
} }
const char * jabber_get_jid(void) const char *
jabber_get_jid(void)
{ {
return xmpp_conn_get_jid(jabber_conn.conn); return xmpp_conn_get_jid(jabber_conn.conn);
} }
void jabber_disconnect(void) void
jabber_disconnect(void)
{ {
if (jabber_conn.conn_status == JABBER_CONNECTED) { if (jabber_conn.conn_status == JABBER_CONNECTED) {
xmpp_conn_release(jabber_conn.conn); xmpp_conn_release(jabber_conn.conn);
@ -133,14 +140,16 @@ void jabber_disconnect(void)
} }
} }
void jabber_process_events(void) void
jabber_process_events(void)
{ {
if (jabber_conn.conn_status == JABBER_CONNECTED if (jabber_conn.conn_status == JABBER_CONNECTED
|| jabber_conn.conn_status == JABBER_CONNECTING) || jabber_conn.conn_status == JABBER_CONNECTING)
xmpp_run_once(jabber_conn.ctx, 10); xmpp_run_once(jabber_conn.ctx, 10);
} }
void jabber_send(const char * const msg, const char * const recipient) void
jabber_send(const char * const msg, const char * const recipient)
{ {
char *coded_msg = str_replace(msg, "&", "&amp;"); char *coded_msg = str_replace(msg, "&", "&amp;");
char *coded_msg2 = str_replace(coded_msg, "<", "&lt;"); char *coded_msg2 = str_replace(coded_msg, "<", "&lt;");
@ -173,7 +182,8 @@ void jabber_send(const char * const msg, const char * const recipient)
} }
} }
void jabber_roster_request(void) void
jabber_roster_request(void)
{ {
xmpp_stanza_t *iq, *query; xmpp_stanza_t *iq, *query;
@ -192,7 +202,8 @@ void jabber_roster_request(void)
xmpp_stanza_release(iq); xmpp_stanza_release(iq);
} }
void jabber_update_presence(jabber_presence_t status, const char * const msg) void
jabber_update_presence(jabber_presence_t status, const char * const msg)
{ {
jabber_conn.presence = status; jabber_conn.presence = status;
@ -240,7 +251,8 @@ void jabber_update_presence(jabber_presence_t status, const char * const msg)
xmpp_stanza_release(pres); xmpp_stanza_release(pres);
} }
static int _jabber_message_handler(xmpp_conn_t * const conn, static int
_jabber_message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
{ {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body"); xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
@ -268,7 +280,8 @@ static int _jabber_message_handler(xmpp_conn_t * const conn,
return 1; return 1;
} }
static void _jabber_conn_handler(xmpp_conn_t * const conn, static void
_jabber_conn_handler(xmpp_conn_t * const conn,
const xmpp_conn_event_t status, const int error, const xmpp_conn_event_t status, const int error,
xmpp_stream_error_t * const stream_error, void * const userdata) xmpp_stream_error_t * const stream_error, void * const userdata)
{ {
@ -317,7 +330,8 @@ static void _jabber_conn_handler(xmpp_conn_t * const conn,
} }
} }
static int _roster_handler(xmpp_conn_t * const conn, static int
_roster_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
{ {
xmpp_stanza_t *query, *item; xmpp_stanza_t *query, *item;
@ -356,7 +370,8 @@ static int _roster_handler(xmpp_conn_t * const conn,
return 1; return 1;
} }
static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata) static int
_ping_timed_handler(xmpp_conn_t * const conn, void * const userdata)
{ {
if (jabber_conn.conn_status == JABBER_CONNECTED) { if (jabber_conn.conn_status == JABBER_CONNECTED) {
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata; xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
@ -383,7 +398,8 @@ static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata)
return 1; return 1;
} }
static int _jabber_presence_handler(xmpp_conn_t * const conn, static int
_jabber_presence_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata) xmpp_stanza_t * const stanza, void * const userdata)
{ {
const char *jid = xmpp_conn_get_jid(jabber_conn.conn); const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
@ -427,5 +443,3 @@ static int _jabber_presence_handler(xmpp_conn_t * const conn,
return 1; return 1;
} }

View File

@ -30,12 +30,14 @@
extern FILE *logp; extern FILE *logp;
void log_msg(const char * const area, const char * const msg) void
log_msg(const char * const area, const char * const msg)
{ {
fprintf(logp, "%s DEBUG: %s\n", area, msg); fprintf(logp, "%s DEBUG: %s\n", area, msg);
} }
void log_init(void) void
log_init(void)
{ {
GString *log_file = g_string_new(getenv("HOME")); GString *log_file = g_string_new(getenv("HOME"));
g_string_append(log_file, "/.profanity/log"); g_string_append(log_file, "/.profanity/log");
@ -46,7 +48,8 @@ void log_init(void)
log_msg(PROF, "Starting Profanity..."); log_msg(PROF, "Starting Profanity...");
} }
void log_close(void) void
log_close(void)
{ {
fclose(logp); fclose(logp);
} }

View File

@ -31,7 +31,8 @@
static gboolean disable_tls = FALSE; static gboolean disable_tls = FALSE;
static gboolean version = FALSE; static gboolean version = FALSE;
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
static GOptionEntry entries[] = static GOptionEntry entries[] =
{ {

View File

@ -73,7 +73,8 @@ static void _set_colour(gchar *val, NCURSES_COLOR_T *pref,
static void _load_colours(void); static void _load_colours(void);
static void _save_prefs(void); static void _save_prefs(void);
void prefs_load(void) void
prefs_load(void)
{ {
ac = p_autocomplete_new(); ac = p_autocomplete_new();
prefs_loc = g_string_new(getenv("HOME")); prefs_loc = g_string_new(getenv("HOME"));
@ -95,7 +96,8 @@ void prefs_load(void)
_load_colours(); _load_colours();
} }
static NCURSES_COLOR_T _lookup_colour(const char * const colour) static NCURSES_COLOR_T
_lookup_colour(const char * const colour)
{ {
int i; int i;
for (i = 0; i < num_colours; i++) { for (i = 0; i < num_colours; i++) {
@ -107,7 +109,8 @@ static NCURSES_COLOR_T _lookup_colour(const char * const colour)
return -99; return -99;
} }
static void _set_colour(gchar *val, NCURSES_COLOR_T *pref, static void
_set_colour(gchar *val, NCURSES_COLOR_T *pref,
NCURSES_COLOR_T def) NCURSES_COLOR_T def)
{ {
if(!val) { if(!val) {
@ -122,7 +125,8 @@ static void _set_colour(gchar *val, NCURSES_COLOR_T *pref,
} }
} }
static void _load_colours(void) static void
_load_colours(void)
{ {
gchar *bkgnd_val = g_key_file_get_string(prefs, "colours", "bkgnd", NULL); gchar *bkgnd_val = g_key_file_get_string(prefs, "colours", "bkgnd", NULL);
_set_colour(bkgnd_val, &colour_prefs.bkgnd, -1); _set_colour(bkgnd_val, &colour_prefs.bkgnd, -1);
@ -152,61 +156,72 @@ static void _load_colours(void)
_set_colour(bar_text_val, &colour_prefs.bar_text, COLOR_WHITE); _set_colour(bar_text_val, &colour_prefs.bar_text, COLOR_WHITE);
} }
char * find_login(char *prefix) char *
find_login(char *prefix)
{ {
return p_autocomplete_complete(ac, prefix); return p_autocomplete_complete(ac, prefix);
} }
void reset_login_search(void) void
reset_login_search(void)
{ {
p_autocomplete_reset(ac); p_autocomplete_reset(ac);
} }
gboolean prefs_get_beep(void) gboolean
prefs_get_beep(void)
{ {
return g_key_file_get_boolean(prefs, "ui", "beep", NULL); return g_key_file_get_boolean(prefs, "ui", "beep", NULL);
} }
void prefs_set_beep(gboolean value) void
prefs_set_beep(gboolean value)
{ {
g_key_file_set_boolean(prefs, "ui", "beep", value); g_key_file_set_boolean(prefs, "ui", "beep", value);
_save_prefs(); _save_prefs();
} }
gboolean prefs_get_notify(void) gboolean
prefs_get_notify(void)
{ {
return g_key_file_get_boolean(prefs, "ui", "notify", NULL); return g_key_file_get_boolean(prefs, "ui", "notify", NULL);
} }
void prefs_set_notify(gboolean value) void
prefs_set_notify(gboolean value)
{ {
g_key_file_set_boolean(prefs, "ui", "notify", value); g_key_file_set_boolean(prefs, "ui", "notify", value);
_save_prefs(); _save_prefs();
} }
gboolean prefs_get_flash(void) gboolean
prefs_get_flash(void)
{ {
return g_key_file_get_boolean(prefs, "ui", "flash", NULL); return g_key_file_get_boolean(prefs, "ui", "flash", NULL);
} }
void prefs_set_flash(gboolean value) void
prefs_set_flash(gboolean value)
{ {
g_key_file_set_boolean(prefs, "ui", "flash", value); g_key_file_set_boolean(prefs, "ui", "flash", value);
_save_prefs(); _save_prefs();
} }
gboolean prefs_get_chlog(void) gboolean
prefs_get_chlog(void)
{ {
return g_key_file_get_boolean(prefs, "ui", "chlog", NULL); return g_key_file_get_boolean(prefs, "ui", "chlog", NULL);
} }
void prefs_set_chlog(gboolean value) void
prefs_set_chlog(gboolean value)
{ {
g_key_file_set_boolean(prefs, "ui", "chlog", value); g_key_file_set_boolean(prefs, "ui", "chlog", value);
_save_prefs(); _save_prefs();
} }
void prefs_add_login(const char *jid) void
prefs_add_login(const char *jid)
{ {
gsize njids; gsize njids;
gchar **jids = gchar **jids =
@ -247,65 +262,77 @@ void prefs_add_login(const char *jid)
} }
} }
gboolean prefs_get_showsplash(void) gboolean
prefs_get_showsplash(void)
{ {
return g_key_file_get_boolean(prefs, "ui", "showsplash", NULL); return g_key_file_get_boolean(prefs, "ui", "showsplash", NULL);
} }
void prefs_set_showsplash(gboolean value) void
prefs_set_showsplash(gboolean value)
{ {
g_key_file_set_boolean(prefs, "ui", "showsplash", value); g_key_file_set_boolean(prefs, "ui", "showsplash", value);
_save_prefs(); _save_prefs();
} }
static void _save_prefs(void) static void
_save_prefs(void)
{ {
gsize g_data_size; gsize g_data_size;
char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL); char *g_prefs_data = g_key_file_to_data(prefs, &g_data_size, NULL);
g_file_set_contents(prefs_loc->str, g_prefs_data, g_data_size, NULL); g_file_set_contents(prefs_loc->str, g_prefs_data, g_data_size, NULL);
} }
NCURSES_COLOR_T prefs_get_bkgnd() NCURSES_COLOR_T
prefs_get_bkgnd()
{ {
return colour_prefs.bkgnd; return colour_prefs.bkgnd;
} }
NCURSES_COLOR_T prefs_get_text() NCURSES_COLOR_T
prefs_get_text()
{ {
return colour_prefs.text; return colour_prefs.text;
} }
NCURSES_COLOR_T prefs_get_online() NCURSES_COLOR_T
prefs_get_online()
{ {
return colour_prefs.online; return colour_prefs.online;
} }
NCURSES_COLOR_T prefs_get_offline() NCURSES_COLOR_T
prefs_get_offline()
{ {
return colour_prefs.offline; return colour_prefs.offline;
} }
NCURSES_COLOR_T prefs_get_err() NCURSES_COLOR_T
prefs_get_err()
{ {
return colour_prefs.err; return colour_prefs.err;
} }
NCURSES_COLOR_T prefs_get_inc() NCURSES_COLOR_T
prefs_get_inc()
{ {
return colour_prefs.inc; return colour_prefs.inc;
} }
NCURSES_COLOR_T prefs_get_bar() NCURSES_COLOR_T
prefs_get_bar()
{ {
return colour_prefs.bar; return colour_prefs.bar;
} }
NCURSES_COLOR_T prefs_get_bar_draw() NCURSES_COLOR_T
prefs_get_bar_draw()
{ {
return colour_prefs.bar_draw; return colour_prefs.bar_draw;
} }
NCURSES_COLOR_T prefs_get_bar_text() NCURSES_COLOR_T
prefs_get_bar_text()
{ {
return colour_prefs.bar_text; return colour_prefs.bar_text;
} }

View File

@ -43,12 +43,14 @@ static const char *_str_func_default(const char *orig);
static const char *_copy_func_default(const char *orig); static const char *_copy_func_default(const char *orig);
static int _deep_equals_func_default(const char *o1, const char *o2); static int _deep_equals_func_default(const char *o1, const char *o2);
PAutocomplete p_autocomplete_new(void) PAutocomplete
p_autocomplete_new(void)
{ {
return p_obj_autocomplete_new(NULL, NULL, NULL, NULL); return p_obj_autocomplete_new(NULL, NULL, NULL, NULL);
} }
PAutocomplete p_obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func, PAutocomplete
p_obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
PEqualDeepFunc equal_deep_func, GDestroyNotify free_func) PEqualDeepFunc equal_deep_func, GDestroyNotify free_func)
{ {
PAutocomplete new = malloc(sizeof(struct p_autocomplete_t)); PAutocomplete new = malloc(sizeof(struct p_autocomplete_t));
@ -79,7 +81,8 @@ PAutocomplete p_obj_autocomplete_new(PStrFunc str_func, PCopyFunc copy_func,
return new; return new;
} }
void p_autocomplete_clear(PAutocomplete ac) void
p_autocomplete_clear(PAutocomplete ac)
{ {
g_slist_free_full(ac->items, ac->free_func); g_slist_free_full(ac->items, ac->free_func);
ac->items = NULL; ac->items = NULL;
@ -87,7 +90,8 @@ void p_autocomplete_clear(PAutocomplete ac)
p_autocomplete_reset(ac); p_autocomplete_reset(ac);
} }
void p_autocomplete_reset(PAutocomplete ac) void
p_autocomplete_reset(PAutocomplete ac)
{ {
ac->last_found = NULL; ac->last_found = NULL;
if (ac->search_str != NULL) { if (ac->search_str != NULL) {
@ -96,7 +100,8 @@ void p_autocomplete_reset(PAutocomplete ac)
} }
} }
gboolean p_autocomplete_add(PAutocomplete ac, void *item) gboolean
p_autocomplete_add(PAutocomplete ac, void *item)
{ {
if (ac->items == NULL) { if (ac->items == NULL) {
ac->items = g_slist_append(ac->items, item); ac->items = g_slist_append(ac->items, item);
@ -134,7 +139,8 @@ gboolean p_autocomplete_add(PAutocomplete ac, void *item)
} }
} }
gboolean p_autocomplete_remove(PAutocomplete ac, const char * const item) gboolean
p_autocomplete_remove(PAutocomplete ac, const char * const item)
{ {
// reset last found if it points to the item to be removed // reset last found if it points to the item to be removed
if (ac->last_found != NULL) if (ac->last_found != NULL)
@ -162,7 +168,8 @@ gboolean p_autocomplete_remove(PAutocomplete ac, const char * const item)
} }
} }
GSList * p_autocomplete_get_list(PAutocomplete ac) GSList *
p_autocomplete_get_list(PAutocomplete ac)
{ {
GSList *copy = NULL; GSList *copy = NULL;
GSList *curr = ac->items; GSList *curr = ac->items;
@ -175,7 +182,8 @@ GSList * p_autocomplete_get_list(PAutocomplete ac)
return copy; return copy;
} }
gchar * p_autocomplete_complete(PAutocomplete ac, gchar *search_str) gchar *
p_autocomplete_complete(PAutocomplete ac, gchar *search_str)
{ {
gchar *found = NULL; gchar *found = NULL;
@ -210,7 +218,8 @@ gchar * p_autocomplete_complete(PAutocomplete ac, gchar *search_str)
} }
} }
static gchar * _search_from(PAutocomplete ac, GSList *curr) static gchar *
_search_from(PAutocomplete ac, GSList *curr)
{ {
while(curr) { while(curr) {
@ -235,17 +244,20 @@ static gchar * _search_from(PAutocomplete ac, GSList *curr)
return NULL; return NULL;
} }
static const char *_str_func_default(const char *orig) static const char *
_str_func_default(const char *orig)
{ {
return orig; return orig;
} }
static const char *_copy_func_default(const char *orig) static const char *
_copy_func_default(const char *orig)
{ {
return strdup(orig); return strdup(orig);
} }
static int _deep_equals_func_default(const char *o1, const char *o2) static int
_deep_equals_func_default(const char *o1, const char *o2)
{ {
return (strcmp(o1, o2) == 0); return (strcmp(o1, o2) == 0);
} }

View File

@ -53,7 +53,8 @@ static void _create_session(PHistory history);
static void _session_previous(PHistory history); static void _session_previous(PHistory history);
static void _session_next(PHistory history); static void _session_next(PHistory history);
PHistory p_history_new(unsigned int size) PHistory
p_history_new(unsigned int size)
{ {
PHistory new_history = malloc(sizeof(struct p_history_t)); PHistory new_history = malloc(sizeof(struct p_history_t));
new_history->items = NULL; new_history->items = NULL;
@ -64,7 +65,8 @@ PHistory p_history_new(unsigned int size)
return new_history; return new_history;
} }
void p_history_append(PHistory history, char *item) void
p_history_append(PHistory history, char *item)
{ {
char *copied = ""; char *copied = "";
if (item != NULL) { if (item != NULL) {
@ -105,7 +107,8 @@ void p_history_append(PHistory history, char *item)
} }
} }
char * p_history_previous(PHistory history, char *item) char *
p_history_previous(PHistory history, char *item)
{ {
// no history // no history
if (history->items == NULL) { if (history->items == NULL) {
@ -135,7 +138,8 @@ char * p_history_previous(PHistory history, char *item)
return result; return result;
} }
char * p_history_next(PHistory history, char *item) char *
p_history_next(PHistory history, char *item)
{ {
// no history, or no session, return NULL // no history, or no session, return NULL
if ((history->items == NULL) || (history->session.items == NULL)) { if ((history->items == NULL) || (history->session.items == NULL)) {
@ -154,7 +158,8 @@ char * p_history_next(PHistory history, char *item)
return result; return result;
} }
static void _replace_history_with_session(PHistory history) static void
_replace_history_with_session(PHistory history)
{ {
g_list_free(history->items); g_list_free(history->items);
history->items = g_list_copy(history->session.items); history->items = g_list_copy(history->session.items);
@ -166,13 +171,15 @@ static void _replace_history_with_session(PHistory history)
_reset_session(history); _reset_session(history);
} }
static gboolean _adding_new(PHistory history) static gboolean
_adding_new(PHistory history)
{ {
return (history->session.sess_curr == return (history->session.sess_curr ==
g_list_last(history->session.items)); g_list_last(history->session.items));
} }
static void _reset_session(PHistory history) static void
_reset_session(PHistory history)
{ {
history->session.items = NULL; history->session.items = NULL;
history->session.sess_curr = NULL; history->session.sess_curr = NULL;
@ -180,29 +187,34 @@ static void _reset_session(PHistory history)
history->session.orig_curr = NULL; history->session.orig_curr = NULL;
} }
static gboolean _has_session(PHistory history) static gboolean
_has_session(PHistory history)
{ {
return (history->session.items != NULL); return (history->session.items != NULL);
} }
static void _remove_first(PHistory history) static void
_remove_first(PHistory history)
{ {
GList *first = g_list_first(history->items); GList *first = g_list_first(history->items);
char *first_item = first->data; char *first_item = first->data;
history->items = g_list_remove(history->items, first_item); history->items = g_list_remove(history->items, first_item);
} }
static void _update_current_session_item(PHistory history, char *item) static void
_update_current_session_item(PHistory history, char *item)
{ {
history->session.sess_curr->data = item; history->session.sess_curr->data = item;
} }
static void _add_to_history(PHistory history, char *item) static void
_add_to_history(PHistory history, char *item)
{ {
history->items = g_list_append(history->items, item); history->items = g_list_append(history->items, item);
} }
static void _remove_last_session_item(PHistory history) static void
_remove_last_session_item(PHistory history)
{ {
history->session.items = g_list_reverse(history->session.items); history->session.items = g_list_reverse(history->session.items);
GList *first = g_list_first(history->session.items); GList *first = g_list_first(history->session.items);
@ -211,19 +223,22 @@ static void _remove_last_session_item(PHistory history)
history->session.items = g_list_reverse(history->session.items); history->session.items = g_list_reverse(history->session.items);
} }
static void _replace_current_with_original(PHistory history) static void
_replace_current_with_original(PHistory history)
{ {
history->session.sess_curr->data = strdup(history->session.orig_curr->data); history->session.sess_curr->data = strdup(history->session.orig_curr->data);
} }
static void _create_session(PHistory history) static void
_create_session(PHistory history)
{ {
history->session.items = g_list_copy(history->items); history->session.items = g_list_copy(history->items);
history->session.sess_curr = g_list_last(history->session.items); history->session.sess_curr = g_list_last(history->session.items);
history->session.orig_curr = g_list_last(history->items); history->session.orig_curr = g_list_last(history->items);
} }
static void _session_previous(PHistory history) static void
_session_previous(PHistory history)
{ {
history->session.sess_curr = history->session.sess_curr =
g_list_previous(history->session.sess_curr); g_list_previous(history->session.sess_curr);
@ -239,7 +254,8 @@ static void _session_previous(PHistory history)
} }
} }
static void _session_next(PHistory history) static void
_session_next(PHistory history)
{ {
history->session.sess_curr = g_list_next(history->session.sess_curr); history->session.sess_curr = g_list_next(history->session.sess_curr);
history->session.orig_curr = g_list_next(history->session.orig_curr); history->session.orig_curr = g_list_next(history->session.orig_curr);

View File

@ -37,7 +37,8 @@
static void _profanity_shutdown(void); static void _profanity_shutdown(void);
void profanity_run(void) void
profanity_run(void)
{ {
gboolean cmd_result = TRUE; gboolean cmd_result = TRUE;
@ -66,7 +67,8 @@ void profanity_run(void)
} }
void profanity_init(const int disable_tls) void
profanity_init(const int disable_tls)
{ {
create_config_directory(); create_config_directory();
log_init(); log_init();
@ -79,7 +81,8 @@ void profanity_init(const int disable_tls)
atexit(_profanity_shutdown); atexit(_profanity_shutdown);
} }
void _profanity_shutdown(void) void
_profanity_shutdown(void)
{ {
jabber_disconnect(); jabber_disconnect();
gui_close(); gui_close();

View File

@ -38,7 +38,8 @@ static char curr_time[80];
static void _status_bar_update_time(void); static void _status_bar_update_time(void);
void create_status_bar(void) void
create_status_bar(void)
{ {
int rows, cols, i; int rows, cols, i;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -58,7 +59,8 @@ void create_status_bar(void)
dirty = TRUE; dirty = TRUE;
} }
void status_bar_refresh(void) void
status_bar_refresh(void)
{ {
char new_time[80]; char new_time[80];
get_time(new_time); get_time(new_time);
@ -76,7 +78,8 @@ void status_bar_refresh(void)
} }
} }
void status_bar_resize(void) void
status_bar_resize(void)
{ {
int rows, cols, i; int rows, cols, i;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -103,7 +106,8 @@ void status_bar_resize(void)
dirty = TRUE; dirty = TRUE;
} }
void status_bar_inactive(const int win) void
status_bar_inactive(const int win)
{ {
is_active[win-1] = FALSE; is_active[win-1] = FALSE;
is_new[win-1] = FALSE; is_new[win-1] = FALSE;
@ -120,7 +124,8 @@ void status_bar_inactive(const int win)
dirty = TRUE; dirty = TRUE;
} }
void status_bar_active(const int win) void
status_bar_active(const int win)
{ {
is_active[win-1] = TRUE; is_active[win-1] = TRUE;
is_new[win-1] = FALSE; is_new[win-1] = FALSE;
@ -140,7 +145,8 @@ void status_bar_active(const int win)
dirty = TRUE; dirty = TRUE;
} }
void status_bar_new(const int win) void
status_bar_new(const int win)
{ {
is_active[win-1] = TRUE; is_active[win-1] = TRUE;
is_new[win-1] = TRUE; is_new[win-1] = TRUE;
@ -162,13 +168,15 @@ void status_bar_new(const int win)
dirty = TRUE; dirty = TRUE;
} }
void status_bar_get_password(void) void
status_bar_get_password(void)
{ {
status_bar_print_message("Enter password:"); status_bar_print_message("Enter password:");
dirty = TRUE; dirty = TRUE;
} }
void status_bar_print_message(const char * const msg) void
status_bar_print_message(const char * const msg)
{ {
if (message != NULL) if (message != NULL)
free(message); free(message);
@ -180,7 +188,8 @@ void status_bar_print_message(const char * const msg)
dirty = TRUE; dirty = TRUE;
} }
void status_bar_clear(void) void
status_bar_clear(void)
{ {
if (message != NULL) { if (message != NULL) {
free(message); free(message);
@ -204,7 +213,8 @@ void status_bar_clear(void)
dirty = TRUE; dirty = TRUE;
} }
static void _status_bar_update_time(void) static void
_status_bar_update_time(void)
{ {
char bar_time[6]; char bar_time[6];
char tstmp[80]; char tstmp[80];
@ -221,4 +231,3 @@ static void _status_bar_update_time(void)
dirty = TRUE; dirty = TRUE;
} }

View File

@ -35,7 +35,8 @@ static jabber_presence_t current_status;
static void _title_bar_draw_title(void); static void _title_bar_draw_title(void);
static void _title_bar_draw_status(void); static void _title_bar_draw_status(void);
void create_title_bar(void) void
create_title_bar(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -47,13 +48,15 @@ void create_title_bar(void)
dirty = TRUE; dirty = TRUE;
} }
void title_bar_title(void) void
title_bar_title(void)
{ {
title_bar_show("Profanity. Type /help for help information."); title_bar_show("Profanity. Type /help for help information.");
dirty = TRUE; dirty = TRUE;
} }
void title_bar_resize(void) void
title_bar_resize(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -66,7 +69,8 @@ void title_bar_resize(void)
dirty = TRUE; dirty = TRUE;
} }
void title_bar_refresh(void) void
title_bar_refresh(void)
{ {
if (dirty) { if (dirty) {
wrefresh(title_bar); wrefresh(title_bar);
@ -75,7 +79,8 @@ void title_bar_refresh(void)
} }
} }
void title_bar_show(const char * const title) void
title_bar_show(const char * const title)
{ {
if (current_title != NULL) if (current_title != NULL)
free(current_title); free(current_title);
@ -85,13 +90,15 @@ void title_bar_show(const char * const title)
_title_bar_draw_title(); _title_bar_draw_title();
} }
void title_bar_set_status(jabber_presence_t status) void
title_bar_set_status(jabber_presence_t status)
{ {
current_status = status; current_status = status;
_title_bar_draw_status(); _title_bar_draw_status();
} }
static void _title_bar_draw_status() static void
_title_bar_draw_status()
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -121,7 +128,8 @@ static void _title_bar_draw_status()
dirty = TRUE; dirty = TRUE;
} }
static void _title_bar_draw_title(void) static void
_title_bar_draw_title(void)
{ {
wmove(title_bar, 0, 0); wmove(title_bar, 0, 0);
int i; int i;
@ -131,4 +139,3 @@ static void _title_bar_draw_title(void)
dirty = TRUE; dirty = TRUE;
} }

View File

@ -25,7 +25,8 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
void get_time(char *thetime) void
get_time(char *thetime)
{ {
time_t rawtime; time_t rawtime;
struct tm *timeinfo; struct tm *timeinfo;
@ -36,7 +37,8 @@ void get_time(char *thetime)
strftime(thetime, 80, "%H:%M", timeinfo); strftime(thetime, 80, "%H:%M", timeinfo);
} }
char * str_replace (const char *string, const char *substr, char *
str_replace (const char *string, const char *substr,
const char *replacement) const char *replacement)
{ {
char *tok = NULL; char *tok = NULL;
@ -80,7 +82,8 @@ char * str_replace (const char *string, const char *substr,
return newstr; return newstr;
} }
int str_contains(char str[], int size, char ch) int
str_contains(char str[], int size, char ch)
{ {
int i; int i;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {

View File

@ -76,7 +76,8 @@ static void _win_resize_all(void);
static void _win_notify(char * short_from); static void _win_notify(char * short_from);
#endif #endif
void gui_init(void) void
gui_init(void)
{ {
initscr(); initscr();
cbreak(); cbreak();
@ -106,7 +107,8 @@ void gui_init(void)
dirty = TRUE; dirty = TRUE;
} }
void gui_refresh(void) void
gui_refresh(void)
{ {
title_bar_refresh(); title_bar_refresh();
status_bar_refresh(); status_bar_refresh();
@ -119,12 +121,14 @@ void gui_refresh(void)
inp_put_back(); inp_put_back();
} }
void gui_close(void) void
gui_close(void)
{ {
endwin(); endwin();
} }
void gui_resize(const int ch, const char * const input, const int size) void
gui_resize(const int ch, const char * const input, const int size)
{ {
title_bar_resize(); title_bar_resize();
status_bar_resize(); status_bar_resize();
@ -133,7 +137,8 @@ void gui_resize(const int ch, const char * const input, const int size)
dirty = TRUE; dirty = TRUE;
} }
int win_close_win(void) int
win_close_win(void)
{ {
if (win_in_chat()) { if (win_in_chat()) {
// reset the chat win to unused // reset the chat win to unused
@ -157,13 +162,15 @@ int win_close_win(void)
} }
} }
int win_in_chat(void) int
win_in_chat(void)
{ {
return ((_curr_prof_win != 0) && return ((_curr_prof_win != 0) &&
(strcmp(_wins[_curr_prof_win].from, "") != 0)); (strcmp(_wins[_curr_prof_win].from, "") != 0));
} }
char *win_get_recipient(void) char *
win_get_recipient(void)
{ {
struct prof_win current = _wins[_curr_prof_win]; struct prof_win current = _wins[_curr_prof_win];
char *recipient = (char *) malloc(sizeof(char) * (strlen(current.from) + 1)); char *recipient = (char *) malloc(sizeof(char) * (strlen(current.from) + 1));
@ -171,7 +178,8 @@ char *win_get_recipient(void)
return recipient; return recipient;
} }
void win_show_incomming_msg(const char * const from, const char * const message) void
win_show_incomming_msg(const char * const from, const char * const message)
{ {
char from_cpy[strlen(from) + 1]; char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from); strcpy(from_cpy, from);
@ -206,7 +214,8 @@ void win_show_incomming_msg(const char * const from, const char * const message)
} }
#ifdef HAVE_LIBNOTIFY_NOTIFY_H #ifdef HAVE_LIBNOTIFY_NOTIFY_H
static void _win_notify(char * short_from) static void
_win_notify(char * short_from)
{ {
notify_init("Profanity"); notify_init("Profanity");
@ -229,7 +238,8 @@ static void _win_notify(char * short_from)
} }
#endif #endif
void win_show_outgoing_msg(const char * const from, const char * const to, void
win_show_outgoing_msg(const char * const from, const char * const to,
const char * const message) const char * const message)
{ {
int win_index = _find_prof_win_index(to); int win_index = _find_prof_win_index(to);
@ -250,7 +260,8 @@ void win_show_outgoing_msg(const char * const from, const char * const to,
} }
} }
void win_contact_online(const char * const from, const char * const show, void
win_contact_online(const char * const from, const char * const show,
const char * const status) const char * const status)
{ {
_show_status_string(_cons_win, from, show, status, "++", "online"); _show_status_string(_cons_win, from, show, status, "++", "online");
@ -265,7 +276,8 @@ void win_contact_online(const char * const from, const char * const show,
dirty = TRUE; dirty = TRUE;
} }
void win_contact_offline(const char * const from, const char * const show, void
win_contact_offline(const char * const from, const char * const show,
const char * const status) const char * const status)
{ {
_show_status_string(_cons_win, from, show, status, "--", "offline"); _show_status_string(_cons_win, from, show, status, "--", "offline");
@ -280,7 +292,8 @@ void win_contact_offline(const char * const from, const char * const show,
dirty = TRUE; dirty = TRUE;
} }
void win_disconnected(void) void
win_disconnected(void)
{ {
int i; int i;
// show message in all active chats // show message in all active chats
@ -300,7 +313,8 @@ void win_disconnected(void)
} }
} }
void cons_prefs(void) void
cons_prefs(void)
{ {
cons_show(""); cons_show("");
cons_show("Current preferences:"); cons_show("Current preferences:");
@ -337,7 +351,8 @@ void cons_prefs(void)
dirty = TRUE; dirty = TRUE;
} }
void cons_help(void) void
cons_help(void)
{ {
cons_show(""); cons_show("");
cons_show("Basic Commands:"); cons_show("Basic Commands:");
@ -381,7 +396,8 @@ void cons_help(void)
dirty = TRUE; dirty = TRUE;
} }
void cons_show_online_contacts(GSList *list) void
cons_show_online_contacts(GSList *list)
{ {
_win_show_time(_cons_win); _win_show_time(_cons_win);
wprintw(_cons_win, "Online contacts:\n"); wprintw(_cons_win, "Online contacts:\n");
@ -404,7 +420,8 @@ void cons_show_online_contacts(GSList *list)
} }
} }
void cons_bad_show(const char * const msg) void
cons_bad_show(const char * const msg)
{ {
_win_show_time(_cons_win); _win_show_time(_cons_win);
wattron(_cons_win, COLOR_PAIR(6)); wattron(_cons_win, COLOR_PAIR(6));
@ -415,7 +432,8 @@ void cons_bad_show(const char * const msg)
dirty = TRUE; dirty = TRUE;
} }
void cons_show(const char * const msg) void
cons_show(const char * const msg)
{ {
_win_show_time(_cons_win); _win_show_time(_cons_win);
wprintw(_cons_win, "%s\n", msg); wprintw(_cons_win, "%s\n", msg);
@ -424,7 +442,8 @@ void cons_show(const char * const msg)
dirty = TRUE; dirty = TRUE;
} }
void cons_bad_command(const char * const cmd) void
cons_bad_command(const char * const cmd)
{ {
_win_show_time(_cons_win); _win_show_time(_cons_win);
wprintw(_cons_win, "Unknown command: %s\n", cmd); wprintw(_cons_win, "Unknown command: %s\n", cmd);
@ -433,13 +452,15 @@ void cons_bad_command(const char * const cmd)
dirty = TRUE; dirty = TRUE;
} }
void win_handle_special_keys(const int * const ch) void
win_handle_special_keys(const int * const ch)
{ {
_win_handle_switch(ch); _win_handle_switch(ch);
_win_handle_page(ch); _win_handle_page(ch);
} }
void win_page_off(void) void
win_page_off(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -457,7 +478,8 @@ void win_page_off(void)
dirty = TRUE; dirty = TRUE;
} }
static void _create_windows(void) static void
_create_windows(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -515,7 +537,8 @@ static void _create_windows(void)
} }
} }
static void _print_splash_logo(WINDOW *win) static void
_print_splash_logo(WINDOW *win)
{ {
wprintw(win, "Welcome to\n"); wprintw(win, "Welcome to\n");
wattron(win, COLOR_PAIR(5)); wattron(win, COLOR_PAIR(5));
@ -529,7 +552,8 @@ static void _print_splash_logo(WINDOW *win)
wattroff(win, COLOR_PAIR(5)); wattroff(win, COLOR_PAIR(5));
} }
static int _find_prof_win_index(const char * const contact) static int
_find_prof_win_index(const char * const contact)
{ {
// find the chat window for recipient // find the chat window for recipient
int i; int i;
@ -540,7 +564,8 @@ static int _find_prof_win_index(const char * const contact)
return i; return i;
} }
static int _new_prof_win(const char * const contact) static int
_new_prof_win(const char * const contact)
{ {
int i; int i;
// find the first unused one // find the first unused one
@ -554,7 +579,9 @@ static int _new_prof_win(const char * const contact)
return i; return i;
} }
static void _win_switch_if_active(const int i)
static void
_win_switch_if_active(const int i)
{ {
win_page_off(); win_page_off();
if (strcmp(_wins[i].from, "") != 0) { if (strcmp(_wins[i].from, "") != 0) {
@ -572,14 +599,16 @@ static void _win_switch_if_active(const int i)
dirty = TRUE; dirty = TRUE;
} }
static void _win_show_time(WINDOW *win) static void
_win_show_time(WINDOW *win)
{ {
char tstmp[80]; char tstmp[80];
get_time(tstmp); get_time(tstmp);
wprintw(win, "%s - ", tstmp); wprintw(win, "%s - ", tstmp);
} }
static void _win_show_user(WINDOW *win, const char * const user, const int colour) static void
_win_show_user(WINDOW *win, const char * const user, const int colour)
{ {
if (colour) if (colour)
wattron(win, COLOR_PAIR(2)); wattron(win, COLOR_PAIR(2));
@ -588,14 +617,16 @@ static void _win_show_user(WINDOW *win, const char * const user, const int colou
wattroff(win, COLOR_PAIR(2)); wattroff(win, COLOR_PAIR(2));
} }
static void _win_show_message(WINDOW *win, const char * const message) static void
_win_show_message(WINDOW *win, const char * const message)
{ {
// wattroff(win, A_BOLD); // wattroff(win, A_BOLD);
wprintw(win, "%s\n", message); wprintw(win, "%s\n", message);
// wattron(win, A_BOLD); // wattron(win, A_BOLD);
} }
static void _current_window_refresh(void) static void
_current_window_refresh(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -604,7 +635,8 @@ static void _current_window_refresh(void)
prefresh(current, _wins[_curr_prof_win].y_pos, 0, 1, 0, rows-3, cols-1); prefresh(current, _wins[_curr_prof_win].y_pos, 0, 1, 0, rows-3, cols-1);
} }
void _win_resize_all(void) void
_win_resize_all(void)
{ {
int rows, cols; int rows, cols;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -623,7 +655,8 @@ void _win_resize_all(void)
prefresh(current, _wins[_curr_prof_win].y_pos, 0, 1, 0, rows-3, cols-1); prefresh(current, _wins[_curr_prof_win].y_pos, 0, 1, 0, rows-3, cols-1);
} }
static void _show_status_string(WINDOW *win, const char * const from, static void
_show_status_string(WINDOW *win, const char * const from,
const char * const show, const char * const status, const char * const pre, const char * const show, const char * const status, const char * const pre,
const char * const default_show) const char * const default_show)
{ {
@ -656,7 +689,8 @@ static void _show_status_string(WINDOW *win, const char * const from,
} }
static void _cons_show_incoming_message(const char * const short_from, const int win_index) static void
_cons_show_incoming_message(const char * const short_from, const int win_index)
{ {
_win_show_time(_cons_win); _win_show_time(_cons_win);
wattron(_cons_win, COLOR_PAIR(7)); wattron(_cons_win, COLOR_PAIR(7));
@ -664,7 +698,8 @@ static void _cons_show_incoming_message(const char * const short_from, const int
wattroff(_cons_win, COLOR_PAIR(7)); wattroff(_cons_win, COLOR_PAIR(7));
} }
static void _win_handle_switch(const int * const ch) static void
_win_handle_switch(const int * const ch)
{ {
if (*ch == KEY_F(1)) { if (*ch == KEY_F(1)) {
_win_switch_if_active(0); _win_switch_if_active(0);
@ -689,7 +724,8 @@ static void _win_handle_switch(const int * const ch)
} }
} }
static void _win_handle_page(const int * const ch) static void
_win_handle_page(const int * const ch)
{ {
int rows, cols, y, x; int rows, cols, y, x;
getmaxyx(stdscr, rows, cols); getmaxyx(stdscr, rows, cols);
@ -725,4 +761,3 @@ static void _win_handle_page(const int * const ch)
dirty = TRUE; dirty = TRUE;
} }
} }