Apply coding style
Regards https://github.com/profanity-im/profanity/issues/1396
This commit is contained in:
@@ -36,10 +36,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
@@ -48,16 +47,17 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "ui/window.h"
|
||||
#include "ui/buffer.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
#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 +81,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 +108,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 +123,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 +143,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 +163,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);
|
||||
|
||||
@@ -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
|
||||
|
||||
202
src/ui/chatwin.c
202
src/ui/chatwin.c
@@ -36,20 +36,20 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "window_list.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "log.h"
|
||||
#include "database.h"
|
||||
#include "config/preferences.h"
|
||||
#include "database.h"
|
||||
#include "log.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "window_list.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#ifdef HAVE_LIBOTR
|
||||
#include "otr/otr.h"
|
||||
#endif
|
||||
@@ -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);
|
||||
|
||||
@@ -37,16 +37,16 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "ui/window.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;
|
||||
|
||||
496
src/ui/console.c
496
src/ui/console.c
File diff suppressed because it is too large
Load Diff
367
src/ui/core.c
367
src/ui/core.c
@@ -39,9 +39,9 @@
|
||||
#include "gitversion.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -57,36 +57,36 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "command/cmd_defs.h"
|
||||
#include "command/cmd_ac.h"
|
||||
#include "command/cmd_defs.h"
|
||||
#include "common.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/theme.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "ui/statusbar.h"
|
||||
#include "log.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/statusbar.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/contact.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/jid.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
#ifdef HAVE_LIBOTR
|
||||
#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) {
|
||||
|
||||
@@ -36,17 +36,17 @@
|
||||
#define _XOPEN_SOURCE_EXTENDED
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/select.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <readline/readline.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
@@ -54,26 +54,26 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "profanity.h"
|
||||
#include "log.h"
|
||||
#include "common.h"
|
||||
#include "command/cmd_ac.h"
|
||||
#include "config/files.h"
|
||||
#include "common.h"
|
||||
#include "config/accounts.h"
|
||||
#include "config/files.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/theme.h"
|
||||
#include "ui/ui.h"
|
||||
#include "log.h"
|
||||
#include "profanity.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/screen.h"
|
||||
#include "ui/statusbar.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/chat_state.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/chat_state.h"
|
||||
#include "xmpp/xmpp.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;
|
||||
}
|
||||
|
||||
384
src/ui/mucwin.c
384
src/ui/mucwin.c
@@ -36,27 +36,27 @@
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "config/preferences.h"
|
||||
#include "log.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#ifdef HAVE_OMEMO
|
||||
#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);
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -48,14 +48,14 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
#include "config/preferences.h"
|
||||
#include "log.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/xmpp.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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -38,20 +38,20 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "config/preferences.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/titlebar.h"
|
||||
#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;
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "xmpp/contact.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
|
||||
typedef enum {
|
||||
ROSTER_CONTACT,
|
||||
@@ -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_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_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_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 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 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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
#include <ncursesw/ncurses.h>
|
||||
@@ -46,42 +46,44 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "config/theme.h"
|
||||
#include "config/preferences.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/statusbar.h"
|
||||
#include "config/theme.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/screen.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "ui/statusbar.h"
|
||||
#include "ui/ui.h"
|
||||
#include "xmpp/contact.h"
|
||||
#include "xmpp/roster_list.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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -34,39 +34,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "config/theme.h"
|
||||
#include "config/preferences.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "config/theme.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/screen.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "ui/titlebar.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/chat_session.h"
|
||||
#include "xmpp/roster_list.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);
|
||||
}
|
||||
|
||||
@@ -36,21 +36,21 @@
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_GTK
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "config/preferences.h"
|
||||
#include "config/files.h"
|
||||
#include "config/preferences.h"
|
||||
#include "log.h"
|
||||
#include "ui/tray.h"
|
||||
#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) {
|
||||
|
||||
426
src/ui/ui.h
426
src/ui/ui.h
@@ -39,9 +39,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "config/tlscerts.h"
|
||||
#include "config/account.h"
|
||||
#include "command/cmd_funcs.h"
|
||||
#include "config/account.h"
|
||||
#include "config/tlscerts.h"
|
||||
#include "ui/win_types.h"
|
||||
#include "xmpp/message.h"
|
||||
#include "xmpp/muc.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
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <wchar.h>
|
||||
#include <glib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef HAVE_NCURSESW_NCURSES_H
|
||||
#include <ncursesw/ncurses.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;
|
||||
|
||||
|
||||
698
src/ui/window.c
698
src/ui/window.c
File diff suppressed because it is too large
Load Diff
@@ -47,48 +47,48 @@
|
||||
#include <ncurses.h>
|
||||
#endif
|
||||
|
||||
#include "ui/ui.h"
|
||||
#include "ui/buffer.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "ui/ui.h"
|
||||
#include "xmpp/chat_state.h"
|
||||
#include "xmpp/contact.h"
|
||||
#include "xmpp/muc.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
|
||||
#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
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -46,26 +46,26 @@
|
||||
#include "config/preferences.h"
|
||||
#include "config/theme.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "tools/http_upload.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/xmpp.h"
|
||||
#include "xmpp/roster_list.h"
|
||||
#include "tools/http_upload.h"
|
||||
#include "xmpp/xmpp.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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user