Debian Codegraph @

src/core/xmpp-settings.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 <string.h>
19
20 #include "module.h"
21 #include "settings.h"
22 #include "signals.h"
23
24 #include "xmpp-servers.h"
25 #include "rosters.h"
26
27 void
28 read_settings(void)
29 {
30 GSList *tmp;
31 XMPP_SERVER_REC *server;
32
33 for (tmp = servers; tmp != NULL; tmp = tmp->next) {
34 if ((server = XMPP_SERVER(tmp->data)) == NULL)
35 continue;
36 /* update priority */
37 if (server->show == XMPP_PRESENCE_AWAY) {
38 if (server->priority != settings_get_int("xmpp_priority_away"))
39 signal_emit("xmpp set presence", 4, server,
40 server->show, server->away_reason,
41 settings_get_int("xmpp_priority_away"));
42 } else {
43 if (server->priority != settings_get_int("xmpp_priority"))
44 signal_emit("xmpp set presence", 4, server,
45 server->show, server->away_reason,
46 settings_get_int("xmpp_priority"));
47 }
48 /* update nick */
49 if (settings_get_bool("xmpp_set_nick_as_username")) {
50 if (strcmp(server->nick, server->user) != 0) {
51 g_free(server->nick);
52 server->nick = g_strdup(server->user);
53 }
54 } else {
55 if (strcmp(server->nick, server->jid) != 0) {
56 g_free(server->nick);
57 server->nick = g_strdup(server->jid);
58 }
59 }
60 }
61
62 #if 0
63 const char *str;
64
65 /* check validity */
66 str = settings_get_str("xmpp_proxy_type");
67 /* TODO print error message */
68 if (settings_get_bool("xmpp_use_proxy")
69 && (str == NULL || g_ascii_strcasecmp(str, XMPP_PROXY_HTTP) != 0))
70 ;
71 str = settings_get_str("xmpp_default_away_mode");
72 if (str == NULL
73 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_AWAY]) != 0
74 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_CHAT]) != 0
75 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_DND]) != 0
76 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_XA]) != 0
77 || g_ascii_strcasecmp(str, xmpp_presence_show[XMPP_PRESENCE_ONLINE]) != 0)
78 ;
79 #endif
80 }
81
82 void
83 xmpp_settings_init(void)
84 {
85 signal_add("setup changed", (SIGNAL_FUNC)read_settings);
86 }
87
88 void
89 xmpp_settings_deinit(void)
90 {
91 signal_remove("setup changed", (SIGNAL_FUNC)read_settings);
92 }