replies in pm at least

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

@ -38,7 +38,7 @@ xmpp.so: $(OBJS)
test: xmpp.so
env LD_PRELOAD=$(DEBUG) \
weechat -a -P buflist -r '/plugin load ./xmpp.so'
weechat -a -P 'buflist,irc' -r '/plugin load ./xmpp.so'
debug: xmpp.so
gdb -ex "handle SIGPIPE nostop noprint pass" --args \

@ -72,8 +72,8 @@ int version_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
{
struct t_account *account = (struct t_account *)userdata;
xmpp_stanza_t *body, *reply;
const char *type, *from, *from_jid;
xmpp_stanza_t *body, *reply, *to;
const char *type, *from, *from_bare;
char *intext, *replytext;
int quit = 0;
@ -84,15 +84,16 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
if (type != NULL && strcmp(type, "error") == 0)
return 1;
from = xmpp_stanza_get_from(stanza);
from_jid = xmpp_jid_bare(account->context, from);
from_bare = xmpp_jid_bare(account->context, from);
to = xmpp_stanza_get_to(stanza);
intext = xmpp_stanza_get_text(body);
struct t_channel *channel = channel__search(account, from_jid);
struct t_channel *channel = channel__search(account, from_bare);
if (!channel)
channel = channel__new(account, CHANNEL_TYPE_PM, from_jid, from_jid);
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
weechat_printf(channel->buffer, "%s: %s", from_jid, intext);
weechat_printf(channel->buffer, "<-(%s)- %s: %s", to, from, intext);
reply = xmpp_stanza_reply(stanza);
if (xmpp_stanza_get_type(reply) == NULL)
@ -107,7 +108,7 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
xmpp_send(conn, reply);
xmpp_stanza_release(reply);
weechat_printf(channel->buffer, "%s: %s",
weechat_printf(channel->buffer, "-> %s: %s",
weechat_config_string(account->options[ACCOUNT_OPTION_JID]),
replytext);
free(replytext);

@ -10,7 +10,6 @@
#include "account.h"
#include "channel.h"
#include "buffer.h"
//#include "request.h"
#include "message.h"
#include "input.h"
@ -18,7 +17,7 @@ int input__data(struct t_gui_buffer *buffer, const char *text)
{
struct t_account *account = NULL;
struct t_channel *channel = NULL;
struct t_request *request;
struct xmpp_stanza_t *message;
buffer__get_account_and_channel(buffer, &account, &channel);
@ -35,13 +34,13 @@ int input__data(struct t_gui_buffer *buffer, const char *text)
return WEECHAT_RC_OK;
}
//TODO: SEND
//request = request_chat_postmessage(account,
// weechat_config_string(
// account->options[ACCOUNT_OPTION_TOKEN]),
// channel->id, text);
//if (request)
// account__register_request(account, request);
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);
}
else
{

Loading…
Cancel
Save