mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 08:46:21 +00:00
Moved function to jabber module
This commit is contained in:
22
jabber.c
22
jabber.c
@@ -9,7 +9,6 @@ extern FILE *logp;
|
|||||||
|
|
||||||
extern WINDOW *main_win;
|
extern WINDOW *main_win;
|
||||||
|
|
||||||
|
|
||||||
int in_message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
int in_message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||||
void * const userdata)
|
void * const userdata)
|
||||||
{
|
{
|
||||||
@@ -57,7 +56,26 @@ void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void prof_send(char *msg, xmpp_ctx_t *ctx, xmpp_conn_t *conn)
|
||||||
|
{
|
||||||
|
xmpp_stanza_t *reply, *body, *text;
|
||||||
|
|
||||||
|
reply = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(reply, "message");
|
||||||
|
xmpp_stanza_set_type(reply, "chat");
|
||||||
|
xmpp_stanza_set_attribute(reply, "to", "boothj5@localhost");
|
||||||
|
|
||||||
|
body = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(body, "body");
|
||||||
|
|
||||||
|
text = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_text(text, msg);
|
||||||
|
xmpp_stanza_add_child(body, text);
|
||||||
|
xmpp_stanza_add_child(reply, body);
|
||||||
|
|
||||||
|
xmpp_send(conn, reply);
|
||||||
|
xmpp_stanza_release(reply);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
jabber.h
4
jabber.h
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
#include <strophe/strophe.h>
|
#include <strophe/strophe.h>
|
||||||
|
|
||||||
// message handlers
|
|
||||||
int in_message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
int in_message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||||
void * const userdata);
|
void * const userdata);
|
||||||
|
|
||||||
// connection handler
|
|
||||||
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
void conn_handler(xmpp_conn_t * const conn, const xmpp_conn_event_t status,
|
||||||
const int error, xmpp_stream_error_t * const stream_error,
|
const int error, xmpp_stream_error_t * const stream_error,
|
||||||
void * const userdata);
|
void * const userdata);
|
||||||
|
|
||||||
|
void prof_send(char *msg, xmpp_ctx_t *ctx, xmpp_conn_t *conn);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
20
profanity.c
20
profanity.c
@@ -134,24 +134,8 @@ void event_loop(xmpp_ctx_t *ctx, xmpp_conn_t *conn)
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// send the message
|
// send the message
|
||||||
xmpp_stanza_t *reply, *body, *text;
|
prof_send(command, ctx, conn);
|
||||||
|
|
||||||
reply = xmpp_stanza_new(ctx);
|
|
||||||
xmpp_stanza_set_name(reply, "message");
|
|
||||||
xmpp_stanza_set_type(reply, "chat");
|
|
||||||
xmpp_stanza_set_attribute(reply, "to", "boothj5@localhost");
|
|
||||||
|
|
||||||
body = xmpp_stanza_new(ctx);
|
|
||||||
xmpp_stanza_set_name(body, "body");
|
|
||||||
|
|
||||||
text = xmpp_stanza_new(ctx);
|
|
||||||
xmpp_stanza_set_text(text, command);
|
|
||||||
xmpp_stanza_add_child(body, text);
|
|
||||||
xmpp_stanza_add_child(reply, body);
|
|
||||||
|
|
||||||
xmpp_send(conn, reply);
|
|
||||||
xmpp_stanza_release(reply);
|
|
||||||
|
|
||||||
// show it in the main window
|
// show it in the main window
|
||||||
wprintw(main_win, "me: %s\n", command);
|
wprintw(main_win, "me: %s\n", command);
|
||||||
wrefresh(main_win);
|
wrefresh(main_win);
|
||||||
|
|||||||
Reference in New Issue
Block a user