Debian Codegraph @

src/fe-common/fe-xmpp-core.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2007 Colin DIDIER
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #include "module.h"
19 #include "core.h"
20 #include "levels.h"
21 #include "module-formats.h"
22 #include "printtext.h"
23 #include "servers-setup.h"
24 #include "settings.h"
25 #include "signals.h"
26 #include "themes.h"
27
28 #include "fe-xmpp-messages.h"
29 #include "fe-xmpp-queries.h"
30 #include "fe-xmpp-status.h"
31 #include "fe-xmpp-windows.h"
32 #include "fe-rosters.h"
33 #include "fe-stanzas.h"
34 #include "xmpp-completion.h"
35 #include "xmpp-formats.h"
36 #include "xep/fe-xep.h"
37
38 static void
39 sig_server_status(SERVER_REC *server, const char *msg)
40 {
41 printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CLIENTNOTICE,
42 XMPPTXT_DEFAULT_EVENT, NULL, msg, NULL);
43 }
44
45 static void
46 sig_server_add_fill(SERVER_SETUP_REC *rec, GHashTable *optlist)
47 {
48 char *value;
49
50 if ((value = g_hash_table_lookup(optlist, "xmppnet")) != NULL) {
51 g_free_and_null(rec->chatnet);
52 if (*value != '\0')
53 rec->chatnet = g_strdup(value);
54 }
55 }
56
57 void
58 fe_xmpp_init(void)
59 {
60 theme_register(fecommon_xmpp_formats);
61
62 signal_add("xmpp server status", sig_server_status);
63 signal_add("server add fill", sig_server_add_fill);
64
65 fe_xmpp_messages_init();
66 fe_xmpp_queries_init();
67 fe_xmpp_status_init();
68 fe_xmpp_windows_init();
69 fe_rosters_init();
70 fe_stanzas_init();
71 xmpp_completion_init();
72 xmpp_formats_init();
73 fe_xep_init();
74
75 module_register("xmpp", "fe");
76
77 /* load irssi-xmpp's fe-text submodule */
78 if (irssi_gui == IRSSI_GUI_TEXT) {
79 char *cmd_line = g_strconcat(settings_get_str("cmdchars"),
80 "load xmpp text", (void *)NULL);
81 signal_emit("send command", 1, cmd_line);
82 g_free(cmd_line);
83 }
84 }
85
86 void
87 fe_xmpp_deinit(void)
88 {
89 signal_remove("xmpp server status", sig_server_status);
90 signal_remove("server add fill", sig_server_add_fill);
91
92 fe_xmpp_messages_deinit();
93 fe_xmpp_queries_deinit();
94 fe_xmpp_status_deinit();
95 fe_xmpp_windows_deinit();
96 fe_rosters_deinit();
97 fe_stanzas_deinit();
98 xmpp_completion_deinit();
99 xmpp_formats_deinit();
100 fe_xep_deinit();
101
102 theme_unregister();
103 }
104
105 #ifdef IRSSI_ABI_VERSION
106 void
107 fe_xmpp_abicheck(int * version)
108 {
109 *version = IRSSI_ABI_VERSION;
110 }
111 #endif