| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#include <string.h> |
| 19 |
|
| 20 |
#include "module.h" |
| 21 |
#include "module-formats.h" |
| 22 |
#include "signals.h" |
| 23 |
#include "statusbar-item.h" |
| 24 |
#include "window-items.h" |
| 25 |
|
| 26 |
#include "xmpp-servers.h" |
| 27 |
#include "xmpp-queries.h" |
| 28 |
|
| 29 |
static void |
| 30 |
item_xmpp_composing(struct SBAR_ITEM_REC *item, int get_size_only) |
| 31 |
{ |
| 32 |
XMPP_SERVER_REC *server; |
| 33 |
XMPP_QUERY_REC *query; |
| 34 |
char *str = NULL; |
| 35 |
|
| 36 |
server = XMPP_SERVER(active_win->active_server); |
| 37 |
if (server == NULL || !IS_XMPP_SERVER(server)) |
| 38 |
goto out; |
| 39 |
query = XMPP_QUERY(active_win->active); |
| 40 |
if (query == NULL) |
| 41 |
goto out; |
| 42 |
if (query->composing_visible) |
| 43 |
str = "{sb composing}"; |
| 44 |
|
| 45 |
out: |
| 46 |
if (str == NULL) { |
| 47 |
if (get_size_only) |
| 48 |
statusbar_item_set_size(item, 0, 0); |
| 49 |
return; |
| 50 |
} |
| 51 |
statusbar_item_default_handler(item, get_size_only, |
| 52 |
str, "", FALSE); |
| 53 |
} |
| 54 |
|
| 55 |
static void |
| 56 |
xmpp_composing_update(void) |
| 57 |
{ |
| 58 |
statusbar_items_redraw("xmpp_composing"); |
| 59 |
} |
| 60 |
|
| 61 |
static void |
| 62 |
event_message_sent(XMPP_SERVER_REC *server, const char *message, |
| 63 |
const char *full_jid, const char *ignore) |
| 64 |
{ |
| 65 |
XMPP_QUERY_REC *query; |
| 66 |
|
| 67 |
if (!IS_XMPP_SERVER(server)) |
| 68 |
return; |
| 69 |
query = xmpp_query_find(server, full_jid); |
| 70 |
if (query != NULL) |
| 71 |
query->composing_visible = FALSE; |
| 72 |
xmpp_composing_update(); |
| 73 |
} |
| 74 |
|
| 75 |
void |
| 76 |
text_composing_init(void) |
| 77 |
{ |
| 78 |
statusbar_item_register("xmpp_composing", NULL, item_xmpp_composing); |
| 79 |
|
| 80 |
signal_add("window changed", xmpp_composing_update); |
| 81 |
signal_add_last("xmpp composing show", xmpp_composing_update); |
| 82 |
signal_add_last("xmpp composing hide", xmpp_composing_update); |
| 83 |
signal_add("message private", event_message_sent); |
| 84 |
signal_add("message xmpp action", event_message_sent); |
| 85 |
} |
| 86 |
|
| 87 |
void |
| 88 |
text_composing_deinit(void) |
| 89 |
{ |
| 90 |
statusbar_item_unregister("xmpp_composing"); |
| 91 |
|
| 92 |
signal_remove("window changed", xmpp_composing_update); |
| 93 |
signal_remove("xmpp composing show", xmpp_composing_update); |
| 94 |
signal_remove("xmpp composing hide", xmpp_composing_update); |
| 95 |
signal_remove("message private", event_message_sent); |
| 96 |
signal_remove("message xmpp action", event_message_sent); |
| 97 |
} |