replies in pm at least

v1
Tony Olagbaiye 3 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 test: xmpp.so
env LD_PRELOAD=$(DEBUG) \ 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 debug: xmpp.so
gdb -ex "handle SIGPIPE nostop noprint pass" --args \ 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) int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
{ {
struct t_account *account = (struct t_account *)userdata; struct t_account *account = (struct t_account *)userdata;
xmpp_stanza_t *body, *reply; xmpp_stanza_t *body, *reply, *to;
const char *type, *from, *from_jid; const char *type, *from, *from_bare;
char *intext, *replytext; char *intext, *replytext;
int quit = 0; 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) if (type != NULL && strcmp(type, "error") == 0)
return 1; return 1;
from = xmpp_stanza_get_from(stanza); 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); 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) 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); reply = xmpp_stanza_reply(stanza);
if (xmpp_stanza_get_type(reply) == NULL) 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_send(conn, reply);
xmpp_stanza_release(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]), weechat_config_string(account->options[ACCOUNT_OPTION_JID]),
replytext); replytext);
free(replytext); free(replytext);

@ -10,7 +10,6 @@
#include "account.h" #include "account.h"
#include "channel.h" #include "channel.h"
#include "buffer.h" #include "buffer.h"
//#include "request.h"
#include "message.h" #include "message.h"
#include "input.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_account *account = NULL;
struct t_channel *channel = NULL; struct t_channel *channel = NULL;
struct t_request *request; struct xmpp_stanza_t *message;
buffer__get_account_and_channel(buffer, &account, &channel); 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; return WEECHAT_RC_OK;
} }
//TODO: SEND message = xmpp_message_new(account->context, "chat", channel->id, NULL);
//request = request_chat_postmessage(account, xmpp_message_set_body(message, text);
// weechat_config_string( xmpp_send(account->connection, message);
// account->options[ACCOUNT_OPTION_TOKEN]), xmpp_stanza_release(message);
// channel->id, text); weechat_printf(channel->buffer, "-> %s: %s",
//if (request) weechat_config_string(account->options[ACCOUNT_OPTION_JID]),
// account__register_request(account, request); text);
} }
else else
{ {

Loading…
Cancel
Save