113
|
1 /* |
|
2 * hooks.c -- Hooks layer |
|
3 * |
|
4 * Copyright (C) 2005 Mikael Berthe <bmikael@lists.lilotux.net> |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License as published by |
|
8 * the Free Software Foundation; either version 2 of the License, or (at |
|
9 * your option) any later version. |
|
10 * |
|
11 * This program is distributed in the hope that it will be useful, but |
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License |
|
17 * along with this program; if not, write to the Free Software |
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
19 * USA |
|
20 */ |
|
21 |
|
22 #include <screen.h> |
|
23 |
|
24 #include "hooks.h" |
|
25 #include "roster.h" |
|
26 #include "histolog.h" |
115
|
27 #include "utf8.h" |
113
|
28 |
|
29 |
|
30 inline void hk_message_in(const char *jid, time_t timestamp, const char *msg) |
|
31 { |
115
|
32 char *buffer = utf8_decode(msg); |
|
33 // XXX Maybe filter out special chars? |
|
34 scr_WriteIncomingMessage(jid, buffer); |
|
35 hlog_write_message(jid, timestamp, FALSE, buffer); |
|
36 free(buffer); |
113
|
37 } |
|
38 |
|
39 inline void hk_message_out(const char *jid, time_t timestamp, const char *msg) |
|
40 { |
|
41 scr_WriteOutgoingMessage(jid, msg); |
|
42 hlog_write_message(jid, timestamp, TRUE, msg); |
|
43 } |
|
44 |
|
45 inline void hk_statuschange(const char *jid, time_t timestamp, |
|
46 enum imstatus status) |
|
47 { |
|
48 scr_LogPrint("Buddy status has changed: [%c>%c] <%s>", |
|
49 imstatus2char[roster_getstatus(jid)], imstatus2char[status], jid); |
|
50 roster_setstatus(jid, status); |
120
|
51 buddylist_build(); |
|
52 scr_DrawRoster(); |
113
|
53 hlog_write_status(jid, 0, status); |
|
54 } |
|
55 |
116
|
56 inline void hk_mystatuschange(time_t timestamp, |
|
57 enum imstatus old_status, enum imstatus new_status) |
|
58 { |
|
59 if (old_status == new_status) |
|
60 return; |
|
61 |
118
|
62 scr_LogPrint("Your status has changed: [%c>%c]", |
116
|
63 imstatus2char[old_status], imstatus2char[new_status]); |
|
64 //hlog_write_status(NULL, 0, status); |
|
65 } |
|
66 |