Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/hooks.c @ 1598:a087125d8fc8
Replace libjabber with loudmouth
author | franky |
---|---|
date | Sun, 11 Oct 2009 15:38:32 +0200 |
parents | 7b36b91a4388 |
children | dcd5d4c75199 |
comparison
equal
deleted
inserted
replaced
1597:4f59a414217e | 1598:a087125d8fc8 |
---|---|
17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 * USA | 19 * USA |
20 */ | 20 */ |
21 | 21 |
22 #include <loudmouth/loudmouth.h> | |
23 #include <stdlib.h> | |
24 #include <string.h> | |
22 #include <sys/types.h> | 25 #include <sys/types.h> |
23 #include <unistd.h> | 26 #include <unistd.h> |
24 #include <stdlib.h> | |
25 | 27 |
26 #include "hooks.h" | 28 #include "hooks.h" |
27 #include "screen.h" | 29 #include "screen.h" |
28 #include "roster.h" | 30 #include "roster.h" |
29 #include "histolog.h" | 31 #include "histolog.h" |
53 */ | 55 */ |
54 fifo_read(); | 56 fifo_read(); |
55 } | 57 } |
56 | 58 |
57 void hk_message_in(const char *bjid, const char *resname, | 59 void hk_message_in(const char *bjid, const char *resname, |
58 time_t timestamp, const char *msg, const char *type, | 60 time_t timestamp, const char *msg, LmMessageSubType type, |
59 guint encrypted) | 61 guint encrypted) |
60 { | 62 { |
61 int new_guy = FALSE; | 63 int new_guy = FALSE; |
62 int is_groupchat = FALSE; // groupchat message | 64 int is_groupchat = FALSE; // groupchat message |
63 int is_room = FALSE; // window is a room window | 65 int is_room = FALSE; // window is a room window |
64 int log_muc_conf = FALSE; | 66 int log_muc_conf = FALSE; |
73 if (encrypted == ENCRYPTED_PGP) | 75 if (encrypted == ENCRYPTED_PGP) |
74 message_flags |= HBB_PREFIX_PGPCRYPT; | 76 message_flags |= HBB_PREFIX_PGPCRYPT; |
75 else if (encrypted == ENCRYPTED_OTR) | 77 else if (encrypted == ENCRYPTED_OTR) |
76 message_flags |= HBB_PREFIX_OTRCRYPT; | 78 message_flags |= HBB_PREFIX_OTRCRYPT; |
77 | 79 |
78 if (type && !strcmp(type, "groupchat")) { | 80 if (type == LM_MESSAGE_SUB_TYPE_GROUPCHAT) { |
79 rtype = ROSTER_TYPE_ROOM; | 81 rtype = ROSTER_TYPE_ROOM; |
80 is_groupchat = TRUE; | 82 is_groupchat = TRUE; |
81 log_muc_conf = settings_opt_get_int("log_muc_conf"); | 83 log_muc_conf = settings_opt_get_int("log_muc_conf"); |
82 if (!resname) { | 84 if (!resname) { |
83 message_flags = HBB_PREFIX_INFO | HBB_PREFIX_NOFLAG; | 85 message_flags = HBB_PREFIX_INFO | HBB_PREFIX_NOFLAG; |
170 } | 172 } |
171 } | 173 } |
172 } | 174 } |
173 } | 175 } |
174 | 176 |
175 if (type && !strcmp(type, "error")) { | 177 if (type == LM_MESSAGE_SUB_TYPE_ERROR) { |
176 message_flags = HBB_PREFIX_ERR | HBB_PREFIX_IN; | 178 message_flags = HBB_PREFIX_ERR | HBB_PREFIX_IN; |
177 scr_LogPrint(LPRINT_LOGNORM, "Error message received from <%s>", bjid); | 179 scr_LogPrint(LPRINT_LOGNORM, "Error message received from <%s>", bjid); |
178 } | 180 } |
179 | 181 |
180 // Note: the hlog_write should not be called first, because in some | 182 // Note: the hlog_write should not be called first, because in some |
290 g_free(bmsg); | 292 g_free(bmsg); |
291 g_free(mmsg); | 293 g_free(mmsg); |
292 } | 294 } |
293 | 295 |
294 void hk_statuschange(const char *bjid, const char *resname, gchar prio, | 296 void hk_statuschange(const char *bjid, const char *resname, gchar prio, |
295 time_t timestamp, enum imstatus status, | 297 time_t timestamp, enum imstatus status, |
296 const char *status_msg) | 298 const char *status_msg) |
297 { | 299 { |
298 int st_in_buf; | 300 int st_in_buf; |
299 enum imstatus oldstat; | 301 enum imstatus oldstat; |
300 char *bn; | 302 char *bn; |
301 char *logsmsg; | 303 char *logsmsg; |
475 g_free(datafname); | 477 g_free(datafname); |
476 datafname = NULL; | 478 datafname = NULL; |
477 scr_LogPrint(LPRINT_LOGNORM, | 479 scr_LogPrint(LPRINT_LOGNORM, |
478 "Unable to create temp file for external command."); | 480 "Unable to create temp file for external command."); |
479 } else { | 481 } else { |
480 write(fd, data_locale, strlen(data_locale)); | 482 size_t data_locale_len = strlen(data_locale); |
481 write(fd, "\n", 1); | 483 ssize_t a = write(fd, data_locale, data_locale_len); |
484 ssize_t b = write(fd, "\n", 1); | |
485 if (a != data_locale_len || b != 1) { | |
486 g_free(datafname); | |
487 datafname = NULL; | |
488 scr_LogPrint(LPRINT_LOGNORM, | |
489 "Unable to write to temp file for external command."); | |
490 } | |
482 close(fd); | 491 close(fd); |
483 arg_data = datafname; | 492 arg_data = datafname; |
484 } | 493 } |
485 g_free(data_locale); | 494 g_free(data_locale); |
486 } | 495 } |