Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / protocols / jabber / gtalk.c
blob5c1d0620752ca1fc9d709931011aa90e153b6932
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #include "internal.h"
24 #include "chat.h"
25 #include "core.h"
26 #include "plugins.h"
27 #include "purpleaccountusersplit.h"
29 #include "gtalk.h"
31 static const char *
32 gtalk_list_icon(PurpleAccount *a, PurpleBuddy *b)
34 return "google-talk";
37 static void
38 gtalk_protocol_init(GTalkProtocol *self)
40 PurpleProtocol *protocol = PURPLE_PROTOCOL(self);
41 PurpleAccountUserSplit *split;
42 PurpleAccountOption *option;
43 GList *encryption_values = NULL;
45 protocol->id = "prpl-gtalk";
46 protocol->name = "Google Talk (XMPP)";
48 /* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */
49 split = purple_account_user_split_new(_("Domain"), "gmail.com", '@');
50 purple_account_user_split_set_reverse(split, FALSE);
51 protocol->user_splits = g_list_append(protocol->user_splits, split);
53 split = purple_account_user_split_new(_("Resource"), "", '/');
54 purple_account_user_split_set_reverse(split, FALSE);
55 protocol->user_splits = g_list_append(protocol->user_splits, split);
57 #define ADD_VALUE(list, desc, v) { \
58 PurpleKeyValuePair *kvp = g_new0(PurpleKeyValuePair, 1); \
59 kvp->key = g_strdup((desc)); \
60 kvp->value = g_strdup((v)); \
61 list = g_list_prepend(list, kvp); \
64 ADD_VALUE(encryption_values, _("Require encryption"), "require_tls");
65 ADD_VALUE(encryption_values, _("Use encryption if available"), "opportunistic_tls");
66 ADD_VALUE(encryption_values, _("Use old-style SSL"), "old_ssl");
67 encryption_values = g_list_reverse(encryption_values);
69 #undef ADD_VALUE
71 option = purple_account_option_list_new(_("Connection security"), "connection_security", encryption_values);
72 protocol->account_options = g_list_append(protocol->account_options,
73 option);
75 option = purple_account_option_bool_new(
76 _("Allow plaintext auth over unencrypted streams"),
77 "auth_plain_in_clear", FALSE);
78 protocol->account_options = g_list_append(protocol->account_options,
79 option);
81 option = purple_account_option_int_new(_("Connect port"), "port", 5222);
82 protocol->account_options = g_list_append(protocol->account_options,
83 option);
85 option = purple_account_option_string_new(_("Connect server"),
86 "connect_server", NULL);
87 protocol->account_options = g_list_append(protocol->account_options,
88 option);
90 option = purple_account_option_string_new(_("File transfer proxies"),
91 "ft_proxies", NULL);
92 protocol->account_options = g_list_append(protocol->account_options,
93 option);
95 option = purple_account_option_string_new(_("BOSH URL"),
96 "bosh_url", NULL);
97 protocol->account_options = g_list_append(protocol->account_options,
98 option);
100 /* this should probably be part of global smiley theme settings later on,
101 shared with MSN */
102 option = purple_account_option_bool_new(_("Show Custom Smileys"),
103 "custom_smileys", TRUE);
104 protocol->account_options = g_list_append(protocol->account_options,
105 option);
108 static void
109 gtalk_protocol_class_init(GTalkProtocolClass *klass)
111 PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass);
113 protocol_class->list_icon = gtalk_list_icon;
116 static void
117 gtalk_protocol_class_finalize(G_GNUC_UNUSED GTalkProtocolClass *klass)
121 static void
122 gtalk_protocol_server_iface_init(PurpleProtocolServerInterface *server_iface)
124 /* disable xmpp functions not available for gtalk */
125 server_iface->register_user = NULL;
126 server_iface->unregister_user = NULL;
129 G_DEFINE_DYNAMIC_TYPE_EXTENDED(
130 GTalkProtocol, gtalk_protocol, JABBER_TYPE_PROTOCOL, 0,
132 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_SERVER,
133 gtalk_protocol_server_iface_init));
135 /* This exists solely because the above macro makes gtalk_protocol_register_type
136 * static. */
137 void
138 gtalk_protocol_register(PurplePlugin *plugin)
140 gtalk_protocol_register_type(G_TYPE_MODULE(plugin));