Debian Codegraph @

src/fe-common/xep/fe-version.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 "levels.h"
20 #include "printtext.h"
21 #include "signals.h"
22
23 #include "xmpp-servers.h"
24 #include "rosters-tools.h"
25 #include "../module-formats.h"
26
27 static void
28 sig_version(XMPP_SERVER_REC *server, const char *jid, const char *client,
29 const char *version, const char *os)
30 {
31 XMPP_ROSTER_USER_REC *user;
32 char *name, *str;
33
34 g_return_if_fail(jid != NULL);
35 if (client == NULL && version == NULL && os == NULL)
36 return;
37 str = g_strconcat("is running ",
38 client != NULL ? client : "",
39 client != NULL && version != NULL ? " " : "",
40 version != NULL ? version : "",
41 (client != NULL || version != NULL) && os != NULL ? " - " : "",
42 os != NULL ? "on " : "",
43 os != NULL ? os : "", (void *)NULL);
44 user = rosters_find_user(server->roster, jid, NULL, NULL);
45 name = user != NULL && user->name != NULL ?
46 format_get_text(MODULE_NAME, NULL, server, NULL,
47 XMPPTXT_FORMAT_NAME, user->name, jid) :
48 format_get_text(MODULE_NAME, NULL, server, NULL,
49 XMPPTXT_FORMAT_JID, jid);
50 printformat_module(MODULE_NAME, server, jid, MSGLEVEL_CRAP,
51 XMPPTXT_MESSAGE_EVENT, name, str);
52 g_free(name);
53 g_free(str);
54 }
55
56 void
57 fe_version_init(void)
58 {
59 signal_add("xmpp version", sig_version);
60 }
61
62 void
63 fe_version_deinit(void)
64 {
65 signal_remove("xmpp version", sig_version);
66 }