1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Moved chat logging to profanity module

Removed jabber modules dependency on chat log
This commit is contained in:
James Booth 2012-10-02 22:00:05 +01:00
parent ee8407f4a4
commit a970b9ea86
3 changed files with 29 additions and 15 deletions

View File

@ -28,6 +28,7 @@
#include "command.h" #include "command.h"
#include "common.h" #include "common.h"
#include "contact_list.h" #include "contact_list.h"
#include "chat_log.h"
#include "history.h" #include "history.h"
#include "jabber.h" #include "jabber.h"
#include "log.h" #include "log.h"
@ -450,6 +451,12 @@ cmd_execute_default(const char * const inp)
if (win_in_chat()) { if (win_in_chat()) {
char *recipient = win_get_recipient(); char *recipient = win_get_recipient();
jabber_send(inp, recipient); jabber_send(inp, recipient);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, recipient, inp, OUT);
}
win_show_outgoing_msg("me", recipient, inp); win_show_outgoing_msg("me", recipient, inp);
free(recipient); free(recipient);
} else { } else {
@ -604,8 +611,15 @@ _cmd_msg(const char * const inp, struct cmd_help_t help)
if ((usr != NULL) && (strlen(inp) > (5 + strlen(usr) + 1))) { if ((usr != NULL) && (strlen(inp) > (5 + strlen(usr) + 1))) {
// get message // get message
msg = strndup(inp+5+strlen(usr)+1, strlen(inp)-(5+strlen(usr)+1)); msg = strndup(inp+5+strlen(usr)+1, strlen(inp)-(5+strlen(usr)+1));
if (msg != NULL) { if (msg != NULL) {
jabber_send(msg, usr); jabber_send(msg, usr);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, usr, msg, OUT);
}
win_show_outgoing_msg("me", usr, msg); win_show_outgoing_msg("me", usr, msg);
} else { } else {
char usage[strlen(help.usage + 8)]; char usage[strlen(help.usage + 8)];
@ -641,6 +655,12 @@ _cmd_tiny(const char * const inp, struct cmd_help_t help)
char *tiny = tinyurl_get(url); char *tiny = tinyurl_get(url);
char *recipient = win_get_recipient(); char *recipient = win_get_recipient();
jabber_send(tiny, recipient); jabber_send(tiny, recipient);
if (prefs_get_chlog()) {
const char *jid = jabber_get_jid();
chat_log_chat(jid, recipient, tiny, OUT);
}
win_show_outgoing_msg("me", recipient, tiny); win_show_outgoing_msg("me", recipient, tiny);
free(recipient); free(recipient);
free(tiny); free(tiny);

View File

@ -25,7 +25,6 @@
#include <strophe.h> #include <strophe.h>
#include "chat_log.h"
#include "common.h" #include "common.h"
#include "jabber.h" #include "jabber.h"
#include "log.h" #include "log.h"
@ -161,11 +160,6 @@ jabber_send(const char * const msg, const char * const recipient)
free(coded_msg); free(coded_msg);
free(coded_msg2); free(coded_msg2);
free(coded_msg3); free(coded_msg3);
if (prefs_get_chlog()) {
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
chat_log_chat(jid, (char *)recipient, msg, OUT);
}
} }
void void
@ -280,15 +274,6 @@ _message_handler(xmpp_conn_t * const conn,
char *from = xmpp_stanza_get_attribute(stanza, "from"); char *from = xmpp_stanza_get_attribute(stanza, "from");
prof_handle_incoming_message(from, message); prof_handle_incoming_message(from, message);
if (prefs_get_chlog()) {
char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
chat_log_chat(jid, short_from, message, IN);
}
return 1; return 1;
} }

View File

@ -101,6 +101,15 @@ prof_handle_incoming_message(char *from, char *message)
{ {
win_show_incomming_msg(from, message); win_show_incomming_msg(from, message);
win_page_off(); win_page_off();
if (prefs_get_chlog()) {
char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
const char *jid = jabber_get_jid();
chat_log_chat(jid, short_from, message, IN);
}
} }
void void