diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-07-07 14:18:57 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-07-07 14:18:57 +0200 |
commit | a2726b6a7d16f5f846a882fbbe9127e4604bb8bb (patch) | |
tree | e6d101676dec96430eafa645ad2b7bd5391a4294 /src/ui | |
parent | 95015cec56fa56f2ef97227edf06de17c65000d9 (diff) | |
download | profani-tty-a2726b6a7d16f5f846a882fbbe9127e4604bb8bb.tar.gz |
Apply coding style
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/buffer.c | 33 | ||||
-rw-r--r-- | src/ui/buffer.h | 30 | ||||
-rw-r--r-- | src/ui/chatwin.c | 184 | ||||
-rw-r--r-- | src/ui/confwin.c | 84 | ||||
-rw-r--r-- | src/ui/console.c | 482 | ||||
-rw-r--r-- | src/ui/core.c | 347 | ||||
-rw-r--r-- | src/ui/inputwin.c | 89 | ||||
-rw-r--r-- | src/ui/mucwin.c | 378 | ||||
-rw-r--r-- | src/ui/notifier.c | 41 | ||||
-rw-r--r-- | src/ui/occupantswin.c | 44 | ||||
-rw-r--r-- | src/ui/privwin.c | 66 | ||||
-rw-r--r-- | src/ui/rosterwin.c | 413 | ||||
-rw-r--r-- | src/ui/screen.c | 21 | ||||
-rw-r--r-- | src/ui/statusbar.c | 110 | ||||
-rw-r--r-- | src/ui/statusbar.h | 4 | ||||
-rw-r--r-- | src/ui/titlebar.c | 206 | ||||
-rw-r--r-- | src/ui/tray.c | 16 | ||||
-rw-r--r-- | src/ui/ui.h | 422 | ||||
-rw-r--r-- | src/ui/win_types.h | 136 | ||||
-rw-r--r-- | src/ui/window.c | 692 | ||||
-rw-r--r-- | src/ui/window.h | 52 | ||||
-rw-r--r-- | src/ui/window_list.c | 364 | ||||
-rw-r--r-- | src/ui/window_list.h | 50 | ||||
-rw-r--r-- | src/ui/xmlwin.c | 6 |
24 files changed, 2135 insertions, 2135 deletions
diff --git a/src/ui/buffer.c b/src/ui/buffer.c index 54178632..f78168ac 100644 --- a/src/ui/buffer.c +++ b/src/ui/buffer.c @@ -53,11 +53,12 @@ #define BUFF_SIZE 1200 -struct prof_buff_t { - GSList *entries; +struct prof_buff_t +{ + GSList* entries; }; -static void _free_entry(ProfBuffEntry *entry); +static void _free_entry(ProfBuffEntry* entry); ProfBuff buffer_create(void) @@ -81,9 +82,9 @@ buffer_free(ProfBuff buffer) } void -buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const display_from, const char *const from_jid, const char *const message, DeliveryReceipt *receipt, const char *const id) +buffer_append(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message, DeliveryReceipt* receipt, const char* const id) { - ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t)); + ProfBuffEntry* e = malloc(sizeof(struct prof_buff_entry_t)); e->show_char = strdup(show_char); e->pad_indent = pad_indent; e->flags = flags; @@ -108,11 +109,11 @@ buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime } void -buffer_remove_entry_by_id(ProfBuff buffer, const char *const id) +buffer_remove_entry_by_id(ProfBuff buffer, const char* const id) { - GSList *entries = buffer->entries; + GSList* entries = buffer->entries; while (entries) { - ProfBuffEntry *entry = entries->data; + ProfBuffEntry* entry = entries->data; if (entry->id && (g_strcmp0(entry->id, id) == 0)) { _free_entry(entry); buffer->entries = g_slist_delete_link(buffer->entries, entries); @@ -123,11 +124,11 @@ buffer_remove_entry_by_id(ProfBuff buffer, const char *const id) } gboolean -buffer_mark_received(ProfBuff buffer, const char *const id) +buffer_mark_received(ProfBuff buffer, const char* const id) { - GSList *entries = buffer->entries; + GSList* entries = buffer->entries; while (entries) { - ProfBuffEntry *entry = entries->data; + ProfBuffEntry* entry = entries->data; if (entry->receipt && g_strcmp0(entry->id, id) == 0) { if (!entry->receipt->received) { entry->receipt->received = TRUE; @@ -143,16 +144,16 @@ buffer_mark_received(ProfBuff buffer, const char *const id) ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry) { - GSList *node = g_slist_nth(buffer->entries, entry); + GSList* node = g_slist_nth(buffer->entries, entry); return node->data; } ProfBuffEntry* -buffer_get_entry_by_id(ProfBuff buffer, const char *const id) +buffer_get_entry_by_id(ProfBuff buffer, const char* const id) { - GSList *entries = buffer->entries; + GSList* entries = buffer->entries; while (entries) { - ProfBuffEntry *entry = entries->data; + ProfBuffEntry* entry = entries->data; if (g_strcmp0(entry->id, id) == 0) { return entry; } @@ -163,7 +164,7 @@ buffer_get_entry_by_id(ProfBuff buffer, const char *const id) } static void -_free_entry(ProfBuffEntry *entry) +_free_entry(ProfBuffEntry* entry) { free(entry->show_char); free(entry->message); diff --git a/src/ui/buffer.h b/src/ui/buffer.h index 997e2a49..02e04d4a 100644 --- a/src/ui/buffer.h +++ b/src/ui/buffer.h @@ -42,36 +42,38 @@ #include "config.h" #include "config/theme.h" -typedef struct delivery_receipt_t { +typedef struct delivery_receipt_t +{ gboolean received; } DeliveryReceipt; -typedef struct prof_buff_entry_t { +typedef struct prof_buff_entry_t +{ // pointer because it could be a unicode symbol as well - char *show_char; + char* show_char; int pad_indent; - GDateTime *time; + GDateTime* time; int flags; theme_item_t theme_item; // from as it is displayed // might be nick, jid.. - char *display_from; - char *from_jid; - char *message; - DeliveryReceipt *receipt; + char* display_from; + char* from_jid; + char* message; + DeliveryReceipt* receipt; // message id, in case we have it - char *id; + char* id; } ProfBuffEntry; -typedef struct prof_buff_t *ProfBuff; +typedef struct prof_buff_t* ProfBuff; ProfBuff buffer_create(); void buffer_free(ProfBuff buffer); -void buffer_append(ProfBuff buffer, const char *show_char, int pad_indent, GDateTime *time, int flags, theme_item_t theme_item, const char *const display_from, const char *const barejid, const char *const message, DeliveryReceipt *receipt, const char *const id); -void buffer_remove_entry_by_id(ProfBuff buffer, const char *const id); +void buffer_append(ProfBuff buffer, const char* show_char, int pad_indent, GDateTime* time, int flags, theme_item_t theme_item, const char* const display_from, const char* const barejid, const char* const message, DeliveryReceipt* receipt, const char* const id); +void buffer_remove_entry_by_id(ProfBuff buffer, const char* const id); int buffer_size(ProfBuff buffer); ProfBuffEntry* buffer_get_entry(ProfBuff buffer, int entry); -ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char *const id); -gboolean buffer_mark_received(ProfBuff buffer, const char *const id); +ProfBuffEntry* buffer_get_entry_by_id(ProfBuff buffer, const char* const id); +gboolean buffer_mark_received(ProfBuff buffer, const char* const id); #endif diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 35ad803f..f204e821 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -57,14 +57,14 @@ #include "omemo/omemo.h" #endif -static void _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid); -static void _chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message); +static void _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid); +static void _chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message); ProfChatWin* -chatwin_new(const char *const barejid) +chatwin_new(const char* const barejid) { - ProfWin *window = wins_new_chat(barejid); - ProfChatWin *chatwin = (ProfChatWin *)window; + ProfWin* window = wins_new_chat(barejid); + ProfChatWin* chatwin = (ProfChatWin*)window; if (!prefs_get_boolean(PREF_MAM) && prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) { _chatwin_history(chatwin, barejid); @@ -74,8 +74,8 @@ chatwin_new(const char *const barejid) PContact contact = roster_get_contact(barejid); if (contact) { if (strcmp(p_contact_presence(contact), "offline") == 0) { - const char * const show = p_contact_presence(contact); - const char * const status = p_contact_status(contact); + const char* const show = p_contact_presence(contact); + const char* const status = p_contact_status(contact); win_show_status_string(window, barejid, show, status, NULL, "--", "offline"); } } @@ -97,24 +97,24 @@ chatwin_new(const char *const barejid) } void -chatwin_receipt_received(ProfChatWin *chatwin, const char *const id) +chatwin_receipt_received(ProfChatWin* chatwin, const char* const id) { assert(chatwin != NULL); - ProfWin *win = (ProfWin*) chatwin; + ProfWin* win = (ProfWin*)chatwin; win_mark_received(win, id); } #ifdef HAVE_LIBOTR void -chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) +chatwin_otr_secured(ProfChatWin* chatwin, gboolean trusted) { assert(chatwin != NULL); chatwin->is_otr = TRUE; chatwin->otr_is_trusted = trusted; - ProfWin *window = (ProfWin*) chatwin; + ProfWin* window = (ProfWin*)chatwin; if (trusted) { win_println(window, THEME_OTR_STARTED_TRUSTED, "!", "OTR session started (trusted)."); } else { @@ -122,7 +122,7 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) } if (wins_is_current(window)) { - title_bar_switch(); + title_bar_switch(); } else { int num = wins_get_num(window); status_bar_new(num, WIN_CHAT, chatwin->barejid); @@ -137,14 +137,14 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) } void -chatwin_otr_unsecured(ProfChatWin *chatwin) +chatwin_otr_unsecured(ProfChatWin* chatwin) { assert(chatwin != NULL); chatwin->is_otr = FALSE; chatwin->otr_is_trusted = FALSE; - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_println(window, THEME_OTR_ENDED, "!", "OTR session ended."); if (wins_is_current(window)) { title_bar_switch(); @@ -152,62 +152,62 @@ chatwin_otr_unsecured(ProfChatWin *chatwin) } void -chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) +chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* data) { assert(chatwin != NULL); switch (event) { - case PROF_OTR_SMP_INIT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); - break; - case PROF_OTR_SMP_INIT_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "%s wants to authenticate your identity with the following question:", chatwin->barejid); - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", " %s", (char*)data); - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "use '/otr answer <answer>'."); - break; - case PROF_OTR_SMP_SENDER_FAIL: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "Authentication failed, the secret you entered does not match the secret entered by %s.", - chatwin->barejid); - break; - case PROF_OTR_SMP_RECEIVER_FAIL: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", - "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); - break; - case PROF_OTR_SMP_ABORT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "SMP session aborted."); - break; - case PROF_OTR_SMP_SUCCESS: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication successful."); - break; - case PROF_OTR_SMP_SUCCESS_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s successfully authenticated you.", chatwin->barejid); - break; - case PROF_OTR_SMP_FAIL_Q: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s failed to authenticate you.", chatwin->barejid); - break; - case PROF_OTR_SMP_AUTH: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s...", chatwin->barejid); - break; - case PROF_OTR_SMP_AUTH_WAIT: - win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s...", chatwin->barejid); - break; - default: - break; + case PROF_OTR_SMP_INIT: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); + break; + case PROF_OTR_SMP_INIT_Q: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "%s wants to authenticate your identity with the following question:", chatwin->barejid); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", " %s", (char*)data); + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "use '/otr answer <answer>'."); + break; + case PROF_OTR_SMP_SENDER_FAIL: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "Authentication failed, the secret you entered does not match the secret entered by %s.", + chatwin->barejid); + break; + case PROF_OTR_SMP_RECEIVER_FAIL: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", + "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); + break; + case PROF_OTR_SMP_ABORT: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "SMP session aborted."); + break; + case PROF_OTR_SMP_SUCCESS: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authentication successful."); + break; + case PROF_OTR_SMP_SUCCESS_Q: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s successfully authenticated you.", chatwin->barejid); + break; + case PROF_OTR_SMP_FAIL_Q: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "%s failed to authenticate you.", chatwin->barejid); + break; + case PROF_OTR_SMP_AUTH: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Authenticating %s...", chatwin->barejid); + break; + case PROF_OTR_SMP_AUTH_WAIT: + win_println((ProfWin*)chatwin, THEME_DEFAULT, "!", "Awaiting authentication from %s...", chatwin->barejid); + break; + default: + break; } } void -chatwin_otr_trust(ProfChatWin *chatwin) +chatwin_otr_trust(ProfChatWin* chatwin) { assert(chatwin != NULL); chatwin->is_otr = TRUE; chatwin->otr_is_trusted = TRUE; - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_println(window, THEME_OTR_TRUSTED, "!", "OTR session trusted."); if (wins_is_current(window)) { title_bar_switch(); @@ -215,14 +215,14 @@ chatwin_otr_trust(ProfChatWin *chatwin) } void -chatwin_otr_untrust(ProfChatWin *chatwin) +chatwin_otr_untrust(ProfChatWin* chatwin) { assert(chatwin != NULL); chatwin->is_otr = TRUE; chatwin->otr_is_trusted = FALSE; - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_println(window, THEME_OTR_UNTRUSTED, "!", "OTR session untrusted."); if (wins_is_current(window)) { title_bar_switch(); @@ -231,11 +231,11 @@ chatwin_otr_untrust(ProfChatWin *chatwin) #endif void -chatwin_recipient_gone(ProfChatWin *chatwin) +chatwin_recipient_gone(ProfChatWin* chatwin) { assert(chatwin != NULL); - const char *display_usr = NULL; + const char* display_usr = NULL; PContact contact = roster_get_contact(chatwin->barejid); if (contact) { if (p_contact_name(contact)) { @@ -251,18 +251,18 @@ chatwin_recipient_gone(ProfChatWin *chatwin) } void -chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created) +chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created) { assert(chatwin != NULL); - char *old_plain = message->plain; + char* old_plain = message->plain; message->plain = plugins_pre_chat_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain); - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; int num = wins_get_num(window); - char *display_name; - char *mybarejid = connection_get_barejid(); + char* display_name; + char* mybarejid = connection_get_barejid(); if (g_strcmp0(mybarejid, message->from_jid->barejid) == 0) { display_name = strdup("me"); } else { @@ -279,7 +279,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr title_bar_set_typing(FALSE); status_bar_active(num, WIN_CHAT, chatwin->barejid); - // not currently viewing chat window with sender + // not currently viewing chat window with sender } else { status_bar_new(num, WIN_CHAT, chatwin->barejid); cons_show_incoming_message(display_name, num, chatwin->unread); @@ -333,12 +333,12 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr } void -chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, - gboolean request_receipt, const char *const replace_id) +chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id, prof_enc_t enc_mode, + gboolean request_receipt, const char* const replace_id) { assert(chatwin != NULL); - char *enc_char; + char* enc_char; if (chatwin->outgoing_char) { enc_char = chatwin->outgoing_char; } else if (enc_mode == PROF_MSG_ENC_OTR) { @@ -368,11 +368,11 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, } void -chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) +chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message) { assert(chatwin != NULL); - char *enc_char; + char* enc_char; if (message->enc == PROF_MSG_ENC_PGP) { enc_char = prefs_get_pgp_char(); } else if (message->enc == PROF_MSG_ENC_OMEMO) { @@ -381,7 +381,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) enc_char = strdup("-"); } - ProfWin *window = (ProfWin*)chatwin; + ProfWin* window = (ProfWin*)chatwin; win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain); int num = wins_get_num(window); @@ -391,13 +391,13 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) } void -chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) +chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last_activity) { assert(chatwin != NULL); - const char *show = string_from_resource_presence(resource->presence); + const char* show = string_from_resource_presence(resource->presence); PContact contact = roster_get_contact(chatwin->barejid); - char *display_str = p_contact_create_display_string(contact, resource->name); + char* display_str = p_contact_create_display_string(contact, resource->name); win_show_status_string((ProfWin*)chatwin, display_str, show, resource->status, last_activity, "++", "online"); @@ -405,12 +405,12 @@ chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last } void -chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) +chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status) { assert(chatwin != NULL); PContact contact = roster_get_contact(chatwin->barejid); - char *display_str = p_contact_create_display_string(contact, resource); + char* display_str = p_contact_create_display_string(contact, resource); win_show_status_string((ProfWin*)chatwin, display_str, "offline", status, NULL, "--", "offline"); @@ -418,11 +418,11 @@ chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) } char* -chatwin_get_string(ProfChatWin *chatwin) +chatwin_get_string(ProfChatWin* chatwin) { assert(chatwin != NULL); - GString *res = g_string_new("Chat "); + GString* res = g_string_new("Chat "); jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { @@ -430,7 +430,7 @@ chatwin_get_string(ProfChatWin *chatwin) if (contact == NULL) { g_string_append(res, chatwin->barejid); } else { - const char *display_name = p_contact_name_or_jid(contact); + const char* display_name = p_contact_name_or_jid(contact); g_string_append(res, display_name); g_string_append_printf(res, " - %s", p_contact_presence(contact)); } @@ -442,14 +442,14 @@ chatwin_get_string(ProfChatWin *chatwin) g_string_append_printf(res, ", %d unread", chatwin->unread); } - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; } void -chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) +chatwin_set_enctext(ProfChatWin* chatwin, const char* const enctext) { if (chatwin->enctext) { free(chatwin->enctext); @@ -458,7 +458,7 @@ chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) } void -chatwin_unset_enctext(ProfChatWin *chatwin) +chatwin_unset_enctext(ProfChatWin* chatwin) { if (chatwin->enctext) { free(chatwin->enctext); @@ -467,7 +467,7 @@ chatwin_unset_enctext(ProfChatWin *chatwin) } void -chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) +chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch) { if (chatwin->incoming_char) { free(chatwin->incoming_char); @@ -476,7 +476,7 @@ chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) } void -chatwin_unset_incoming_char(ProfChatWin *chatwin) +chatwin_unset_incoming_char(ProfChatWin* chatwin) { if (chatwin->incoming_char) { free(chatwin->incoming_char); @@ -485,7 +485,7 @@ chatwin_unset_incoming_char(ProfChatWin *chatwin) } void -chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) +chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch) { if (chatwin->outgoing_char) { free(chatwin->outgoing_char); @@ -494,7 +494,7 @@ chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) } void -chatwin_unset_outgoing_char(ProfChatWin *chatwin) +chatwin_unset_outgoing_char(ProfChatWin* chatwin) { if (chatwin->outgoing_char) { free(chatwin->outgoing_char); @@ -503,14 +503,14 @@ chatwin_unset_outgoing_char(ProfChatWin *chatwin) } static void -_chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid) +_chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid) { if (!chatwin->history_shown) { - GSList *history = log_database_get_previous_chat(contact_barejid); - GSList *curr = history; + GSList* history = log_database_get_previous_chat(contact_barejid); + GSList* curr = history; while (curr) { - ProfMessage *msg = curr->data; + ProfMessage* msg = curr->data; win_print_history((ProfWin*)chatwin, msg); curr = g_slist_next(curr); } @@ -521,7 +521,7 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact_barejid) } static void -_chatwin_set_last_message(ProfChatWin *chatwin, const char *const id, const char *const message) +_chatwin_set_last_message(ProfChatWin* chatwin, const char* const id, const char* const message) { free(chatwin->last_message); chatwin->last_message = strdup(message); diff --git a/src/ui/confwin.c b/src/ui/confwin.c index af37a640..5dc57923 100644 --- a/src/ui/confwin.c +++ b/src/ui/confwin.c @@ -41,12 +41,12 @@ #include "ui/win_types.h" #include "ui/window_list.h" -static void _confwin_form_field(ProfWin *window, char *tag, FormField *field); +static void _confwin_form_field(ProfWin* window, char* tag, FormField* field); void -confwin_show_form(ProfConfWin *confwin) +confwin_show_form(ProfConfWin* confwin) { - ProfWin *window = (ProfWin*) confwin; + ProfWin* window = (ProfWin*)confwin; if (confwin->form->title) { win_print(window, THEME_DEFAULT, "-", "Form title: "); win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title); @@ -57,18 +57,18 @@ confwin_show_form(ProfConfWin *confwin) confwin_form_help(confwin); - GSList *fields = confwin->form->fields; - GSList *curr_field = fields; + GSList* fields = confwin->form->fields; + GSList* curr_field = fields; while (curr_field) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if (field->values) { - char *value = field->values->data; + char* value = field->values->data; win_println(window, THEME_DEFAULT, "-", "%s", value); } } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { - char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); + char* tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); _confwin_form_field(window, tag, field); } @@ -77,22 +77,22 @@ confwin_show_form(ProfConfWin *confwin) } void -confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag) +confwin_show_form_field(ProfConfWin* confwin, DataForm* form, char* tag) { assert(confwin != NULL); - FormField *field = form_get_field_by_tag(form, tag); - ProfWin *window = (ProfWin*)confwin; + FormField* field = form_get_field_by_tag(form, tag); + ProfWin* window = (ProfWin*)confwin; _confwin_form_field(window, tag, field); win_println(window, THEME_DEFAULT, "-", ""); } void -confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) +confwin_handle_configuration(ProfConfWin* confwin, DataForm* form) { assert(confwin != NULL); - ProfWin *window = (ProfWin*)confwin; + ProfWin* window = (ProfWin*)confwin; ui_focus_win(window); confwin_show_form(confwin); @@ -107,12 +107,12 @@ confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) } void -confwin_field_help(ProfConfWin *confwin, char *tag) +confwin_field_help(ProfConfWin* confwin, char* tag) { assert(confwin != NULL); - ProfWin *window = (ProfWin*) confwin; - FormField *field = form_get_field_by_tag(confwin->form, tag); + ProfWin* window = (ProfWin*)confwin; + FormField* field = form_get_field_by_tag(confwin->form, tag); if (field) { win_print(window, THEME_DEFAULT, "-", "%s", field->label); if (field->required) { @@ -126,8 +126,8 @@ confwin_field_help(ProfConfWin *confwin, char *tag) win_println(window, THEME_DEFAULT, "-", " Type : %s", field->type); int num_values = 0; - GSList *curr_option = NULL; - FormOption *option = NULL; + GSList* curr_option = NULL; + FormOption* option = NULL; switch (field->type_t) { case FIELD_TEXT_SINGLE: @@ -190,12 +190,12 @@ confwin_field_help(ProfConfWin *confwin, char *tag) } void -confwin_form_help(ProfConfWin *confwin) +confwin_form_help(ProfConfWin* confwin) { assert(confwin != NULL); if (confwin->form->instructions) { - ProfWin *window = (ProfWin*) confwin; + ProfWin* window = (ProfWin*)confwin; win_println(window, THEME_DEFAULT, "-", "Supplied instructions:"); win_println(window, THEME_DEFAULT, "-", "%s", confwin->form->instructions); win_println(window, THEME_DEFAULT, "-", ""); @@ -203,7 +203,7 @@ confwin_form_help(ProfConfWin *confwin) } static void -_confwin_form_field(ProfWin *window, char *tag, FormField *field) +_confwin_form_field(ProfWin* window, char* tag, FormField* field) { win_print(window, THEME_AWAY, "-", "[%s] ", tag); win_append(window, THEME_DEFAULT, "%s", field->label); @@ -213,15 +213,15 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) win_append(window, THEME_DEFAULT, ": "); } - GSList *values = field->values; - GSList *curr_value = values; + GSList* values = field->values; + GSList* curr_value = values; switch (field->type_t) { case FIELD_HIDDEN: break; case FIELD_TEXT_SINGLE: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { win_append(window, THEME_ONLINE, "[hidden]"); @@ -234,7 +234,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_TEXT_PRIVATE: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { win_append(window, THEME_ONLINE, "[hidden]"); } @@ -245,8 +245,8 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) win_newline(window); int index = 1; while (curr_value) { - char *value = curr_value->data; - GString *val_tag = g_string_new(""); + char* value = curr_value->data; + GString* val_tag = g_string_new(""); g_string_printf(val_tag, "val%d", index++); win_println(window, THEME_ONLINE, "-", " [%s] %s", val_tag->str, value); g_string_free(val_tag, TRUE); @@ -257,7 +257,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value == NULL) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { - char *value = curr_value->data; + char* value = curr_value->data; if (value == NULL) { win_appendln(window, THEME_OFFLINE, "FALSE"); } else { @@ -272,11 +272,11 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) case FIELD_LIST_SINGLE: if (curr_value) { win_newline(window); - char *value = curr_value->data; - GSList *options = field->options; - GSList *curr_option = options; + char* value = curr_value->data; + GSList* options = field->options; + GSList* curr_option = options; while (curr_option) { - FormOption *option = curr_option->data; + FormOption* option = curr_option->data; if (g_strcmp0(option->value, value) == 0) { win_println(window, THEME_ONLINE, "-", " [%s] %s", option->value, option->label); } else { @@ -289,10 +289,10 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) case FIELD_LIST_MULTI: if (curr_value) { win_newline(window); - GSList *options = field->options; - GSList *curr_option = options; + GSList* options = field->options; + GSList* curr_option = options; while (curr_option) { - FormOption *option = curr_option->data; + FormOption* option = curr_option->data; if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) { win_println(window, THEME_ONLINE, "-", " [%s] %s", option->value, option->label); } else { @@ -304,7 +304,7 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) break; case FIELD_JID_SINGLE: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { win_append(window, THEME_ONLINE, "%s", value); } @@ -314,14 +314,14 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) case FIELD_JID_MULTI: win_newline(window); while (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; win_println(window, THEME_ONLINE, "-", " %s", value); curr_value = g_slist_next(curr_value); } break; case FIELD_FIXED: if (curr_value) { - char *value = curr_value->data; + char* value = curr_value->data; if (value) { win_append(window, THEME_DEFAULT, "%s", value); } @@ -334,17 +334,17 @@ _confwin_form_field(ProfWin *window, char *tag, FormField *field) } char* -confwin_get_string(ProfConfWin *confwin) +confwin_get_string(ProfConfWin* confwin) { assert(confwin != NULL); - GString *res = g_string_new(""); + GString* res = g_string_new(""); - char *title = win_get_title((ProfWin*)confwin); + char* title = win_get_title((ProfWin*)confwin); g_string_append(res, title); free(title); - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; diff --git a/src/ui/console.c b/src/ui/console.c index 3696de81..2a52f9ea 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -34,7 +34,6 @@ * */ - #include <string.h> #include <stdlib.h> #include <assert.h> @@ -63,16 +62,16 @@ #endif static void _cons_splash_logo(void); -void _show_roster_contacts(GSList *list, gboolean show_groups); +void _show_roster_contacts(GSList* list, gboolean show_groups); void -cons_debug(const char *const msg, ...) +cons_debug(const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (strcmp(PACKAGE_STATUS, "development") == 0) { va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(console, THEME_DEFAULT, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -81,12 +80,12 @@ cons_debug(const char *const msg, ...) } void -cons_show(const char *const msg, ...) +cons_show(const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(console, THEME_DEFAULT, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -94,12 +93,12 @@ cons_show(const char *const msg, ...) } void -cons_show_padded(int pad, const char *const msg, ...) +cons_show_padded(int pad, const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println_indent(console, pad, "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -107,15 +106,15 @@ cons_show_padded(int pad, const char *const msg, ...) } void -cons_show_help(const char *const cmd, CommandHelp *help) +cons_show_help(const char* const cmd, CommandHelp* help) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); win_println(console, THEME_HELP_HEADER, "-", "%s", &cmd[1]); win_print(console, THEME_HELP_HEADER, "-", ""); int i; - for (i = 0; i < strlen(cmd) - 1 ; i++) { + for (i = 0; i < strlen(cmd) - 1; i++) { win_append(console, THEME_HELP_HEADER, "-"); } win_appendln(console, THEME_HELP_HEADER, ""); @@ -150,9 +149,9 @@ cons_show_help(const char *const cmd, CommandHelp *help) } void -cons_bad_cmd_usage(const char *const cmd) +cons_bad_cmd_usage(const char* const cmd) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_printf(msg, "Invalid usage, see '/help %s' for details.", &cmd[1]); cons_show(""); @@ -162,12 +161,12 @@ cons_bad_cmd_usage(const char *const cmd) } void -cons_show_error(const char *const msg, ...) +cons_show_error(const char* const msg, ...) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); va_list arg; va_start(arg, msg); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, msg, arg); win_println(console, THEME_ERROR, "-", "%s", fmt_msg->str); g_string_free(fmt_msg, TRUE); @@ -177,7 +176,7 @@ cons_show_error(const char *const msg, ...) } void -cons_show_tlscert_summary(TLSCertificate *cert) +cons_show_tlscert_summary(TLSCertificate* cert) { if (!cert) { return; @@ -189,7 +188,7 @@ cons_show_tlscert_summary(TLSCertificate *cert) } void -cons_show_tlscert(TLSCertificate *cert) +cons_show_tlscert(TLSCertificate* cert) { if (!cert) { return; @@ -269,10 +268,10 @@ cons_show_tlscert(TLSCertificate *cert) } void -cons_show_typing(const char *const barejid) +cons_show_typing(const char* const barejid) { - ProfWin *console = wins_get_console(); - const char * display_usr = NULL; + ProfWin* console = wins_get_console(); + const char* display_usr = NULL; PContact contact = roster_get_contact(barejid); if (contact) { if (p_contact_name(contact)) { @@ -289,10 +288,10 @@ cons_show_typing(const char *const barejid) } char* -_room_triggers_to_string(GList *triggers) +_room_triggers_to_string(GList* triggers) { - GString *triggers_str = g_string_new(""); - GList *curr = triggers; + GString* triggers_str = g_string_new(""); + GList* curr = triggers; while (curr) { g_string_append_printf(triggers_str, "\"%s\"", (char*)curr->data); curr = g_list_next(curr); @@ -301,29 +300,29 @@ _room_triggers_to_string(GList *triggers) } } - char *result = triggers_str->str; + char* result = triggers_str->str; g_string_free(triggers_str, FALSE); return result; } void -cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, - GList *triggers, int unread) +cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, + GList* triggers, int unread) { - ProfWin *const console = wins_get_console(); + ProfWin* const console = wins_get_console(); int ui_index = win_index; if (ui_index == 10) { ui_index = 0; } - char *muc_show = prefs_get_string(PREF_CONSOLE_MUC); + char* muc_show = prefs_get_string(PREF_CONSOLE_MUC); if (g_strcmp0(muc_show, "all") == 0) { if (mention) { win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); } else if (triggers) { - char *triggers_str = _room_triggers_to_string(triggers); + char* triggers_str = _room_triggers_to_string(triggers); win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); } else { @@ -336,7 +335,7 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, win_println(console, THEME_MENTION, "-", "<< room mention: %s in %s (win %d)", nick, room, ui_index); cons_alert(); } else if (triggers) { - char *triggers_str = _room_triggers_to_string(triggers); + char* triggers_str = _room_triggers_to_string(triggers); win_println(console, THEME_TRIGGER, "-", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); free(triggers_str); cons_alert(); @@ -349,16 +348,16 @@ cons_show_incoming_room_message(const char *const nick, const char *const room, } void -cons_show_incoming_message(const char *const short_from, const int win_index, int unread) +cons_show_incoming_message(const char* const short_from, const int win_index, int unread) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int ui_index = win_index; if (ui_index == 10) { ui_index = 0; } - char *chat_show = prefs_get_string(PREF_CONSOLE_CHAT); + char* chat_show = prefs_get_string(PREF_CONSOLE_CHAT); if (g_strcmp0(chat_show, "all") == 0) { win_println(console, THEME_INCOMING, "-", "<< chat message: %s (win %d)", short_from, ui_index); cons_alert(); @@ -371,16 +370,16 @@ cons_show_incoming_message(const char *const short_from, const int win_index, in } void -cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index, int unread) +cons_show_incoming_private_message(const char* const nick, const char* const room, const int win_index, int unread) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int ui_index = win_index; if (ui_index == 10) { ui_index = 0; } - char *priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); + char* priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); if (g_strcmp0(priv_show, "all") == 0) { win_println(console, THEME_INCOMING, "-", "<< private message: %s in %s (win %d)", nick, room, ui_index); cons_alert(); @@ -395,7 +394,7 @@ cons_show_incoming_private_message(const char *const nick, const char *const roo void cons_about(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int rows, cols; getmaxyx(stdscr, rows, cols); @@ -428,7 +427,7 @@ cons_about(void) cons_check_version(FALSE); } - pnoutrefresh(console->layout->win, 0, 0, 1, 0, rows-3, cols-1); + pnoutrefresh(console->layout->win, 0, 0, 1, 0, rows - 3, cols - 1); cons_alert(); } @@ -436,8 +435,8 @@ cons_about(void) void cons_check_version(gboolean not_available_msg) { - ProfWin *console = wins_get_console(); - char *latest_release = release_get_latest(); + ProfWin* console = wins_get_console(); + char* latest_release = release_get_latest(); if (latest_release) { gboolean relase_valid = g_regex_match_simple("^\\d+\\.\\d+\\.\\d+$", latest_release, 0, 0); @@ -461,15 +460,15 @@ cons_check_version(gboolean not_available_msg) } void -cons_show_login_success(ProfAccount *account, gboolean secured) +cons_show_login_success(ProfAccount* account, gboolean secured) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); - const char *fulljid = connection_get_fulljid(); + const char* fulljid = connection_get_fulljid(); win_print(console, THEME_DEFAULT, "-", "%s logged in successfully, ", fulljid); resource_presence_t presence = accounts_get_login_presence(account->name); - const char *presence_str = string_from_resource_presence(presence); + const char* presence_str = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_append(console, presence_colour, "%s", presence_str); @@ -484,9 +483,9 @@ cons_show_login_success(ProfAccount *account, gboolean secured) void cons_show_wins(gboolean unread) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); - GSList *window_strings = wins_create_summary(unread); + GSList* window_strings = wins_create_summary(unread); if (unread && window_strings == NULL) { cons_show("No windows with unread messages."); @@ -497,7 +496,7 @@ cons_show_wins(gboolean unread) cons_show("Active windows:"); } - GSList *curr = window_strings; + GSList* curr = window_strings; while (curr) { if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) { win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data); @@ -512,7 +511,7 @@ cons_show_wins(gboolean unread) } void -cons_show_room_invites(GList *invites) +cons_show_room_invites(GList* invites) { cons_show(""); if (invites == NULL) { @@ -531,21 +530,21 @@ cons_show_room_invites(GList *invites) void cons_show_info(PContact pcontact) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_show_info(console, pcontact); cons_alert(); } void -cons_show_caps(const char *const fulljid, resource_presence_t presence) +cons_show_caps(const char* const fulljid, resource_presence_t presence) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); - EntityCapabilities *caps = caps_lookup(fulljid); + EntityCapabilities* caps = caps_lookup(fulljid); if (caps) { - const char *resource_presence = string_from_resource_presence(presence); + const char* resource_presence = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(console, presence_colour, "-", "%s", fulljid); @@ -553,7 +552,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(console, THEME_DEFAULT, "-", "Identity: "); if (identity->name) { win_append(console, THEME_DEFAULT, "%s", identity->name); @@ -574,7 +573,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(console, THEME_DEFAULT, "-", "Software: %s", software_version->software); } @@ -597,7 +596,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) if (caps->features) { win_println(console, THEME_DEFAULT, "-", "Features:"); - GSList *feature = caps->features; + GSList* feature = caps->features; while (feature) { win_println(console, THEME_DEFAULT, "-", " %s", feature->data); feature = g_slist_next(feature); @@ -615,12 +614,12 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) void cons_show_received_subs(void) { - GList *received = presence_get_subscription_requests(); + GList* received = presence_get_subscription_requests(); if (received == NULL) { cons_show("No outstanding subscription requests."); } else { cons_show("Outstanding subscription requests from:", - g_list_length(received)); + g_list_length(received)); while (received) { cons_show(" %s", received->data); received = g_list_next(received); @@ -634,13 +633,13 @@ cons_show_received_subs(void) void cons_show_sent_subs(void) { - if (roster_has_pending_subscriptions()) { - GSList *contacts = roster_get_contacts(ROSTER_ORD_NAME); + if (roster_has_pending_subscriptions()) { + GSList* contacts = roster_get_contacts(ROSTER_ORD_NAME); PContact contact = NULL; cons_show("Awaiting subscription responses from:"); - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { - contact = (PContact) curr->data; + contact = (PContact)curr->data; if (p_contact_pending_out(contact)) { cons_show(" %s", p_contact_barejid(contact)); } @@ -654,13 +653,13 @@ cons_show_sent_subs(void) } void -cons_show_room_list(GSList *rooms, const char *const conference_node) +cons_show_room_list(GSList* rooms, const char* const conference_node) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (rooms && (g_slist_length(rooms) > 0)) { cons_show("Chat rooms at %s:", conference_node); while (rooms) { - DiscoItem *room = rooms->data; + DiscoItem* room = rooms->data; win_print(console, THEME_DEFAULT, "-", " %s", room->jid); if (room->name) { win_append(console, THEME_DEFAULT, ", (%s)", room->name); @@ -676,9 +675,9 @@ cons_show_room_list(GSList *rooms, const char *const conference_node) } void -cons_show_bookmarks(const GList *list) +cons_show_bookmarks(const GList* list) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (list == NULL) { cons_show(""); @@ -688,10 +687,10 @@ cons_show_bookmarks(const GList *list) cons_show("Bookmarks:"); while (list) { - Bookmark *item = list->data; + Bookmark* item = list->data; theme_item_t presence_colour = THEME_TEXT; - ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); + ProfWin* roomwin = (ProfWin*)wins_get_muc(item->barejid); if (muc_active(item->barejid) && roomwin) { presence_colour = THEME_ONLINE; @@ -730,10 +729,9 @@ cons_show_bookmarks(const GList *list) } void -cons_show_disco_info(const char *jid, GSList *identities, GSList *features) +cons_show_disco_info(const char* jid, GSList* identities, GSList* features) { - if ((identities && (g_slist_length(identities) > 0)) || - (features && (g_slist_length(features) > 0))) { + if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { cons_show(""); cons_show("Service discovery info for %s", jid); @@ -741,8 +739,8 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features) cons_show(" Identities"); } while (identities) { - DiscoIdentity *identity = identities->data; // anme trpe, cat - GString *identity_str = g_string_new(" "); + DiscoIdentity* identity = identities->data; // anme trpe, cat + GString* identity_str = g_string_new(" "); if (identity->name) { identity_str = g_string_append(identity_str, identity->name); identity_str = g_string_append(identity_str, " "); @@ -772,14 +770,14 @@ cons_show_disco_info(const char *jid, GSList *identities, GSList *features) } void -cons_show_disco_items(GSList *items, const char *const jid) +cons_show_disco_items(GSList* items, const char* const jid) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (items && (g_slist_length(items) > 0)) { cons_show(""); cons_show("Service discovery items for %s:", jid); while (items) { - DiscoItem *item = items->data; + DiscoItem* item = items->data; win_print(console, THEME_DEFAULT, "-", " %s", item->jid); if (item->name) { win_append(console, THEME_DEFAULT, ", (%s)", item->name); @@ -796,9 +794,9 @@ cons_show_disco_items(GSList *items, const char *const jid) } void -cons_show_status(const char *const barejid) +cons_show_status(const char* const barejid) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); PContact pcontact = roster_get_contact(barejid); if (pcontact) { @@ -811,9 +809,9 @@ cons_show_status(const char *const barejid) } void -cons_show_room_invite(const char *const invitor, const char * const room, const char *const reason) +cons_show_room_invite(const char* const invitor, const char* const room, const char* const reason) { - char *display_from = NULL; + char* display_from = NULL; PContact contact = roster_get_contact(invitor); if (contact) { if (p_contact_name(contact)) { @@ -847,16 +845,15 @@ cons_show_room_invite(const char *const invitor, const char * const room, const } void -cons_show_account_list(gchar **accounts) +cons_show_account_list(gchar** accounts) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); int size = g_strv_length(accounts); if (size > 0) { cons_show("Accounts:"); int i = 0; for (i = 0; i < size; i++) { - if ((connection_get_status() == JABBER_CONNECTED) && - (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { + if ((connection_get_status() == JABBER_CONNECTED) && (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { resource_presence_t presence = accounts_get_last_presence(accounts[i]); theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence)); win_println(console, presence_colour, "-", "%s", accounts[i]); @@ -874,61 +871,61 @@ cons_show_account_list(gchar **accounts) } void -cons_show_account(ProfAccount *account) +cons_show_account(ProfAccount* account) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); cons_show("Account %s:", account->name); if (account->enabled) { - cons_show ("enabled : TRUE"); + cons_show("enabled : TRUE"); } else { - cons_show ("enabled : FALSE"); + cons_show("enabled : FALSE"); } - cons_show ("jid : %s", account->jid); + cons_show("jid : %s", account->jid); if (account->eval_password) { - cons_show ("eval_password : %s", account->eval_password); + cons_show("eval_password : %s", account->eval_password); } else if (account->password) { - cons_show ("password : [redacted]"); + cons_show("password : [redacted]"); } if (account->resource) { - cons_show ("resource : %s", account->resource); + cons_show("resource : %s", account->resource); } if (account->server) { - cons_show ("server : %s", account->server); + cons_show("server : %s", account->server); } if (account->port != 0) { - cons_show ("port : %d", account->port); + cons_show("port : %d", account->port); } if (account->muc_service) { - cons_show ("muc service : %s", account->muc_service); + cons_show("muc service : %s", account->muc_service); } if (account->muc_nick) { - cons_show ("muc nick : %s", account->muc_nick); + cons_show("muc nick : %s", account->muc_nick); } if (account->tls_policy) { - cons_show ("TLS policy : %s", account->tls_policy); + cons_show("TLS policy : %s", account->tls_policy); } if (account->auth_policy) { - cons_show ("Auth policy : %s", account->auth_policy); + cons_show("Auth policy : %s", account->auth_policy); } if (account->last_presence) { - cons_show ("Last presence : %s", account->last_presence); + cons_show("Last presence : %s", account->last_presence); } if (account->login_presence) { - cons_show ("Login presence : %s", account->login_presence); + cons_show("Login presence : %s", account->login_presence); } if (account->startscript) { - cons_show ("Start script : %s", account->startscript); + cons_show("Start script : %s", account->startscript); } if (account->theme) { - cons_show ("Theme : %s", account->theme); + cons_show("Theme : %s", account->theme); } if (account->otr_policy) { - cons_show ("OTR policy : %s", account->otr_policy); + cons_show("OTR policy : %s", account->otr_policy); } if (g_list_length(account->otr_manual) > 0) { - GString *manual = g_string_new("OTR manual : "); - GList *curr = account->otr_manual; + GString* manual = g_string_new("OTR manual : "); + GList* curr = account->otr_manual; while (curr) { g_string_append(manual, curr->data); if (curr->next) { @@ -940,8 +937,8 @@ cons_show_account(ProfAccount *account) g_string_free(manual, TRUE); } if (g_list_length(account->otr_opportunistic) > 0) { - GString *opportunistic = g_string_new("OTR opportunistic : "); - GList *curr = account->otr_opportunistic; + GString* opportunistic = g_string_new("OTR opportunistic : "); + GList* curr = account->otr_opportunistic; while (curr) { g_string_append(opportunistic, curr->data); if (curr->next) { @@ -953,8 +950,8 @@ cons_show_account(ProfAccount *account) g_string_free(opportunistic, TRUE); } if (g_list_length(account->otr_always) > 0) { - GString *always = g_string_new("OTR always : "); - GList *curr = account->otr_always; + GString* always = g_string_new("OTR always : "); + GList* curr = account->otr_always; while (curr) { g_string_append(always, curr->data); if (curr->next) { @@ -967,27 +964,26 @@ cons_show_account(ProfAccount *account) } if (account->pgp_keyid) { - cons_show ("PGP Key ID : %s", account->pgp_keyid); + cons_show("PGP Key ID : %s", account->pgp_keyid); } - cons_show ("Priority : chat:%d, online:%d, away:%d, xa:%d, dnd:%d", - account->priority_chat, account->priority_online, account->priority_away, - account->priority_xa, account->priority_dnd); + cons_show("Priority : chat:%d, online:%d, away:%d, xa:%d, dnd:%d", + account->priority_chat, account->priority_online, account->priority_away, + account->priority_xa, account->priority_dnd); - if ((connection_get_status() == JABBER_CONNECTED) && - (g_strcmp0(session_get_account_name(), account->name) == 0)) { - GList *resources = connection_get_available_resources(); - GList *ordered_resources = NULL; + if ((connection_get_status() == JABBER_CONNECTED) && (g_strcmp0(session_get_account_name(), account->name) == 0)) { + GList* resources = connection_get_available_resources(); + GList* ordered_resources = NULL; - GList *curr = resources; + GList* curr = resources; if (curr) { win_println(console, THEME_DEFAULT, "-", "Resources:"); // sort in order of availability while (curr) { - Resource *resource = curr->data; + Resource* resource = curr->data; ordered_resources = g_list_insert_sorted(ordered_resources, - resource, (GCompareFunc)resource_compare_availability); + resource, (GCompareFunc)resource_compare_availability); curr = g_list_next(curr); } } @@ -996,8 +992,8 @@ cons_show_account(ProfAccount *account) curr = ordered_resources; while (curr) { - Resource *resource = curr->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = curr->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(console, presence_colour, "-", " %s (%d), %s", resource->name, resource->priority, resource_presence); @@ -1005,14 +1001,14 @@ cons_show_account(ProfAccount *account) win_append(console, presence_colour, ", \"%s\"", resource->status); } win_appendln(console, THEME_DEFAULT, ""); - Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); - EntityCapabilities *caps = caps_lookup(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(account->jid, resource->name); + EntityCapabilities* caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(console, THEME_DEFAULT, "-", " Identity: "); if (identity->name) { win_append(console, THEME_DEFAULT, "%s", identity->name); @@ -1033,7 +1029,7 @@ cons_show_account(ProfAccount *account) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(console, THEME_DEFAULT, "-", " Software: %s", software_version->software); } @@ -1066,17 +1062,17 @@ cons_show_account(ProfAccount *account) } void -cons_show_aliases(GList *aliases) +cons_show_aliases(GList* aliases) { if (aliases == NULL) { cons_show("No aliases configured."); return; } - GList *curr = aliases; + GList* curr = aliases; cons_show("Command aliases:"); while (curr) { - ProfAlias *alias = curr->data; + ProfAlias* alias = curr->data; cons_show(" /%s -> %s", alias->name, alias->value); curr = g_list_next(curr); } @@ -1086,7 +1082,7 @@ cons_show_aliases(GList *aliases) void cons_theme_setting(void) { - char *theme = prefs_get_string(PREF_THEME); + char* theme = prefs_get_string(PREF_THEME); if (theme == NULL) { cons_show("Theme (/theme) : default"); } else { @@ -1180,15 +1176,15 @@ cons_titlebar_setting(void) void cons_console_setting(void) { - char *chatsetting = prefs_get_string(PREF_CONSOLE_CHAT); + char* chatsetting = prefs_get_string(PREF_CONSOLE_CHAT); cons_show("Console chat messages (/console) : %s", chatsetting); g_free(chatsetting); - char *mucsetting = prefs_get_string(PREF_CONSOLE_MUC); + char* mucsetting = prefs_get_string(PREF_CONSOLE_MUC); cons_show("Console MUC messages (/console) : %s", mucsetting); g_free(mucsetting); - char *privsetting = prefs_get_string(PREF_CONSOLE_PRIVATE); + char* privsetting = prefs_get_string(PREF_CONSOLE_PRIVATE); cons_show("Console private messages (/console) : %s", privsetting); g_free(privsetting); } @@ -1201,9 +1197,9 @@ cons_presence_setting(void) else cons_show("Titlebar presence (/presence) : OFF"); - char *console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *chat = prefs_get_string(PREF_STATUSES_CHAT); - char *room = prefs_get_string(PREF_STATUSES_MUC); + char* console = prefs_get_string(PREF_STATUSES_CONSOLE); + char* chat = prefs_get_string(PREF_STATUSES_CHAT); + char* room = prefs_get_string(PREF_STATUSES_MUC); cons_show("Console presence (/presence) : %s", console); cons_show("Chat presence (/presence) : %s", chat); @@ -1303,7 +1299,7 @@ cons_rooms_cache_setting(void) void cons_autoconnect_setting(void) { - char *pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); + char* pref_connect_account = prefs_get_string(PREF_CONNECT_ACCOUNT); if (pref_connect_account) cons_show("Autoconnect (/autoconnect) : %s", pref_connect_account); else @@ -1315,56 +1311,56 @@ cons_autoconnect_setting(void) void cons_time_setting(void) { - char *pref_time_console = prefs_get_string(PREF_TIME_CONSOLE); + char* pref_time_console = prefs_get_string(PREF_TIME_CONSOLE); if (g_strcmp0(pref_time_console, "off") == 0) cons_show("Time console (/time) : OFF"); else cons_show("Time console (/time) : %s", pref_time_console); g_free(pref_time_console); - char *pref_time_chat = prefs_get_string(PREF_TIME_CHAT); + char* pref_time_chat = prefs_get_string(PREF_TIME_CHAT); if (g_strcmp0(pref_time_chat, "off") == 0) cons_show("Time chat (/time) : OFF"); else cons_show("Time chat (/time) : %s", pref_time_chat); g_free(pref_time_chat); - char *pref_time_muc = prefs_get_string(PREF_TIME_MUC); + char* pref_time_muc = prefs_get_string(PREF_TIME_MUC); if (g_strcmp0(pref_time_muc, "off") == 0) cons_show("Time MUC (/time) : OFF"); else cons_show("Time MUC (/time) : %s", pref_time_muc); g_free(pref_time_muc); - char *pref_time_conf = prefs_get_string(PREF_TIME_CONFIG); + char* pref_time_conf = prefs_get_string(PREF_TIME_CONFIG); if (g_strcmp0(pref_time_conf, "off") == 0) cons_show("Time config (/time) : OFF"); else cons_show("Time config (/time) : %s", pref_time_conf); g_free(pref_time_conf); - char *pref_time_private = prefs_get_string(PREF_TIME_PRIVATE); + char* pref_time_private = prefs_get_string(PREF_TIME_PRIVATE); if (g_strcmp0(pref_time_private, "off") == 0) cons_show("Time private (/time) : OFF"); else cons_show("Time private (/time) : %s", pref_time_private); g_free(pref_time_private); - char *pref_time_xml = prefs_get_string(PREF_TIME_XMLCONSOLE); + char* pref_time_xml = prefs_get_string(PREF_TIME_XMLCONSOLE); if (g_strcmp0(pref_time_xml, "off") == 0) cons_show("Time XML Console (/time) : OFF"); else cons_show("Time XML Console (/time) : %s", pref_time_xml); g_free(pref_time_xml); - char *pref_time_statusbar = prefs_get_string(PREF_TIME_STATUSBAR); + char* pref_time_statusbar = prefs_get_string(PREF_TIME_STATUSBAR); if (g_strcmp0(pref_time_statusbar, "off") == 0) cons_show("Time statusbar (/time) : OFF"); else cons_show("Time statusbar (/time) : %s", pref_time_statusbar); g_free(pref_time_statusbar); - char *pref_time_lastactivity = prefs_get_string(PREF_TIME_LASTACTIVITY); + char* pref_time_lastactivity = prefs_get_string(PREF_TIME_LASTACTIVITY); cons_show("Time last activity (/time) : %s", pref_time_lastactivity); g_free(pref_time_lastactivity); } @@ -1491,7 +1487,7 @@ cons_roster_setting(void) else cons_show("Roster unsubscribed (/roster) : hide"); - char *count = prefs_get_string(PREF_ROSTER_COUNT); + char* count = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(count, "off") == 0) { cons_show("Roster count (/roster) : OFF"); } else { @@ -1504,15 +1500,15 @@ cons_roster_setting(void) else cons_show("Roster count zero (/roster) : OFF"); - char *by = prefs_get_string(PREF_ROSTER_BY); + char* by = prefs_get_string(PREF_ROSTER_BY); cons_show("Roster by (/roster) : %s", by); g_free(by); - char *order = prefs_get_string(PREF_ROSTER_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ORDER); cons_show("Roster order (/roster) : %s", order); g_free(order); - char *unread = prefs_get_string(PREF_ROSTER_UNREAD); + char* unread = prefs_get_string(PREF_ROSTER_UNREAD); if (g_strcmp0(unread, "before") == 0) { cons_show("Roster unread (/roster) : before"); } else if (g_strcmp0(unread, "after") == 0) { @@ -1527,7 +1523,7 @@ cons_roster_setting(void) else cons_show("Roster rooms (/roster) : hide"); - char *priv = prefs_get_string(PREF_ROSTER_PRIVATE); + char* priv = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(priv, "room") == 0) { cons_show("Roster private (/roster) : room"); } else if (g_strcmp0(priv, "group") == 0) { @@ -1537,23 +1533,23 @@ cons_roster_setting(void) } g_free(priv); - char *rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS); + char* rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS); cons_show("Roster rooms position (/roster) : %s", rooms_pos); g_free(rooms_pos); - char *rooms_by = prefs_get_string(PREF_ROSTER_ROOMS_BY); + char* rooms_by = prefs_get_string(PREF_ROSTER_ROOMS_BY); cons_show("Roster rooms by (/roster) : %s", rooms_by); g_free(rooms_by); - char *rooms_use = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); + char* rooms_use = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); cons_show("Roster rooms use (/roster) : %s", rooms_use); g_free(rooms_use); - char *rooms_order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); + char* rooms_order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); cons_show("Roster rooms order (/roster) : %s", rooms_order); g_free(rooms_order); - char *roomsunread = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); + char* roomsunread = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); if (g_strcmp0(roomsunread, "before") == 0) { cons_show("Roster rooms unread (/roster) : before"); } else if (g_strcmp0(roomsunread, "after") == 0) { @@ -1768,7 +1764,6 @@ cons_receipts_setting(void) cons_show("Send receipts (/receipts) : ON"); else cons_show("Send receipts (/receipts) : OFF"); - } void @@ -1827,7 +1822,7 @@ cons_statusbar_setting(void) cons_show("Max tab length (/statusbar) : %d", pref_len); } - char *pref_self = prefs_get_string(PREF_STATUSBAR_SELF); + char* pref_self = prefs_get_string(PREF_STATUSBAR_SELF); if (g_strcmp0(pref_self, "off") == 0) { cons_show("Self statusbar display (/statusbar) : OFF"); } else { @@ -1835,11 +1830,11 @@ cons_statusbar_setting(void) } g_free(pref_self); - char *pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT); + char* pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT); cons_show("Chat tab display (/statusbar) : %s", pref_chat); g_free(pref_chat); - char *pref_room = prefs_get_string(PREF_STATUSBAR_ROOM); + char* pref_room = prefs_get_string(PREF_STATUSBAR_ROOM); cons_show("Room tab display (/statusbar) : %s", pref_room); g_free(pref_room); } @@ -1847,7 +1842,7 @@ cons_statusbar_setting(void) void cons_winpos_setting(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); cons_show("Title bar postion (/titlebar) : %d", placement->titlebar_pos); cons_show("Main window postion (/mainwin) : %d", placement->mainwin_pos); cons_show("Status bar postion (/statusbar) : %d", placement->statusbar_pos); @@ -1900,7 +1895,7 @@ cons_show_log_prefs(void) void cons_autoaway_setting(void) { - char *pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE); + char* pref_autoaway_mode = prefs_get_string(PREF_AUTOAWAY_MODE); if (strcmp(pref_autoaway_mode, "off") == 0) { cons_show("Autoaway (/autoaway mode) : OFF"); } else { @@ -1924,7 +1919,7 @@ cons_autoaway_setting(void) cons_show("Autoaway xa minutes (/autoaway time) : %d minutes", xa_time); } - char *pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE); + char* pref_autoaway_message = prefs_get_string(PREF_AUTOAWAY_MESSAGE); if ((pref_autoaway_message == NULL) || (strcmp(pref_autoaway_message, "") == 0)) { cons_show("Autoaway away message (/autoaway message) : OFF"); } else { @@ -1932,7 +1927,7 @@ cons_autoaway_setting(void) } g_free(pref_autoaway_message); - char *pref_autoxa_message = prefs_get_string(PREF_AUTOXA_MESSAGE); + char* pref_autoxa_message = prefs_get_string(PREF_AUTOXA_MESSAGE); if ((pref_autoxa_message == NULL) || (strcmp(pref_autoxa_message, "") == 0)) { cons_show("Autoaway xa message (/autoaway message) : OFF"); } else { @@ -2001,7 +1996,7 @@ cons_autoping_setting(void) void cons_color_setting(void) { - char *color_pref = prefs_get_string(PREF_COLOR_NICK); + char* color_pref = prefs_get_string(PREF_COLOR_NICK); if (!color_pref) { cons_show("Consistent color generation for nicks (/color) : OFF"); @@ -2058,7 +2053,7 @@ cons_correction_setting(void) cons_show("Last Message Correction (XEP-0308) (/correction) : OFF"); } - char *cc = prefs_get_correction_char(); + char* cc = prefs_get_correction_char(); cons_show("LMC indication char (/correction char) : %s", cc); free(cc); } @@ -2066,17 +2061,17 @@ cons_correction_setting(void) void cons_executable_setting(void) { - char *avatar = prefs_get_string(PREF_AVATAR_CMD); + char* avatar = prefs_get_string(PREF_AVATAR_CMD); cons_show("Default '/avatar open' command (/executable avatar) : %s", avatar); g_free(avatar); //TODO: there needs to be a way to get all the "locales"/schemes so we can //display the defualt openers for all filetypes - gchar **urlopen = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, ""); + gchar** urlopen = prefs_get_string_list_with_option(PREF_URL_OPEN_CMD, ""); cons_show("Default '/url open' command (/executable urlopen) : %s", urlopen[1]); g_strfreev(urlopen); - char *urlsave = prefs_get_string(PREF_URL_SAVE_CMD); + char* urlsave = prefs_get_string(PREF_URL_SAVE_CMD); cons_show("Default '/url save' command (/executable urlsave) : %s", urlsave); g_free(urlsave); } @@ -2110,11 +2105,11 @@ cons_show_otr_prefs(void) cons_show("OTR preferences:"); cons_show(""); - char *policy_value = prefs_get_string(PREF_OTR_POLICY); + char* policy_value = prefs_get_string(PREF_OTR_POLICY); cons_show("OTR policy (/otr policy) : %s", policy_value); g_free(policy_value); - char *log_value = prefs_get_string(PREF_OTR_LOG); + char* log_value = prefs_get_string(PREF_OTR_LOG); if (strcmp(log_value, "on") == 0) { cons_show("OTR logging (/otr log) : ON"); } else if (strcmp(log_value, "off") == 0) { @@ -2124,7 +2119,7 @@ cons_show_otr_prefs(void) } g_free(log_value); - char *ch = prefs_get_otr_char(); + char* ch = prefs_get_otr_char(); cons_show("OTR char (/otr char) : %s", ch); free(ch); @@ -2143,7 +2138,7 @@ cons_show_pgp_prefs(void) cons_show("PGP preferences:"); cons_show(""); - char *log_value = prefs_get_string(PREF_PGP_LOG); + char* log_value = prefs_get_string(PREF_PGP_LOG); if (strcmp(log_value, "on") == 0) { cons_show("PGP logging (/pgp log) : ON"); } else if (strcmp(log_value, "off") == 0) { @@ -2153,7 +2148,7 @@ cons_show_pgp_prefs(void) } g_free(log_value); - char *ch = prefs_get_pgp_char(); + char* ch = prefs_get_pgp_char(); cons_show("PGP char (/pgp char) : %s", ch); free(ch); @@ -2172,11 +2167,11 @@ cons_show_omemo_prefs(void) cons_show("OMEMO preferences:"); cons_show(""); - char *policy_value = prefs_get_string(PREF_OMEMO_POLICY); + char* policy_value = prefs_get_string(PREF_OMEMO_POLICY); cons_show("OMEMO policy (/omemo policy) : %s", policy_value); g_free(policy_value); - char *log_value = prefs_get_string(PREF_OMEMO_LOG); + char* log_value = prefs_get_string(PREF_OMEMO_LOG); if (strcmp(log_value, "on") == 0) { cons_show("OMEMO logging (/omemo log) : ON"); } else if (strcmp(log_value, "off") == 0) { @@ -2186,7 +2181,7 @@ cons_show_omemo_prefs(void) } g_free(log_value); - char *ch = prefs_get_omemo_char(); + char* ch = prefs_get_omemo_char(); cons_show("OMEMO char (/omemo char) : %s", ch); free(ch); @@ -2200,7 +2195,7 @@ cons_show_omemo_prefs(void) } void -cons_show_themes(GSList *themes) +cons_show_themes(GSList* themes) { cons_show(""); @@ -2218,7 +2213,7 @@ cons_show_themes(GSList *themes) } void -cons_show_scripts(GSList *scripts) +cons_show_scripts(GSList* scripts) { cons_show(""); @@ -2236,7 +2231,7 @@ cons_show_scripts(GSList *scripts) } void -cons_show_script(const char *const script, GSList *commands) +cons_show_script(const char* const script, GSList* commands) { cons_show(""); @@ -2306,7 +2301,7 @@ cons_help(void) void cons_navigation_help(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); win_println(console, THEME_HELP_HEADER, "-", "Navigation"); cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); @@ -2323,7 +2318,7 @@ cons_navigation_help(void) } void -cons_show_roster_group(const char *const group, GSList *list) +cons_show_roster_group(const char* const group, GSList* list) { cons_show(""); @@ -2339,7 +2334,7 @@ cons_show_roster_group(const char *const group, GSList *list) } void -cons_show_roster(GSList *list) +cons_show_roster(GSList* list) { cons_show(""); cons_show("Roster: jid (nick) - subscription - groups"); @@ -2350,39 +2345,38 @@ cons_show_roster(GSList *list) } void -cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) +cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity) { - const char *show = string_from_resource_presence(resource->presence); - char *display_str = p_contact_create_display_string(contact, resource->name); + const char* show = string_from_resource_presence(resource->presence); + char* display_str = p_contact_create_display_string(contact, resource->name); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_show_status_string(console, display_str, show, resource->status, last_activity, - "++", "online"); + "++", "online"); free(display_str); } void -cons_show_contact_offline(PContact contact, char *resource, char *status) +cons_show_contact_offline(PContact contact, char* resource, char* status) { - char *display_str = p_contact_create_display_string(contact, resource); + char* display_str = p_contact_create_display_string(contact, resource); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_show_status_string(console, display_str, "offline", status, NULL, "--", - "offline"); + "offline"); free(display_str); } void -cons_show_contacts(GSList *list) +cons_show_contacts(GSList* list) { - ProfWin *console = wins_get_console(); - GSList *curr = list; + ProfWin* console = wins_get_console(); + GSList* curr = list; - while(curr) { + while (curr) { PContact contact = curr->data; - if ((strcmp(p_contact_subscription(contact), "to") == 0) || - (strcmp(p_contact_subscription(contact), "both") == 0)) { + 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); @@ -2393,14 +2387,14 @@ cons_show_contacts(GSList *list) void cons_alert(void) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->type != WIN_CONSOLE) { status_bar_new(1, WIN_CONSOLE, "console"); } } char* -cons_get_string(ProfConsoleWin *conswin) +cons_get_string(ProfConsoleWin* conswin) { assert(conswin != NULL); @@ -2408,17 +2402,17 @@ cons_get_string(ProfConsoleWin *conswin) } void -_cons_theme_bar_prop(theme_item_t theme, char *prop) +_cons_theme_bar_prop(theme_item_t theme, char* prop) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); - GString *propstr = g_string_new(" "); + GString* propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); win_print(console, THEME_TEXT, "-", "%s", propstr->str); g_string_free(propstr, TRUE); - GString *valstr = g_string_new(" "); - char *setting = theme_get_string(prop); + GString* valstr = g_string_new(" "); + char* setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); win_append(console, theme, "%s", valstr->str); @@ -2427,17 +2421,17 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) } void -_cons_theme_prop(theme_item_t theme, char *prop) +_cons_theme_prop(theme_item_t theme, char* prop) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); - GString *propstr = g_string_new(" "); + GString* propstr = g_string_new(" "); g_string_append_printf(propstr, "%-24s", prop); win_print(console, THEME_TEXT, "-", "%s", propstr->str); g_string_free(propstr, TRUE); - GString *valstr = g_string_new(""); - char *setting = theme_get_string(prop); + GString* valstr = g_string_new(""); + char* setting = theme_get_string(prop); g_string_append_printf(valstr, "%s", setting); theme_free_string(setting); win_appendln(console, theme, "%s", valstr->str); @@ -2558,32 +2552,32 @@ cons_theme_colours(void) */ - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show("Available colours:"); - win_print(console, THEME_WHITE, "-", " white "); - win_appendln(console, THEME_WHITE_BOLD, " bold_white"); + win_print(console, THEME_WHITE, "-", " white "); + win_appendln(console, THEME_WHITE_BOLD, " bold_white"); - win_print(console, THEME_GREEN, "-", " green "); - win_appendln(console, THEME_GREEN_BOLD, " bold_green"); + win_print(console, THEME_GREEN, "-", " green "); + win_appendln(console, THEME_GREEN_BOLD, " bold_green"); - win_print(console, THEME_RED, "-", " red "); - win_appendln(console, THEME_RED_BOLD, " bold_red"); + win_print(console, THEME_RED, "-", " red "); + win_appendln(console, THEME_RED_BOLD, " bold_red"); - win_print(console, THEME_YELLOW, "-", " yellow "); - win_appendln(console, THEME_YELLOW_BOLD, " bold_yellow"); + win_print(console, THEME_YELLOW, "-", " yellow "); + win_appendln(console, THEME_YELLOW_BOLD, " bold_yellow"); - win_print(console, THEME_BLUE, "-", " blue "); - win_appendln(console, THEME_BLUE_BOLD, " bold_blue"); + win_print(console, THEME_BLUE, "-", " blue "); + win_appendln(console, THEME_BLUE_BOLD, " bold_blue"); - win_print(console, THEME_CYAN, "-", " cyan "); - win_appendln(console, THEME_CYAN_BOLD, " bold_cyan"); + win_print(console, THEME_CYAN, "-", " cyan "); + win_appendln(console, THEME_CYAN_BOLD, " bold_cyan"); - win_print(console, THEME_MAGENTA, "-", " magenta "); - win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta"); + win_print(console, THEME_MAGENTA, "-", " magenta "); + win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta"); - win_print(console, THEME_BLACK, "-", " black "); - win_appendln(console, THEME_BLACK_BOLD, " bold_black"); + win_print(console, THEME_BLACK, "-", " black "); + win_appendln(console, THEME_BLACK_BOLD, " bold_black"); if (COLORS >= 256) { cons_show("Your terminal supports 256 colours."); @@ -2598,7 +2592,7 @@ cons_theme_colours(void) static void _cons_splash_logo(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_DEFAULT, "-", "Welcome to"); win_println(console, THEME_SPLASH, "-", " ___ _ "); @@ -2622,14 +2616,14 @@ _cons_splash_logo(void) } void -_show_roster_contacts(GSList *list, gboolean show_groups) +_show_roster_contacts(GSList* list, gboolean show_groups) { - ProfWin *console = wins_get_console(); - GSList *curr = list; - while(curr) { + ProfWin* console = wins_get_console(); + GSList* curr = list; + while (curr) { PContact contact = curr->data; - GString *title = g_string_new(" "); + GString* title = g_string_new(" "); title = g_string_append(title, p_contact_barejid(contact)); if (p_contact_name(contact)) { title = g_string_append(title, " ("); @@ -2637,7 +2631,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) title = g_string_append(title, ")"); } - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); theme_item_t presence_colour = THEME_TEXT; if (p_contact_subscribed(contact)) { presence_colour = theme_main_presence_attrs(presence); @@ -2649,7 +2643,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); win_append(console, THEME_DEFAULT, " - "); - GString *sub = g_string_new(""); + GString* sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { sub = g_string_append(sub, ", request sent"); @@ -2672,9 +2666,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(sub, TRUE); if (show_groups) { - GSList *groups = p_contact_groups(contact); + GSList* groups = p_contact_groups(contact); if (groups) { - GString *groups_str = g_string_new(" - "); + GString* groups_str = g_string_new(" - "); while (groups) { g_string_append(groups_str, groups->data); if (g_slist_next(groups)) { @@ -2694,7 +2688,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } void -cons_show_bookmarks_ignore(gchar **list, gsize len) +cons_show_bookmarks_ignore(gchar** list, gsize len) { if (len == 0) { cons_show(""); @@ -2703,12 +2697,12 @@ cons_show_bookmarks_ignore(gchar **list, gsize len) } int i; - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); cons_show(""); cons_show("Ignored bookmarks:"); - for(i=0; i<len; i++) { + for (i = 0; i < len; i++) { win_print(console, THEME_DEFAULT, "-", " %s", list[i]); win_newline(console); } diff --git a/src/ui/core.c b/src/ui/core.c index b2256c56..e61de7e7 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -80,13 +80,13 @@ #include "otr/otr.h" #endif -static char *win_title; +static char* win_title; static int inp_size; static gboolean perform_resize = FALSE; -static GTimer *ui_idle_time; +static GTimer* ui_idle_time; #ifdef HAVE_LIBXSS -static Display *display; +static Display* display; #endif static void _ui_draw_term_title(void); @@ -114,7 +114,7 @@ ui_init(void) #endif ui_idle_time = g_timer_new(); inp_size = 0; - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); win_update_virtual(window); } @@ -127,7 +127,7 @@ ui_sigwinch_handler(int sig) void ui_update(void) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->layout->paged == 0) { win_move_to_end(current); } @@ -155,7 +155,7 @@ ui_get_idle_time(void) { // if compiled with libxss, get the x sessions idle time #ifdef HAVE_LIBXSS - XScreenSaverInfo *info = XScreenSaverAllocInfo(); + XScreenSaverInfo* info = XScreenSaverAllocInfo(); if (info && display) { XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); unsigned long result = info->idle; @@ -202,7 +202,7 @@ ui_resize(void) wins_resize_all(); status_bar_resize(); inp_win_resize(); - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); win_update_virtual(window); } @@ -226,10 +226,10 @@ ui_load_colours(void) } void -ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) +ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity) { - char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); + char* show_console = prefs_get_string(PREF_STATUSES_CONSOLE); + char* show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); PContact contact = roster_get_contact(barejid); // show nothing @@ -243,21 +243,21 @@ ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) if (g_strcmp0(show_console, "all") == 0) { cons_show_contact_online(contact, resource, last_activity); - // show in console of "online" and presence online + // show in console of "online" and presence online } else if (g_strcmp0(show_console, "online") == 0 && resource->presence == RESOURCE_ONLINE) { cons_show_contact_online(contact, resource, last_activity); } // show in chat win if "all" if (g_strcmp0(show_chat_win, "all") == 0) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_online(chatwin, resource, last_activity); } - // show in char win if "online" and presence online + // show in char win if "online" and presence online } else if (g_strcmp0(show_chat_win, "online") == 0 && resource->presence == RESOURCE_ONLINE) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_online(chatwin, resource, last_activity); } @@ -268,28 +268,28 @@ ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) } void -ui_contact_typing(const char *const barejid, const char *const resource) +ui_contact_typing(const char* const barejid, const char* const resource) { - ProfChatWin *chatwin = wins_get_chat(barejid); - ProfWin *window = (ProfWin*) chatwin; - ChatSession *session = chat_session_get(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); + ProfWin* window = (ProfWin*)chatwin; + ChatSession* session = chat_session_get(barejid); if (prefs_get_boolean(PREF_INTYPE)) { // no chat window for user if (chatwin == NULL) { cons_show_typing(barejid); - // have chat window but not currently in it + // have chat window but not currently in it } else if (!wins_is_current(window)) { cons_show_typing(barejid); - // in chat window with user, no session or session with resource + // in chat window with user, no session or session with resource } else if (!session || (session && g_strcmp0(session->resource, resource) == 0)) { title_bar_set_typing(TRUE); int num = wins_get_num(window); status_bar_active(num, WIN_CHAT, chatwin->barejid); - } + } } if (prefs_get_boolean(PREF_NOTIFY_TYPING)) { @@ -297,9 +297,9 @@ ui_contact_typing(const char *const barejid, const char *const resource) if (window) { is_current = wins_is_current(window); } - if ( !is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT)) ) { + if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_TYPING_CURRENT))) { PContact contact = roster_get_contact(barejid); - char const *display_usr = NULL; + char const* display_usr = NULL; if (contact) { if (p_contact_name(contact)) { display_usr = p_contact_name(contact); @@ -315,7 +315,7 @@ ui_contact_typing(const char *const barejid, const char *const resource) } void -ui_roster_add(const char *const barejid, const char *const name) +ui_roster_add(const char* const barejid, const char* const name) { if (name) { cons_show("Roster item added: %s (%s)", barejid, name); @@ -326,42 +326,42 @@ ui_roster_add(const char *const barejid, const char *const name) } void -ui_roster_remove(const char *const barejid) +ui_roster_remove(const char* const barejid) { cons_show("Roster item removed: %s", barejid); rosterwin_roster(); } void -ui_contact_already_in_group(const char *const contact, const char *const group) +ui_contact_already_in_group(const char* const contact, const char* const group) { cons_show("%s already in group %s", contact, group); rosterwin_roster(); } void -ui_contact_not_in_group(const char *const contact, const char *const group) +ui_contact_not_in_group(const char* const contact, const char* const group) { cons_show("%s is not currently in group %s", contact, group); rosterwin_roster(); } void -ui_group_added(const char *const contact, const char *const group) +ui_group_added(const char* const contact, const char* const group) { cons_show("%s added to group %s", contact, group); rosterwin_roster(); } void -ui_group_removed(const char *const contact, const char *const group) +ui_group_removed(const char* const contact, const char* const group) { cons_show("%s removed from group %s", contact, group); rosterwin_roster(); } void -ui_handle_login_account_success(ProfAccount *account, gboolean secured) +ui_handle_login_account_success(ProfAccount* account, gboolean secured) { if (account->theme) { if (theme_load(account->theme, false)) { @@ -394,7 +394,7 @@ ui_handle_login_account_success(ProfAccount *account, gboolean secured) void ui_update_presence(const resource_presence_t resource_presence, - const char *const message, const char *const show) + const char* const message, const char* const show) { contact_presence_t contact_presence = contact_presence_from_resource_presence(resource_presence); title_bar_set_presence(contact_presence); @@ -407,24 +407,24 @@ ui_update_presence(const resource_presence_t resource_presence, } void -ui_handle_recipient_error(const char *const recipient, const char *const err_msg) +ui_handle_recipient_error(const char* const recipient, const char* const err_msg) { // always show in console cons_show_error("Error from %s: %s", recipient, err_msg); - ProfChatWin *chatwin = wins_get_chat(recipient); + ProfChatWin* chatwin = wins_get_chat(recipient); if (chatwin) { win_println((ProfWin*)chatwin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } - ProfMucWin *mucwin = wins_get_muc(recipient); + ProfMucWin* mucwin = wins_get_muc(recipient); if (mucwin) { win_println((ProfWin*)mucwin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; } - ProfPrivateWin *privatewin = wins_get_private(recipient); + ProfPrivateWin* privatewin = wins_get_private(recipient); if (privatewin) { win_println((ProfWin*)privatewin, THEME_ERROR, "!", "Error from %s: %s", recipient, err_msg); return; @@ -432,9 +432,9 @@ ui_handle_recipient_error(const char *const recipient, const char *const err_msg } void -ui_handle_otr_error(const char *const barejid, const char *const message) +ui_handle_otr_error(const char* const barejid, const char* const message) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { win_println((ProfWin*)chatwin, THEME_ERROR, "!", "%s", message); } else { @@ -443,9 +443,9 @@ ui_handle_otr_error(const char *const barejid, const char *const message) } void -ui_handle_error(const char *const err_msg) +ui_handle_error(const char* const err_msg) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_printf(msg, "Error %s", err_msg); cons_show_error(msg->str); @@ -454,9 +454,9 @@ ui_handle_error(const char *const err_msg) } void -ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)) +ui_invalid_command_usage(const char* const cmd, void (*setting_func)(void)) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_printf(msg, "Invalid usage, see '/help %s' for details.", &cmd[1]); if (setting_func) { @@ -465,7 +465,7 @@ ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)) } else { cons_show(""); cons_show(msg->str); - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if (current->type == WIN_CHAT) { win_println(current, THEME_DEFAULT, "-", "%s", msg->str); } @@ -488,16 +488,16 @@ ui_disconnected(void) void ui_close_connected_win(int index) { - ProfWin *window = wins_get_by_num(index); + ProfWin* window = wins_get_by_num(index); if (window) { if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); presence_leave_chat_room(mucwin->roomjid); muc_leave(mucwin->roomjid); ui_leave_room(mucwin->roomjid); } else if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); #ifdef HAVE_LIBOTR if (chatwin->is_otr) { @@ -516,8 +516,8 @@ ui_close_all_wins(void) int count = 0; jabber_conn_status_t conn_status = connection_get_status(); - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); @@ -543,8 +543,8 @@ ui_close_read_wins(void) int count = 0; jabber_conn_status_t conn_status = connection_get_status(); - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); @@ -567,14 +567,14 @@ ui_close_read_wins(void) void ui_redraw_all_room_rosters(void) { - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_MUC && win_has_active_subwin(window)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); occupantswin_occupants(mucwin->roomjid); } @@ -588,14 +588,14 @@ ui_redraw_all_room_rosters(void) void ui_hide_all_room_rosters(void) { - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_MUC && win_has_active_subwin(window)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin_hide_occupants(mucwin); } @@ -609,14 +609,14 @@ ui_hide_all_room_rosters(void) void ui_show_all_room_rosters(void) { - GList *win_nums = wins_get_nums(); - GList *curr = win_nums; + GList* win_nums = wins_get_nums(); + GList* curr = win_nums; while (curr) { int num = GPOINTER_TO_INT(curr->data); - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_MUC && !win_has_active_subwin(window)) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin_show_occupants(mucwin); } @@ -630,10 +630,10 @@ ui_show_all_room_rosters(void) gboolean ui_win_has_unsaved_form(int num) { - ProfWin *window = wins_get_by_num(num); + ProfWin* window = wins_get_by_num(num); if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); return confwin->form->modified; } else { @@ -642,7 +642,7 @@ ui_win_has_unsaved_form(int num) } void -ui_focus_win(ProfWin *window) +ui_focus_win(ProfWin* window) { assert(window != NULL); @@ -650,35 +650,34 @@ ui_focus_win(ProfWin *window) return; } - ProfWin *old_current = wins_get_current(); + ProfWin* old_current = wins_get_current(); if (old_current->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)old_current; + ProfConfWin* confwin = (ProfConfWin*)old_current; cmd_ac_remove_form_fields(confwin->form); } if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; cmd_ac_add_form_fields(confwin->form); } // check for trackbar last position separator - switch (old_current->type) - { + switch (old_current->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)old_current; + ProfChatWin* chatwin = (ProfChatWin*)old_current; win_remove_entry_message(old_current, chatwin->barejid); break; } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)old_current; + ProfMucWin* mucwin = (ProfMucWin*)old_current; win_remove_entry_message(old_current, mucwin->roomjid); break; } case WIN_PRIVATE: { - ProfPrivateWin *privwin = (ProfPrivateWin*)old_current; + ProfPrivateWin* privwin = (ProfPrivateWin*)old_current; win_remove_entry_message(old_current, privwin->fulljid); break; } @@ -697,7 +696,7 @@ ui_focus_win(ProfWin *window) } status_bar_current(i); - char *identifier = win_get_tab_identifier(window); + char* identifier = win_get_tab_identifier(window); status_bar_active(i, window->type, identifier); free(identifier); } @@ -705,9 +704,9 @@ ui_focus_win(ProfWin *window) void ui_close_win(int index) { - ProfWin *window = wins_get_by_num(index); + ProfWin* window = wins_get_by_num(index); if (window && window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; if (confwin->form) { cmd_ac_remove_form_fields(confwin->form); } @@ -725,17 +724,17 @@ ui_prune_wins(void) jabber_conn_status_t conn_status = connection_get_status(); gboolean pruned = FALSE; - GSList *wins = wins_get_prune_wins(); + GSList* wins = wins_get_prune_wins(); if (wins) { pruned = TRUE; } - GSList *curr = wins; + GSList* curr = wins; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { if (conn_status == JABBER_CONNECTED) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; chat_session_remove(chatwin->barejid); } } @@ -759,13 +758,13 @@ ui_prune_wins(void) } void -ui_print_system_msg_from_recipient(const char *const barejid, const char *message) +ui_print_system_msg_from_recipient(const char* const barejid, const char* message) { if (barejid == NULL || message == NULL) return; - ProfChatWin *chatwin = wins_get_chat(barejid); - ProfWin *window = (ProfWin*)chatwin; + ProfChatWin* chatwin = wins_get_chat(barejid); + ProfWin* window = (ProfWin*)chatwin; if (window == NULL) { window = wins_new_chat(barejid); if (window) { @@ -782,19 +781,19 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag } void -ui_room_join(const char *const roomjid, gboolean focus) +ui_room_join(const char* const roomjid, gboolean focus) { - ProfMucWin *mucwin = wins_get_muc(roomjid); + ProfMucWin* mucwin = wins_get_muc(roomjid); if (mucwin == NULL) { mucwin = mucwin_new(roomjid); } - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; - char *nick = muc_nick(roomjid); + char* nick = muc_nick(roomjid); win_print(window, 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); + char* role = muc_role_str(roomjid); + char* affiliation = muc_affiliation_str(roomjid); if (role) { win_append(window, THEME_ROOMINFO, ", role: %s", role); } @@ -809,14 +808,14 @@ ui_room_join(const char *const roomjid, gboolean focus) } else { int num = wins_get_num(window); status_bar_active(num, WIN_MUC, mucwin->roomjid); - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_TYPING, "!", "-> Autojoined %s as %s (%d).", roomjid, nick, num); } - GList *privwins = wins_get_private_chats(roomjid); - GList *curr = privwins; + GList* privwins = wins_get_private_chats(roomjid); + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_joined(privwin); curr = g_list_next(curr); } @@ -824,17 +823,17 @@ ui_room_join(const char *const roomjid, gboolean focus) } void -ui_switch_to_room(const char *const roomjid) +ui_switch_to_room(const char* const roomjid) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); ui_focus_win(window); } void -ui_room_destroy(const char *const roomjid) +ui_room_destroy(const char* const roomjid) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window == NULL) { log_error("Received room destroy result, but no window open for %s.", roomjid); } else { @@ -843,9 +842,9 @@ ui_room_destroy(const char *const roomjid) cons_show("Room destroyed: %s", roomjid); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_destroyed(privwin); curr = g_list_next(curr); } @@ -853,37 +852,36 @@ ui_room_destroy(const char *const roomjid) } void -ui_leave_room(const char *const roomjid) +ui_leave_room(const char* const roomjid) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window) { int num = wins_get_num(window); ui_close_win(num); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_left(privwin); curr = g_list_next(curr); } g_list_free(privwins); - } void -ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid, - const char *const password) +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); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(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(); + ProfWin* console = wins_get_console(); if (reason) { win_println(console, THEME_TYPING, "!", "<- Room destroyed: %s, reason: %s", roomjid, reason); @@ -900,9 +898,9 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha } } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_destroyed(privwin); curr = g_list_next(curr); } @@ -910,17 +908,17 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha } void -ui_room_kicked(const char *const roomjid, const char *const actor, const char *const reason) +ui_room_kicked(const char* const roomjid, const char* const actor, const char* const reason) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(roomjid); if (window == NULL) { log_error("Received kick, but no window open for %s.", roomjid); } else { int num = wins_get_num(window); ui_close_win(num); - GString *message = g_string_new("Kicked from "); + GString* message = g_string_new("Kicked from "); g_string_append(message, roomjid); if (actor) { g_string_append(message, " by "); @@ -931,14 +929,14 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c g_string_append(message, reason); } - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_TYPING, "!", "<- %s", message->str); g_string_free(message, TRUE); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_kicked(privwin, actor, reason); curr = g_list_next(curr); } @@ -946,17 +944,17 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c } void -ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason) +ui_room_banned(const char* const roomjid, const char* const actor, const char* const reason) { - ProfWin *window = (ProfWin*)wins_get_muc(roomjid); - GList *privwins = wins_get_private_chats(roomjid); + ProfWin* window = (ProfWin*)wins_get_muc(roomjid); + GList* privwins = wins_get_private_chats(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 "); + GString* message = g_string_new("Banned from "); g_string_append(message, roomjid); if (actor) { g_string_append(message, " by "); @@ -967,14 +965,14 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c g_string_append(message, reason); } - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); win_println(console, THEME_TYPING, "!", "<- %s", message->str); g_string_free(message, TRUE); } - GList *curr = privwins; + GList* curr = privwins; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; privwin_room_banned(privwin, actor, reason); curr = g_list_next(curr); } @@ -984,7 +982,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c int ui_win_unread(int index) { - ProfWin *window = wins_get_by_num(index); + ProfWin* window = wins_get_by_num(index); if (window) { return win_unread(window); } else { @@ -1007,9 +1005,9 @@ ui_get_line(void) } char* -ui_ask_pgp_passphrase(const char *hint, int prev_fail) +ui_ask_pgp_passphrase(const char* hint, int prev_fail) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_println(current, THEME_DEFAULT, "-", ""); @@ -1030,11 +1028,11 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail) } void -ui_contact_offline(char *barejid, char *resource, char *status) +ui_contact_offline(char* barejid, char* resource, char* status) { - char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE); - char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); - Jid *jid = jid_create_from_bare_and_resource(barejid, resource); + char* show_console = prefs_get_string(PREF_STATUSES_CONSOLE); + char* show_chat_win = prefs_get_string(PREF_STATUSES_CHAT); + Jid* jid = jid_create_from_bare_and_resource(barejid, resource); PContact contact = roster_get_contact(barejid); if (p_contact_subscription(contact)) { if (strcmp(p_contact_subscription(contact), "none") != 0) { @@ -1043,21 +1041,21 @@ ui_contact_offline(char *barejid, char *resource, char *status) if (g_strcmp0(show_console, "all") == 0) { cons_show_contact_offline(contact, resource, status); - // show in console of "online" + // show in console of "online" } else if (g_strcmp0(show_console, "online") == 0) { cons_show_contact_offline(contact, resource, status); } // show in chat win if "all" if (g_strcmp0(show_chat_win, "all") == 0) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_offline(chatwin, resource, status); } - // show in chat win if "online" and presence online + // show in chat win if "online" and presence online } else if (g_strcmp0(show_chat_win, "online") == 0) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { chatwin_contact_offline(chatwin, resource, status); } @@ -1065,7 +1063,7 @@ ui_contact_offline(char *barejid, char *resource, char *status) } } - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin && chatwin->resource_override && (g_strcmp0(resource, chatwin->resource_override) == 0)) { FREE_SET_NULL(chatwin->resource_override); } @@ -1085,7 +1083,8 @@ void ui_goodbye_title(void) { int result = system("/bin/echo -ne \"\033]0;Thanks for using Profanity\007\""); - if(result == -1) log_error("Error printing title on shutdown"); + if (result == -1) + log_error("Error printing title on shutdown"); } static void @@ -1095,21 +1094,21 @@ _ui_draw_term_title(void) jabber_conn_status_t status = connection_get_status(); if (status == JABBER_CONNECTED) { - const char * const jid = connection_get_fulljid(); + const char* const jid = connection_get_fulljid(); gint unread = wins_get_total_unread(); if (unread != 0) { snprintf(new_win_title, sizeof(new_win_title), - "/bin/echo -n \"%c]0;%s (%d) - %s%c\"", '\033', "Profanity", - unread, jid, '\007'); + "/bin/echo -n \"%c]0;%s (%d) - %s%c\"", '\033', "Profanity", + unread, jid, '\007'); } else { snprintf(new_win_title, sizeof(new_win_title), - "/bin/echo -n \"%c]0;%s - %s%c\"", '\033', "Profanity", jid, - '\007'); + "/bin/echo -n \"%c]0;%s - %s%c\"", '\033', "Profanity", jid, + '\007'); } } else { snprintf(new_win_title, sizeof(new_win_title), "/bin/echo -n \"%c]0;%s%c\"", '\033', - "Profanity", '\007'); + "Profanity", '\007'); } if (g_strcmp0(win_title, new_win_title) != 0) { // print to x-window title bar @@ -1125,10 +1124,10 @@ _ui_draw_term_title(void) } void -ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message) +ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message) { - ProfWin *window = NULL; - GString *message_str = g_string_new(""); + ProfWin* window = NULL; + GString* message_str = g_string_new(""); if (roomjid) { window = (ProfWin*)wins_get_muc(roomjid); @@ -1149,15 +1148,15 @@ ui_handle_room_configuration_form_error(const char *const roomjid, const char *c } void -ui_handle_room_config_submit_result(const char *const roomjid) +ui_handle_room_config_submit_result(const char* const roomjid) { if (roomjid) { - ProfWin *form_window = NULL; - ProfWin *muc_window = (ProfWin*)wins_get_muc(roomjid); + ProfWin* form_window = NULL; + ProfWin* muc_window = (ProfWin*)wins_get_muc(roomjid); - GString *form_recipient = g_string_new(roomjid); + GString* form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); - form_window = (ProfWin*) wins_get_conf(form_recipient->str); + form_window = (ProfWin*)wins_get_conf(form_recipient->str); g_string_free(form_recipient, TRUE); if (form_window) { @@ -1169,7 +1168,7 @@ ui_handle_room_config_submit_result(const char *const roomjid) ui_focus_win((ProfWin*)muc_window); win_println(muc_window, THEME_ROOMINFO, "!", "Room configuration successful"); } else { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); ui_focus_win(console); cons_show("Room configuration successful: %s", roomjid); } @@ -1179,17 +1178,17 @@ ui_handle_room_config_submit_result(const char *const roomjid) } void -ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message) +ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (roomjid) { - ProfWin *muc_window = NULL; - ProfWin *form_window = NULL; + ProfWin* muc_window = NULL; + ProfWin* form_window = NULL; muc_window = (ProfWin*)wins_get_muc(roomjid); - GString *form_recipient = g_string_new(roomjid); + GString* form_recipient = g_string_new(roomjid); g_string_append(form_recipient, " config"); - form_window = (ProfWin*) wins_get_conf(form_recipient->str); + form_window = (ProfWin*)wins_get_conf(form_recipient->str); g_string_free(form_recipient, TRUE); if (form_window) { @@ -1217,7 +1216,7 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char } void -ui_show_lines(ProfWin *window, gchar** lines) +ui_show_lines(ProfWin* window, gchar** lines) { if (lines) { int i; @@ -1230,7 +1229,7 @@ ui_show_lines(ProfWin *window, gchar** lines) void ui_show_roster(void) { - ProfWin *window = wins_get_console(); + ProfWin* window = wins_get_console(); if (window && !win_has_active_subwin(window)) { wins_show_subwin(window); rosterwin_roster(); @@ -1240,18 +1239,18 @@ ui_show_roster(void) void ui_hide_roster(void) { - ProfWin *window = wins_get_console(); + ProfWin* window = wins_get_console(); if (window && win_has_active_subwin(window)) { wins_hide_subwin(window); } } void -ui_handle_software_version_error(const char *const roomjid, const char *const message) +ui_handle_software_version_error(const char* const roomjid, const char* const message) { - GString *message_str = g_string_new(""); + GString* message_str = g_string_new(""); - ProfWin *window = wins_get_console(); + ProfWin* window = wins_get_console(); g_string_printf(message_str, "Could not get software version"); if (message) { @@ -1265,15 +1264,15 @@ ui_handle_software_version_error(const char *const roomjid, const char *const me } 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) +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* 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) { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 6a1a6f48..45cd3313 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -73,7 +73,7 @@ #include "xmpp/roster_list.h" #include "xmpp/chat_state.h" -static WINDOW *inp_win; +static WINDOW* inp_win; static int pad_start = 0; static struct timeval p_rl_timeout; @@ -81,21 +81,21 @@ static struct timeval p_rl_timeout; static gint inp_timeout = 0; static gint no_input_count = 0; -static FILE *discard; +static FILE* discard; static fd_set fds; static int r; -static char *inp_line = NULL; +static char* inp_line = NULL; static gboolean get_password = FALSE; static void _inp_win_update_virtual(void); static int _inp_edited(const wint_t ch); static void _inp_win_handle_scroll(void); -static int _inp_offset_to_col(char *str, int offset); -static void _inp_write(char *line, int offset); +static int _inp_offset_to_col(char* str, int offset); +static void _inp_write(char* line, int offset); static void _inp_rl_addfuncs(void); -static int _inp_rl_getc(FILE *stream); -static void _inp_rl_linehandler(char *line); +static int _inp_rl_getc(FILE* stream); +static void _inp_rl_linehandler(char* line); static int _inp_rl_tab_handler(int count, int key); static int _inp_rl_shift_tab_handler(int count, int key); static int _inp_rl_win_clear_handler(int count, int key); @@ -147,7 +147,8 @@ create_input_window(void) rl_callback_handler_install(NULL, _inp_rl_linehandler); inp_win = newpad(1, INP_WIN_MAX); - wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));; + wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT)); + ; keypad(inp_win, TRUE); wmove(inp_win, 0, 0); @@ -169,7 +170,7 @@ inp_readline(void) pthread_mutex_lock(&lock); if (r < 0) { if (errno != EINTR) { - char *err_msg = strerror(errno); + char* err_msg = strerror(errno); log_error("Readline failed: %s", err_msg); } return NULL; @@ -178,10 +179,7 @@ inp_readline(void) if (FD_ISSET(fileno(rl_instream), &fds)) { rl_callback_read_char(); - if (rl_line_buffer && - rl_line_buffer[0] != '/' && - rl_line_buffer[0] != '\0' && - rl_line_buffer[0] != '\n') { + if (rl_line_buffer && rl_line_buffer[0] != '/' && rl_line_buffer[0] != '\0' && rl_line_buffer[0] != '\n') { chat_state_activity(); } @@ -198,7 +196,7 @@ inp_readline(void) if (inp_line) { if (!get_password && prefs_get_boolean(PREF_SLASH_GUARD)) { if (strlen(inp_line) > 1) { - char *res = (char*) memchr (inp_line+1, '/', 3); + char* res = (char*)memchr(inp_line + 1, '/', 3); if (res) { cons_show("Your text contains a slash in the first 4 characters"); return NULL; @@ -225,14 +223,15 @@ inp_win_resize(void) } } - wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT));; + wbkgd(inp_win, theme_attrs(THEME_INPUT_TEXT)); + ; _inp_win_update_virtual(); } void inp_nonblocking(gboolean reset) { - if (! prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) { + if (!prefs_get_boolean(PREF_INPBLOCK_DYNAMIC)) { inp_timeout = prefs_get_inpblock(); return; } @@ -269,7 +268,7 @@ inp_get_line(void) wmove(inp_win, 0, 0); _inp_win_update_virtual(); doupdate(); - char *line = NULL; + char* line = NULL; while (!line) { line = inp_readline(); ui_update(); @@ -285,7 +284,7 @@ inp_get_password(void) wmove(inp_win, 0, 0); _inp_win_update_virtual(); doupdate(); - char *password = NULL; + char* password = NULL; get_password = TRUE; while (!password) { password = inp_readline(); @@ -307,11 +306,11 @@ _inp_win_update_virtual(void) { int wcols = getmaxx(stdscr); int row = screen_inputwin_row(); - pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols-2); + pnoutrefresh(inp_win, 0, pad_start, row, 0, row, wcols - 2); } static void -_inp_write(char *line, int offset) +_inp_write(char* line, int offset) { int col = _inp_offset_to_col(line, offset); werase(inp_win); @@ -346,7 +345,7 @@ _inp_edited(const wint_t ch) } // printable - char bytes[MB_CUR_MAX+1]; + char bytes[MB_CUR_MAX + 1]; size_t utf_len = wcrtomb(bytes, ch, &mbstate); if (utf_len == (size_t)-1) { return 0; @@ -358,7 +357,7 @@ _inp_edited(const wint_t ch) } static int -_inp_offset_to_col(char *str, int offset) +_inp_offset_to_col(char* str, int offset) { int i = 0; int col = 0; @@ -384,7 +383,7 @@ _inp_win_handle_scroll(void) if (col == 0) { pad_start = 0; - } else if (col >= pad_start + (wcols -2)) { + } else if (col >= pad_start + (wcols - 2)) { pad_start = col - (wcols / 2); if (pad_start < 0) { pad_start = 0; @@ -503,7 +502,7 @@ _inp_rl_startup_hook(void) rl_variable_bind("disable-completion", "on"); // check for and load ~/.config/profanity/inputrc - gchar *inputrc = files_get_inputrc_file(); + gchar* inputrc = files_get_inputrc_file(); if (inputrc) { rl_read_init_file(inputrc); g_free(inputrc); @@ -513,7 +512,7 @@ _inp_rl_startup_hook(void) } static void -_inp_rl_linehandler(char *line) +_inp_rl_linehandler(char* line) { if (line && *line) { if (!get_password) { @@ -526,7 +525,7 @@ _inp_rl_linehandler(char *line) static gboolean shift_tab = FALSE; static int -_inp_rl_getc(FILE *stream) +_inp_rl_getc(FILE* stream) { int ch = rl_getc(stream); @@ -545,7 +544,7 @@ _inp_rl_getc(FILE *stream) shift_tab = FALSE; if (_inp_edited(ch)) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); cmd_ac_reset(window); } return ch; @@ -554,7 +553,7 @@ _inp_rl_getc(FILE *stream) static int _inp_rl_win_clear_handler(int count, int key) { - ProfWin *win = wins_get_current(); + ProfWin* win = wins_get_current(); win_clear(win); return 0; } @@ -562,7 +561,7 @@ _inp_rl_win_clear_handler(int count, int key) static int _inp_rl_win_close_handler(int count, int key) { - ProfWin *win = wins_get_current(); + ProfWin* win = wins_get_current(); gchar* args = 0; cmd_close(win, 0, &args); return 0; @@ -575,17 +574,17 @@ _inp_rl_tab_handler(int count, int key) return 0; } - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) { - char *result = muc_autocomplete(current, rl_line_buffer, FALSE); + char* result = muc_autocomplete(current, rl_line_buffer, FALSE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; free(result); } } else if (strncmp(rl_line_buffer, "/", 1) == 0) { - ProfWin *window = wins_get_current(); - char *result = cmd_ac_complete(window, rl_line_buffer, FALSE); + ProfWin* window = wins_get_current(); + char* result = cmd_ac_complete(window, rl_line_buffer, FALSE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; @@ -603,17 +602,17 @@ _inp_rl_shift_tab_handler(int count, int key) return 0; } - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); if ((strncmp(rl_line_buffer, "/", 1) != 0) && (current->type == WIN_MUC)) { - char *result = muc_autocomplete(current, rl_line_buffer, TRUE); + char* result = muc_autocomplete(current, rl_line_buffer, TRUE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; free(result); } } else if (strncmp(rl_line_buffer, "/", 1) == 0) { - ProfWin *window = wins_get_current(); - char *result = cmd_ac_complete(window, rl_line_buffer, TRUE); + ProfWin* window = wins_get_current(); + char* result = cmd_ac_complete(window, rl_line_buffer, TRUE); if (result) { rl_replace_line(result, 1); rl_point = rl_end; @@ -627,7 +626,7 @@ _inp_rl_shift_tab_handler(int count, int key) static void _go_to_win(int i) { - ProfWin *window = wins_get_by_num(i); + ProfWin* window = wins_get_by_num(i); if (window) { ui_focus_win(window); } @@ -776,7 +775,7 @@ _inp_rl_win_20_handler(int count, int key) static int _inp_rl_win_prev_handler(int count, int key) { - ProfWin *window = wins_get_previous(); + ProfWin* window = wins_get_previous(); if (window) { ui_focus_win(window); } @@ -786,7 +785,7 @@ _inp_rl_win_prev_handler(int count, int key) static int _inp_rl_win_next_handler(int count, int key) { - ProfWin *window = wins_get_next(); + ProfWin* window = wins_get_next(); if (window) { ui_focus_win(window); } @@ -796,7 +795,7 @@ _inp_rl_win_next_handler(int count, int key) static int _inp_rl_win_next_unread_handler(int count, int key) { - ProfWin *window = wins_get_next_unread(); + ProfWin* window = wins_get_next_unread(); if (window) { ui_focus_win(window); } @@ -806,7 +805,7 @@ _inp_rl_win_next_unread_handler(int count, int key) static int _inp_rl_win_pageup_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_page_up(current); return 0; } @@ -814,7 +813,7 @@ _inp_rl_win_pageup_handler(int count, int key) static int _inp_rl_win_pagedown_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_page_down(current); return 0; } @@ -822,7 +821,7 @@ _inp_rl_win_pagedown_handler(int count, int key) static int _inp_rl_subwin_pageup_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_sub_page_up(current); return 0; } @@ -830,7 +829,7 @@ _inp_rl_subwin_pageup_handler(int count, int key) static int _inp_rl_subwin_pagedown_handler(int count, int key) { - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); win_sub_page_down(current); return 0; } diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 66f33a4b..b89a990f 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -50,13 +50,13 @@ #include "omemo/omemo.h" #endif -static void _mucwin_set_last_message(ProfMucWin *mucwin, const char *const id, const char *const message); +static void _mucwin_set_last_message(ProfMucWin* mucwin, const char* const id, const char* const message); ProfMucWin* -mucwin_new(const char *const barejid) +mucwin_new(const char* const barejid) { - ProfWin *window = wins_new_muc(barejid); - ProfMucWin *mucwin = (ProfMucWin *)window; + ProfWin* window = wins_new_muc(barejid); + ProfMucWin* mucwin = (ProfMucWin*)window; mucwin->last_msg_timestamp = NULL; @@ -71,11 +71,11 @@ mucwin_new(const char *const barejid) } void -mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason) +mucwin_role_change(ProfMucWin* mucwin, const char* const role, const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "Your role has been changed to: %s", role); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -87,12 +87,12 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const } void -mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor, - const char *const reason) +mucwin_affiliation_change(ProfMucWin* mucwin, const char* const affiliation, const char* const actor, + const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "Your affiliation has been changed to: %s", affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -104,12 +104,12 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con } void -mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, const char *const affiliation, - const char *const actor, const char *const reason) +mucwin_role_and_affiliation_change(ProfMucWin* mucwin, const char* const role, const char* const affiliation, + const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -120,14 +120,13 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c win_appendln(window, THEME_ROOMINFO, ""); } - void -mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const actor, const char *const reason) +mucwin_occupant_role_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "%s's role has been changed to: %s", nick, role); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -139,12 +138,12 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch } void -mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, const char *const affiliation, - const char *const actor, const char *const reason) +mucwin_occupant_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const affiliation, + const char* const actor, const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "%s's affiliation has been changed to: %s", nick, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -156,12 +155,12 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c } 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) +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; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, "!", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); if (actor) { win_append(window, THEME_ROOMINFO, ", by: %s", actor); @@ -173,29 +172,28 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons } void -mucwin_room_info_error(ProfMucWin *mucwin, const char *const error) +mucwin_room_info_error(ProfMucWin* mucwin, const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_DEFAULT, "!", "Room info request failed: %s", error); win_println(window, THEME_DEFAULT, "-", ""); } void -mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) +mucwin_room_disco_info(ProfMucWin* mucwin, GSList* identities, GSList* features) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - if ((identities && (g_slist_length(identities) > 0)) || - (features && (g_slist_length(features) > 0))) { + ProfWin* window = (ProfWin*)mucwin; + if ((identities && (g_slist_length(identities) > 0)) || (features && (g_slist_length(features) > 0))) { if (identities) { win_println(window, THEME_DEFAULT, "!", "Identities:"); } while (identities) { - DiscoIdentity *identity = identities->data; // anme trpe, cat - GString *identity_str = g_string_new(" "); + DiscoIdentity* identity = identities->data; // anme trpe, cat + GString* identity_str = g_string_new(" "); if (identity->name) { identity_str = g_string_append(identity_str, identity->name); identity_str = g_string_append(identity_str, " "); @@ -224,11 +222,11 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) } void -mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) +mucwin_roster(ProfMucWin* mucwin, GList* roster, const char* const presence) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if ((roster == NULL) || (g_list_length(roster) == 0)) { if (presence == NULL) { win_println(window, THEME_ROOMINFO, "!", "Room is empty."); @@ -244,8 +242,8 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) } while (roster) { - Occupant *occupant = roster->data; - const char *presence_str = string_from_resource_presence(occupant->presence); + 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_append(window, presence_colour, "%s", occupant->nick); @@ -261,22 +259,22 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) } void -mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick) +mucwin_occupant_offline(ProfMucWin* mucwin, const char* const nick) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_OFFLINE, "!", "<- %s has left the room.", nick); } void -mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason) +mucwin_occupant_kicked(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - GString *message = g_string_new(nick); + ProfWin* window = (ProfWin*)mucwin; + GString* message = g_string_new(nick); g_string_append(message, " has been kicked from the room"); if (actor) { g_string_append(message, " by "); @@ -292,13 +290,13 @@ mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *c } void -mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason) +mucwin_occupant_banned(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - GString *message = g_string_new(nick); + ProfWin* window = (ProfWin*)mucwin; + GString* message = g_string_new(nick); g_string_append(message, " has been banned from the room"); if (actor) { g_string_append(message, " by "); @@ -314,12 +312,12 @@ mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *c } 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) +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; + ProfWin* window = (ProfWin*)mucwin; win_print(window, THEME_ONLINE, "!", "-> %s has joined the room", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (role) { @@ -333,42 +331,42 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c } void -mucwin_occupant_presence(ProfMucWin *mucwin, const char *const nick, - const char *const show, const char *const status) +mucwin_occupant_presence(ProfMucWin* mucwin, const char* const nick, + const char* const show, const char* const status) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_show_status_string(window, nick, show, status, NULL, "++", "online"); } void -mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick) +mucwin_occupant_nick_change(ProfMucWin* mucwin, const char* const old_nick, const char* const nick) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_THEM, "!", "** %s is now known as %s", old_nick, nick); } void -mucwin_nick_change(ProfMucWin *mucwin, const char *const nick) +mucwin_nick_change(ProfMucWin* mucwin, const char* const nick) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ME, "!", "** You are now known as %s", nick); } void -mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) +mucwin_history(ProfMucWin* mucwin, const ProfMessage* const message) { assert(mucwin != NULL); - char *nick = message->from_jid->resourcepart; - char *mynick = muc_nick(mucwin->roomjid); - GSList *mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick); - GList *triggers = prefs_message_get_triggers(message->plain); + char* nick = message->from_jid->resourcepart; + char* mynick = muc_nick(mucwin->roomjid); + GSList* mentions = get_mentions(prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD), prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE), message->plain, mynick); + GList* triggers = prefs_message_get_triggers(message->plain); mucwin_incoming_msg(mucwin, message, mentions, triggers, FALSE); @@ -379,15 +377,15 @@ mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) } static void -_mucwin_print_mention(ProfWin *window, const char *const message, const char *const from, const char *const mynick, GSList *mentions, const char *const ch, int flags) +_mucwin_print_mention(ProfWin* window, const char* const message, const char* const from, const char* const mynick, GSList* mentions, const char* const ch, int flags) { int last_pos = 0; int pos; - GSList *curr = mentions; + GSList* curr = mentions; while (curr) { pos = GPOINTER_TO_INT(curr->data); - char *before_str = g_strndup(message + last_pos, pos - last_pos); + char* before_str = g_strndup(message + last_pos, pos - last_pos); if (strncmp(before_str, "/me ", 4) == 0) { win_print_them(window, THEME_ROOMMENTION, ch, flags, ""); win_append_highlight(window, THEME_ROOMMENTION, "*%s ", from); @@ -397,7 +395,7 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str); } g_free(before_str); - char *mynick_str = g_strndup(message + pos, strlen(mynick)); + char* mynick_str = g_strndup(message + pos, strlen(mynick)); win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", mynick_str); g_free(mynick_str); @@ -418,31 +416,33 @@ _cmp_trigger_weight(gconstpointer a, gconstpointer b) int alen = strlen((char*)a); int blen = strlen((char*)b); - if (alen > blen) return -1; - if (alen < blen) return 1; + if (alen > blen) + return -1; + if (alen < blen) + return 1; return 0; } static void -_mucwin_print_triggers(ProfWin *window, const char *const message, GList *triggers) +_mucwin_print_triggers(ProfWin* window, const char* const message, GList* triggers) { - GList *weighted_triggers = NULL; - GList *curr = triggers; + GList* weighted_triggers = NULL; + GList* curr = triggers; while (curr) { weighted_triggers = g_list_insert_sorted(weighted_triggers, curr->data, (GCompareFunc)_cmp_trigger_weight); curr = g_list_next(curr); } - char *message_lower = g_utf8_strdown(message, -1); + char* message_lower = g_utf8_strdown(message, -1); // find earliest trigger in message int first_trigger_pos = -1; int first_trigger_len = -1; curr = weighted_triggers; while (curr) { - char *trigger_lower = g_utf8_strdown(curr->data, -1); - char *trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower); + char* trigger_lower = g_utf8_strdown(curr->data, -1); + char* trigger_ptr = g_strstr_len(message_lower, -1, trigger_lower); // not found, try next if (trigger_ptr == NULL) { @@ -496,15 +496,15 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge } void -mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id) +mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* const id, prof_enc_t enc_mode, const char* const replace_id) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; - char *mynick = muc_nick(mucwin->roomjid); + ProfWin* window = (ProfWin*)mucwin; + char* mynick = muc_nick(mucwin->roomjid); // displayed message char - char *ch; + char* ch; if (mucwin->message_char) { ch = strdup(mucwin->message_char); } else if (enc_mode == PROF_MSG_ENC_OTR) { @@ -529,7 +529,7 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *c } void -mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection) +mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList* mentions, GList* triggers, gboolean filter_reflection) { assert(mucwin != NULL); int flags = 0; @@ -543,10 +543,10 @@ mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList flags |= UNTRUSTED; } - ProfWin *window = (ProfWin*)mucwin; - char *mynick = muc_nick(mucwin->roomjid); + ProfWin* window = (ProfWin*)mucwin; + char* mynick = muc_nick(mucwin->roomjid); - char *ch; + char* ch; if (mucwin->message_char) { ch = strdup(mucwin->message_char); } else if (message->enc == PROF_MSG_ENC_OTR) { @@ -575,11 +575,11 @@ mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList } void -mucwin_requires_config(ProfMucWin *mucwin) +mucwin_requires_config(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; int num = wins_get_num(window); win_println(window, THEME_DEFAULT, "-", ""); @@ -593,18 +593,18 @@ mucwin_requires_config(ProfMucWin *mucwin) if (wins_is_current(window)) { status_bar_active(num, WIN_MUC, mucwin->roomjid); - // not currently on groupchat window + // not currently on groupchat window } else { status_bar_new(num, WIN_MUC, mucwin->roomjid); } } void -mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject) +mucwin_subject(ProfMucWin* mucwin, const char* const nick, const char* const subject) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (subject) { if (nick) { win_print(window, THEME_ROOMINFO, "!", "*%s has set the room subject: ", nick); @@ -623,20 +623,20 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub } void -mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error) +mucwin_kick_error(ProfMucWin* mucwin, const char* const nick, const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error kicking %s: %s", nick, error); } void -mucwin_broadcast(ProfMucWin *mucwin, const char *const message) +mucwin_broadcast(ProfMucWin* mucwin, const char* const message) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; int num = wins_get_num(window); win_print(window, THEME_ROOMINFO, "!", "Room message: "); @@ -646,33 +646,33 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message) if (wins_is_current(window)) { status_bar_active(num, WIN_MUC, mucwin->roomjid); - // not currently on groupchat window + // not currently on groupchat window } else { status_bar_new(num, WIN_MUC, mucwin->roomjid); } } void -mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, - const char *const error) +mucwin_affiliation_list_error(ProfMucWin* mucwin, const char* const affiliation, + const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error retrieving %s list: %s", affiliation, error); } void -mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids) +mucwin_handle_affiliation_list(ProfMucWin* mucwin, const char* const affiliation, GSList* jids) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (jids) { win_println(window, THEME_DEFAULT, "!", "Affiliation: %s", affiliation); - GSList *curr_jid = jids; + GSList* curr_jid = jids; while (curr_jid) { - const char *jid = curr_jid->data; + const char* jid = curr_jid->data; win_println(window, THEME_DEFAULT, "!", " %s", jid); curr_jid = g_slist_next(curr_jid); } @@ -684,52 +684,52 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation } void -mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) +mucwin_show_affiliation_list(ProfMucWin* mucwin, muc_affiliation_t affiliation) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*) mucwin; - GSList *occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation); + ProfWin* window = (ProfWin*)mucwin; + GSList* occupants = muc_occupants_by_affiliation(mucwin->roomjid, affiliation); if (!occupants) { switch (affiliation) { - case MUC_AFFILIATION_OWNER: - win_println(window, THEME_DEFAULT, "!", "No owners found."); - break; - case MUC_AFFILIATION_ADMIN: - win_println(window, THEME_DEFAULT, "!", "No admins found."); - break; - case MUC_AFFILIATION_MEMBER: - win_println(window, THEME_DEFAULT, "!", "No members found."); - break; - case MUC_AFFILIATION_OUTCAST: - win_println(window, THEME_DEFAULT, "!", "No outcasts found."); - break; - default: - break; + case MUC_AFFILIATION_OWNER: + win_println(window, THEME_DEFAULT, "!", "No owners found."); + break; + case MUC_AFFILIATION_ADMIN: + win_println(window, THEME_DEFAULT, "!", "No admins found."); + break; + case MUC_AFFILIATION_MEMBER: + win_println(window, THEME_DEFAULT, "!", "No members found."); + break; + case MUC_AFFILIATION_OUTCAST: + win_println(window, THEME_DEFAULT, "!", "No outcasts found."); + break; + default: + break; } win_println(window, THEME_DEFAULT, "-", ""); } else { switch (affiliation) { - case MUC_AFFILIATION_OWNER: - win_println(window, THEME_DEFAULT, "!", "Owners:"); - break; - case MUC_AFFILIATION_ADMIN: - win_println(window, THEME_DEFAULT, "!", "Admins:"); - break; - case MUC_AFFILIATION_MEMBER: - win_println(window, THEME_DEFAULT, "!", "Members:"); - break; - case MUC_AFFILIATION_OUTCAST: - win_println(window, THEME_DEFAULT, "!", "Outcasts:"); - break; - default: - break; + case MUC_AFFILIATION_OWNER: + win_println(window, THEME_DEFAULT, "!", "Owners:"); + break; + case MUC_AFFILIATION_ADMIN: + win_println(window, THEME_DEFAULT, "!", "Admins:"); + break; + case MUC_AFFILIATION_MEMBER: + win_println(window, THEME_DEFAULT, "!", "Members:"); + break; + case MUC_AFFILIATION_OUTCAST: + win_println(window, THEME_DEFAULT, "!", "Outcasts:"); + break; + default: + break; } - GSList *curr_occupant = occupants; - while(curr_occupant) { - Occupant *occupant = curr_occupant->data; + GSList* curr_occupant = occupants; + while (curr_occupant) { + Occupant* occupant = curr_occupant->data; if (occupant->affiliation == affiliation) { if (occupant->jid) { win_println(window, THEME_DEFAULT, "!", " %s (%s)", occupant->nick, occupant->jid); @@ -746,26 +746,26 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) } void -mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error) +mucwin_role_list_error(ProfMucWin* mucwin, const char* const role, const char* const error) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error retrieving %s list: %s", role, error); } void -mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks) +mucwin_handle_role_list(ProfMucWin* mucwin, const char* const role, GSList* nicks) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (nicks) { win_println(window, THEME_DEFAULT, "!", "Role: %s", role); - GSList *curr_nick = nicks; + GSList* curr_nick = nicks; while (curr_nick) { - const char *nick = curr_nick->data; - Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); + const char* nick = curr_nick->data; + Occupant* occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { if (occupant->jid) { win_println(window, THEME_DEFAULT, "!", " %s (%s)", nick, occupant->jid); @@ -785,46 +785,46 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick } void -mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) +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); + ProfWin* window = (ProfWin*)mucwin; + GSList* occupants = muc_occupants_by_role(mucwin->roomjid, role); if (!occupants) { switch (role) { - case MUC_ROLE_MODERATOR: - win_println(window, THEME_DEFAULT, "!", "No moderators found."); - break; - case MUC_ROLE_PARTICIPANT: - win_println(window, THEME_DEFAULT, "!", "No participants found."); - break; - case MUC_ROLE_VISITOR: - win_println(window, THEME_DEFAULT, "!", "No visitors found."); - break; - default: - break; + case MUC_ROLE_MODERATOR: + win_println(window, THEME_DEFAULT, "!", "No moderators found."); + break; + case MUC_ROLE_PARTICIPANT: + win_println(window, THEME_DEFAULT, "!", "No participants found."); + break; + case MUC_ROLE_VISITOR: + win_println(window, THEME_DEFAULT, "!", "No visitors found."); + break; + default: + break; } win_println(window, THEME_DEFAULT, "-", ""); } else { switch (role) { - case MUC_ROLE_MODERATOR: - win_println(window, THEME_DEFAULT, "!", "Moderators:"); - break; - case MUC_ROLE_PARTICIPANT: - win_println(window, THEME_DEFAULT, "!", "Participants:"); - break; - case MUC_ROLE_VISITOR: - win_println(window, THEME_DEFAULT, "!", "Visitors:"); - break; - default: - break; + case MUC_ROLE_MODERATOR: + win_println(window, THEME_DEFAULT, "!", "Moderators:"); + break; + case MUC_ROLE_PARTICIPANT: + win_println(window, THEME_DEFAULT, "!", "Participants:"); + break; + case MUC_ROLE_VISITOR: + win_println(window, THEME_DEFAULT, "!", "Visitors:"); + break; + default: + break; } - GSList *curr_occupant = occupants; - while(curr_occupant) { - Occupant *occupant = curr_occupant->data; + GSList* curr_occupant = occupants; + while (curr_occupant) { + Occupant* occupant = curr_occupant->data; if (occupant->role == role) { if (occupant->jid) { win_println(window, THEME_DEFAULT, "!", " %s (%s)", occupant->nick, occupant->jid); @@ -841,34 +841,34 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) } void -mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const char *const affiliation, - const char *const error) +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; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error setting %s affiliation for %s: %s", affiliation, jid, error); } void -mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const error) +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; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_ERROR, "!", "Error setting %s role for %s: %s", role, nick, error); } void -mucwin_info(ProfMucWin *mucwin) +mucwin_info(ProfMucWin* mucwin) { assert(mucwin != NULL); - char *role = muc_role_str(mucwin->roomjid); - char *affiliation = muc_affiliation_str(mucwin->roomjid); + char* role = muc_role_str(mucwin->roomjid); + char* affiliation = muc_affiliation_str(mucwin->roomjid); - ProfWin *window = (ProfWin*) mucwin; + ProfWin* window = (ProfWin*)mucwin; win_println(window, THEME_DEFAULT, "!", "Room: %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, "!", "Affiliation: %s", affiliation); win_println(window, THEME_DEFAULT, "!", "Role: %s", role); @@ -876,22 +876,22 @@ mucwin_info(ProfMucWin *mucwin) } void -mucwin_update_occupants(ProfMucWin *mucwin) +mucwin_update_occupants(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (win_has_active_subwin(window)) { occupantswin_occupants(mucwin->roomjid); } } void -mucwin_show_occupants(ProfMucWin *mucwin) +mucwin_show_occupants(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (!win_has_active_subwin(window)) { wins_show_subwin(window); occupantswin_occupants(mucwin->roomjid); @@ -899,36 +899,36 @@ mucwin_show_occupants(ProfMucWin *mucwin) } void -mucwin_hide_occupants(ProfMucWin *mucwin) +mucwin_hide_occupants(ProfMucWin* mucwin) { assert(mucwin != NULL); - ProfWin *window = (ProfWin*)mucwin; + ProfWin* window = (ProfWin*)mucwin; if (win_has_active_subwin(window)) { wins_hide_subwin(window); } } char* -mucwin_get_string(ProfMucWin *mucwin) +mucwin_get_string(ProfMucWin* mucwin) { assert(mucwin != NULL); - GString *res = g_string_new("Room "); + GString* res = g_string_new("Room "); g_string_append(res, mucwin->roomjid); if (mucwin->unread > 0) { g_string_append_printf(res, ", %d unread", mucwin->unread); } - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; } void -mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) +mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext) { if (mucwin->enctext) { free(mucwin->enctext); @@ -937,7 +937,7 @@ mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) } void -mucwin_unset_enctext(ProfMucWin *mucwin) +mucwin_unset_enctext(ProfMucWin* mucwin) { if (mucwin->enctext) { free(mucwin->enctext); @@ -946,7 +946,7 @@ mucwin_unset_enctext(ProfMucWin *mucwin) } void -mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) +mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch) { if (mucwin->message_char) { free(mucwin->message_char); @@ -955,7 +955,7 @@ mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) } void -mucwin_unset_message_char(ProfMucWin *mucwin) +mucwin_unset_message_char(ProfMucWin* mucwin) { if (mucwin->message_char) { free(mucwin->message_char); @@ -964,7 +964,7 @@ mucwin_unset_message_char(ProfMucWin *mucwin) } static void -_mucwin_set_last_message(ProfMucWin *mucwin, const char *const id, const char *const message) +_mucwin_set_last_message(ProfMucWin* mucwin, const char* const id, const char* const message) { free(mucwin->last_message); mucwin->last_message = strdup(message); diff --git a/src/ui/notifier.c b/src/ui/notifier.c index a0814b47..352351f9 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -55,7 +55,7 @@ #include "xmpp/xmpp.h" #include "xmpp/muc.h" -static GTimer *remind_timer; +static GTimer* remind_timer; void notifier_initialise(void) @@ -75,7 +75,7 @@ notifier_uninit(void) } void -notify_typing(const char *const name) +notify_typing(const char* const name) { char message[strlen(name) + 1 + 11]; sprintf(message, "%s: typing...", name); @@ -84,9 +84,9 @@ notify_typing(const char *const name) } void -notify_invite(const char *const from, const char *const room, const char *const reason) +notify_invite(const char* const from, const char* const room, const char* const reason) { - GString *message = g_string_new("Room invite\nfrom: "); + GString* message = g_string_new("Room invite\nfrom: "); g_string_append(message, from); g_string_append(message, "\nto: "); g_string_append(message, room); @@ -100,14 +100,14 @@ notify_invite(const char *const from, const char *const room, const char *const } void -notify_message(const char *const name, int num, const char *const text) +notify_message(const char* const name, int num, const char* const text) { int ui_index = num; if (ui_index == 10) { ui_index = 0; } - GString *message = g_string_new(""); + GString* message = g_string_new(""); g_string_append_printf(message, "%s (win %d)", name, ui_index); if (text && prefs_get_boolean(PREF_NOTIFY_CHAT_TEXT)) { g_string_append_printf(message, "\n%s", text); @@ -118,14 +118,14 @@ notify_message(const char *const name, int num, const char *const text) } void -notify_room_message(const char *const nick, const char *const room, int num, const char *const text) +notify_room_message(const char* const nick, const char* const room, int num, const char* const text) { int ui_index = num; if (ui_index == 10) { ui_index = 0; } - GString *message = g_string_new(""); + GString* message = g_string_new(""); g_string_append_printf(message, "%s in %s (win %d)", nick, room, ui_index); if (text && prefs_get_boolean(PREF_NOTIFY_ROOM_TEXT)) { g_string_append_printf(message, "\n%s", text); @@ -137,9 +137,9 @@ notify_room_message(const char *const nick, const char *const room, int num, con } void -notify_subscription(const char *const from) +notify_subscription(const char* const from) { - GString *message = g_string_new("Subscription request: \n"); + GString* message = g_string_new("Subscription request: \n"); g_string_append(message, from); notify(message->str, 10000, "Incoming message"); g_string_free(message, TRUE); @@ -156,7 +156,7 @@ notify_remind(void) gint open = muc_invites_count(); gint subs = presence_sub_request_count(); - GString *text = g_string_new(""); + GString* text = g_string_new(""); if (donotify && unread > 0) { if (unread == 1) { @@ -164,7 +164,6 @@ notify_remind(void) } else { g_string_append_printf(text, "%d unread messages", unread); } - } if (open > 0) { if (unread > 0) { @@ -198,7 +197,7 @@ notify_remind(void) } void -notify(const char *const message, int timeout, const char *const category) +notify(const char* const message, int timeout, const char* const category) { #ifdef HAVE_LIBNOTIFY log_debug("Attempting notification: %s", message); @@ -211,13 +210,13 @@ notify(const char *const message, int timeout, const char *const category) notify_init("Profanity"); } if (notify_is_initted()) { - NotifyNotification *notification; + NotifyNotification* notification; notification = notify_notification_new("Profanity", message, NULL); notify_notification_set_timeout(notification, timeout); notify_notification_set_category(notification, category); notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL); - GError *error = NULL; + GError* error = NULL; gboolean notify_success = notify_notification_show(notification, &error); if (!notify_success) { @@ -247,17 +246,17 @@ notify(const char *const message, int timeout, const char *const category) // For a Ballon Tip nid.uFlags = NIF_INFO; - strcpy(nid.szInfoTitle, "Profanity"); // Title + strcpy(nid.szInfoTitle, "Profanity"); // Title strncpy(nid.szInfo, message, sizeof(nid.szInfo) - 1); // Copy Tip - nid.uTimeout = timeout; // 3 Seconds + nid.uTimeout = timeout; // 3 Seconds nid.dwInfoFlags = NIIF_INFO; Shell_NotifyIcon(NIM_MODIFY, &nid); #endif #ifdef HAVE_OSXNOTIFY - GString *notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '"); + GString* notify_command = g_string_new("terminal-notifier -title \"Profanity\" -message '"); - char *escaped_single = str_replace(message, "'", "'\\''"); + char* escaped_single = str_replace(message, "'", "'\\''"); if (escaped_single[0] == '<') { g_string_append(notify_command, "\\<"); @@ -278,8 +277,8 @@ notify(const char *const message, int timeout, const char *const category) g_string_append(notify_command, "'"); free(escaped_single); - char *term_name = getenv("TERM_PROGRAM"); - char *app_id = NULL; + char* term_name = getenv("TERM_PROGRAM"); + char* app_id = NULL; if (g_strcmp0(term_name, "Apple_Terminal") == 0) { app_id = "com.apple.Terminal"; } else if (g_strcmp0(term_name, "iTerm.app") == 0) { diff --git a/src/ui/occupantswin.c b/src/ui/occupantswin.c index aff680ea..1834e47c 100644 --- a/src/ui/occupantswin.c +++ b/src/ui/occupantswin.c @@ -42,9 +42,9 @@ #include "ui/window_list.h" static void -_occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean showjid) +_occuptantswin_occupant(ProfLayoutSplit* layout, Occupant* occupant, gboolean showjid) { - int colour = 0; //init to workaround compiler warning + int colour = 0; //init to workaround compiler warning theme_item_t presence_colour = THEME_ROSTER_ONLINE; //init to workaround compiler warning if (prefs_get_boolean(PREF_OCCUPANTS_COLOR_NICK)) { @@ -52,13 +52,13 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh wattron(layout->subwin, colour); } else { - const char *presence_str = string_from_resource_presence(occupant->presence); + const char* presence_str = string_from_resource_presence(occupant->presence); presence_colour = theme_main_presence_attrs(presence_str); wattron(layout->subwin, theme_attrs(presence_colour)); } - GString *spaces = g_string_new(" "); + GString* spaces = g_string_new(" "); int indent = prefs_get_occupants_indent(); int current_indent = 0; @@ -70,7 +70,7 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh } } - GString *msg = g_string_new(spaces->str); + GString* msg = g_string_new(spaces->str); char ch = prefs_get_occupants_char(); if (ch) { @@ -85,7 +85,7 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh g_string_free(msg, TRUE); if (showjid && occupant->jid) { - GString *msg = g_string_new(spaces->str); + GString* msg = g_string_new(spaces->str); g_string_append(msg, " "); g_string_append(msg, occupant->jid); @@ -104,18 +104,18 @@ _occuptantswin_occupant(ProfLayoutSplit *layout, Occupant *occupant, gboolean sh } void -occupantswin_occupants(const char *const roomjid) +occupantswin_occupants(const char* const roomjid) { - ProfMucWin *mucwin = wins_get_muc(roomjid); + ProfMucWin* mucwin = wins_get_muc(roomjid); if (mucwin) { - GList *occupants = muc_roster(roomjid); + GList* occupants = muc_roster(roomjid); if (occupants) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)mucwin->window.layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)mucwin->window.layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); werase(layout->subwin); - GString *prefix = g_string_new(" "); + GString* prefix = g_string_new(" "); char ch = prefs_get_occupants_header_char(); if (ch) { @@ -124,7 +124,7 @@ occupantswin_occupants(const char *const roomjid) if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { - GString *role = g_string_new(prefix->str); + GString* role = g_string_new(prefix->str); g_string_append(role, "Moderators"); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); @@ -132,9 +132,9 @@ occupantswin_occupants(const char *const roomjid) win_sub_print(layout->subwin, role->str, TRUE, FALSE, 0); wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); g_string_free(role, TRUE); - GList *roster_curr = occupants; + GList* roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; if (occupant->role == MUC_ROLE_MODERATOR) { _occuptantswin_occupant(layout, occupant, mucwin->showjid); } @@ -151,7 +151,7 @@ occupantswin_occupants(const char *const roomjid) g_string_free(role, TRUE); roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; if (occupant->role == MUC_ROLE_PARTICIPANT) { _occuptantswin_occupant(layout, occupant, mucwin->showjid); } @@ -168,14 +168,14 @@ occupantswin_occupants(const char *const roomjid) g_string_free(role, TRUE); roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; if (occupant->role == MUC_ROLE_VISITOR) { _occuptantswin_occupant(layout, occupant, mucwin->showjid); } roster_curr = g_list_next(roster_curr); } } else { - GString *role = g_string_new(prefix->str); + GString* role = g_string_new(prefix->str); g_string_append(role, "Occupants\n"); wattron(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); @@ -184,9 +184,9 @@ occupantswin_occupants(const char *const roomjid) wattroff(layout->subwin, theme_attrs(THEME_OCCUPANTS_HEADER)); g_string_free(role, TRUE); - GList *roster_curr = occupants; + GList* roster_curr = occupants; while (roster_curr) { - Occupant *occupant = roster_curr->data; + Occupant* occupant = roster_curr->data; _occuptantswin_occupant(layout, occupant, mucwin->showjid); roster_curr = g_list_next(roster_curr); } @@ -202,12 +202,12 @@ occupantswin_occupants(const char *const roomjid) void occupantswin_occupants_all(void) { - GList *rooms = muc_rooms(); - GList *curr = rooms; + GList* rooms = muc_rooms(); + GList* curr = rooms; while (curr) { char* roomjid = curr->data; - ProfMucWin *mw = wins_get_muc(roomjid); + ProfMucWin* mw = wins_get_muc(roomjid); if (mw != NULL) { mucwin_update_occupants(mw); } diff --git a/src/ui/privwin.c b/src/ui/privwin.c index c18588fb..e4e6e29a 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -44,14 +44,14 @@ #include "ui/window_list.h" void -privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) +privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message) { assert(privatewin != NULL); - ProfWin *window = (ProfWin*) privatewin; + ProfWin* window = (ProfWin*)privatewin; int num = wins_get_num(window); - Jid *jidp = jid_create(privatewin->fulljid); + Jid* jidp = jid_create(privatewin->fulljid); if (jidp == NULL) { return; } @@ -65,7 +65,7 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) title_bar_set_typing(FALSE); status_bar_active(num, WIN_PRIVATE, privatewin->fulljid); - // not currently viewing chat window with sender + // not currently viewing chat window with sender } else { status_bar_new(num, WIN_PRIVATE, privatewin->fulljid); cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread); @@ -93,15 +93,15 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) } void -privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message) +privwin_outgoing_msg(ProfPrivateWin* privwin, const char* const message) { assert(privwin != NULL); - win_print_outgoing((ProfWin*)privwin, "-", NULL, NULL , message); + win_print_outgoing((ProfWin*)privwin, "-", NULL, NULL, message); } void -privwin_message_occupant_offline(ProfPrivateWin *privwin) +privwin_message_occupant_offline(ProfPrivateWin* privwin) { assert(privwin != NULL); @@ -109,7 +109,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin) } void -privwin_message_left_room(ProfPrivateWin *privwin) +privwin_message_left_room(ProfPrivateWin* privwin) { assert(privwin != NULL); @@ -117,24 +117,24 @@ privwin_message_left_room(ProfPrivateWin *privwin) } void -privwin_occupant_offline(ProfPrivateWin *privwin) +privwin_occupant_offline(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->occupant_offline = TRUE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "-", "<- %s has left the room.", jidp->resourcepart); jid_destroy(jidp); } void -privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->occupant_offline = TRUE; - Jid *jidp = jid_create(privwin->fulljid); - GString *message = g_string_new(jidp->resourcepart); + Jid* jidp = jid_create(privwin->fulljid); + GString* message = g_string_new(jidp->resourcepart); jid_destroy(jidp); g_string_append(message, " has been kicked from the room"); if (actor) { @@ -151,13 +151,13 @@ privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const } void -privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->occupant_offline = TRUE; - Jid *jidp = jid_create(privwin->fulljid); - GString *message = g_string_new(jidp->resourcepart); + Jid* jidp = jid_create(privwin->fulljid); + GString* message = g_string_new(jidp->resourcepart); jid_destroy(jidp); g_string_append(message, " has been banned from the room"); if (actor) { @@ -174,57 +174,57 @@ privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const } void -privwin_occupant_online(ProfPrivateWin *privwin) +privwin_occupant_online(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->occupant_offline = FALSE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_ONLINE, "-", "-- %s has joined the room.", jidp->resourcepart); jid_destroy(jidp); } void -privwin_room_destroyed(ProfPrivateWin *privwin) +privwin_room_destroyed(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->room_left = TRUE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- %s has been destroyed.", jidp->barejid); jid_destroy(jidp); } void -privwin_room_joined(ProfPrivateWin *privwin) +privwin_room_joined(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->room_left = FALSE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have joined %s.", jidp->barejid); jid_destroy(jidp); } void -privwin_room_left(ProfPrivateWin *privwin) +privwin_room_left(ProfPrivateWin* privwin) { assert(privwin != NULL); privwin->room_left = TRUE; - Jid *jidp = jid_create(privwin->fulljid); + Jid* jidp = jid_create(privwin->fulljid); win_println((ProfWin*)privwin, THEME_OFFLINE, "!", "-- You have left %s.", jidp->barejid); jid_destroy(jidp); } void -privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_room_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->room_left = TRUE; - GString *message = g_string_new("Kicked from "); - Jid *jidp = jid_create(privwin->fulljid); + GString* message = g_string_new("Kicked from "); + Jid* jidp = jid_create(privwin->fulljid); g_string_append(message, jidp->barejid); jid_destroy(jidp); if (actor) { @@ -241,13 +241,13 @@ privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char } void -privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) +privwin_room_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason) { assert(privwin != NULL); privwin->room_left = TRUE; - GString *message = g_string_new("Banned from "); - Jid *jidp = jid_create(privwin->fulljid); + GString* message = g_string_new("Banned from "); + Jid* jidp = jid_create(privwin->fulljid); g_string_append(message, jidp->barejid); jid_destroy(jidp); if (actor) { @@ -264,18 +264,18 @@ privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char } char* -privwin_get_string(ProfPrivateWin *privwin) +privwin_get_string(ProfPrivateWin* privwin) { assert(privwin != NULL); - GString *res = g_string_new("Private "); + GString* res = g_string_new("Private "); g_string_append(res, privwin->fulljid); if (privwin->unread > 0) { g_string_append_printf(res, ", %d unread", privwin->unread); } - char *resstr = res->str; + char* resstr = res->str; g_string_free(res, FALSE); return resstr; diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index eb025c4e..3375414c 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -51,39 +51,39 @@ typedef enum { ROSTER_CONTACT_UNREAD } roster_contact_theme_t; -static void _rosterwin_contacts_all(ProfLayoutSplit *layout); -static void _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const presence, char *title); -static void _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group); -static void _rosteriwin_unsubscribed(ProfLayoutSplit *layout); -static void _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *title, GSList *contacts); -static void _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins); - -static void _rosterwin_contact(ProfLayoutSplit *layout, PContact contact); -static void _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin); -static void _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *status, - int current_indent); -static void _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent, - roster_contact_theme_t theme_type, int unread); - -static void _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms); -static void _rosterwin_rooms_by_service(ProfLayoutSplit *layout); -static void _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title); -static void _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin); -static void _rosterwin_print_rooms(ProfLayoutSplit *layout); - -static void _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats); -static void _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs); - -static GSList* _filter_contacts(GSList *contacts); -static GSList* _filter_contacts_with_presence(GSList *contacts, const char *const presence); -static theme_item_t _get_roster_theme(roster_contact_theme_t theme_type, const char *presence); -static int _compare_rooms_name(ProfMucWin *a, ProfMucWin *b); -static int _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b); +static void _rosterwin_contacts_all(ProfLayoutSplit* layout); +static void _rosterwin_contacts_by_presence(ProfLayoutSplit* layout, const char* const presence, char* title); +static void _rosterwin_contacts_by_group(ProfLayoutSplit* layout, char* group); +static void _rosteriwin_unsubscribed(ProfLayoutSplit* layout); +static void _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* title, GSList* contacts); +static void _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins); + +static void _rosterwin_contact(ProfLayoutSplit* layout, PContact contact); +static void _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin); +static void _rosterwin_presence(ProfLayoutSplit* layout, const char* presence, const char* status, + int current_indent); +static void _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_indent, + roster_contact_theme_t theme_type, int unread); + +static void _rosterwin_rooms(ProfLayoutSplit* layout, char* title, GList* rooms); +static void _rosterwin_rooms_by_service(ProfLayoutSplit* layout); +static void _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title); +static void _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin); +static void _rosterwin_print_rooms(ProfLayoutSplit* layout); + +static void _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats); +static void _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs); + +static GSList* _filter_contacts(GSList* contacts); +static GSList* _filter_contacts_with_presence(GSList* contacts, const char* const presence); +static theme_item_t _get_roster_theme(roster_contact_theme_t theme_type, const char* presence); +static int _compare_rooms_name(ProfMucWin* a, ProfMucWin* b); +static int _compare_rooms_unread(ProfMucWin* a, ProfMucWin* b); void rosterwin_roster(void) { - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); if (!console) { return; } @@ -93,20 +93,20 @@ rosterwin_roster(void) return; } - ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)console->layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); werase(layout->subwin); - char *roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS); + char* roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS); if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "first") == 0)) { _rosterwin_print_rooms(layout); - GList *orphaned_privchats = NULL; - GList *privchats = wins_get_private_chats(NULL); - GList *curr = privchats; + GList* orphaned_privchats = NULL; + GList* privchats = wins_get_private_chats(NULL); + GList* curr = privchats; while (curr) { - ProfPrivateWin *privwin = curr->data; - Jid *jidp = jid_create(privwin->fulljid); + ProfPrivateWin* privwin = curr->data; + Jid* jidp = jid_create(privwin->fulljid); if (!muc_active(jidp->barejid)) { orphaned_privchats = g_list_append(orphaned_privchats, privwin); } @@ -114,17 +114,16 @@ rosterwin_roster(void) curr = g_list_next(curr); } - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "group") == 0 || orphaned_privchats) { _rosterwin_private_chats(layout, orphaned_privchats); } g_free(privpref); g_list_free(orphaned_privchats); - } if (prefs_get_boolean(PREF_ROSTER_CONTACTS)) { - char *by = prefs_get_string(PREF_ROSTER_BY); + char* by = prefs_get_string(PREF_ROSTER_BY); if (g_strcmp0(by, "presence") == 0) { _rosterwin_contacts_by_presence(layout, "chat", "Available for chat"); _rosterwin_contacts_by_presence(layout, "online", "Online"); @@ -133,8 +132,8 @@ rosterwin_roster(void) _rosterwin_contacts_by_presence(layout, "dnd", "Do not disturb"); _rosterwin_contacts_by_presence(layout, "offline", "Offline"); } else if (g_strcmp0(by, "group") == 0) { - GList *groups = roster_get_groups(); - GList *curr_group = groups; + GList* groups = roster_get_groups(); + GList* curr_group = groups; while (curr_group) { _rosterwin_contacts_by_group(layout, curr_group->data); curr_group = g_list_next(curr_group); @@ -154,12 +153,12 @@ rosterwin_roster(void) if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "last") == 0)) { _rosterwin_print_rooms(layout); - GList *orphaned_privchats = NULL; - GList *privchats = wins_get_private_chats(NULL); - GList *curr = privchats; + GList* orphaned_privchats = NULL; + GList* privchats = wins_get_private_chats(NULL); + GList* curr = privchats; while (curr) { - ProfPrivateWin *privwin = curr->data; - Jid *jidp = jid_create(privwin->fulljid); + ProfPrivateWin* privwin = curr->data; + Jid* jidp = jid_create(privwin->fulljid); if (!muc_active(jidp->barejid)) { orphaned_privchats = g_list_append(orphaned_privchats, privwin); } @@ -167,7 +166,7 @@ rosterwin_roster(void) curr = g_list_next(curr); } - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "group") == 0 || orphaned_privchats) { _rosterwin_private_chats(layout, orphaned_privchats); } @@ -180,11 +179,11 @@ rosterwin_roster(void) } static void -_rosterwin_contacts_all(ProfLayoutSplit *layout) +_rosterwin_contacts_all(ProfLayoutSplit* layout) { - GSList *contacts = NULL; + GSList* contacts = NULL; - char *order = prefs_get_string(PREF_ROSTER_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ORDER); if (g_strcmp0(order, "presence") == 0) { contacts = roster_get_contacts(ROSTER_ORD_PRESENCE); } else { @@ -192,13 +191,13 @@ _rosterwin_contacts_all(ProfLayoutSplit *layout) } g_free(order); - GSList *filtered_contacts = _filter_contacts(contacts); + GSList* filtered_contacts = _filter_contacts(contacts); g_slist_free(contacts); _rosterwin_contacts_header(layout, "Roster", filtered_contacts); if (filtered_contacts) { - GSList *curr_contact = filtered_contacts; + GSList* curr_contact = filtered_contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); @@ -209,16 +208,16 @@ _rosterwin_contacts_all(ProfLayoutSplit *layout) } static void -_rosteriwin_unsubscribed(ProfLayoutSplit *layout) +_rosteriwin_unsubscribed(ProfLayoutSplit* layout) { - GList *wins = wins_get_chat_unsubscribed(); + GList* wins = wins_get_chat_unsubscribed(); if (wins) { _rosterwin_unsubscribed_header(layout, wins); } - GList *curr = wins; + GList* curr = wins; while (curr) { - ProfChatWin *chatwin = curr->data; + ProfChatWin* chatwin = curr->data; _rosterwin_unsubscribed_item(layout, chatwin); curr = g_list_next(curr); } @@ -227,10 +226,10 @@ _rosteriwin_unsubscribed(ProfLayoutSplit *layout) } static void -_rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const presence, char *title) +_rosterwin_contacts_by_presence(ProfLayoutSplit* layout, const char* const presence, char* title) { - GSList *contacts = roster_get_contacts_by_presence(presence); - GSList *filtered_contacts = _filter_contacts_with_presence(contacts, presence); + GSList* contacts = roster_get_contacts_by_presence(presence); + GSList* filtered_contacts = _filter_contacts_with_presence(contacts, presence); g_slist_free(contacts); // if this group has contacts, or if we want to show empty groups @@ -239,7 +238,7 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese } if (filtered_contacts) { - GSList *curr_contact = filtered_contacts; + GSList* curr_contact = filtered_contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); @@ -250,11 +249,11 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese } static void -_rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) +_rosterwin_contacts_by_group(ProfLayoutSplit* layout, char* group) { - GSList *contacts = NULL; + GSList* contacts = NULL; - char *order = prefs_get_string(PREF_ROSTER_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ORDER); if (g_strcmp0(order, "presence") == 0) { contacts = roster_get_group(group, ROSTER_ORD_PRESENCE); } else { @@ -262,7 +261,7 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) } g_free(order); - GSList *filtered_contacts = _filter_contacts(contacts); + GSList* filtered_contacts = _filter_contacts(contacts); g_slist_free(contacts); if (filtered_contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) { @@ -272,7 +271,7 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) _rosterwin_contacts_header(layout, "no group", filtered_contacts); } - GSList *curr_contact = filtered_contacts; + GSList* curr_contact = filtered_contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); @@ -283,10 +282,10 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group) } static void -_rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) +_rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin) { - const char *const name = chatwin->barejid; - const char *const presence = "offline"; + const char* const name = chatwin->barejid; + const char* const presence = "offline"; int unread = 0; roster_contact_theme_t theme_type = ROSTER_CONTACT; @@ -300,7 +299,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) theme_item_t presence_colour = _get_roster_theme(theme_type, presence); wattron(layout->subwin, theme_attrs(presence_colour)); - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); int indent = prefs_get_roster_contact_indent(); int current_indent = 0; if (indent > 0) { @@ -315,7 +314,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) g_string_append_printf(msg, "%c", ch); } - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) { g_string_append_printf(msg, "(%d) ", unread); unread = 0; @@ -334,16 +333,16 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin) } static void -_rosterwin_contact(ProfLayoutSplit *layout, PContact contact) +_rosterwin_contact(ProfLayoutSplit* layout, PContact contact) { - const char *name = p_contact_name_or_jid(contact); - const char *presence = p_contact_presence(contact); - const char *status = p_contact_status(contact); - const char *barejid = p_contact_barejid(contact); + const char* name = p_contact_name_or_jid(contact); + const char* presence = p_contact_presence(contact); + const char* status = p_contact_status(contact); + const char* barejid = p_contact_barejid(contact); int unread = 0; roster_contact_theme_t theme_type = ROSTER_CONTACT; - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { if (chatwin->unread > 0) { theme_type = ROSTER_CONTACT_UNREAD; @@ -362,7 +361,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) wattron(layout->subwin, theme_attrs(presence_colour)); } - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); int indent = prefs_get_roster_contact_indent(); int current_indent = 0; if (indent > 0) { @@ -377,7 +376,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) g_string_append_printf(msg, "%c", ch); } - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) { g_string_append_printf(msg, "(%d) ", unread); unread = 0; @@ -408,7 +407,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) _rosterwin_resources(layout, contact, current_indent, theme_type, unread); } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { if (unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -422,8 +421,8 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact) } static void -_rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *status, - int current_indent) +_rosterwin_presence(ProfLayoutSplit* layout, const char* presence, const char* status, + int current_indent) { // don't show presence for offline contacts gboolean is_offline = g_strcmp0(presence, "offline") == 0; @@ -431,7 +430,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s return; } - char *by = prefs_get_string(PREF_ROSTER_BY); + char* by = prefs_get_string(PREF_ROSTER_BY); gboolean by_presence = g_strcmp0(by, "presence") == 0; g_free(by); @@ -449,13 +448,13 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s wattron(layout->subwin, theme_attrs(colour)); if (presence_indent == -1) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); g_string_append_printf(msg, ": \"%s\"", status); win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent); g_string_free(msg, TRUE); wattroff(layout->subwin, theme_attrs(colour)); } else { - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); while (current_indent > 0) { g_string_append(msg, " "); current_indent--; @@ -468,11 +467,11 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s } } - // show both presence and status when not grouped by presence + // show both presence and status when not grouped by presence } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || (status && prefs_get_boolean(PREF_ROSTER_STATUS))) { wattron(layout->subwin, theme_attrs(colour)); if (presence_indent == -1) { - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) { g_string_append_printf(msg, ": %s", presence); if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) { @@ -485,7 +484,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s g_string_free(msg, TRUE); wattroff(layout->subwin, theme_attrs(colour)); } else { - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); while (current_indent > 0) { g_string_append(msg, " "); current_indent--; @@ -507,22 +506,22 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s } static void -_rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent, roster_contact_theme_t theme_type, - int unread) +_rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_indent, roster_contact_theme_t theme_type, + int unread) { gboolean join = prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN); - GList *resources = p_contact_get_available_resources(contact); + GList* resources = p_contact_get_available_resources(contact); if (resources) { // resource on same line as contact if (join && (g_list_length(resources) == 1)) { - Resource *resource = resources->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = resources->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t resource_presence_colour = _get_roster_theme(theme_type, resource_presence); wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(""); + GString* msg = g_string_new(""); char ch = prefs_get_roster_resource_char(); if (ch) { g_string_append_printf(msg, "%c", ch); @@ -534,7 +533,7 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde g_string_append_printf(msg, " %d", resource->priority); } - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { g_string_append_printf(msg, " (%d)", unread); } @@ -549,16 +548,16 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde _rosterwin_presence(layout, resource_presence, resource->status, current_indent); } - // resource(s) on new lines + // resource(s) on new lines } else { gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); theme_item_t presence_colour = _get_roster_theme(theme_type, presence); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -573,14 +572,14 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde current_indent += resource_indent; } - GList *curr_resource = resources; + GList* curr_resource = resources; while (curr_resource) { - Resource *resource = curr_resource->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = curr_resource->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t resource_presence_colour = _get_roster_theme(ROSTER_CONTACT, resource_presence); wattron(layout->subwin, theme_attrs(resource_presence_colour)); - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); int this_indent = current_indent; while (this_indent > 0) { g_string_append(msg, " "); @@ -607,14 +606,14 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde } } } else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) { - const char *presence = p_contact_presence(contact); - const char *status = p_contact_status(contact); + const char* presence = p_contact_presence(contact); + const char* status = p_contact_status(contact); theme_item_t presence_colour = _get_roster_theme(theme_type, presence); gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -627,11 +626,11 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde } else { gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP); - char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD); if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) { - GString *unreadmsg = g_string_new(""); + GString* unreadmsg = g_string_new(""); g_string_append_printf(unreadmsg, " (%d)", unread); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); theme_item_t presence_colour = _get_roster_theme(theme_type, presence); wattron(layout->subwin, theme_attrs(presence_colour)); @@ -643,18 +642,17 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde } g_list_free(resources); - } static void -_rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms) +_rosterwin_rooms(ProfLayoutSplit* layout, char* title, GList* rooms) { - GList *rooms_sorted = NULL; - GList *curr_room = rooms; + GList* rooms_sorted = NULL; + GList* curr_room = rooms; while (curr_room) { - ProfMucWin *mucwin = wins_get_muc(curr_room->data); + ProfMucWin* mucwin = wins_get_muc(curr_room->data); if (mucwin) { - char *order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); + char* order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER); if (g_strcmp0(order, "unread") == 0) { rooms_sorted = g_list_insert_sorted(rooms_sorted, mucwin, (GCompareFunc)_compare_rooms_unread); } else { @@ -669,7 +667,7 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms) if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) { _rosterwin_rooms_header(layout, rooms_sorted, title); - GList *curr_room = rooms_sorted; + GList* curr_room = rooms_sorted; while (curr_room) { _rosterwin_room(layout, curr_room->data); curr_room = g_list_next(curr_room); @@ -680,14 +678,14 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms) } static void -_rosterwin_rooms_by_service(ProfLayoutSplit *layout) +_rosterwin_rooms_by_service(ProfLayoutSplit* layout) { - GList *rooms = muc_rooms(); - GList *curr = rooms; - GList *services = NULL; + GList* rooms = muc_rooms(); + GList* curr = rooms; + GList* services = NULL; while (curr) { - char *roomjid = curr->data; - Jid *jidp = jid_create(roomjid); + char* roomjid = curr->data; + Jid* jidp = jid_create(roomjid); if (!g_list_find_custom(services, jidp->domainpart, (GCompareFunc)g_strcmp0)) { services = g_list_insert_sorted(services, strdup(jidp->domainpart), (GCompareFunc)g_strcmp0); @@ -697,15 +695,15 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout) curr = g_list_next(curr); } - GList *curr_service = services; + GList* curr_service = services; while (curr_service) { - char *service = curr_service->data; - GList *filtered_rooms = NULL; + char* service = curr_service->data; + GList* filtered_rooms = NULL; curr = rooms; while (curr) { - char *roomjid = curr->data; - Jid *jidp = jid_create(roomjid); + char* roomjid = curr->data; + Jid* jidp = jid_create(roomjid); if (g_strcmp0(curr_service->data, jidp->domainpart) == 0) { filtered_rooms = g_list_append(filtered_rooms, strdup(jidp->barejid)); @@ -726,9 +724,9 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout) } static void -_rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) +_rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin) { - GString *msg = g_string_new(" "); + GString* msg = g_string_new(" "); if (mucwin->unread_mentions) { wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION)); @@ -754,17 +752,17 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append_printf(msg, "%c", ch); } - char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && mucwin->unread > 0) { g_string_append_printf(msg, "(%d) ", mucwin->unread); } - char *use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); - char *roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); + char* use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME); + char* roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); if (g_strcmp0(roombypref, "service") == 0) { if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) { - Jid *jidp = jid_create(mucwin->roomjid); + Jid* jidp = jid_create(mucwin->roomjid); g_string_append(msg, jidp->localpart); jid_destroy(jidp); } else { @@ -780,10 +778,9 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append(msg, mucwin->room_name); } } else { - Jid *jidp = jid_create(mucwin->roomjid); + Jid* jidp = jid_create(mucwin->roomjid); - if (mucwin->room_name == NULL || - (g_strcmp0(use_as_name, "jid") == 0)) { + if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) { g_string_append(msg, jidp->localpart); } else { g_string_append(msg, mucwin->room_name); @@ -816,15 +813,15 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM)); } - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "room") == 0) { - GList *privs = wins_get_private_chats(mucwin->roomjid); - GList *curr = privs; + GList* privs = wins_get_private_chats(mucwin->roomjid); + GList* curr = privs; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; win_sub_newline_lazy(layout->subwin); - GString *privmsg = g_string_new(" "); + GString* privmsg = g_string_new(" "); indent = prefs_get_roster_contact_indent(); current_indent = 0; if (indent > 0) { @@ -855,7 +852,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) g_string_append_printf(privmsg, "%c", ch); } - char *nick = privwin->fulljid + strlen(mucwin->roomjid) + 1; + char* nick = privwin->fulljid + strlen(mucwin->roomjid) + 1; g_string_append(privmsg, nick); if ((g_strcmp0(unreadpos, "after") == 0) && privwin->unread > 0) { @@ -863,9 +860,9 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) } g_free(unreadpos); - const char *presence = "offline"; + const char* presence = "offline"; - Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); + Occupant* occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { presence = string_from_resource_presence(occupant->presence); } @@ -892,13 +889,13 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin) } static void -_rosterwin_print_rooms(ProfLayoutSplit *layout) +_rosterwin_print_rooms(ProfLayoutSplit* layout) { - char *roomsbypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); + char* roomsbypref = prefs_get_string(PREF_ROSTER_ROOMS_BY); if (g_strcmp0(roomsbypref, "service") == 0) { _rosterwin_rooms_by_service(layout); } else { - GList *rooms = muc_rooms(); + GList* rooms = muc_rooms(); _rosterwin_rooms(layout, "Rooms", rooms); g_list_free(rooms); } @@ -906,15 +903,15 @@ _rosterwin_print_rooms(ProfLayoutSplit *layout) } static void -_rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) +_rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats) { - GList *privs = NULL; + GList* privs = NULL; - char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE); + char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(privpref, "group") == 0) { privs = wins_get_private_chats(NULL); } else { - GList *curr = orphaned_privchats; + GList* curr = orphaned_privchats; while (curr) { privs = g_list_append(privs, curr->data); curr = g_list_next(curr); @@ -924,12 +921,12 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) if (privs || prefs_get_boolean(PREF_ROSTER_EMPTY)) { _rosterwin_private_header(layout, privs); - GList *curr = privs; + GList* curr = privs; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; win_sub_newline_lazy(layout->subwin); - GString *privmsg = g_string_new(" "); + GString* privmsg = g_string_new(" "); int indent = prefs_get_roster_contact_indent(); int current_indent = 0; if (indent > 0) { @@ -940,7 +937,7 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) } } - char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); + char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD); if ((g_strcmp0(unreadpos, "before") == 0) && privwin->unread > 0) { g_string_append_printf(privmsg, "(%d) ", privwin->unread); } @@ -957,11 +954,11 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) } g_free(unreadpos); - Jid *jidp = jid_create(privwin->fulljid); - Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart); + Jid* jidp = jid_create(privwin->fulljid); + Occupant* occupant = muc_roster_item(jidp->barejid, jidp->resourcepart); jid_destroy(jidp); - const char *presence = "offline"; + const char* presence = "offline"; if (occupant) { presence = string_from_resource_presence(occupant->presence); } @@ -988,24 +985,28 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats) } static theme_item_t -_get_roster_theme(roster_contact_theme_t theme_type, const char *presence) +_get_roster_theme(roster_contact_theme_t theme_type, const char* presence) { switch (theme_type) { - case ROSTER_CONTACT: return theme_roster_presence_attrs(presence); - case ROSTER_CONTACT_ACTIVE: return theme_roster_active_presence_attrs(presence); - case ROSTER_CONTACT_UNREAD: return theme_roster_unread_presence_attrs(presence); - default: return theme_roster_presence_attrs(presence); + case ROSTER_CONTACT: + return theme_roster_presence_attrs(presence); + case ROSTER_CONTACT_ACTIVE: + return theme_roster_active_presence_attrs(presence); + case ROSTER_CONTACT_UNREAD: + return theme_roster_unread_presence_attrs(presence); + default: + return theme_roster_presence_attrs(presence); } } static int -_compare_rooms_name(ProfMucWin *a, ProfMucWin *b) +_compare_rooms_name(ProfMucWin* a, ProfMucWin* b) { return g_strcmp0(a->roomjid, b->roomjid); } static int -_compare_rooms_unread(ProfMucWin *a, ProfMucWin *b) +_compare_rooms_unread(ProfMucWin* a, ProfMucWin* b) { if (a->unread > b->unread) { return -1; @@ -1017,11 +1018,11 @@ _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b) } static void -_rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) +_rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins) { win_sub_newline_lazy(layout->subwin); - GString *header = g_string_new(" "); + GString* header = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(header, "%c", ch); @@ -1029,7 +1030,7 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) g_string_append(header, "Unsubscribed"); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int itemcount = g_list_length(wins); if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1039,9 +1040,9 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) } } else if (g_strcmp0(countpref, "unread") == 0) { int unreadcount = 0; - GList *curr = wins; + GList* curr = wins; while (curr) { - ProfChatWin *chatwin = curr->data; + ProfChatWin* chatwin = curr->data; unreadcount += chatwin->unread; curr = g_list_next(curr); } @@ -1063,11 +1064,11 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins) } static void -_rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSList *contacts) +_rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSList* contacts) { win_sub_newline_lazy(layout->subwin); - GString *header = g_string_new(" "); + GString* header = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(header, "%c", ch); @@ -1075,7 +1076,7 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL g_string_append(header, title); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int itemcount = g_slist_length(contacts); if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1085,11 +1086,11 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL } } else if (g_strcmp0(countpref, "unread") == 0) { int unreadcount = 0; - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { PContact contact = curr->data; - const char *barejid = p_contact_barejid(contact); - ProfChatWin *chatwin = wins_get_chat(barejid); + const char* barejid = p_contact_barejid(contact); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { unreadcount += chatwin->unread; } @@ -1113,17 +1114,17 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL } static void -_rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title) +_rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title) { win_sub_newline_lazy(layout->subwin); - GString *header = g_string_new(" "); + GString* header = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(header, "%c", ch); } g_string_append(header, title); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int count = g_list_length(rooms); if (count == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1133,18 +1134,18 @@ _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title) } } else if (g_strcmp0(countpref, "unread") == 0) { int unread = 0; - GList *curr = rooms; + GList* curr = rooms; while (curr) { - ProfMucWin *mucwin = curr->data; + ProfMucWin* mucwin = curr->data; unread += mucwin->unread; // include private chats - char *prefpriv = prefs_get_string(PREF_ROSTER_PRIVATE); + char* prefpriv = prefs_get_string(PREF_ROSTER_PRIVATE); if (g_strcmp0(prefpriv, "room") == 0) { - GList *privwins = wins_get_private_chats(mucwin->roomjid); - GList *curr_priv = privwins; + GList* privwins = wins_get_private_chats(mucwin->roomjid); + GList* curr_priv = privwins; while (curr_priv) { - ProfPrivateWin *privwin = curr_priv->data; + ProfPrivateWin* privwin = curr_priv->data; unread += privwin->unread; curr_priv = g_list_next(curr_priv); } @@ -1173,18 +1174,18 @@ _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title) } static void -_rosterwin_private_header(ProfLayoutSplit *layout, GList *privs) +_rosterwin_private_header(ProfLayoutSplit* layout, GList* privs) { win_sub_newline_lazy(layout->subwin); - GString *title_str = g_string_new(" "); + GString* title_str = g_string_new(" "); char ch = prefs_get_roster_header_char(); if (ch) { g_string_append_printf(title_str, "%c", ch); } g_string_append(title_str, "Private chats"); - char *countpref = prefs_get_string(PREF_ROSTER_COUNT); + char* countpref = prefs_get_string(PREF_ROSTER_COUNT); if (g_strcmp0(countpref, "items") == 0) { int itemcount = g_list_length(privs); if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) { @@ -1194,9 +1195,9 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs) } } else if (g_strcmp0(countpref, "unread") == 0) { int unreadcount = 0; - GList *curr = privs; + GList* curr = privs; while (curr) { - ProfPrivateWin *privwin = curr->data; + ProfPrivateWin* privwin = curr->data; unreadcount += privwin->unread; curr = g_list_next(curr); } @@ -1218,32 +1219,32 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs) } static GSList* -_filter_contacts(GSList *contacts) +_filter_contacts(GSList* contacts) { - GSList *filtered_contacts = NULL; + GSList* filtered_contacts = NULL; // if show offline, include all contacts if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { filtered_contacts = g_slist_append(filtered_contacts, curr->data); curr = g_slist_next(curr); } - // if dont show offline + // if dont show offline } else { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { PContact contact = curr->data; - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); // include if offline and unread messages if (g_strcmp0(presence, "offline") == 0) { - ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact)); + ProfChatWin* chatwin = wins_get_chat(p_contact_barejid(contact)); if (chatwin && chatwin->unread > 0) { filtered_contacts = g_slist_append(filtered_contacts, contact); } - // include if not offline + // include if not offline } else { filtered_contacts = g_slist_append(filtered_contacts, contact); } @@ -1255,27 +1256,27 @@ _filter_contacts(GSList *contacts) } static GSList* -_filter_contacts_with_presence(GSList *contacts, const char *const presence) +_filter_contacts_with_presence(GSList* contacts, const char* const presence) { - GSList *filtered_contacts = NULL; + GSList* filtered_contacts = NULL; // handling offline contacts if (g_strcmp0(presence, "offline") == 0) { // if show offline, include all contacts if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { filtered_contacts = g_slist_append(filtered_contacts, curr->data); curr = g_slist_next(curr); } - // otherwise show if unread messages + // otherwise show if unread messages } else { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { PContact contact = curr->data; - ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact)); + ProfChatWin* chatwin = wins_get_chat(p_contact_barejid(contact)); if (chatwin && chatwin->unread > 0) { filtered_contacts = g_slist_append(filtered_contacts, contact); } @@ -1283,9 +1284,9 @@ _filter_contacts_with_presence(GSList *contacts, const char *const presence) } } - // any other presence, include all + // any other presence, include all } else { - GSList *curr = contacts; + GSList* curr = contacts; while (curr) { filtered_contacts = g_slist_append(filtered_contacts, curr->data); curr = g_slist_next(curr); diff --git a/src/ui/screen.c b/src/ui/screen.c index 2e6faf4b..8a676082 100644 --- a/src/ui/screen.c +++ b/src/ui/screen.c @@ -44,7 +44,8 @@ #include "config/preferences.h" int -_screen_line_row(int win_pos, int mainwin_pos) { +_screen_line_row(int win_pos, int mainwin_pos) +{ int wrows = getmaxy(stdscr); if (win_pos == 1) { @@ -54,7 +55,7 @@ _screen_line_row(int win_pos, int mainwin_pos) { if (win_pos == 2) { int row = 1; if (mainwin_pos == 1) { - row = wrows-3; + row = wrows - 3; } return row; @@ -63,19 +64,19 @@ _screen_line_row(int win_pos, int mainwin_pos) { if (win_pos == 3) { int row = 2; if (mainwin_pos == 1 || mainwin_pos == 2) { - row = wrows-2; + row = wrows - 2; } return row; } - return wrows-1; + return wrows - 1; } int screen_titlebar_row(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->titlebar_pos, placement->mainwin_pos); prefs_free_win_placement(placement); @@ -85,7 +86,7 @@ screen_titlebar_row(void) int screen_statusbar_row(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->statusbar_pos, placement->mainwin_pos); prefs_free_win_placement(placement); @@ -95,7 +96,7 @@ screen_statusbar_row(void) int screen_inputwin_row(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int row = _screen_line_row(placement->inputwin_pos, placement->mainwin_pos); prefs_free_win_placement(placement); @@ -105,8 +106,8 @@ screen_inputwin_row(void) int screen_mainwin_row_start(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); - int row = placement->mainwin_pos-1; + ProfWinPlacement* placement = prefs_get_win_placement(); + int row = placement->mainwin_pos - 1; prefs_free_win_placement(placement); return row; @@ -115,7 +116,7 @@ screen_mainwin_row_start(void) int screen_mainwin_row_end(void) { - ProfWinPlacement *placement = prefs_get_win_placement(); + ProfWinPlacement* placement = prefs_get_win_placement(); int wrows = getmaxy(stdscr); int row = wrows - (5 - placement->mainwin_pos); prefs_free_win_placement(placement); diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index d2c67483..146cc1ea 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -55,33 +55,35 @@ #include "xmpp/roster_list.h" #include "xmpp/contact.h" -typedef struct _status_bar_tab_t { +typedef struct _status_bar_tab_t +{ win_type_t window_type; - char *identifier; + char* identifier; gboolean highlight; - char *display_name; + char* display_name; } StatusBarTab; -typedef struct _status_bar_t { - gchar *time; - char *prompt; - char *fulljid; - GHashTable *tabs; +typedef struct _status_bar_t +{ + gchar* time; + char* prompt; + char* fulljid; + GHashTable* tabs; int current_tab; } StatusBar; -static GTimeZone *tz; -static StatusBar *statusbar; -static WINDOW *statusbar_win; +static GTimeZone* tz; +static StatusBar* statusbar; +static WINDOW* statusbar_win; static int _status_bar_draw_time(int pos); static void _status_bar_draw_maintext(int pos); static int _status_bar_draw_bracket(gboolean current, int pos, char* ch); static int _status_bar_draw_extended_tabs(int pos); -static int _status_bar_draw_tab(StatusBarTab *tab, int pos, int num); -static void _destroy_tab(StatusBarTab *tab); +static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num); +static void _destroy_tab(StatusBarTab* tab); static int _tabs_width(void); -static char* _display_name(StatusBarTab *tab); +static char* _display_name(StatusBarTab* tab); static gboolean _extended_new(void); void @@ -94,7 +96,7 @@ status_bar_init(void) statusbar->prompt = NULL; statusbar->fulljid = NULL; statusbar->tabs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)_destroy_tab); - StatusBarTab *console = calloc(1, sizeof(StatusBarTab)); + StatusBarTab* console = calloc(1, sizeof(StatusBarTab)); console->window_type = WIN_CONSOLE; console->identifier = strdup("console"); console->display_name = NULL; @@ -175,14 +177,14 @@ status_bar_inactive(const int win) } void -_create_tab(const int win, win_type_t wintype, char *identifier, gboolean highlight) +_create_tab(const int win, win_type_t wintype, char* identifier, gboolean highlight) { int true_win = win; if (true_win == 0) { true_win = 10; } - StatusBarTab *tab = malloc(sizeof(StatusBarTab)); + StatusBarTab* tab = malloc(sizeof(StatusBarTab)); tab->identifier = strdup(identifier); tab->highlight = highlight; tab->window_type = wintype; @@ -196,13 +198,11 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli if (contact && p_contact_name(contact)) { tab->display_name = strdup(p_contact_name(contact)); } else { - char *pref = prefs_get_string(PREF_STATUSBAR_CHAT); + char* pref = prefs_get_string(PREF_STATUSBAR_CHAT); if (g_strcmp0("user", pref) == 0) { - Jid *jidp = jid_create(tab->identifier); + Jid* jidp = jid_create(tab->identifier); if (jidp) { - tab->display_name = jidp->localpart != NULL ? - strdup(jidp->localpart) : - strdup(jidp->barejid); + tab->display_name = jidp->localpart != NULL ? strdup(jidp->localpart) : strdup(jidp->barejid); jid_destroy(jidp); } else { tab->display_name = strdup(tab->identifier); @@ -220,7 +220,7 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli } void -status_bar_active(const int win, win_type_t wintype, char *identifier) +status_bar_active(const int win, win_type_t wintype, char* identifier) { _create_tab(win, wintype, identifier, FALSE); } @@ -232,7 +232,7 @@ status_bar_new(const int win, win_type_t wintype, char* identifier) } void -status_bar_set_prompt(const char *const prompt) +status_bar_set_prompt(const char* const prompt) { if (statusbar->prompt) { free(statusbar->prompt); @@ -255,7 +255,7 @@ status_bar_clear_prompt(void) } void -status_bar_set_fulljid(const char *const fulljid) +status_bar_set_fulljid(const char* const fulljid) { if (statusbar->fulljid) { free(statusbar->fulljid); @@ -296,7 +296,7 @@ status_bar_draw(void) gint max_tabs = prefs_get_statusbartabs(); int i = 1; for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab) { pos = _status_bar_draw_tab(tab, pos, i); } @@ -319,7 +319,7 @@ _extended_new(void) int i = 0; for (i = max_tabs + 1; i <= tabs_count; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab && tab->highlight) { return TRUE; } @@ -364,7 +364,7 @@ _status_bar_draw_extended_tabs(int pos) } static int -_status_bar_draw_tab(StatusBarTab *tab, int pos, int num) +_status_bar_draw_tab(StatusBarTab* tab, int pos, int num) { int display_num = num == 10 ? 0 : num; gboolean is_current = num == statusbar->current_tab; @@ -397,7 +397,7 @@ _status_bar_draw_tab(StatusBarTab *tab, int pos, int num) pos++; } if (show_name) { - char *display_name = _display_name(tab); + char* display_name = _display_name(tab); mvwprintw(statusbar_win, 0, pos, display_name); pos += utf8_display_len(display_name); free(display_name); @@ -428,7 +428,7 @@ _status_bar_draw_bracket(gboolean current, int pos, char* ch) static int _status_bar_draw_time(int pos) { - char *time_pref = prefs_get_string(PREF_TIME_STATUSBAR); + char* time_pref = prefs_get_string(PREF_TIME_STATUSBAR); if (g_strcmp0(time_pref, "off") == 0) { g_free(time_pref); return pos; @@ -439,8 +439,8 @@ _status_bar_draw_time(int pos) statusbar->time = NULL; } - GDateTime *datetime = g_date_time_new_now(tz); - statusbar->time = g_date_time_format(datetime, time_pref); + GDateTime* datetime = g_date_time_new_now(tz); + statusbar->time = g_date_time_format(datetime, time_pref); assert(statusbar->time != NULL); g_date_time_unref(datetime); @@ -477,17 +477,17 @@ _status_bar_draw_maintext(int pos) gboolean stop = FALSE; if (statusbar->fulljid) { - char *pref = prefs_get_string(PREF_STATUSBAR_SELF); + char* pref = prefs_get_string(PREF_STATUSBAR_SELF); if (g_strcmp0(pref, "off") == 0) { stop = true; } else if (g_strcmp0(pref, "user") == 0) { - Jid *jidp = jid_create(statusbar->fulljid); + Jid* jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->localpart); jid_destroy(jidp); stop = true; } else if (g_strcmp0(pref, "barejid") == 0) { - Jid *jidp = jid_create(statusbar->fulljid); + Jid* jidp = jid_create(statusbar->fulljid); mvwprintw(statusbar_win, 0, pos, jidp->barejid); jid_destroy(jidp); stop = true; @@ -502,7 +502,7 @@ _status_bar_draw_maintext(int pos) } static void -_destroy_tab(StatusBarTab *tab) +_destroy_tab(StatusBarTab* tab) { if (tab) { if (tab->identifier) { @@ -527,14 +527,14 @@ _tabs_width(void) int width = g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1; int i = 0; for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab) { gboolean is_current = i == statusbar->current_tab; // dont calculate this in because not shown if (!show_read && !is_current && !tab->highlight) continue; - char *display_name = _display_name(tab); + char* display_name = _display_name(tab); width += utf8_display_len(display_name); width += 4; free(display_name); @@ -547,14 +547,14 @@ _tabs_width(void) int width = g_hash_table_size(statusbar->tabs) > max_tabs ? 4 : 1; int i = 0; for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); if (tab) { gboolean is_current = i == statusbar->current_tab; // dont calculate this in because not shown if (!show_read && !is_current && !tab->highlight) continue; - char *display_name = _display_name(tab); + char* display_name = _display_name(tab); width += utf8_display_len(display_name); width += 2; free(display_name); @@ -570,9 +570,9 @@ _tabs_width(void) } static char* -_display_name(StatusBarTab *tab) +_display_name(StatusBarTab* tab) { - char *fullname = NULL; + char* fullname = NULL; if (tab->window_type == WIN_CONSOLE) { fullname = strdup("console"); @@ -585,10 +585,10 @@ _display_name(StatusBarTab *tab) fullname = strdup(tab->display_name); } } else if (tab->window_type == WIN_MUC) { - char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); + char* pref = prefs_get_string(PREF_STATUSBAR_ROOM); if (g_strcmp0("room", pref) == 0) { - Jid *jidp = jid_create(tab->identifier); - char *room = strdup(jidp->localpart); + Jid* jidp = jid_create(tab->identifier); + char* room = strdup(jidp->localpart); jid_destroy(jidp); fullname = room; } else { @@ -596,11 +596,11 @@ _display_name(StatusBarTab *tab) } g_free(pref); } else if (tab->window_type == WIN_CONFIG) { - char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); - GString *display_str = g_string_new(""); + char* pref = prefs_get_string(PREF_STATUSBAR_ROOM); + GString* display_str = g_string_new(""); if (g_strcmp0("room", pref) == 0) { - Jid *jidp = jid_create(tab->identifier); + Jid* jidp = jid_create(tab->identifier); g_string_append(display_str, jidp->localpart); jid_destroy(jidp); } else { @@ -609,19 +609,19 @@ _display_name(StatusBarTab *tab) g_free(pref); g_string_append(display_str, " conf"); - char *result = strdup(display_str->str); + char* result = strdup(display_str->str); g_string_free(display_str, TRUE); fullname = result; } else if (tab->window_type == WIN_PRIVATE) { - char *pref = prefs_get_string(PREF_STATUSBAR_ROOM); + char* pref = prefs_get_string(PREF_STATUSBAR_ROOM); if (g_strcmp0("room", pref) == 0) { - GString *display_str = g_string_new(""); - Jid *jidp = jid_create(tab->identifier); + GString* display_str = g_string_new(""); + Jid* jidp = jid_create(tab->identifier); g_string_append(display_str, jidp->localpart); g_string_append(display_str, "/"); g_string_append(display_str, jidp->resourcepart); jid_destroy(jidp); - char *result = strdup(display_str->str); + char* result = strdup(display_str->str); g_string_free(display_str, TRUE); fullname = result; } else { @@ -642,9 +642,9 @@ _display_name(StatusBarTab *tab) return fullname; } - gchar *trimmed = g_utf8_substring(fullname, 0, tablen); + gchar* trimmed = g_utf8_substring(fullname, 0, tablen); free(fullname); - char *trimmedname = strdup(trimmed); + char* trimmedname = strdup(trimmed); g_free(trimmed); return trimmedname; diff --git a/src/ui/statusbar.h b/src/ui/statusbar.h index 6c5513f9..4946e8c3 100644 --- a/src/ui/statusbar.h +++ b/src/ui/statusbar.h @@ -40,9 +40,9 @@ void status_bar_init(void); void status_bar_draw(void); void status_bar_close(void); void status_bar_resize(void); -void status_bar_set_prompt(const char *const prompt); +void status_bar_set_prompt(const char* const prompt); void status_bar_clear_prompt(void); -void status_bar_set_fulljid(const char *const fulljid); +void status_bar_set_fulljid(const char* const fulljid); void status_bar_clear_fulljid(void); void status_bar_current(int i); diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 0a688e10..e587bab0 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -52,21 +52,21 @@ #include "xmpp/roster_list.h" #include "xmpp/chat_session.h" -static WINDOW *win; +static WINDOW* win; static contact_presence_t current_presence; static gboolean tls_secured; static gboolean is_connected; static gboolean typing; -static GTimer *typing_elapsed; +static GTimer* typing_elapsed; static void _title_bar_draw(void); -static void _show_self_presence(void); -static int _calc_self_presence(void); -static void _show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos); -static void _show_privacy(ProfChatWin *chatwin); -static void _show_muc_privacy(ProfMucWin *mucwin); -static void _show_scrolled(ProfWin *current); +static void _show_self_presence(void); +static int _calc_self_presence(void); +static void _show_contact_presence(ProfChatWin* chatwin, int pos, int maxpos); +static void _show_privacy(ProfChatWin* chatwin); +static void _show_muc_privacy(ProfMucWin* mucwin); +static void _show_scrolled(ProfWin* current); void create_title_bar(void) @@ -87,7 +87,7 @@ create_title_bar(void) void title_bar_update_virtual(void) { - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); if (window->type != WIN_CONSOLE) { if (typing_elapsed) { gdouble seconds = g_timer_elapsed(typing_elapsed, NULL); @@ -186,7 +186,7 @@ _title_bar_draw(void) { int pos; int maxrightpos; - ProfWin *current = wins_get_current(); + ProfWin* current = wins_get_current(); werase(win); wmove(win, 0, 0); @@ -195,7 +195,7 @@ _title_bar_draw(void) waddch(win, ' '); } - char *title = win_get_title(current); + char* title = win_get_title(current); mvwprintw(win, 0, 0, " %s", title); pos = strlen(title) + 1; @@ -207,7 +207,7 @@ _title_bar_draw(void) maxrightpos = _calc_self_presence(); if (current && current->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) current; + ProfChatWin* chatwin = (ProfChatWin*)current; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); _show_contact_presence(chatwin, pos, maxrightpos); _show_privacy(chatwin); @@ -217,7 +217,7 @@ _title_bar_draw(void) wprintw(win, " (typing...)"); } } else if (current && current->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) current; + ProfMucWin* mucwin = (ProfMucWin*)current; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); _show_muc_privacy(mucwin); _show_scrolled(current); @@ -230,7 +230,7 @@ _title_bar_draw(void) } static void -_show_scrolled(ProfWin *current) +_show_scrolled(ProfWin* current) { if (current && current->layout->paged == 1) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); @@ -255,26 +255,25 @@ _calc_self_presence(void) { int tls_start = 0; - switch (current_presence) - { - case CONTACT_ONLINE: - tls_start = 15; - break; - case CONTACT_AWAY: - tls_start = 13; - break; - case CONTACT_DND: - tls_start = 12; - break; - case CONTACT_CHAT: - tls_start = 13; - break; - case CONTACT_XA: - tls_start = 11; - break; - case CONTACT_OFFLINE: - tls_start = 16; - break; + switch (current_presence) { + case CONTACT_ONLINE: + tls_start = 15; + break; + case CONTACT_AWAY: + tls_start = 13; + break; + case CONTACT_DND: + tls_start = 12; + break; + case CONTACT_CHAT: + tls_start = 13; + break; + case CONTACT_XA: + tls_start = 11; + break; + case CONTACT_OFFLINE: + tls_start = 16; + break; } return tls_start - 1; @@ -291,68 +290,67 @@ _show_self_presence(void) int tls_start = 0; - switch (current_presence) - { - case CONTACT_ONLINE: - presence_attrs = theme_attrs(THEME_TITLE_ONLINE); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 9, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 8, "online"); - wattroff(win, presence_attrs); - tls_start = 15; - break; - case CONTACT_AWAY: - presence_attrs = theme_attrs(THEME_TITLE_AWAY); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 7, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 6, "away"); - wattroff(win, presence_attrs); - tls_start = 13; - break; - case CONTACT_DND: - presence_attrs = theme_attrs(THEME_TITLE_DND); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 6, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 5, "dnd"); - wattroff(win, presence_attrs); - tls_start = 12; - break; - case CONTACT_CHAT: - presence_attrs = theme_attrs(THEME_TITLE_CHAT); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 7, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 6, "chat"); - wattroff(win, presence_attrs); - tls_start = 13; - break; - case CONTACT_XA: - presence_attrs = theme_attrs(THEME_TITLE_XA); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 5, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 4, "xa"); - wattroff(win, presence_attrs); - tls_start = 11; - break; - case CONTACT_OFFLINE: - presence_attrs = theme_attrs(THEME_TITLE_OFFLINE); - wattron(win, bracket_attrs); - mvwaddch(win, 0, cols - 10, '['); - wattroff(win, bracket_attrs); - wattron(win, presence_attrs); - mvwprintw(win, 0, cols - 9, "offline"); - wattroff(win, presence_attrs); - tls_start = 16; - break; + switch (current_presence) { + case CONTACT_ONLINE: + presence_attrs = theme_attrs(THEME_TITLE_ONLINE); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 9, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 8, "online"); + wattroff(win, presence_attrs); + tls_start = 15; + break; + case CONTACT_AWAY: + presence_attrs = theme_attrs(THEME_TITLE_AWAY); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 7, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 6, "away"); + wattroff(win, presence_attrs); + tls_start = 13; + break; + case CONTACT_DND: + presence_attrs = theme_attrs(THEME_TITLE_DND); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 6, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 5, "dnd"); + wattroff(win, presence_attrs); + tls_start = 12; + break; + case CONTACT_CHAT: + presence_attrs = theme_attrs(THEME_TITLE_CHAT); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 7, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 6, "chat"); + wattroff(win, presence_attrs); + tls_start = 13; + break; + case CONTACT_XA: + presence_attrs = theme_attrs(THEME_TITLE_XA); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 5, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 4, "xa"); + wattroff(win, presence_attrs); + tls_start = 11; + break; + case CONTACT_OFFLINE: + presence_attrs = theme_attrs(THEME_TITLE_OFFLINE); + wattron(win, bracket_attrs); + mvwaddch(win, 0, cols - 10, '['); + wattroff(win, bracket_attrs); + wattron(win, presence_attrs); + mvwprintw(win, 0, cols - 9, "offline"); + wattroff(win, presence_attrs); + tls_start = 16; + break; } wattron(win, bracket_attrs); @@ -381,7 +379,7 @@ _show_self_presence(void) } static void -_show_muc_privacy(ProfMucWin *mucwin) +_show_muc_privacy(ProfMucWin* mucwin) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED); @@ -417,7 +415,7 @@ _show_muc_privacy(ProfMucWin *mucwin) } static void -_show_privacy(ProfChatWin *chatwin) +_show_privacy(ProfChatWin* chatwin) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); int encrypted_attrs = theme_attrs(THEME_TITLE_ENCRYPTED); @@ -492,7 +490,7 @@ _show_privacy(ProfChatWin *chatwin) } if (chatwin->pgp_send || chatwin->pgp_recv) { - GString *pgpmsg = g_string_new("PGP "); + GString* pgpmsg = g_string_new("PGP "); if (chatwin->pgp_send && !chatwin->pgp_recv) { g_string_append(pgpmsg, "send"); } else if (!chatwin->pgp_send && chatwin->pgp_recv) { @@ -545,12 +543,12 @@ _show_privacy(ProfChatWin *chatwin) } static void -_show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos) +_show_contact_presence(ProfChatWin* chatwin, int pos, int maxpos) { int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); - char *resource = NULL; + char* resource = NULL; - ChatSession *session = chat_session_get(chatwin->barejid); + ChatSession* session = chat_session_get(chatwin->barejid); if (chatwin->resource_override) { resource = chatwin->resource_override; } else if (session && session->resource) { @@ -567,14 +565,14 @@ _show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos) if (prefs_get_boolean(PREF_PRESENCE)) { theme_item_t presence_colour = THEME_TITLE_OFFLINE; - const char *presence = "offline"; + const char* presence = "offline"; jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { PContact contact = roster_get_contact(chatwin->barejid); if (contact) { if (resource) { - Resource *resourcep = p_contact_get_resource(contact, resource); + Resource* resourcep = p_contact_get_resource(contact, resource); if (resourcep) { presence = string_from_resource_presence(resourcep->presence); } diff --git a/src/ui/tray.c b/src/ui/tray.c index 6d79b379..c1b07245 100644 --- a/src/ui/tray.c +++ b/src/ui/tray.c @@ -48,9 +48,9 @@ #include "ui/window_list.h" static gboolean gtk_ready = FALSE; -static GtkStatusIcon *prof_tray = NULL; -static GString *icon_filename = NULL; -static GString *icon_msg_filename = NULL; +static GtkStatusIcon* prof_tray = NULL; +static GString* icon_filename = NULL; +static GString* icon_msg_filename = NULL; static gint unread_messages; static gboolean shutting_down; static guint timer; @@ -66,7 +66,7 @@ static guint timer; static void _get_icons(void) { - GString *icons_dir = NULL; + GString* icons_dir = NULL; #ifdef ICONS_PATH @@ -79,18 +79,18 @@ _get_icons(void) #endif /* ICONS_PATH */ - gchar *icons_dir_s = files_get_config_path(DIR_ICONS); + gchar* icons_dir_s = files_get_config_path(DIR_ICONS); icons_dir = g_string_new(icons_dir_s); g_free(icons_dir_s); - GError *err = NULL; + GError* err = NULL; if (!g_file_test(icons_dir->str, G_FILE_TEST_IS_DIR)) { return; } - GDir *dir = g_dir_open(icons_dir->str, 0, &err); + GDir* dir = g_dir_open(icons_dir->str, 0, &err); if (dir) { - GString *name = g_string_new(g_dir_read_name(dir)); + GString* name = g_string_new(g_dir_read_name(dir)); while (name->len) { if (g_strcmp0("proIcon.png", name->str) == 0) { if (icon_filename) { diff --git a/src/ui/ui.h b/src/ui/ui.h index b91ea8b4..6efc837b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -50,12 +50,12 @@ #include "otr/otr.h" #endif -#define NO_ME 1 -#define NO_DATE 2 -#define NO_EOL 4 -#define NO_COLOUR_FROM 8 -#define NO_COLOUR_DATE 16 -#define UNTRUSTED 32 +#define NO_ME 1 +#define NO_DATE 2 +#define NO_EOL 4 +#define NO_COLOUR_FROM 8 +#define NO_COLOUR_DATE 16 +#define UNTRUSTED 32 // core UI void ui_init(void); @@ -64,12 +64,12 @@ void ui_update(void); void ui_close(void); void ui_redraw(void); void ui_resize(void); -void ui_focus_win(ProfWin *window); +void ui_focus_win(ProfWin* window); void ui_sigwinch_handler(int sig); -void ui_handle_otr_error(const char *const barejid, const char *const message); +void ui_handle_otr_error(const char* const barejid, const char* const message); unsigned long ui_get_idle_time(void); void ui_reset_idle_time(void); -void ui_print_system_msg_from_recipient(const char *const barejid, const char *message); +void ui_print_system_msg_from_recipient(const char* const barejid, const char* message); void ui_close_connected_win(int index); int ui_close_all_wins(void); int ui_close_read_wins(void); @@ -77,167 +77,167 @@ void ui_close_win(int index); int ui_win_unread(int index); char* ui_ask_password(void); char* ui_get_line(void); -char* ui_ask_pgp_passphrase(const char *hint, int prev_fail); -void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity); -void ui_contact_typing(const char *const barejid, const char *const resource); +char* ui_ask_pgp_passphrase(const char* hint, int prev_fail); +void ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity); +void ui_contact_typing(const char* const barejid, const char* const resource); void ui_disconnected(void); -void ui_room_join(const char *const roomjid, gboolean focus); -void ui_switch_to_room(const char *const roomjid); -void ui_room_destroy(const char *const roomjid); -void ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid, - const char *const password); -void ui_room_kicked(const char *const roomjid, const char *const actor, const char *const reason); -void ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason); -void ui_leave_room(const char *const roomjid); +void ui_room_join(const char* const roomjid, gboolean focus); +void ui_switch_to_room(const char* const roomjid); +void ui_room_destroy(const char* const roomjid); +void ui_room_destroyed(const char* const roomjid, const char* const reason, const char* const new_jid, + const char* const password); +void ui_room_kicked(const char* const roomjid, const char* const actor, const char* const reason); +void ui_room_banned(const char* const roomjid, const char* const actor, const char* const reason); +void ui_leave_room(const char* const roomjid); void ui_show_roster(void); void ui_hide_roster(void); -void ui_roster_add(const char *const barejid, const char *const name); -void ui_roster_remove(const char *const barejid); -void ui_contact_already_in_group(const char *const contact, const char *const group); -void ui_contact_not_in_group(const char *const contact, const char *const group); -void ui_group_added(const char *const contact, const char *const group); -void ui_group_removed(const char *const contact, const char *const group); -void ui_contact_offline(char *barejid, char *resource, char *status); -void ui_handle_recipient_error(const char *const recipient, const char *const err_msg); -void ui_handle_error(const char *const err_msg); +void ui_roster_add(const char* const barejid, const char* const name); +void ui_roster_remove(const char* const barejid); +void ui_contact_already_in_group(const char* const contact, const char* const group); +void ui_contact_not_in_group(const char* const contact, const char* const group); +void ui_group_added(const char* const contact, const char* const group); +void ui_group_removed(const char* const contact, const char* const group); +void ui_contact_offline(char* barejid, char* resource, char* status); +void ui_handle_recipient_error(const char* const recipient, const char* const err_msg); +void ui_handle_error(const char* const err_msg); void ui_clear_win_title(void); void ui_goodbye_title(void); -void ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message); -void ui_handle_room_config_submit_result(const char *const roomjid); -void ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message); -void ui_show_lines(ProfWin *window, gchar** lines); +void ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message); +void ui_handle_room_config_submit_result(const char* const roomjid); +void ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message); +void ui_show_lines(ProfWin* window, gchar** lines); void ui_redraw_all_room_rosters(void); void ui_show_all_room_rosters(void); void ui_hide_all_room_rosters(void); -void ui_handle_software_version_error(const char *const roomjid, const char *const message); -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); +void ui_handle_software_version_error(const char* const roomjid, const char* const message); +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); void ui_prune_wins(void); -void ui_auto_away(char *message, gint time, resource_presence_t res_presence); -void ui_handle_login_account_success(ProfAccount *account, gboolean secured); -void ui_update_presence(const resource_presence_t resource_presence, const char *const message, const char *const show); -void ui_invalid_command_usage(const char *const cmd, void (*setting_func)(void)); +void ui_auto_away(char* message, gint time, resource_presence_t res_presence); +void ui_handle_login_account_success(ProfAccount* account, gboolean secured); +void ui_update_presence(const resource_presence_t resource_presence, const char* const message, const char* const show); +void ui_invalid_command_usage(const char* const cmd, void (*setting_func)(void)); gboolean ui_win_has_unsaved_form(int num); // Chat window -ProfChatWin* chatwin_new(const char *const barejid); -void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created); -void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id); -void chatwin_recipient_gone(ProfChatWin *chatwin); -void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, gboolean request_receipt, const char *const replace_id); -void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message); -void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity); -void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status); -char* chatwin_get_string(ProfChatWin *chatwin); +ProfChatWin* chatwin_new(const char* const barejid); +void chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created); +void chatwin_receipt_received(ProfChatWin* chatwin, const char* const id); +void chatwin_recipient_gone(ProfChatWin* chatwin); +void chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id, prof_enc_t enc_mode, gboolean request_receipt, const char* const replace_id); +void chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message); +void chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last_activity); +void chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status); +char* chatwin_get_string(ProfChatWin* chatwin); #ifdef HAVE_LIBOTR -void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted); -void chatwin_otr_unsecured(ProfChatWin *chatwin); -void chatwin_otr_trust(ProfChatWin *chatwin); -void chatwin_otr_untrust(ProfChatWin *chatwin); -void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data); +void chatwin_otr_secured(ProfChatWin* chatwin, gboolean trusted); +void chatwin_otr_unsecured(ProfChatWin* chatwin); +void chatwin_otr_trust(ProfChatWin* chatwin); +void chatwin_otr_untrust(ProfChatWin* chatwin); +void chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* data); #endif -void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext); -void chatwin_unset_enctext(ProfChatWin *chatwin); -void chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch); -void chatwin_unset_incoming_char(ProfChatWin *chatwin); -void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch); -void chatwin_unset_outgoing_char(ProfChatWin *chatwin); +void chatwin_set_enctext(ProfChatWin* chatwin, const char* const enctext); +void chatwin_unset_enctext(ProfChatWin* chatwin); +void chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch); +void chatwin_unset_incoming_char(ProfChatWin* chatwin); +void chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch); +void chatwin_unset_outgoing_char(ProfChatWin* chatwin); // MUC window -ProfMucWin* mucwin_new(const char *const barejid); -void mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const actor, const char *const reason); -void mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, const char *const actor, - const char *const reason); -void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, - const char *const affiliation, const char *const actor, const char *const reason); -void mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const char *const role, - const char *const actor, const char *const reason); -void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, - const char *const affiliation, const char *const actor, const char *const reason); -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); -void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence); -void mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message); -void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id); -void mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection); -void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject); -void mucwin_requires_config(ProfMucWin *mucwin); -void mucwin_info(ProfMucWin *mucwin); -void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role); -void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation); -void mucwin_room_info_error(ProfMucWin *mucwin, const char *const error); -void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features); -void mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason); -void mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *const actor, - const char *const reason); -void mucwin_broadcast(ProfMucWin *mucwin, const char *const message); -void mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick); -void mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *const roles, - const char *const affiliation, const char *const show, const char *const status); -void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, const char *const nick); -void mucwin_nick_change(ProfMucWin *mucwin, const char *const nick); -void mucwin_occupant_presence(ProfMucWin *mucwin, const char *const nick, const char *const show, - const char *const status); -void mucwin_update_occupants(ProfMucWin *mucwin); -void mucwin_show_occupants(ProfMucWin *mucwin); -void mucwin_hide_occupants(ProfMucWin *mucwin); -void mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation, const char *const error); -void mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation, GSList *jids); -void mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const char *const affiliation, - const char *const error); -void mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *const role, const char *const error); -void mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *const error); -void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks); -void mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const error); -char* mucwin_get_string(ProfMucWin *mucwin); -void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext); -void mucwin_unset_enctext(ProfMucWin *mucwin); -void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch); -void mucwin_unset_message_char(ProfMucWin *mucwin); +ProfMucWin* mucwin_new(const char* const barejid); +void mucwin_role_change(ProfMucWin* mucwin, const char* const role, const char* const actor, const char* const reason); +void mucwin_affiliation_change(ProfMucWin* mucwin, const char* const affiliation, const char* const actor, + const char* const reason); +void mucwin_role_and_affiliation_change(ProfMucWin* mucwin, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason); +void mucwin_occupant_role_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const actor, const char* const reason); +void mucwin_occupant_affiliation_change(ProfMucWin* mucwin, const char* const nick, + const char* const affiliation, const char* const actor, const char* const reason); +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); +void mucwin_roster(ProfMucWin* mucwin, GList* occupants, const char* const presence); +void mucwin_history(ProfMucWin* mucwin, const ProfMessage* const message); +void mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* const id, prof_enc_t enc_mode, const char* const replace_id); +void mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList* mentions, GList* triggers, gboolean filter_reflection); +void mucwin_subject(ProfMucWin* mucwin, const char* const nick, const char* const subject); +void mucwin_requires_config(ProfMucWin* mucwin); +void mucwin_info(ProfMucWin* mucwin); +void mucwin_show_role_list(ProfMucWin* mucwin, muc_role_t role); +void mucwin_show_affiliation_list(ProfMucWin* mucwin, muc_affiliation_t affiliation); +void mucwin_room_info_error(ProfMucWin* mucwin, const char* const error); +void mucwin_room_disco_info(ProfMucWin* mucwin, GSList* identities, GSList* features); +void mucwin_occupant_kicked(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason); +void mucwin_occupant_banned(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason); +void mucwin_broadcast(ProfMucWin* mucwin, const char* const message); +void mucwin_occupant_offline(ProfMucWin* mucwin, const char* const nick); +void mucwin_occupant_online(ProfMucWin* mucwin, const char* const nick, const char* const roles, + const char* const affiliation, const char* const show, const char* const status); +void mucwin_occupant_nick_change(ProfMucWin* mucwin, const char* const old_nick, const char* const nick); +void mucwin_nick_change(ProfMucWin* mucwin, const char* const nick); +void mucwin_occupant_presence(ProfMucWin* mucwin, const char* const nick, const char* const show, + const char* const status); +void mucwin_update_occupants(ProfMucWin* mucwin); +void mucwin_show_occupants(ProfMucWin* mucwin); +void mucwin_hide_occupants(ProfMucWin* mucwin); +void mucwin_affiliation_list_error(ProfMucWin* mucwin, const char* const affiliation, const char* const error); +void mucwin_handle_affiliation_list(ProfMucWin* mucwin, const char* const affiliation, GSList* jids); +void mucwin_affiliation_set_error(ProfMucWin* mucwin, const char* const jid, const char* const affiliation, + const char* const error); +void mucwin_role_set_error(ProfMucWin* mucwin, const char* const nick, const char* const role, const char* const error); +void mucwin_role_list_error(ProfMucWin* mucwin, const char* const role, const char* const error); +void mucwin_handle_role_list(ProfMucWin* mucwin, const char* const role, GSList* nicks); +void mucwin_kick_error(ProfMucWin* mucwin, const char* const nick, const char* const error); +char* mucwin_get_string(ProfMucWin* mucwin); +void mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext); +void mucwin_unset_enctext(ProfMucWin* mucwin); +void mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch); +void mucwin_unset_message_char(ProfMucWin* mucwin); // MUC private chat window -void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message); -void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message); -void privwin_message_occupant_offline(ProfPrivateWin *privwin); +void privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message); +void privwin_outgoing_msg(ProfPrivateWin* privwin, const char* const message); +void privwin_message_occupant_offline(ProfPrivateWin* privwin); -void privwin_message_left_room(ProfPrivateWin *privwin); +void privwin_message_left_room(ProfPrivateWin* privwin); -char* privwin_get_string(ProfPrivateWin *privwin); -void privwin_occupant_offline(ProfPrivateWin *privwin); -void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_occupant_online(ProfPrivateWin *privwin); +char* privwin_get_string(ProfPrivateWin* privwin); +void privwin_occupant_offline(ProfPrivateWin* privwin); +void privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_occupant_online(ProfPrivateWin* privwin); -void privwin_room_destroyed(ProfPrivateWin *privwin); -void privwin_room_left(ProfPrivateWin *privwin); -void privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason); -void privwin_room_joined(ProfPrivateWin *privwin); +void privwin_room_destroyed(ProfPrivateWin* privwin); +void privwin_room_left(ProfPrivateWin* privwin); +void privwin_room_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_room_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason); +void privwin_room_joined(ProfPrivateWin* privwin); // config window -void confwin_handle_configuration(ProfConfWin *confwin, DataForm *form); -void confwin_show_form(ProfConfWin *confwin); -void confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag); -void confwin_form_help(ProfConfWin *confwin); -void confwin_field_help(ProfConfWin *confwin, char *tag); -char* confwin_get_string(ProfConfWin *confwin); +void confwin_handle_configuration(ProfConfWin* confwin, DataForm* form); +void confwin_show_form(ProfConfWin* confwin); +void confwin_show_form_field(ProfConfWin* confwin, DataForm* form, char* tag); +void confwin_form_help(ProfConfWin* confwin); +void confwin_field_help(ProfConfWin* confwin, char* tag); +char* confwin_get_string(ProfConfWin* confwin); // xml console -void xmlwin_show(ProfXMLWin *xmlwin, const char *const msg); -char* xmlwin_get_string(ProfXMLWin *xmlwin); +void xmlwin_show(ProfXMLWin* xmlwin, const char* const msg); +char* xmlwin_get_string(ProfXMLWin* xmlwin); // Input window char* inp_readline(void); void inp_nonblocking(gboolean reset); // Console window -void cons_show(const char *const msg, ...); -void cons_show_padded(int pad, const char *const msg, ...); +void cons_show(const char* const msg, ...); +void cons_show_padded(int pad, const char* const msg, ...); void cons_about(void); void cons_help(void); -void cons_show_help(const char *const cmd, CommandHelp *help); -void cons_bad_cmd_usage(const char *const cmd); +void cons_show_help(const char* const cmd, CommandHelp* help); +void cons_bad_cmd_usage(const char* const cmd); void cons_navigation_help(void); void cons_prefs(void); void cons_show_ui_prefs(void); @@ -249,36 +249,36 @@ void cons_show_connection_prefs(void); void cons_show_otr_prefs(void); void cons_show_pgp_prefs(void); void cons_show_omemo_prefs(void); -void cons_show_account(ProfAccount *account); -void cons_debug(const char *const msg, ...); -void cons_show_error(const char *const cmd, ...); -void cons_show_contacts(GSList *list); -void cons_show_roster(GSList *list); -void cons_show_roster_group(const char *const group, GSList *list); +void cons_show_account(ProfAccount* account); +void cons_debug(const char* const msg, ...); +void cons_show_error(const char* const cmd, ...); +void cons_show_contacts(GSList* list); +void cons_show_roster(GSList* list); +void cons_show_roster_group(const char* const group, GSList* list); void cons_show_wins(gboolean unread); -char* cons_get_string(ProfConsoleWin *conswin); -void cons_show_status(const char *const barejid); +char* cons_get_string(ProfConsoleWin* conswin); +void cons_show_status(const char* const barejid); void cons_show_info(PContact pcontact); -void cons_show_caps(const char *const fulljid, resource_presence_t presence); -void cons_show_themes(GSList *themes); -void cons_show_scripts(GSList *scripts); -void cons_show_script(const char *const script, GSList *commands); -void cons_show_aliases(GList *aliases); -void cons_show_login_success(ProfAccount *account, gboolean secured); -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_bookmarks_ignore(gchar **list, gsize len); -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, const char *const reason); +void cons_show_caps(const char* const fulljid, resource_presence_t presence); +void cons_show_themes(GSList* themes); +void cons_show_scripts(GSList* scripts); +void cons_show_script(const char* const script, GSList* commands); +void cons_show_aliases(GList* aliases); +void cons_show_login_success(ProfAccount* account, gboolean secured); +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_bookmarks_ignore(gchar** list, gsize len); +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, const char* const reason); void cons_check_version(gboolean not_available_msg); -void cons_show_typing(const char *const barejid); -void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, - gboolean mention, GList *triggers, int unread); -void cons_show_incoming_message(const char *const short_from, const int win_index, int unread); -void cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index, int unread); -void cons_show_room_invites(GList *invites); +void cons_show_typing(const char* const barejid); +void cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, + gboolean mention, GList* triggers, int unread); +void cons_show_incoming_message(const char* const short_from, const int win_index, int unread); +void cons_show_incoming_private_message(const char* const nick, const char* const room, const int win_index, int unread); +void cons_show_room_invites(GList* invites); void cons_show_received_subs(void); void cons_show_sent_subs(void); void cons_alert(void); @@ -322,80 +322,80 @@ void cons_os_setting(void); void cons_correction_setting(void); void cons_executable_setting(void); void cons_slashguard_setting(void); -void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); -void cons_show_contact_offline(PContact contact, char *resource, char *status); +void cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity); +void cons_show_contact_offline(PContact contact, char* resource, char* status); void cons_theme_properties(void); void cons_theme_colours(void); -void cons_show_tlscert(TLSCertificate *cert); -void cons_show_tlscert_summary(TLSCertificate *cert); +void cons_show_tlscert(TLSCertificate* cert); +void cons_show_tlscert_summary(TLSCertificate* cert); // title bar void title_bar_set_presence(contact_presence_t presence); // status bar void status_bar_inactive(const int win); -void status_bar_active(const int win, win_type_t wintype, char *identifier); -void status_bar_new(const int win, win_type_t wintype, char *identifier); +void status_bar_active(const int win, win_type_t wintype, char* identifier); +void status_bar_new(const int win, win_type_t wintype, char* identifier); void status_bar_set_all_inactive(void); // roster window void rosterwin_roster(void); // occupants window -void occupantswin_occupants(const char *const room); +void occupantswin_occupants(const char* const room); void occupantswin_occupants_all(void); // window interface ProfWin* win_create_console(void); ProfWin* win_create_xmlconsole(void); -ProfWin* win_create_chat(const char *const barejid); -ProfWin* win_create_muc(const char *const roomjid); -ProfWin* win_create_config(const char *const title, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata); -ProfWin* win_create_private(const char *const fulljid); -ProfWin* win_create_plugin(const char *const plugin_name, const char *const tag); -void win_update_virtual(ProfWin *window); -void win_free(ProfWin *window); -gboolean win_notify_remind(ProfWin *window); -int win_unread(ProfWin *window); -void win_resize(ProfWin *window); -void win_hide_subwin(ProfWin *window); -void win_show_subwin(ProfWin *window); -void win_refresh_without_subwin(ProfWin *window); -void win_refresh_with_subwin(ProfWin *window); +ProfWin* win_create_chat(const char* const barejid); +ProfWin* win_create_muc(const char* const roomjid); +ProfWin* win_create_config(const char* const title, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata); +ProfWin* win_create_private(const char* const fulljid); +ProfWin* win_create_plugin(const char* const plugin_name, const char* const tag); +void win_update_virtual(ProfWin* window); +void win_free(ProfWin* window); +gboolean win_notify_remind(ProfWin* window); +int win_unread(ProfWin* window); +void win_resize(ProfWin* window); +void win_hide_subwin(ProfWin* window); +void win_show_subwin(ProfWin* window); +void win_refresh_without_subwin(ProfWin* window); +void win_refresh_with_subwin(ProfWin* window); -void win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...); -void win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...); -void win_println_indent(ProfWin *window, int pad, const char *const message, ...); +void win_print(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...); +void win_println(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...); +void win_println_indent(ProfWin* window, int pad, const char* const message, ...); -void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); -void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_append(ProfWin* window, theme_item_t theme_item, const char* const message, ...); +void win_appendln(ProfWin* window, theme_item_t theme_item, const char* const message, ...); -void win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...); -void win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_append_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...); +void win_appendln_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...); -char* win_get_title(ProfWin *window); -void win_show_occupant(ProfWin *window, Occupant *occupant); -void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); -void win_show_contact(ProfWin *window, PContact contact); -void win_show_info(ProfWin *window, PContact contact); -void win_clear(ProfWin *window); -char* win_get_tab_identifier(ProfWin *window); -char* win_to_string(ProfWin *window); -void win_command_list_error(ProfWin *window, const char *const error); -void win_command_exec_error(ProfWin *window, const char *const command, const char *const error, ...); -void win_handle_command_list(ProfWin *window, GSList *cmds); -void win_handle_command_exec_status(ProfWin *window, const char *const type, const char *const value); -void win_handle_command_exec_result_note(ProfWin *window, const char *const type, const char *const value); +char* win_get_title(ProfWin* window); +void win_show_occupant(ProfWin* window, Occupant* occupant); +void win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupant); +void win_show_contact(ProfWin* window, PContact contact); +void win_show_info(ProfWin* window, PContact contact); +void win_clear(ProfWin* window); +char* win_get_tab_identifier(ProfWin* window); +char* win_to_string(ProfWin* window); +void win_command_list_error(ProfWin* window, const char* const error); +void win_command_exec_error(ProfWin* window, const char* const command, const char* const error, ...); +void win_handle_command_list(ProfWin* window, GSList* cmds); +void win_handle_command_exec_status(ProfWin* window, const char* const type, const char* const value); +void win_handle_command_exec_result_note(ProfWin* window, const char* const type, const char* const value); // desktop notifications void notifier_initialise(void); void notifier_uninit(void); -void notify_typing(const char *const name); -void notify_message(const char *const name, int win, const char *const text); -void notify_room_message(const char *const nick, const char *const room, int win, const char *const text); +void notify_typing(const char* const name); +void notify_message(const char* const name, int win, const char* const text); +void notify_room_message(const char* const nick, const char* const room, int win, const char* const text); void notify_remind(void); -void notify_invite(const char *const from, const char *const room, const char *const reason); -void notify(const char *const message, int timeout, const char *const category); -void notify_subscription(const char *const from); +void notify_invite(const char* const from, const char* const room, const char* const reason); +void notify(const char* const message, int timeout, const char* const category); +void notify_subscription(const char* const from); #endif diff --git a/src/ui/win_types.h b/src/ui/win_types.h index cb6834c6..d4196111 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -51,13 +51,13 @@ #include "ui/buffer.h" #include "xmpp/chat_state.h" -#define LAYOUT_SPLIT_MEMCHECK 12345671 -#define PROFCHATWIN_MEMCHECK 22374522 -#define PROFMUCWIN_MEMCHECK 52345276 -#define PROFPRIVATEWIN_MEMCHECK 77437483 -#define PROFCONFWIN_MEMCHECK 64334685 -#define PROFXMLWIN_MEMCHECK 87333463 -#define PROFPLUGINWIN_MEMCHECK 43434777 +#define LAYOUT_SPLIT_MEMCHECK 12345671 +#define PROFCHATWIN_MEMCHECK 22374522 +#define PROFMUCWIN_MEMCHECK 52345276 +#define PROFPRIVATEWIN_MEMCHECK 77437483 +#define PROFCONFWIN_MEMCHECK 64334685 +#define PROFXMLWIN_MEMCHECK 87333463 +#define PROFPLUGINWIN_MEMCHECK 43434777 typedef enum { FIELD_HIDDEN, @@ -73,30 +73,33 @@ typedef enum { FIELD_UNKNOWN } form_field_type_t; -typedef struct form_option_t { - char *label; - char *value; +typedef struct form_option_t +{ + char* label; + char* value; } FormOption; -typedef struct form_field_t { - char *label; - char *type; +typedef struct form_field_t +{ + char* label; + char* type; form_field_type_t type_t; - char *var; - char *description; + char* var; + char* description; gboolean required; - GSList *values; - GSList *options; + GSList* values; + GSList* options; Autocomplete value_ac; } FormField; -typedef struct data_form_t { - char *type; - char *title; - char *instructions; - GSList *fields; - GHashTable *var_to_tag; - GHashTable *tag_to_var; +typedef struct data_form_t +{ + char* type; + char* title; + char* instructions; + GSList* fields; + GHashTable* var_to_tag; + GHashTable* tag_to_var; Autocomplete tag_ac; gboolean modified; } DataForm; @@ -106,21 +109,24 @@ typedef enum { LAYOUT_SPLIT } layout_type_t; -typedef struct prof_layout_t { +typedef struct prof_layout_t +{ layout_type_t type; - WINDOW *win; + WINDOW* win; ProfBuff buffer; int y_pos; int paged; } ProfLayout; -typedef struct prof_layout_simple_t { +typedef struct prof_layout_simple_t +{ ProfLayout base; } ProfLayoutSimple; -typedef struct prof_layout_split_t { +typedef struct prof_layout_split_t +{ ProfLayout base; - WINDOW *subwin; + WINDOW* subwin; int sub_y_pos; unsigned long memcheck; } ProfLayoutSplit; @@ -135,87 +141,95 @@ typedef enum { WIN_PLUGIN } win_type_t; -typedef struct prof_win_t { +typedef struct prof_win_t +{ win_type_t type; - ProfLayout *layout; + ProfLayout* layout; Autocomplete urls_ac; } ProfWin; -typedef struct prof_console_win_t { +typedef struct prof_console_win_t +{ ProfWin window; } ProfConsoleWin; -typedef struct prof_chat_win_t { +typedef struct prof_chat_win_t +{ ProfWin window; - char *barejid; + char* barejid; int unread; - ChatState *state; + ChatState* state; gboolean is_otr; gboolean otr_is_trusted; gboolean pgp_send; gboolean pgp_recv; gboolean is_omemo; - gboolean is_ox; // XEP-0373: OpenPGP for XMPP - char *resource_override; + gboolean is_ox; // XEP-0373: OpenPGP for XMPP + char* resource_override; gboolean history_shown; unsigned long memcheck; - char *enctext; - char *incoming_char; - char *outgoing_char; + char* enctext; + char* incoming_char; + char* outgoing_char; // For LMC - char *last_message; - char *last_msg_id; + char* last_message; + char* last_msg_id; } ProfChatWin; -typedef struct prof_muc_win_t { +typedef struct prof_muc_win_t +{ ProfWin window; - char *roomjid; - char *room_name; + char* roomjid; + char* room_name; int unread; gboolean unread_mentions; gboolean unread_triggers; gboolean showjid; gboolean is_omemo; unsigned long memcheck; - char *enctext; - char *message_char; - GDateTime *last_msg_timestamp; + char* enctext; + char* message_char; + GDateTime* last_msg_timestamp; // For LMC - char *last_message; - char *last_msg_id; + char* last_message; + char* last_msg_id; } ProfMucWin; typedef struct prof_conf_win_t ProfConfWin; -typedef void (*ProfConfWinCallback)(ProfConfWin *); +typedef void (*ProfConfWinCallback)(ProfConfWin*); -struct prof_conf_win_t { +struct prof_conf_win_t +{ ProfWin window; - char *roomjid; - DataForm *form; + char* roomjid; + DataForm* form; unsigned long memcheck; ProfConfWinCallback submit; ProfConfWinCallback cancel; - const void *userdata; + const void* userdata; }; -typedef struct prof_private_win_t { +typedef struct prof_private_win_t +{ ProfWin window; - char *fulljid; + char* fulljid; int unread; unsigned long memcheck; gboolean occupant_offline; gboolean room_left; } ProfPrivateWin; -typedef struct prof_xml_win_t { +typedef struct prof_xml_win_t +{ ProfWin window; unsigned long memcheck; } ProfXMLWin; -typedef struct prof_plugin_win_t { +typedef struct prof_plugin_win_t +{ ProfWin window; - char *tag; - char *plugin_name; + char* tag; + char* plugin_name; unsigned long memcheck; } ProfPluginWin; diff --git a/src/ui/window.c b/src/ui/window.c index 9840716d..33651866 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -60,22 +60,22 @@ #include "xmpp/roster_list.h" #define CONS_WIN_TITLE "Profanity. Type /help for help information." -#define XML_WIN_TITLE "XML Console" +#define XML_WIN_TITLE "XML Console" -#define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X)) +#define CEILING(X) (X - (int)(X) > 0 ? (int)(X + 1) : (int)(X)) static void -_win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const display_from, const char *const from_jid, const char *const message_id, const char *const message, ...); -static void _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDateTime *time, - int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt); -static void _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent); +_win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...); +static void _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDateTime* time, + int flags, theme_item_t theme_item, const char* const from, const char* const message, DeliveryReceipt* receipt); +static void _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pad_indent); int win_roster_cols(void) { int roster_win_percent = prefs_get_roster_size(); int cols = getmaxx(stdscr); - return CEILING( (((double)cols) / 100) * roster_win_percent); + return CEILING((((double)cols) / 100) * roster_win_percent); } int @@ -83,7 +83,7 @@ win_occpuants_cols(void) { int occupants_win_percent = prefs_get_occupants_size(); int cols = getmaxx(stdscr); - return CEILING( (((double)cols) / 100) * occupants_win_percent); + return CEILING((((double)cols) / 100) * occupants_win_percent); } static ProfLayout* @@ -91,7 +91,7 @@ _win_create_simple_layout(void) { int cols = getmaxx(stdscr); - ProfLayoutSimple *layout = malloc(sizeof(ProfLayoutSimple)); + ProfLayoutSimple* layout = malloc(sizeof(ProfLayoutSimple)); layout->base.type = LAYOUT_SIMPLE; layout->base.win = newpad(PAD_SIZE, cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); @@ -108,7 +108,7 @@ _win_create_split_layout(void) { int cols = getmaxx(stdscr); - ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit)); + ProfLayoutSplit* layout = malloc(sizeof(ProfLayoutSplit)); layout->base.type = LAYOUT_SPLIT; layout->base.win = newpad(PAD_SIZE, cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); @@ -126,7 +126,7 @@ _win_create_split_layout(void) ProfWin* win_create_console(void) { - ProfConsoleWin *new_win = malloc(sizeof(ProfConsoleWin)); + ProfConsoleWin* new_win = malloc(sizeof(ProfConsoleWin)); new_win->window.type = WIN_CONSOLE; new_win->window.layout = _win_create_split_layout(); @@ -134,9 +134,9 @@ win_create_console(void) } ProfWin* -win_create_chat(const char *const barejid) +win_create_chat(const char* const barejid) { - ProfChatWin *new_win = malloc(sizeof(ProfChatWin)); + ProfChatWin* new_win = malloc(sizeof(ProfChatWin)); new_win->window.type = WIN_CHAT; new_win->window.layout = _win_create_simple_layout(); @@ -163,20 +163,21 @@ win_create_chat(const char *const barejid) } ProfWin* -win_create_muc(const char *const roomjid) +win_create_muc(const char* const roomjid) { - ProfMucWin *new_win = malloc(sizeof(ProfMucWin)); + ProfMucWin* new_win = malloc(sizeof(ProfMucWin)); int cols = getmaxx(stdscr); new_win->window.type = WIN_MUC; - ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit)); + ProfLayoutSplit* layout = malloc(sizeof(ProfLayoutSplit)); layout->base.type = LAYOUT_SPLIT; if (prefs_get_boolean(PREF_OCCUPANTS)) { int subwin_cols = win_occpuants_cols(); layout->base.win = newpad(PAD_SIZE, cols - subwin_cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); - layout->subwin = newpad(PAD_SIZE, subwin_cols);; + layout->subwin = newpad(PAD_SIZE, subwin_cols); + ; wbkgd(layout->subwin, theme_attrs(THEME_TEXT)); } else { layout->base.win = newpad(PAD_SIZE, (cols)); @@ -213,9 +214,9 @@ win_create_muc(const char *const roomjid) } ProfWin* -win_create_config(const char *const roomjid, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata) +win_create_config(const char* const roomjid, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata) { - ProfConfWin *new_win = malloc(sizeof(ProfConfWin)); + ProfConfWin* new_win = malloc(sizeof(ProfConfWin)); new_win->window.type = WIN_CONFIG; new_win->window.layout = _win_create_simple_layout(); new_win->roomjid = strdup(roomjid); @@ -230,9 +231,9 @@ win_create_config(const char *const roomjid, DataForm *form, ProfConfWinCallback } ProfWin* -win_create_private(const char *const fulljid) +win_create_private(const char* const fulljid) { - ProfPrivateWin *new_win = malloc(sizeof(ProfPrivateWin)); + ProfPrivateWin* new_win = malloc(sizeof(ProfPrivateWin)); new_win->window.type = WIN_PRIVATE; new_win->window.layout = _win_create_simple_layout(); new_win->fulljid = strdup(fulljid); @@ -248,7 +249,7 @@ win_create_private(const char *const fulljid) ProfWin* win_create_xmlconsole(void) { - ProfXMLWin *new_win = malloc(sizeof(ProfXMLWin)); + ProfXMLWin* new_win = malloc(sizeof(ProfXMLWin)); new_win->window.type = WIN_XML; new_win->window.layout = _win_create_simple_layout(); @@ -258,9 +259,9 @@ win_create_xmlconsole(void) } ProfWin* -win_create_plugin(const char *const plugin_name, const char *const tag) +win_create_plugin(const char* const plugin_name, const char* const tag) { - ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin)); + ProfPluginWin* new_win = malloc(sizeof(ProfPluginWin)); new_win->window.type = WIN_PLUGIN; new_win->window.layout = _win_create_simple_layout(); @@ -273,7 +274,7 @@ win_create_plugin(const char *const plugin_name, const char *const tag) } char* -win_get_title(ProfWin *window) +win_get_title(ProfWin* window) { if (window == NULL) { return strdup(CONS_WIN_TITLE); @@ -282,13 +283,13 @@ win_get_title(ProfWin *window) return strdup(CONS_WIN_TITLE); } if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { PContact contact = roster_get_contact(chatwin->barejid); if (contact) { - const char *name = p_contact_name_or_jid(contact); + const char* name = p_contact_name_or_jid(contact); return strdup(name); } else { return strdup(chatwin->barejid); @@ -298,12 +299,12 @@ win_get_title(ProfWin *window) } } if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); gboolean show_titlebar_jid = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_JID); gboolean show_titlebar_name = prefs_get_boolean(PREF_TITLEBAR_MUC_TITLE_NAME); - GString *title = g_string_new(""); + GString* title = g_string_new(""); if (show_titlebar_name) { g_string_append(title, mucwin->room_name); @@ -313,24 +314,24 @@ win_get_title(ProfWin *window) g_string_append(title, mucwin->roomjid); } - char *title_str = title->str; + char* title_str = title->str; g_string_free(title, FALSE); return title_str; } if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*) window; + ProfConfWin* confwin = (ProfConfWin*)window; assert(confwin->memcheck == PROFCONFWIN_MEMCHECK); - GString *title = g_string_new(confwin->roomjid); + GString* title = g_string_new(confwin->roomjid); g_string_append(title, " config"); if (confwin->form->modified) { g_string_append(title, " *"); } - char *title_str = title->str; + char* title_str = title->str; g_string_free(title, FALSE); return title_str; } if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); return strdup(privatewin->fulljid); } @@ -338,7 +339,7 @@ win_get_title(ProfWin *window) return strdup(XML_WIN_TITLE); } if (window->type == WIN_PLUGIN) { - ProfPluginWin *pluginwin = (ProfPluginWin*) window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; assert(pluginwin->memcheck == PROFPLUGINWIN_MEMCHECK); return strdup(pluginwin->tag); } @@ -347,104 +348,104 @@ win_get_title(ProfWin *window) } char* -win_get_tab_identifier(ProfWin *window) +win_get_tab_identifier(ProfWin* window) { assert(window != NULL); switch (window->type) { - case WIN_CONSOLE: - { - return strdup("console"); - } - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - return strdup(chatwin->barejid); - } - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - return strdup(mucwin->roomjid); - } - case WIN_CONFIG: - { - ProfConfWin *confwin = (ProfConfWin*)window; - return strdup(confwin->roomjid); - } - case WIN_PRIVATE: - { - ProfPrivateWin *privwin = (ProfPrivateWin*)window; - return strdup(privwin->fulljid); - } - case WIN_PLUGIN: - { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; - return strdup(pluginwin->tag); - } - case WIN_XML: - { - return strdup("xmlconsole"); - } - default: - return strdup("UNKNOWN"); + case WIN_CONSOLE: + { + return strdup("console"); + } + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + return strdup(chatwin->barejid); + } + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + return strdup(mucwin->roomjid); + } + case WIN_CONFIG: + { + ProfConfWin* confwin = (ProfConfWin*)window; + return strdup(confwin->roomjid); + } + case WIN_PRIVATE: + { + ProfPrivateWin* privwin = (ProfPrivateWin*)window; + return strdup(privwin->fulljid); + } + case WIN_PLUGIN: + { + ProfPluginWin* pluginwin = (ProfPluginWin*)window; + return strdup(pluginwin->tag); + } + case WIN_XML: + { + return strdup("xmlconsole"); + } + default: + return strdup("UNKNOWN"); } } char* -win_to_string(ProfWin *window) +win_to_string(ProfWin* window) { assert(window != NULL); switch (window->type) { - case WIN_CONSOLE: - { - ProfConsoleWin *conswin = (ProfConsoleWin*)window; - return cons_get_string(conswin); - } - case WIN_CHAT: - { - ProfChatWin *chatwin = (ProfChatWin*)window; - return chatwin_get_string(chatwin); - } - case WIN_MUC: - { - ProfMucWin *mucwin = (ProfMucWin*)window; - return mucwin_get_string(mucwin); - } - case WIN_CONFIG: - { - ProfConfWin *confwin = (ProfConfWin*)window; - return confwin_get_string(confwin); - } - case WIN_PRIVATE: - { - ProfPrivateWin *privwin = (ProfPrivateWin*)window; - return privwin_get_string(privwin); - } - case WIN_XML: - { - ProfXMLWin *xmlwin = (ProfXMLWin*)window; - return xmlwin_get_string(xmlwin); - } - case WIN_PLUGIN: - { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; - GString *gstring = g_string_new(""); - g_string_append_printf(gstring, "Plugin: %s", pluginwin->tag); - char *res = gstring->str; - g_string_free(gstring, FALSE); - return res; - } - default: - return NULL; + case WIN_CONSOLE: + { + ProfConsoleWin* conswin = (ProfConsoleWin*)window; + return cons_get_string(conswin); + } + case WIN_CHAT: + { + ProfChatWin* chatwin = (ProfChatWin*)window; + return chatwin_get_string(chatwin); + } + case WIN_MUC: + { + ProfMucWin* mucwin = (ProfMucWin*)window; + return mucwin_get_string(mucwin); + } + case WIN_CONFIG: + { + ProfConfWin* confwin = (ProfConfWin*)window; + return confwin_get_string(confwin); + } + case WIN_PRIVATE: + { + ProfPrivateWin* privwin = (ProfPrivateWin*)window; + return privwin_get_string(privwin); + } + case WIN_XML: + { + ProfXMLWin* xmlwin = (ProfXMLWin*)window; + return xmlwin_get_string(xmlwin); + } + case WIN_PLUGIN: + { + ProfPluginWin* pluginwin = (ProfPluginWin*)window; + GString* gstring = g_string_new(""); + g_string_append_printf(gstring, "Plugin: %s", pluginwin->tag); + char* res = gstring->str; + g_string_free(gstring, FALSE); + return res; + } + default: + return NULL; } } void -win_hide_subwin(ProfWin *window) +win_hide_subwin(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { delwin(layout->subwin); } @@ -461,7 +462,7 @@ win_hide_subwin(ProfWin *window) } void -win_show_subwin(ProfWin *window) +win_show_subwin(ProfWin* window) { int cols = getmaxx(stdscr); int subwin_cols = 0; @@ -476,7 +477,7 @@ win_show_subwin(ProfWin *window) subwin_cols = win_roster_cols(); } - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; layout->subwin = newpad(PAD_SIZE, subwin_cols); wbkgd(layout->subwin, theme_attrs(THEME_TEXT)); wresize(layout->base.win, PAD_SIZE, cols - subwin_cols); @@ -487,7 +488,7 @@ void win_free(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { delwin(layout->subwin); } @@ -502,7 +503,7 @@ win_free(ProfWin* window) switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; free(chatwin->barejid); free(chatwin->resource_override); free(chatwin->enctext); @@ -515,7 +516,7 @@ win_free(ProfWin* window) } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; free(mucwin->roomjid); free(mucwin->room_name); free(mucwin->enctext); @@ -526,20 +527,20 @@ win_free(ProfWin* window) } case WIN_CONFIG: { - ProfConfWin *conf = (ProfConfWin*)window; + ProfConfWin* conf = (ProfConfWin*)window; free(conf->roomjid); form_destroy(conf->form); break; } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; free(privatewin->fulljid); break; } case WIN_PLUGIN: { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; free(pluginwin->tag); free(pluginwin->plugin_name); break; @@ -552,12 +553,12 @@ win_free(ProfWin* window) } void -win_page_up(ProfWin *window) +win_page_up(ProfWin* window) { int rows = getmaxy(stdscr); int y = getcury(window->layout->win); int page_space = rows - 4; - int *page_start = &(window->layout->y_pos); + int* page_start = &(window->layout->y_pos); *page_start -= page_space; @@ -575,12 +576,12 @@ win_page_up(ProfWin *window) } void -win_page_down(ProfWin *window) +win_page_down(ProfWin* window) { int rows = getmaxy(stdscr); int y = getcury(window->layout->win); int page_space = rows - 4; - int *page_start = &(window->layout->y_pos); + int* page_start = &(window->layout->y_pos); *page_start += page_space; @@ -602,19 +603,19 @@ win_page_down(ProfWin *window) } void -win_sub_page_down(ProfWin *window) +win_sub_page_down(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { int rows = getmaxy(stdscr); int page_space = rows - 4; - ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* split_layout = (ProfLayoutSplit*)window->layout; int sub_y = getcury(split_layout->subwin); - int *sub_y_pos = &(split_layout->sub_y_pos); + int* sub_y_pos = &(split_layout->sub_y_pos); *sub_y_pos += page_space; // only got half a screen, show full screen - if ((sub_y- (*sub_y_pos)) < page_space) + if ((sub_y - (*sub_y_pos)) < page_space) *sub_y_pos = sub_y - page_space; // went past end, show full screen @@ -626,13 +627,13 @@ win_sub_page_down(ProfWin *window) } void -win_sub_page_up(ProfWin *window) +win_sub_page_up(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { int rows = getmaxy(stdscr); int page_space = rows - 4; - ProfLayoutSplit *split_layout = (ProfLayoutSplit*)window->layout; - int *sub_y_pos = &(split_layout->sub_y_pos); + ProfLayoutSplit* split_layout = (ProfLayoutSplit*)window->layout; + int* sub_y_pos = &(split_layout->sub_y_pos); *sub_y_pos -= page_space; @@ -645,7 +646,7 @@ win_sub_page_up(ProfWin *window) } void -win_clear(ProfWin *window) +win_clear(ProfWin* window) { if (!prefs_get_boolean(PREF_CLEAR_PERSIST_HISTORY)) { werase(window->layout->win); @@ -655,19 +656,19 @@ win_clear(ProfWin *window) } int y = getcury(window->layout->win); - int *page_start = &(window->layout->y_pos); + int* page_start = &(window->layout->y_pos); *page_start = y; window->layout->paged = 1; win_update_virtual(window); } void -win_resize(ProfWin *window) +win_resize(ProfWin* window) { int cols = getmaxx(stdscr); if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { int subwin_cols = 0; if (window->type == WIN_CONSOLE) { @@ -682,7 +683,7 @@ win_resize(ProfWin *window) if (window->type == WIN_CONSOLE) { rosterwin_roster(); } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin *)window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); occupantswin_occupants(mucwin->roomjid); } @@ -699,14 +700,14 @@ win_resize(ProfWin *window) } void -win_update_virtual(ProfWin *window) +win_update_virtual(ProfWin* window) { int cols = getmaxx(stdscr); int row_start = screen_mainwin_row_start(); int row_end = screen_mainwin_row_end(); if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (layout->subwin) { int subwin_cols = 0; if (window->type == WIN_MUC) { @@ -714,36 +715,36 @@ win_update_virtual(ProfWin *window) } else { subwin_cols = win_roster_cols(); } - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols - subwin_cols) - 1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols - subwin_cols), row_end, cols - 1); } else { - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols-1); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, cols - 1); } } else { - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1); + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols - 1); } } void -win_refresh_without_subwin(ProfWin *window) +win_refresh_without_subwin(ProfWin* window) { int cols = getmaxx(stdscr); if ((window->type == WIN_MUC) || (window->type == WIN_CONSOLE)) { int row_start = screen_mainwin_row_start(); int row_end = screen_mainwin_row_end(); - pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols-1); + pnoutrefresh(window->layout->win, window->layout->y_pos, 0, row_start, 0, row_end, cols - 1); } } void -win_refresh_with_subwin(ProfWin *window) +win_refresh_with_subwin(ProfWin* window) { int subwin_cols = 0; int cols = getmaxx(stdscr); int row_start = screen_mainwin_row_start(); int row_end = screen_mainwin_row_end(); - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; if (window->type == WIN_MUC) { subwin_cols = win_occpuants_cols(); @@ -754,12 +755,12 @@ win_refresh_with_subwin(ProfWin *window) return; } - pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols-subwin_cols)-1); - pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols-subwin_cols), row_end, cols-1); + pnoutrefresh(layout->base.win, layout->base.y_pos, 0, row_start, 0, row_end, (cols - subwin_cols) - 1); + pnoutrefresh(layout->subwin, layout->sub_y_pos, 0, row_start, (cols - subwin_cols), row_end, cols - 1); } void -win_move_to_end(ProfWin *window) +win_move_to_end(ProfWin* window) { window->layout->paged = 0; @@ -774,9 +775,9 @@ win_move_to_end(ProfWin *window) } void -win_show_occupant(ProfWin *window, Occupant *occupant) +win_show_occupant(ProfWin* window, Occupant* occupant) { - const char *presence_str = string_from_resource_presence(occupant->presence); + const char* presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); @@ -791,13 +792,13 @@ win_show_occupant(ProfWin *window, Occupant *occupant) } void -win_show_contact(ProfWin *window, PContact contact) +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); + 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); @@ -810,7 +811,7 @@ win_show_contact(ProfWin *window, PContact contact) win_append(window, presence_colour, " is %s", presence); if (last_activity) { - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); g_date_time_unref(now); @@ -835,11 +836,11 @@ win_show_contact(ProfWin *window, PContact contact) } void -win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant) +win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupant) { - const char *presence_str = string_from_resource_presence(occupant->presence); - const char *occupant_affiliation = muc_occupant_affiliation_str(occupant); - const char *occupant_role = muc_occupant_role_str(occupant); + const char* presence_str = string_from_resource_presence(occupant->presence); + const char* occupant_affiliation = muc_occupant_affiliation_str(occupant); + const char* occupant_role = muc_occupant_role_str(occupant); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); @@ -859,14 +860,14 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_println(window, THEME_DEFAULT, "!", " Affiliation: %s", occupant_affiliation); win_println(window, THEME_DEFAULT, "!", " Role: %s", occupant_role); - Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); - EntityCapabilities *caps = caps_lookup(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(room, occupant->nick); + EntityCapabilities* caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(window, THEME_DEFAULT, "!", " Identity: "); if (identity->name) { win_append(window, THEME_DEFAULT, "%s", identity->name); @@ -887,7 +888,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(window, THEME_DEFAULT, "!", " Software: %s", software_version->software); } @@ -915,13 +916,13 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa } void -win_show_info(ProfWin *window, PContact contact) +win_show_info(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 *sub = p_contact_subscription(contact); - GDateTime *last_activity = p_contact_last_activity(contact); + const char* barejid = p_contact_barejid(contact); + const char* name = p_contact_name(contact); + const char* presence = p_contact_presence(contact); + const char* sub = p_contact_subscription(contact); + GDateTime* last_activity = p_contact_last_activity(contact); theme_item_t presence_colour = theme_main_presence_attrs(presence); @@ -937,7 +938,7 @@ win_show_info(ProfWin *window, PContact contact) } if (last_activity) { - GDateTime *now = g_date_time_new_now_local(); + GDateTime* now = g_date_time_new_now_local(); GTimeSpan span = g_date_time_difference(now, last_activity); int hours = span / G_TIME_SPAN_HOUR; @@ -947,35 +948,34 @@ win_show_info(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_println(window, THEME_DEFAULT, "-", "Last activity: %dh%dm%ds", hours, minutes, seconds); - } - else { - win_println(window, THEME_DEFAULT, "-", "Last activity: %dm%ds", minutes, seconds); + win_println(window, THEME_DEFAULT, "-", "Last activity: %dh%dm%ds", hours, minutes, seconds); + } else { + win_println(window, THEME_DEFAULT, "-", "Last activity: %dm%ds", minutes, seconds); } g_date_time_unref(now); } - GList *resources = p_contact_get_available_resources(contact); - GList *ordered_resources = NULL; + GList* resources = p_contact_get_available_resources(contact); + GList* ordered_resources = NULL; if (resources) { win_println(window, THEME_DEFAULT, "-", "Resources:"); // sort in order of availability - GList *curr = resources; + GList* curr = resources; while (curr) { - Resource *resource = curr->data; + Resource* resource = curr->data; ordered_resources = g_list_insert_sorted(ordered_resources, - resource, (GCompareFunc)resource_compare_availability); + resource, (GCompareFunc)resource_compare_availability); curr = g_list_next(curr); } } g_list_free(resources); - GList *curr = ordered_resources; + GList* curr = ordered_resources; while (curr) { - Resource *resource = curr->data; - const char *resource_presence = string_from_resource_presence(resource->presence); + Resource* resource = curr->data; + const char* resource_presence = string_from_resource_presence(resource->presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(window, presence_colour, "-", " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { @@ -983,14 +983,14 @@ win_show_info(ProfWin *window, PContact contact) } win_newline(window); - Jid *jidp = jid_create_from_bare_and_resource(barejid, resource->name); - EntityCapabilities *caps = caps_lookup(jidp->fulljid); + Jid* jidp = jid_create_from_bare_and_resource(barejid, resource->name); + EntityCapabilities* caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { - DiscoIdentity *identity = caps->identity; + DiscoIdentity* identity = caps->identity; win_print(window, THEME_DEFAULT, "-", " Identity: "); if (identity->name) { win_append(window, THEME_DEFAULT, "%s", identity->name); @@ -1011,7 +1011,7 @@ win_show_info(ProfWin *window, PContact contact) } if (caps->software_version) { - SoftwareVersion *software_version = caps->software_version; + SoftwareVersion* software_version = caps->software_version; if (software_version->software) { win_print(window, THEME_DEFAULT, "-", " Software: %s", software_version->software); } @@ -1041,10 +1041,10 @@ win_show_info(ProfWin *window, PContact contact) } 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) +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; @@ -1064,8 +1064,8 @@ win_show_status_string(ProfWin *window, const char *const from, win_append(window, presence_colour, " is %s", default_show); if (last_activity) { - gchar *date_fmt = NULL; - char *time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); + gchar* date_fmt = NULL; + char* time_pref = prefs_get_string(PREF_TIME_LASTACTIVITY); date_fmt = g_date_time_format(last_activity, time_pref); g_free(time_pref); assert(date_fmt != NULL); @@ -1082,9 +1082,9 @@ win_show_status_string(ProfWin *window, const char *const from, } static void -_win_correct(ProfWin *window, const char *const message, const char *const id, const char *const replace_id, const char *const from_jid) +_win_correct(ProfWin* window, const char* const message, const char* const id, const char* const replace_id, const char* const from_jid) { - ProfBuffEntry *entry = buffer_get_entry_by_id(window->layout->buffer, replace_id); + ProfBuffEntry* entry = buffer_get_entry_by_id(window->layout->buffer, replace_id); if (!entry) { log_debug("Replace ID %s could not be found in buffer. Message: %s", replace_id, message); return; @@ -1124,7 +1124,7 @@ _win_correct(ProfWin *window, const char *const message, const char *const id, c } void -win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMessage *message) +win_print_incoming(ProfWin* window, const char* const display_name_from, ProfMessage* message) { int flags = NO_ME; @@ -1132,53 +1132,52 @@ win_print_incoming(ProfWin *window, const char *const display_name_from, ProfMes flags |= UNTRUSTED; } - switch (window->type) + switch (window->type) { + case WIN_CHAT: { - case WIN_CHAT: - { - char *enc_char; - ProfChatWin *chatwin = (ProfChatWin*)window; - - if (chatwin->incoming_char) { - enc_char = strdup(chatwin->incoming_char); - } else if (message->enc == PROF_MSG_ENC_OTR) { - enc_char = prefs_get_otr_char(); - } else if (message->enc == PROF_MSG_ENC_PGP) { - enc_char = prefs_get_pgp_char(); - } else if (message->enc == PROF_MSG_ENC_OX) { // XEP-0373: OpenPGP for XMPP - enc_char = prefs_get_ox_char(); - } else if (message->enc == PROF_MSG_ENC_OMEMO) { - enc_char = prefs_get_omemo_char(); - } else { - enc_char = strdup("-"); - } - - if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) { - _win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->barejid); - } else { - _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); - } + char* enc_char; + ProfChatWin* chatwin = (ProfChatWin*)window; + + if (chatwin->incoming_char) { + enc_char = strdup(chatwin->incoming_char); + } else if (message->enc == PROF_MSG_ENC_OTR) { + enc_char = prefs_get_otr_char(); + } else if (message->enc == PROF_MSG_ENC_PGP) { + enc_char = prefs_get_pgp_char(); + } else if (message->enc == PROF_MSG_ENC_OX) { // XEP-0373: OpenPGP for XMPP + enc_char = prefs_get_ox_char(); + } else if (message->enc == PROF_MSG_ENC_OMEMO) { + enc_char = prefs_get_omemo_char(); + } else { + enc_char = strdup("-"); + } - free(enc_char); - break; + if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) { + _win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->barejid); + } else { + _win_printf(window, enc_char, 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); } - case WIN_PRIVATE: - _win_printf(window, "-", 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); - break; - default: - assert(FALSE); - break; + + free(enc_char); + break; + } + case WIN_PRIVATE: + _win_printf(window, "-", 0, message->timestamp, flags, THEME_TEXT_THEM, display_name_from, message->from_jid->barejid, message->id, "%s", message->plain); + break; + default: + assert(FALSE); + break; } } void -win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_char, int flags, const char *const them) +win_print_them(ProfWin* window, theme_item_t theme_item, const char* const show_char, int flags, const char* const them) { _win_printf(window, show_char, 0, NULL, flags | NO_ME | NO_EOL, theme_item, them, NULL, NULL, ""); } void -win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const ProfMessage *const message) +win_println_incoming_muc_msg(ProfWin* window, char* show_char, int flags, const ProfMessage* const message) { if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && message->replace_id) { _win_correct(window, message->plain, message->id, message->replace_id, message->from_jid->fulljid); @@ -1190,9 +1189,9 @@ win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const } void -win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message) +win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* const me, const char* const id, const char* const replace_id, const char* const message) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); if (prefs_get_boolean(PREF_CORRECTION_ALLOW) && replace_id) { _win_correct(window, message, id, replace_id, me); @@ -1205,11 +1204,11 @@ win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const m } void -win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, const char *const replace_id, const char *const message) +win_print_outgoing(ProfWin* window, const char* show_char, const char* const id, const char* const replace_id, const char* const message) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); - const char *myjid = connection_get_fulljid(); + const char* myjid = connection_get_fulljid(); if (replace_id) { _win_correct(window, message, id, replace_id, myjid); } else { @@ -1222,14 +1221,14 @@ win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, } void -win_print_history(ProfWin *window, const ProfMessage *const message) +win_print_history(ProfWin* window, const ProfMessage* const message) { g_date_time_ref(message->timestamp); - char *display_name; + char* display_name; int flags = 0; - const char *jid = connection_get_fulljid(); - Jid *jidp = jid_create(jid); + const char* jid = connection_get_fulljid(); + Jid* jidp = jid_create(jid); if (g_strcmp0(jidp->barejid, message->from_jid->barejid) == 0) { display_name = strdup("me"); @@ -1249,13 +1248,13 @@ win_print_history(ProfWin *window, const ProfMessage *const message) } void -win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...) +win_print(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, show_char, 0, timestamp, NO_EOL, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1269,13 +1268,13 @@ win_print(ProfWin *window, theme_item_t theme_item, const char *show_char, const } void -win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, const char *const message, ...) +win_println(ProfWin* window, theme_item_t theme_item, const char* show_char, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, show_char, 0, timestamp, 0, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1289,13 +1288,13 @@ win_println(ProfWin *window, theme_item_t theme_item, const char *show_char, con } void -win_println_indent(ProfWin *window, int pad, const char *const message, ...) +win_println_indent(ProfWin* window, int pad, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", pad, timestamp, 0, THEME_DEFAULT, "", NULL, fmt_msg->str, NULL, NULL); @@ -1309,13 +1308,13 @@ win_println_indent(ProfWin *window, int pad, const char *const message, ...) } void -win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_append(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE | NO_EOL, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1329,13 +1328,13 @@ win_append(ProfWin *window, theme_item_t theme_item, const char *const message, } void -win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_appendln(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1349,13 +1348,13 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message } void -win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_append_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE | NO_ME | NO_EOL, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1369,13 +1368,13 @@ win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const } void -win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +win_appendln_highlight(ProfWin* window, theme_item_t theme_item, const char* const message, ...) { - GDateTime *timestamp = g_date_time_new_now_local(); + GDateTime* timestamp = g_date_time_new_now_local(); va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, "-", 0, timestamp, NO_DATE | NO_ME, theme_item, "", NULL, fmt_msg->str, NULL, NULL); @@ -1389,20 +1388,20 @@ win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *con } void -win_print_http_upload(ProfWin *window, const char *const message, char *url) +win_print_http_upload(ProfWin* window, const char* const message, char* url) { win_print_outgoing_with_receipt(window, "!", NULL, message, url, NULL); } void -win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const char *const from, const char *const message, char *id, const char *const replace_id) +win_print_outgoing_with_receipt(ProfWin* window, const char* show_char, const char* const from, const char* const message, char* id, const char* const replace_id) { - GDateTime *time = g_date_time_new_now_local(); + GDateTime* time = g_date_time_new_now_local(); - DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t)); + DeliveryReceipt* receipt = malloc(sizeof(struct delivery_receipt_t)); receipt->received = FALSE; - const char *myjid = connection_get_fulljid(); + const char* myjid = connection_get_fulljid(); if (replace_id) { _win_correct(window, message, id, replace_id, myjid); } else { @@ -1416,7 +1415,7 @@ win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const ch } void -win_mark_received(ProfWin *window, const char *const id) +win_mark_received(ProfWin* window, const char* const id) { gboolean received = buffer_mark_received(window->layout->buffer, id); if (received) { @@ -1425,9 +1424,9 @@ win_mark_received(ProfWin *window, const char *const id) } void -win_update_entry_message(ProfWin *window, const char *const id, const char *const message) +win_update_entry_message(ProfWin* window, const char* const id, const char* const message) { - ProfBuffEntry *entry = buffer_get_entry_by_id(window->layout->buffer, id); + ProfBuffEntry* entry = buffer_get_entry_by_id(window->layout->buffer, id); if (entry) { free(entry->message); entry->message = strdup(message); @@ -1436,20 +1435,20 @@ win_update_entry_message(ProfWin *window, const char *const id, const char *cons } void -win_remove_entry_message(ProfWin *window, const char *const id) +win_remove_entry_message(ProfWin* window, const char* const id) { buffer_remove_entry_by_id(window->layout->buffer, id); win_redraw(window); } void -win_newline(ProfWin *window) +win_newline(ProfWin* window) { win_appendln(window, THEME_DEFAULT, ""); } static void -_win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const display_from, const char *const from_jid, const char *const message_id, const char *const message, ...) +_win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...) { if (timestamp == NULL) { timestamp = g_date_time_new_now_local(); @@ -1459,7 +1458,7 @@ _win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *t va_list arg; va_start(arg, message); - GString *fmt_msg = g_string_new(NULL); + GString* fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); buffer_append(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, display_from, from_jid, fmt_msg->str, NULL, message_id); @@ -1474,8 +1473,8 @@ _win_printf(ProfWin *window, const char *show_char, int pad_indent, GDateTime *t } static void -_win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDateTime *time, - int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt) +_win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDateTime* time, + int flags, theme_item_t theme_item, const char* const from, const char* const message, DeliveryReceipt* receipt) { // flags : 1st bit = 0/1 - me/not me. define: NO_ME // 2nd bit = 0/1 - date/no date. define: NO_DATE @@ -1488,29 +1487,29 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat int colour = theme_attrs(THEME_ME); size_t indent = 0; - char *time_pref = NULL; + char* time_pref = NULL; switch (window->type) { - case WIN_CHAT: - time_pref = prefs_get_string(PREF_TIME_CHAT); - break; - case WIN_MUC: - time_pref = prefs_get_string(PREF_TIME_MUC); - break; - case WIN_CONFIG: - time_pref = prefs_get_string(PREF_TIME_CONFIG); - break; - case WIN_PRIVATE: - time_pref = prefs_get_string(PREF_TIME_PRIVATE); - break; - case WIN_XML: - time_pref = prefs_get_string(PREF_TIME_XMLCONSOLE); - break; - default: - time_pref = prefs_get_string(PREF_TIME_CONSOLE); - break; - } - - gchar *date_fmt = NULL; + case WIN_CHAT: + time_pref = prefs_get_string(PREF_TIME_CHAT); + break; + case WIN_MUC: + time_pref = prefs_get_string(PREF_TIME_MUC); + break; + case WIN_CONFIG: + time_pref = prefs_get_string(PREF_TIME_CONFIG); + break; + case WIN_PRIVATE: + time_pref = prefs_get_string(PREF_TIME_PRIVATE); + break; + case WIN_XML: + time_pref = prefs_get_string(PREF_TIME_XMLCONSOLE); + break; + default: + time_pref = prefs_get_string(PREF_TIME_CONSOLE); + break; + } + + gchar* date_fmt = NULL; if (g_strcmp0(time_pref, "off") == 0 || time == NULL) { date_fmt = g_strdup(""); } else { @@ -1519,7 +1518,7 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat g_free(time_pref); assert(date_fmt != NULL); - if(strlen(date_fmt) != 0){ + if (strlen(date_fmt) != 0) { indent = 3 + strlen(date_fmt); } @@ -1541,7 +1540,7 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat colour = theme_attrs(THEME_THEM); } - char *color_pref = prefs_get_string(PREF_COLOR_NICK); + char* color_pref = prefs_get_string(PREF_COLOR_NICK); if (color_pref != NULL && (strcmp(color_pref, "false") != 0)) { if (flags & NO_ME || (!(flags & NO_ME) && prefs_get_boolean(PREF_COLOR_NICK_OWN))) { colour = theme_hash_attrs(from); @@ -1583,9 +1582,9 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat } if (prefs_get_boolean(PREF_WRAP)) { - _win_print_wrapped(window->layout->win, message+offset, indent, pad_indent); + _win_print_wrapped(window->layout->win, message + offset, indent, pad_indent); } else { - wprintw(window->layout->win, "%s", message+offset); + wprintw(window->layout->win, "%s", message + offset); } if ((flags & NO_EOL) == 0) { @@ -1609,7 +1608,7 @@ _win_print_internal(ProfWin *window, const char *show_char, int pad_indent, GDat } static void -_win_indent(WINDOW *win, int size) +_win_indent(WINDOW* win, int size) { int i = 0; for (i = 0; i < size; i++) { @@ -1618,13 +1617,13 @@ _win_indent(WINDOW *win, int size) } static void -_win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent) +_win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pad_indent) { int starty = getcury(win); int wordi = 0; - char *word = malloc(strlen(message) + 1); + char* word = malloc(strlen(message) + 1); - gchar *curr_ch = g_utf8_offset_to_pointer(message, 0); + gchar* curr_ch = g_utf8_offset_to_pointer(message, 0); while (*curr_ch != '\0') { @@ -1633,13 +1632,13 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa waddch(win, ' '); curr_ch = g_utf8_next_char(curr_ch); - // handle newline + // handle newline } else if (*curr_ch == '\n') { waddch(win, '\n'); _win_indent(win, indent + pad_indent); curr_ch = g_utf8_next_char(curr_ch); - // handle word + // handle word } else { wordi = 0; int wordlen = 0; @@ -1668,8 +1667,8 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa // word larger than line if (wordlen > linelen) { - gchar *word_ch = g_utf8_offset_to_pointer(word, 0); - while(*word_ch != '\0') { + gchar* word_ch = g_utf8_offset_to_pointer(word, 0); + while (*word_ch != '\0') { curx = getcurx(win); cury = getcury(win); gboolean firstline = cury == starty; @@ -1681,14 +1680,14 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa _win_indent(win, indent + pad_indent); } - gchar copy[wordi+1]; + gchar copy[wordi + 1]; g_utf8_strncpy(copy, word_ch, 1); waddstr(win, copy); word_ch = g_utf8_next_char(word_ch); } - // newline and print word + // newline and print word } else { waddch(win, '\n'); curx = getcurx(win); @@ -1704,7 +1703,7 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa waddstr(win, word); } - // no wrap required + // no wrap required } else { curx = getcurx(win); cury = getcury(win); @@ -1734,7 +1733,7 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa } void -win_print_trackbar(ProfWin *window) +win_print_trackbar(ProfWin* window) { int cols = getmaxx(window->layout->win); @@ -1742,7 +1741,7 @@ win_print_trackbar(ProfWin *window) wattron(window->layout->win, theme_attrs(THEME_TRACKBAR)); int i; - for (i=1; i<cols; i++) { + for (i = 1; i < cols; i++) { wprintw(window->layout->win, "-"); } @@ -1752,14 +1751,14 @@ win_print_trackbar(ProfWin *window) } void -win_redraw(ProfWin *window) +win_redraw(ProfWin* window) { int i, size; werase(window->layout->win); size = buffer_size(window->layout->buffer); for (i = 0; i < size; i++) { - ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i); + ProfBuffEntry* e = buffer_get_entry(window->layout->buffer, i); if (e->display_from == NULL && e->message && e->message[0] == '-') { // just an indicator to print the trackbar/separator not the actual message @@ -1772,10 +1771,10 @@ win_redraw(ProfWin *window) } gboolean -win_has_active_subwin(ProfWin *window) +win_has_active_subwin(ProfWin* window) { if (window->layout->type == LAYOUT_SPLIT) { - ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout; + ProfLayoutSplit* layout = (ProfLayoutSplit*)window->layout; return (layout->subwin != NULL); } else { return FALSE; @@ -1783,12 +1782,12 @@ win_has_active_subwin(ProfWin *window) } gboolean -win_notify_remind(ProfWin *window) +win_notify_remind(ProfWin* window) { switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); if (prefs_get_boolean(PREF_NOTIFY_CHAT) && chatwin->unread > 0) { @@ -1799,14 +1798,14 @@ win_notify_remind(ProfWin *window) } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); return prefs_do_room_notify_mention(mucwin->roomjid, mucwin->unread, mucwin->unread_mentions, mucwin->unread_triggers); } case WIN_PRIVATE: { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); if (prefs_get_boolean(PREF_NOTIFY_CHAT) && privatewin->unread > 0) { @@ -1821,18 +1820,18 @@ win_notify_remind(ProfWin *window) } int -win_unread(ProfWin *window) +win_unread(ProfWin* window) { if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); return chatwin->unread; } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); return mucwin->unread; } else if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK); return privatewin->unread; } else { @@ -1841,7 +1840,7 @@ win_unread(ProfWin *window) } void -win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent) +win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int indent) { int maxx = getmaxx(win); int curx = getcurx(win); @@ -1854,22 +1853,22 @@ win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int inden } if (newline) { - wmove(win, cury+1, 0); + wmove(win, cury + 1, 0); } } void -win_sub_newline_lazy(WINDOW *win) +win_sub_newline_lazy(WINDOW* win) { int curx = getcurx(win); if (curx > 0) { int cury = getcury(win); - wmove(win, cury+1, 0); + wmove(win, cury + 1, 0); } } void -win_command_list_error(ProfWin *window, const char *const error) +win_command_list_error(ProfWin* window, const char* const error) { assert(window != NULL); @@ -1877,12 +1876,12 @@ win_command_list_error(ProfWin *window, const char *const error) } void -win_command_exec_error(ProfWin *window, const char *const command, const char *const error, ...) +win_command_exec_error(ProfWin* window, const char* const command, const char* const error, ...) { assert(window != NULL); va_list arg; va_start(arg, error); - GString *msg = g_string_new(NULL); + GString* msg = g_string_new(NULL); g_string_vprintf(msg, error, arg); win_println(window, THEME_ERROR, "!", "Error executing command %s: %s", command, msg->str); @@ -1892,15 +1891,15 @@ win_command_exec_error(ProfWin *window, const char *const command, const char *c } void -win_handle_command_list(ProfWin *window, GSList *cmds) +win_handle_command_list(ProfWin* window, GSList* cmds) { assert(window != NULL); if (cmds) { win_println(window, THEME_DEFAULT, "!", "Ad hoc commands:"); - GSList *curr_cmd = cmds; + GSList* curr_cmd = cmds; while (curr_cmd) { - const char *cmd = curr_cmd->data; + const char* cmd = curr_cmd->data; win_println(window, THEME_DEFAULT, "!", " %s", cmd); curr_cmd = g_slist_next(curr_cmd); } @@ -1912,21 +1911,21 @@ win_handle_command_list(ProfWin *window, GSList *cmds) } void -win_handle_command_exec_status(ProfWin *window, const char *const command, const char *const value) +win_handle_command_exec_status(ProfWin* window, const char* const command, const char* const value) { assert(window != NULL); win_println(window, THEME_DEFAULT, "!", "%s %s", command, value); } void -win_handle_command_exec_result_note(ProfWin *window, const char *const type, const char *const value) +win_handle_command_exec_result_note(ProfWin* window, const char* const type, const char* const value) { assert(window != NULL); win_println(window, THEME_DEFAULT, "!", value); } void -win_insert_last_read_position_marker(ProfWin *window, char* id) +win_insert_last_read_position_marker(ProfWin* window, char* id) { int i, size; size = buffer_size(window->layout->buffer); @@ -1934,7 +1933,7 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) // TODO: this is somewhat costly. We should improve this later. // check if we already have a separator present for (i = 0; i < size; i++) { - ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i); + ProfBuffEntry* e = buffer_get_entry(window->layout->buffer, i); // if yes, don't print a new one if (e->id && (g_strcmp0(e->id, id) == 0)) { @@ -1942,7 +1941,7 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) } } - GDateTime *time = g_date_time_new_now_local(); + GDateTime* time = g_date_time_new_now_local(); // the trackbar/separator will actually be print in win_redraw(). // this only puts it in the buffer and win_redraw() will interpret it. @@ -1952,4 +1951,3 @@ win_insert_last_read_position_marker(ProfWin *window, char* id) g_date_time_unref(time); } - diff --git a/src/ui/window.h b/src/ui/window.h index 4dc8e7d2..17316b05 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -56,39 +56,39 @@ #define PAD_SIZE 1000 -void win_move_to_end(ProfWin *window); -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); +void win_move_to_end(ProfWin* window); +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); -void win_print_them(ProfWin *window, theme_item_t theme_item, const char *const show_char, int flags, const char *const them); -void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message); -void win_print_outgoing(ProfWin *window, const char *show_char, const char *const id, const char *const replace_id, const char *const message); -void win_print_outgoing_with_receipt(ProfWin *window, const char *show_char, const char *const from, const char *const message, char *id, const char *const replace_id); -void win_println_incoming_muc_msg(ProfWin *window, char *show_char, int flags, const ProfMessage *const message); -void win_print_outgoing_muc_msg(ProfWin *window, char *show_char, const char *const me, const char *const id, const char *const replace_id, const char *const message); -void win_print_history(ProfWin *window, const ProfMessage *const message); +void win_print_them(ProfWin* window, theme_item_t theme_item, const char* const show_char, int flags, const char* const them); +void win_print_incoming(ProfWin* window, const char* const from, ProfMessage* message); +void win_print_outgoing(ProfWin* window, const char* show_char, const char* const id, const char* const replace_id, const char* const message); +void win_print_outgoing_with_receipt(ProfWin* window, const char* show_char, const char* const from, const char* const message, char* id, const char* const replace_id); +void win_println_incoming_muc_msg(ProfWin* window, char* show_char, int flags, const ProfMessage* const message); +void win_print_outgoing_muc_msg(ProfWin* window, char* show_char, const char* const me, const char* const id, const char* const replace_id, const char* const message); +void win_print_history(ProfWin* window, const ProfMessage* const message); -void win_print_http_upload(ProfWin *window, const char *const message, char *url); +void win_print_http_upload(ProfWin* window, const char* const message, char* url); -void win_newline(ProfWin *window); -void win_redraw(ProfWin *window); +void win_newline(ProfWin* window); +void win_redraw(ProfWin* window); int win_roster_cols(void); int win_occpuants_cols(void); -void win_sub_print(WINDOW *win, char *msg, gboolean newline, gboolean wrap, int indent); -void win_sub_newline_lazy(WINDOW *win); -void win_mark_received(ProfWin *window, const char *const id); -void win_update_entry_message(ProfWin *window, const char *const id, const char *const message); +void win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int indent); +void win_sub_newline_lazy(WINDOW* win); +void win_mark_received(ProfWin* window, const char* const id); +void win_update_entry_message(ProfWin* window, const char* const id, const char* const message); -gboolean win_has_active_subwin(ProfWin *window); +gboolean win_has_active_subwin(ProfWin* window); -void win_page_up(ProfWin *window); -void win_page_down(ProfWin *window); -void win_sub_page_down(ProfWin *window); -void win_sub_page_up(ProfWin *window); +void win_page_up(ProfWin* window); +void win_page_down(ProfWin* window); +void win_sub_page_down(ProfWin* window); +void win_sub_page_up(ProfWin* window); -void win_insert_last_read_position_marker(ProfWin *window, char* id); -void win_remove_entry_message(ProfWin *window, const char *const id); +void win_insert_last_read_position_marker(ProfWin* window, char* id); +void win_remove_entry_message(ProfWin* window, const char* const id); #endif diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 3972fadb..bb59e64d 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -52,20 +52,20 @@ #include "xmpp/roster_list.h" #include "tools/http_upload.h" -static GHashTable *windows; +static GHashTable* windows; static int current; static Autocomplete wins_ac; static Autocomplete wins_close_ac; static int _wins_cmp_num(gconstpointer a, gconstpointer b); -static int _wins_get_next_available_num(GList *used); +static int _wins_get_next_available_num(GList* used); void wins_init(void) { windows = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)win_free); - ProfWin *console = win_create_console(); + ProfWin* console = win_create_console(); g_hash_table_insert(windows, GINT_TO_POINTER(1), console); current = 1; @@ -85,22 +85,22 @@ wins_get_console(void) } gboolean -wins_chat_exists(const char *const barejid) +wins_chat_exists(const char* const barejid) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); return (chatwin != NULL); } ProfChatWin* -wins_get_chat(const char *const barejid) +wins_get_chat(const char* const barejid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; if (g_strcmp0(chatwin->barejid, barejid) == 0) { g_list_free(values); return chatwin; @@ -114,7 +114,7 @@ wins_get_chat(const char *const barejid) } static gint -_cmp_unsubscribed_wins(ProfChatWin *a, ProfChatWin *b) +_cmp_unsubscribed_wins(ProfChatWin* a, ProfChatWin* b) { return g_strcmp0(a->barejid, b->barejid); } @@ -122,14 +122,14 @@ _cmp_unsubscribed_wins(ProfChatWin *a, ProfChatWin *b) GList* wins_get_chat_unsubscribed(void) { - GList *result = NULL; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* result = NULL; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; PContact contact = roster_get_contact(chatwin->barejid); if (contact == NULL) { result = g_list_insert_sorted(result, chatwin, (GCompareFunc)_cmp_unsubscribed_wins); @@ -143,15 +143,15 @@ wins_get_chat_unsubscribed(void) } ProfConfWin* -wins_get_conf(const char *const roomjid) +wins_get_conf(const char* const roomjid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CONFIG) { - ProfConfWin *confwin = (ProfConfWin*)window; + ProfConfWin* confwin = (ProfConfWin*)window; if (g_strcmp0(confwin->roomjid, roomjid) == 0) { g_list_free(values); return confwin; @@ -165,15 +165,15 @@ wins_get_conf(const char *const roomjid) } ProfMucWin* -wins_get_muc(const char *const roomjid) +wins_get_muc(const char* const roomjid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; if (g_strcmp0(mucwin->roomjid, roomjid) == 0) { g_list_free(values); return mucwin; @@ -187,15 +187,15 @@ wins_get_muc(const char *const roomjid) } ProfPrivateWin* -wins_get_private(const char *const fulljid) +wins_get_private(const char* const fulljid) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; if (g_strcmp0(privatewin->fulljid, fulljid) == 0) { g_list_free(values); return privatewin; @@ -209,15 +209,15 @@ wins_get_private(const char *const fulljid) } ProfPluginWin* -wins_get_plugin(const char *const tag) +wins_get_plugin(const char* const tag) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_PLUGIN) { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; if (g_strcmp0(pluginwin->tag, tag) == 0) { g_list_free(values); return pluginwin; @@ -231,9 +231,9 @@ wins_get_plugin(const char *const tag) } void -wins_close_plugin(char *tag) +wins_close_plugin(char* tag) { - ProfWin *toclose = wins_get_by_string(tag); + ProfWin* toclose = wins_get_by_string(tag); if (toclose == NULL) { return; } @@ -245,18 +245,18 @@ wins_close_plugin(char *tag) } GList* -wins_get_private_chats(const char *const roomjid) +wins_get_private_chats(const char* const roomjid) { - GList *result = NULL; - GString *prefix = g_string_new(roomjid); + GList* result = NULL; + GString* prefix = g_string_new(roomjid); g_string_append(prefix, "/"); - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*)window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) { result = g_list_append(result, privatewin); } @@ -270,15 +270,15 @@ wins_get_private_chats(const char *const roomjid) } void -wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick) +wins_private_nick_change(const char* const roomjid, const char* const oldnick, const char* const newnick) { - Jid *oldjid = jid_create_from_bare_and_resource(roomjid, oldnick); + Jid* oldjid = jid_create_from_bare_and_resource(roomjid, oldnick); - ProfPrivateWin *privwin = wins_get_private(oldjid->fulljid); + ProfPrivateWin* privwin = wins_get_private(oldjid->fulljid); if (privwin) { free(privwin->fulljid); - Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick); + Jid* newjid = jid_create_from_bare_and_resource(roomjid, newnick); privwin->fulljid = strdup(newjid->fulljid); win_println((ProfWin*)privwin, THEME_THEM, "!", "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); @@ -294,9 +294,9 @@ wins_private_nick_change(const char *const roomjid, const char *const oldnick, c } void -wins_change_nick(const char *const barejid, const char *const oldnick, const char *const newnick) +wins_change_nick(const char* const barejid, const char* const oldnick, const char* const newnick) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { if (oldnick) { autocomplete_remove(wins_ac, oldnick); @@ -308,9 +308,9 @@ wins_change_nick(const char *const barejid, const char *const oldnick, const cha } void -wins_remove_nick(const char *const barejid, const char *const oldnick) +wins_remove_nick(const char* const barejid, const char* const oldnick) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { if (oldnick) { autocomplete_remove(wins_ac, oldnick); @@ -338,23 +338,23 @@ wins_get_nums(void) void wins_set_current_by_num(int i) { - ProfWin *window = g_hash_table_lookup(windows, GINT_TO_POINTER(i)); + ProfWin* window = g_hash_table_lookup(windows, GINT_TO_POINTER(i)); if (window) { current = i; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*) window; + ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); chatwin->unread = 0; plugins_on_chat_win_focus(chatwin->barejid); } else if (window->type == WIN_MUC) { - ProfMucWin *mucwin = (ProfMucWin*) window; + ProfMucWin* mucwin = (ProfMucWin*)window; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); mucwin->unread = 0; mucwin->unread_mentions = FALSE; mucwin->unread_triggers = FALSE; plugins_on_room_win_focus(mucwin->roomjid); } else if (window->type == WIN_PRIVATE) { - ProfPrivateWin *privatewin = (ProfPrivateWin*) window; + ProfPrivateWin* privatewin = (ProfPrivateWin*)window; privatewin->unread = 0; } } @@ -367,45 +367,45 @@ wins_get_by_num(int i) } ProfWin* -wins_get_by_string(const char *str) +wins_get_by_string(const char* str) { if (g_strcmp0(str, "console") == 0) { - ProfWin *conswin = wins_get_console(); + ProfWin* conswin = wins_get_console(); return conswin; } if (g_strcmp0(str, "xmlconsole") == 0) { - ProfXMLWin *xmlwin = wins_get_xmlconsole(); - return (ProfWin*)xmlwin; + ProfXMLWin* xmlwin = wins_get_xmlconsole(); + return (ProfWin*)xmlwin; } - ProfChatWin *chatwin = wins_get_chat(str); + ProfChatWin* chatwin = wins_get_chat(str); if (chatwin) { return (ProfWin*)chatwin; } jabber_conn_status_t conn_status = connection_get_status(); if (conn_status == JABBER_CONNECTED) { - char *barejid = roster_barejid_from_name(str); + char* barejid = roster_barejid_from_name(str); if (barejid) { - ProfChatWin *chatwin = wins_get_chat(barejid); + ProfChatWin* chatwin = wins_get_chat(barejid); if (chatwin) { return (ProfWin*)chatwin; } } } - ProfMucWin *mucwin = wins_get_muc(str); + ProfMucWin* mucwin = wins_get_muc(str); if (mucwin) { return (ProfWin*)mucwin; } - ProfPrivateWin *privwin = wins_get_private(str); + ProfPrivateWin* privwin = wins_get_private(str); if (privwin) { return (ProfWin*)privwin; } - ProfPluginWin *pluginwin = wins_get_plugin(str); + ProfPluginWin* pluginwin = wins_get_plugin(str); if (pluginwin) { return (ProfWin*)pluginwin; } @@ -417,9 +417,9 @@ ProfWin* wins_get_next(void) { // get and sort win nums - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); - GList *curr = keys; + GList* curr = keys; // find our place in the list while (curr) { @@ -435,7 +435,7 @@ wins_get_next(void) int next = GPOINTER_TO_INT(curr->data); g_list_free(keys); return wins_get_by_num(next); - // otherwise return the first window (console) + // otherwise return the first window (console) } else { g_list_free(keys); return wins_get_console(); @@ -446,9 +446,9 @@ ProfWin* wins_get_previous(void) { // get and sort win nums - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); - GList *curr = keys; + GList* curr = keys; // find our place in the list while (curr) { @@ -464,7 +464,7 @@ wins_get_previous(void) int previous = GPOINTER_TO_INT(curr->data); g_list_free(keys); return wins_get_by_num(previous); - // otherwise return the last window + // otherwise return the last window } else { int new_num = GPOINTER_TO_INT(g_list_last(keys)->data); g_list_free(keys); @@ -473,14 +473,14 @@ wins_get_previous(void) } int -wins_get_num(ProfWin *window) +wins_get_num(ProfWin* window) { - GList *keys = g_hash_table_get_keys(windows); - GList *curr = keys; + GList* keys = g_hash_table_get_keys(windows); + GList* curr = keys; while (curr) { gconstpointer num_p = curr->data; - ProfWin *curr_win = g_hash_table_lookup(windows, num_p); + ProfWin* curr_win = g_hash_table_lookup(windows, num_p); if (curr_win == window) { g_list_free(keys); return GPOINTER_TO_INT(num_p); @@ -507,11 +507,11 @@ wins_close_by_num(int i) // go to console if closing current window if (i == current) { current = 1; - ProfWin *window = wins_get_current(); + ProfWin* window = wins_get_current(); win_update_virtual(window); } - ProfWin *window = wins_get_by_num(i); + ProfWin* window = wins_get_by_num(i); if (window) { // cancel upload proccesses of this window http_upload_cancel_processes(window); @@ -519,7 +519,7 @@ wins_close_by_num(int i) switch (window->type) { case WIN_CHAT: { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; autocomplete_remove(wins_ac, chatwin->barejid); autocomplete_remove(wins_close_ac, chatwin->barejid); @@ -539,7 +539,7 @@ wins_close_by_num(int i) } case WIN_MUC: { - ProfMucWin *mucwin = (ProfMucWin*)window; + ProfMucWin* mucwin = (ProfMucWin*)window; autocomplete_remove(wins_ac, mucwin->roomjid); autocomplete_remove(wins_close_ac, mucwin->roomjid); @@ -551,7 +551,7 @@ wins_close_by_num(int i) } case WIN_PRIVATE: { - ProfPrivateWin *privwin = (ProfPrivateWin*)window; + ProfPrivateWin* privwin = (ProfPrivateWin*)window; autocomplete_remove(wins_ac, privwin->fulljid); autocomplete_remove(wins_close_ac, privwin->fulljid); autocomplete_free(window->urls_ac); @@ -565,7 +565,7 @@ wins_close_by_num(int i) } case WIN_PLUGIN: { - ProfPluginWin *pluginwin = (ProfPluginWin*)window; + ProfPluginWin* pluginwin = (ProfPluginWin*)window; plugins_close_win(pluginwin->plugin_name, pluginwin->tag); autocomplete_remove(wins_ac, pluginwin->tag); autocomplete_remove(wins_close_ac, pluginwin->tag); @@ -583,9 +583,9 @@ wins_close_by_num(int i) } gboolean -wins_is_current(ProfWin *window) +wins_is_current(ProfWin* window) { - ProfWin *current_window = wins_get_current(); + ProfWin* current_window = wins_get_current(); if (current_window == window) { return TRUE; @@ -597,10 +597,10 @@ wins_is_current(ProfWin *window) ProfWin* wins_new_xmlconsole(void) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_xmlconsole(); + ProfWin* newwin = win_create_xmlconsole(); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, "xmlconsole"); autocomplete_add(wins_close_ac, "xmlconsole"); @@ -608,12 +608,12 @@ wins_new_xmlconsole(void) } ProfWin* -wins_new_chat(const char *const barejid) +wins_new_chat(const char* const barejid) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_chat(barejid); + ProfWin* newwin = win_create_chat(barejid); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, barejid); @@ -632,12 +632,12 @@ wins_new_chat(const char *const barejid) } ProfWin* -wins_new_muc(const char *const roomjid) +wins_new_muc(const char* const roomjid) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_muc(roomjid); + ProfWin* newwin = win_create_muc(roomjid); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, roomjid); autocomplete_add(wins_close_ac, roomjid); @@ -647,24 +647,24 @@ wins_new_muc(const char *const roomjid) } ProfWin* -wins_new_config(const char *const roomjid, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata) +wins_new_config(const char* const roomjid, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_config(roomjid, form, submit, cancel, userdata); + ProfWin* newwin = win_create_config(roomjid, form, submit, cancel, userdata); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); return newwin; } ProfWin* -wins_new_private(const char *const fulljid) +wins_new_private(const char* const fulljid) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_private(fulljid); + ProfWin* newwin = win_create_private(fulljid); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, fulljid); autocomplete_add(wins_close_ac, fulljid); @@ -673,13 +673,13 @@ wins_new_private(const char *const fulljid) return newwin; } -ProfWin * -wins_new_plugin(const char *const plugin_name, const char * const tag) +ProfWin* +wins_new_plugin(const char* const plugin_name, const char* const tag) { - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); int result = _wins_get_next_available_num(keys); g_list_free(keys); - ProfWin *newwin = win_create_plugin(plugin_name, tag); + ProfWin* newwin = win_create_plugin(plugin_name, tag); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, tag); autocomplete_add(wins_close_ac, tag); @@ -689,11 +689,11 @@ wins_new_plugin(const char *const plugin_name, const char * const tag) gboolean wins_do_notify_remind(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (win_notify_remind(window)) { g_list_free(values); return TRUE; @@ -708,11 +708,11 @@ int wins_get_total_unread(void) { int result = 0; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; result += win_unread(window); curr = g_list_next(curr); } @@ -723,30 +723,30 @@ wins_get_total_unread(void) void wins_resize_all(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; win_resize(window); curr = g_list_next(curr); } g_list_free(values); - ProfWin *current_win = wins_get_current(); + ProfWin* current_win = wins_get_current(); win_update_virtual(current_win); } void -wins_hide_subwin(ProfWin *window) +wins_hide_subwin(ProfWin* window) { win_hide_subwin(window); - ProfWin *current_win = wins_get_current(); + ProfWin* current_win = wins_get_current(); win_refresh_without_subwin(current_win); } void -wins_show_subwin(ProfWin *window) +wins_show_subwin(ProfWin* window) { win_show_subwin(window); @@ -755,20 +755,20 @@ wins_show_subwin(ProfWin *window) return; } - ProfWin *current_win = wins_get_current(); + ProfWin* current_win = wins_get_current(); win_refresh_with_subwin(current_win); } ProfXMLWin* wins_get_xmlconsole(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_XML) { - ProfXMLWin *xmlwin = (ProfXMLWin*)window; + ProfXMLWin* xmlwin = (ProfXMLWin*)window; assert(xmlwin->memcheck == PROFXMLWIN_MEMCHECK); g_list_free(values); return xmlwin; @@ -783,14 +783,14 @@ wins_get_xmlconsole(void) GSList* wins_get_chat_recipients(void) { - GSList *result = NULL; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GSList* result = NULL; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type == WIN_CHAT) { - ProfChatWin *chatwin = (ProfChatWin*)window; + ProfChatWin* chatwin = (ProfChatWin*)window; result = g_slist_append(result, chatwin->barejid); } curr = g_list_next(curr); @@ -802,17 +802,13 @@ wins_get_chat_recipients(void) GSList* wins_get_prune_wins(void) { - GSList *result = NULL; - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GSList* result = NULL; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; - if (win_unread(window) == 0 && - window->type != WIN_MUC && - window->type != WIN_CONFIG && - window->type != WIN_XML && - window->type != WIN_CONSOLE) { + ProfWin* window = curr->data; + if (win_unread(window) == 0 && window->type != WIN_MUC && window->type != WIN_CONFIG && window->type != WIN_XML && window->type != WIN_CONSOLE) { result = g_slist_append(result, window); } curr = g_list_next(curr); @@ -824,11 +820,11 @@ wins_get_prune_wins(void) void wins_lost_connection(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type != WIN_CONSOLE) { win_println(window, THEME_ERROR, "-", "Lost connection."); @@ -845,11 +841,11 @@ wins_lost_connection(void) void wins_reestablished_connection(void) { - GList *values = g_hash_table_get_values(windows); - GList *curr = values; + GList* values = g_hash_table_get_values(windows); + GList* curr = values; while (curr) { - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (window->type != WIN_CONSOLE) { win_println(window, THEME_TEXT, "-", "Connection re-established."); @@ -866,18 +862,18 @@ wins_reestablished_connection(void) void wins_swap(int source_win, int target_win) { - ProfWin *source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win)); - ProfWin *console = wins_get_console(); + ProfWin* source = g_hash_table_lookup(windows, GINT_TO_POINTER(source_win)); + ProfWin* console = wins_get_console(); if (source) { - ProfWin *target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win)); + ProfWin* target = g_hash_table_lookup(windows, GINT_TO_POINTER(target_win)); // target window empty if (target == NULL) { g_hash_table_steal(windows, GINT_TO_POINTER(source_win)); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); status_bar_inactive(source_win); - char *identifier = win_get_tab_identifier(source); + char* identifier = win_get_tab_identifier(source); if (win_unread(source) > 0) { status_bar_new(target_win, source->type, identifier); } else { @@ -889,14 +885,14 @@ wins_swap(int source_win, int target_win) ui_focus_win(console); } - // target window occupied + // target window occupied } else { g_hash_table_steal(windows, GINT_TO_POINTER(source_win)); g_hash_table_steal(windows, GINT_TO_POINTER(target_win)); g_hash_table_insert(windows, GINT_TO_POINTER(source_win), target); g_hash_table_insert(windows, GINT_TO_POINTER(target_win), source); - char *source_identifier = win_get_tab_identifier(source); - char *target_identifier = win_get_tab_identifier(target); + char* source_identifier = win_get_tab_identifier(source); + char* target_identifier = win_get_tab_identifier(target); if (win_unread(source) > 0) { status_bar_new(target_win, source->type, source_identifier); } else { @@ -940,14 +936,14 @@ _wins_cmp_num(gconstpointer a, gconstpointer b) } static int -_wins_get_next_available_num(GList *used) +_wins_get_next_available_num(GList* used) { // only console used if (g_list_length(used) == 1) { return 2; } else { - GList *sorted = NULL; - GList *curr = used; + GList* sorted = NULL; + GList* curr = used; while (curr) { sorted = g_list_insert_sorted(sorted, curr->data, _wins_cmp_num); curr = g_list_next(curr); @@ -961,8 +957,7 @@ _wins_get_next_available_num(GList *used) while (curr) { int curr_num = GPOINTER_TO_INT(curr->data); - if (((last_num != 9) && ((last_num + 1) != curr_num)) || - ((last_num == 9) && (curr_num != 0))) { + if (((last_num != 9) && ((last_num + 1) != curr_num)) || ((last_num == 9) && (curr_num != 0))) { result = last_num + 1; if (result == 10) { result = 0; @@ -993,11 +988,11 @@ wins_tidy(void) { gboolean tidy_required = FALSE; // check for gaps - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); // get last used - GList *last = g_list_last(keys); + GList* last = g_list_last(keys); int last_num = GPOINTER_TO_INT(last->data); // find first free num TODO - Will sort again @@ -1010,14 +1005,14 @@ wins_tidy(void) if (tidy_required) { status_bar_set_all_inactive(); - GHashTable *new_windows = g_hash_table_new_full(g_direct_hash, - g_direct_equal, NULL, (GDestroyNotify)win_free); + GHashTable* new_windows = g_hash_table_new_full(g_direct_hash, + g_direct_equal, NULL, (GDestroyNotify)win_free); int num = 1; - GList *curr = keys; + GList* curr = keys; while (curr) { - ProfWin *window = g_hash_table_lookup(windows, curr->data); - char *identifier = win_get_tab_identifier(window); + ProfWin* window = g_hash_table_lookup(windows, curr->data); + char* identifier = win_get_tab_identifier(window); g_hash_table_steal(windows, curr->data); if (num == 10) { g_hash_table_insert(new_windows, GINT_TO_POINTER(0), window); @@ -1042,7 +1037,7 @@ wins_tidy(void) g_hash_table_destroy(windows); windows = new_windows; current = 1; - ProfWin *console = wins_get_console(); + ProfWin* console = wins_get_console(); ui_focus_win(console); g_list_free(keys); return TRUE; @@ -1059,19 +1054,19 @@ wins_create_summary(gboolean unread) return NULL; } - GSList *result = NULL; + GSList* result = NULL; - GList *keys = g_hash_table_get_keys(windows); + GList* keys = g_hash_table_get_keys(windows); keys = g_list_sort(keys, _wins_cmp_num); - GList *curr = keys; + GList* curr = keys; while (curr) { - ProfWin *window = g_hash_table_lookup(windows, curr->data); + ProfWin* window = g_hash_table_lookup(windows, curr->data); if (!unread || (unread && win_unread(window) > 0)) { - GString *line = g_string_new(""); + GString* line = g_string_new(""); int ui_index = GPOINTER_TO_INT(curr->data); - char *winstring = win_to_string(window); + char* winstring = win_to_string(window); if (!winstring) { g_string_free(line, TRUE); continue; @@ -1093,13 +1088,13 @@ wins_create_summary(gboolean unread) } char* -win_autocomplete(const char *const search_str, gboolean previous, void *context) +win_autocomplete(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(wins_ac, search_str, TRUE, previous); } char* -win_close_autocomplete(const char *const search_str, gboolean previous, void *context) +win_close_autocomplete(const char* const search_str, gboolean previous, void* context) { return autocomplete_complete(wins_close_ac, search_str, TRUE, previous); } @@ -1128,16 +1123,16 @@ ProfWin* wins_get_next_unread(void) { // get and sort win nums - GList *values = g_hash_table_get_values(windows); + GList* values = g_hash_table_get_values(windows); values = g_list_sort(values, _wins_cmp_num); - GList *curr = values; + GList* curr = values; while (curr) { if (current == GPOINTER_TO_INT(curr->data)) { break; } - ProfWin *window = curr->data; + ProfWin* window = curr->data; if (win_unread(window) > 0) { g_list_free(values); return window; @@ -1151,34 +1146,33 @@ wins_get_next_unread(void) } void -wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message) +wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message) { - GRegex *regex; - GMatchInfo *match_info; + GRegex* regex; + GMatchInfo* match_info; regex = g_regex_new("(https?|aesgcm)://\\S+", 0, 0, NULL); - g_regex_match (regex, message->plain, 0, &match_info); + g_regex_match(regex, message->plain, 0, &match_info); - while (g_match_info_matches (match_info)) - { - gchar *word = g_match_info_fetch (match_info, 0); + while (g_match_info_matches(match_info)) { + gchar* word = g_match_info_fetch(match_info, 0); autocomplete_add_reverse(win->urls_ac, word); // for people who run profanity a long time, we don't want to waste a lot of memory autocomplete_remove_older_than_max_reverse(win->urls_ac, 20); - g_free (word); - g_match_info_next (match_info, NULL); + g_free(word); + g_match_info_next(match_info, NULL); } - g_match_info_free (match_info); - g_regex_unref (regex); + g_match_info_free(match_info); + g_regex_unref(regex); } char* -wins_get_url(const char *const search_str, gboolean previous, void *context) +wins_get_url(const char* const search_str, gboolean previous, void* context) { - ProfWin *win = (ProfWin*)context; + ProfWin* win = (ProfWin*)context; return autocomplete_complete(win->urls_ac, search_str, FALSE, previous); } diff --git a/src/ui/window_list.h b/src/ui/window_list.h index 6547354d..e02358f9 100644 --- a/src/ui/window_list.h +++ b/src/ui/window_list.h @@ -41,43 +41,43 @@ void wins_init(void); ProfWin* wins_new_xmlconsole(void); -ProfWin* wins_new_chat(const char *const barejid); -ProfWin* wins_new_muc(const char *const roomjid); -ProfWin* wins_new_config(const char *const roomjid, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata); -ProfWin* wins_new_private(const char *const fulljid); -ProfWin* wins_new_plugin(const char *const plugin_name, const char *const tag); +ProfWin* wins_new_chat(const char* const barejid); +ProfWin* wins_new_muc(const char* const roomjid); +ProfWin* wins_new_config(const char* const roomjid, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata); +ProfWin* wins_new_private(const char* const fulljid); +ProfWin* wins_new_plugin(const char* const plugin_name, const char* const tag); -gboolean wins_chat_exists(const char *const barejid); -GList* wins_get_private_chats(const char *const roomjid); -void wins_private_nick_change(const char *const roomjid, const char *const oldnick, const char *const newnick); -void wins_change_nick(const char *const barejid, const char *const oldnick, const char *const newnick); -void wins_remove_nick(const char *const barejid, const char *const oldnick); +gboolean wins_chat_exists(const char* const barejid); +GList* wins_get_private_chats(const char* const roomjid); +void wins_private_nick_change(const char* const roomjid, const char* const oldnick, const char* const newnick); +void wins_change_nick(const char* const barejid, const char* const oldnick, const char* const newnick); +void wins_remove_nick(const char* const barejid, const char* const oldnick); ProfWin* wins_get_console(void); -ProfChatWin* wins_get_chat(const char *const barejid); +ProfChatWin* wins_get_chat(const char* const barejid); GList* wins_get_chat_unsubscribed(void); -ProfMucWin* wins_get_muc(const char *const roomjid); -ProfConfWin* wins_get_conf(const char *const roomjid); -ProfPrivateWin* wins_get_private(const char *const fulljid); -ProfPluginWin* wins_get_plugin(const char *const tag); +ProfMucWin* wins_get_muc(const char* const roomjid); +ProfConfWin* wins_get_conf(const char* const roomjid); +ProfPrivateWin* wins_get_private(const char* const fulljid); +ProfPluginWin* wins_get_plugin(const char* const tag); ProfXMLWin* wins_get_xmlconsole(void); -void wins_close_plugin(char *tag); +void wins_close_plugin(char* tag); ProfWin* wins_get_current(void); void wins_set_current_by_num(int i); ProfWin* wins_get_by_num(int i); -ProfWin* wins_get_by_string(const char *str); +ProfWin* wins_get_by_string(const char* str); ProfWin* wins_get_next(void); ProfWin* wins_get_previous(void); ProfWin* wins_get_next_unread(void); -int wins_get_num(ProfWin *window); +int wins_get_num(ProfWin* window); int wins_get_current_num(void); void wins_close_by_num(int i); -gboolean wins_is_current(ProfWin *window); +gboolean wins_is_current(ProfWin* window); gboolean wins_do_notify_remind(void); int wins_get_total_unread(void); void wins_resize_all(void); @@ -90,15 +90,15 @@ GSList* wins_create_summary(gboolean unread); void wins_destroy(void); GList* wins_get_nums(void); void wins_swap(int source_win, int target_win); -void wins_hide_subwin(ProfWin *window); -void wins_show_subwin(ProfWin *window); +void wins_hide_subwin(ProfWin* window); +void wins_show_subwin(ProfWin* window); -char* win_autocomplete(const char *const search_str, gboolean previous, void *context); +char* win_autocomplete(const char* const search_str, gboolean previous, void* context); void win_reset_search_attempts(void); -char* win_close_autocomplete(const char *const search_str, gboolean previous, void *context); +char* win_close_autocomplete(const char* const search_str, gboolean previous, void* context); void win_close_reset_search_attempts(void); -void wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message); -char* wins_get_url(const char *const search_str, gboolean previous, void *context); +void wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message); +char* wins_get_url(const char* const search_str, gboolean previous, void* context); #endif diff --git a/src/ui/xmlwin.c b/src/ui/xmlwin.c index b6a085ef..cee8f21a 100644 --- a/src/ui/xmlwin.c +++ b/src/ui/xmlwin.c @@ -40,11 +40,11 @@ #include "ui/window_list.h" void -xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) +xmlwin_show(ProfXMLWin* xmlwin, const char* const msg) { assert(xmlwin != NULL); - ProfWin *window = (ProfWin*)xmlwin; + ProfWin* window = (ProfWin*)xmlwin; if (g_str_has_prefix(msg, "SENT:")) { win_println(window, THEME_DEFAULT, "-", "SENT:"); win_println(window, THEME_ONLINE, "-", "%s", &msg[6]); @@ -57,7 +57,7 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg) } char* -xmlwin_get_string(ProfXMLWin *xmlwin) +xmlwin_get_string(ProfXMLWin* xmlwin) { assert(xmlwin != NULL); |