handle /me

v1
Tony Olagbaiye 4 years ago
parent 60db9faf1b
commit b48a796e3d
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -83,6 +83,8 @@
* [ ] OMEMO presence
* [ ] OMEMO messages
* [ ] MUC PMs
* [ ] Send typing notifications
* [ ] Recv typing notifications
** TODO [#B] Implement completion engine (milestone v0.3)
** TODO [#D] Close all issues (milestone v1.0)

@ -49,8 +49,7 @@ void buffer__get_account_and_channel(struct t_gui_buffer *buffer,
/* no account or channel found */
}
char *buffer__typing_bar_cb(const void *pointer,
void *data,
char *buffer__typing_bar_cb(const void *pointer, void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,

@ -9,8 +9,7 @@ void buffer__get_account_and_channel(struct t_gui_buffer *buffer,
struct t_account **account,
struct t_channel **channel);
char *buffer__typing_bar_cb(const void *pointer,
void *data,
char *buffer__typing_bar_cb(const void *pointer, void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
struct t_gui_buffer *buffer,

@ -599,7 +599,13 @@ struct t_channel_member *channel__add_member(struct t_account *account,
}
void channel__send_message(struct t_account *account, struct t_channel *channel,
const char *to, const char *message)
{
const char *to, const char *body)
{
struct xmpp_stanza_t *message = xmpp_message_new(account->context, "chat", to, NULL);
xmpp_message_set_body(message, body);
xmpp_send(account->connection, message);
xmpp_stanza_release(message);
weechat_printf(channel->buffer, "%s: %s",
weechat_config_string(account->options[ACCOUNT_OPTION_JID]),
body);
}

@ -117,4 +117,7 @@ struct t_channel_member *channel__add_member(struct t_account *account,
struct t_channel *channel,
const char *id);
void channel__send_message(struct t_account *account, struct t_channel *channel,
const char *to, const char *body);
#endif /*WEECHAT_XMPP_CHANNEL_H*/

@ -332,13 +332,12 @@ int command__me(const void *pointer, void *data,
char **argv, char **argv_eol)
{
struct t_account *ptr_account = NULL;
struct t_xmpp_channel *ptr_channel = NULL;
//struct t_xmpp_request *request;
struct t_channel *ptr_channel = NULL;
struct xmpp_stanza_t *message;
char *text;
(void) pointer;
(void) data;
(void) buffer;
(void) argv;
buffer__get_account_and_channel(buffer, &ptr_account, &ptr_channel);
@ -365,14 +364,15 @@ int command__me(const void *pointer, void *data,
if (argc > 1)
{
text = argv_eol[1];
text = argv_eol[0];
//request = xmpp_request_chat_memessage(ptr_account,
// weechat_config_string(
// ptr_account->options[XMPP_ACCOUNT_OPTION_TOKEN]),
// ptr_channel->id, text);
//if (request)
// xmpp_account_register_request(ptr_account, request);
message = xmpp_message_new(ptr_account->context, "chat", ptr_channel->name, NULL);
xmpp_message_set_body(message, text);
xmpp_send(ptr_account->connection, message);
xmpp_stanza_release(message);
weechat_printf(ptr_channel->buffer, "* %s %s",
weechat_config_string(ptr_account->options[ACCOUNT_OPTION_JID]),
text);
}
return WEECHAT_RC_OK;

@ -75,7 +75,6 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
xmpp_stanza_t *body, *reply, *to;
const char *type, *from, *from_bare;
char *intext, *replytext;
int quit = 0;
body = xmpp_stanza_get_child_by_name(stanza, "body");
if (body == NULL)
@ -93,7 +92,12 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
if (!channel)
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
weechat_printf(channel->buffer, "<-(%s)- %s: %s", to, from, intext);
if (strcmp(to, channel->id) == 0)
weechat_printf(channel->buffer, "%s [to %s]: %s", from, to, intext);
else if (strncmp(intext, "/me ", 4) == 0)
weechat_printf(channel->buffer, "* %s %s", from, intext+4);
else
weechat_printf(channel->buffer, "%s: %s", from, intext);
xmpp_free(account->context, intext);
@ -111,7 +115,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
if (status == XMPP_CONN_CONNECT) {
xmpp_stanza_t *pres;
weechat_printf(account->buffer, "DEBUG: connected");
//weechat_printf(account->buffer, "DEBUG: connected");
xmpp_handler_add(conn, version_handler, "jabber:iq:version", "iq", NULL,
account);
xmpp_handler_add(conn, message_handler, NULL, "message", NULL, account);
@ -121,7 +125,7 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
xmpp_send(conn, pres);
xmpp_stanza_release(pres);
} else {
weechat_printf(account->buffer, "DEBUG: disconnected");
//weechat_printf(account->buffer, "DEBUG: disconnected");
//xmpp_stop(account->context);
}
}

@ -17,7 +17,6 @@ int input__data(struct t_gui_buffer *buffer, const char *text)
{
struct t_account *account = NULL;
struct t_channel *channel = NULL;
struct xmpp_stanza_t *message;
buffer__get_account_and_channel(buffer, &account, &channel);
@ -34,13 +33,7 @@ int input__data(struct t_gui_buffer *buffer, const char *text)
return WEECHAT_RC_OK;
}
message = xmpp_message_new(account->context, "chat", channel->id, NULL);
xmpp_message_set_body(message, text);
xmpp_send(account->connection, message);
xmpp_stanza_release(message);
weechat_printf(channel->buffer, "-> %s: %s",
weechat_config_string(account->options[ACCOUNT_OPTION_JID]),
text);
channel__send_message(account, channel, channel->id, text);
}
else
{

Loading…
Cancel
Save