libpurple/protocols/jabber/usernick.c

Tue, 21 Mar 2023 02:07:16 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 21 Mar 2023 02:07:16 -0500
changeset 42176
8f7b46f497c6
parent 41967
025eee9e6f1d
child 42291
a86b7bcbb471
permissions
-rw-r--r--

Remove libsoup2 code

Soup 3 has been required since /r/2068.

Testing Done:
Compiled only.

Reviewed at https://reviews.imfreedom.org/r/2375/

17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
1 /*
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
6 * source distribution.
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
7 *
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
11 * (at your option) any later version.
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
12 *
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
16 * GNU General Public License for more details.
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
17 *
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
28321
c8d617c408ab Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents: 27016
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
21 *
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
22 */
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
23
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
25
40358
e6fe6fc1f516 move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents: 37101
diff changeset
26 #include <purple.h>
19898
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 17804
diff changeset
27
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
28 #include "usernick.h"
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
29 #include "pep.h"
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
30 #include <string.h>
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
31
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
32 static void jabber_nick_cb(JabberStream *js, const char *from, PurpleXmlNode *items) {
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
33 /* it doesn't make sense to have more than one item here, so let's just pick the first one */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
34 PurpleXmlNode *item = purple_xmlnode_get_child(items, "item");
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
35 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
36 PurpleXmlNode *nick;
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
37 char *nickname = NULL;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
38
26997
e30b31076fcb Handle User Nick notifications via <presence/> stanzas (receive-only). Refs #864.
Paul Aurich <darkrain42@pidgin.im>
parents: 26072
diff changeset
39 /* ignore the nick of people not on our buddy list */
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
40 if (!buddy || !item)
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
41 return;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
42
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
43 nick = purple_xmlnode_get_child_with_namespace(item, "nick", "http://jabber.org/protocol/nick");
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
44 if (!nick)
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
45 return;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
46 nickname = purple_xmlnode_get_data(nick);
35499
c4c5e0a670b1 Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents: 34940
diff changeset
47 purple_serv_got_alias(js->gc, from, nickname);
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
48 g_free(nickname);
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
49 }
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
50
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
51 static void do_nick_set(JabberStream *js, const char *nick) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
52 PurpleXmlNode *publish, *nicknode;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
53
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
54 publish = purple_xmlnode_new("publish");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
55 purple_xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
56 nicknode = purple_xmlnode_new_child(purple_xmlnode_new_child(publish, "item"), "nick");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
57 purple_xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
58
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
59 if(nick && nick[0] != '\0')
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
60 purple_xmlnode_insert_data(nicknode, nick, -1);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
61
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
62 jabber_pep_publish(js, publish);
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
63 /* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
64 (yay for well-defined memory management rules) */
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
65 }
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
66
41967
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41789
diff changeset
67 static void
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41789
diff changeset
68 do_nick_got_own_nick_cb(JabberStream *js, G_GNUC_UNUSED const char *from,
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41789
diff changeset
69 PurpleXmlNode *items)
025eee9e6f1d Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41789
diff changeset
70 {
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
71 char *oldnickname = NULL;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
72 PurpleXmlNode *item = NULL;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 29782
diff changeset
73
27016
1e21b1e058c0 On errors, don't pretend we did fetch something, pass NULL.
Paul Aurich <darkrain42@pidgin.im>
parents: 26997
diff changeset
74 if (items)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
75 item = purple_xmlnode_get_child(items,"item");
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
76
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
77 if(item) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
78 PurpleXmlNode *nick = purple_xmlnode_get_child_with_namespace(item,"nick","http://jabber.org/protocol/nick");
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
79 if(nick)
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 31294
diff changeset
80 oldnickname = purple_xmlnode_get_data(nick);
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
81 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
82
21653
621c47778132 merge of '73ae9aeda3c58fbf8437421da68d19d06f93e686'
Evan Schoenberg <evands@pidgin.im>
parents: 21233
diff changeset
83 purple_request_input(js->gc, _("Set User Nickname"), _("Please specify a new nickname for you."),
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
84 _("This information is visible to all contacts on your contact list, so choose something appropriate."),
41314
0dc72eacd8bf Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40441
diff changeset
85 oldnickname, FALSE, FALSE, NULL, _("Set"), G_CALLBACK(do_nick_set), _("Cancel"), NULL,
34329
ddbc1337332c Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 31294
diff changeset
86 purple_request_cpar_from_connection(js->gc), js);
20169
497e1cd1e059 Merged xmpp leak fixes
Evan Schoenberg <evands@pidgin.im>
parents: 19994
diff changeset
87 g_free(oldnickname);
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
88 }
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
89
41789
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
90 static void
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
91 do_nick_set_nick(G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter,
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
92 G_GNUC_UNUSED gpointer data)
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
93 {
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
94 const char *account_id = NULL;
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
95 PurpleAccountManager *manager = NULL;
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
96 PurpleAccount *account = NULL;
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
97 PurpleConnection *connection = NULL;
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
98 JabberStream *js = NULL;
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
99
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
100 if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) {
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
101 g_critical("XMPP Set Nickname action parameter is of incorrect type %s",
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
102 g_variant_get_type_string(parameter));
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
103 }
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
104
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
105 account_id = g_variant_get_string(parameter, NULL);
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
106 manager = purple_account_manager_get_default();
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
107 account = purple_account_manager_find_by_id(manager, account_id);
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
108 connection = purple_account_get_connection(account);
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
109 js = purple_connection_get_protocol_data(connection);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21653
diff changeset
110
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
111 /* since the nickname might have been changed by another resource of this account, we always have to request the old one
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
112 from the server to present as the default for the new one */
29782
ca4fedd9e890 jabber: Allow jabber_pep_request_item() to take NULL for JID; server's routing takes care of the rest
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
113 jabber_pep_request_item(js, NULL, "http://jabber.org/protocol/nick", NULL, do_nick_got_own_nick_cb);
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
114 }
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
115
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
116 void jabber_nick_init(void) {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21653
diff changeset
117 jabber_add_feature("http://jabber.org/protocol/nick", jabber_pep_namespace_only_when_pep_enabled_cb);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 21653
diff changeset
118 jabber_pep_register_handler("http://jabber.org/protocol/nick", jabber_nick_cb);
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
119 }
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
120
41789
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
121 void
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
122 jabber_nick_add_action_entries(GSimpleActionGroup *group) {
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
123 GActionEntry entries[] = {
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
124 {
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
125 .name = "set-nickname",
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
126 .activate = do_nick_set_nick,
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
127 .parameter_type = "s",
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
128 },
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
129 };
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
130 gsize nentries = G_N_ELEMENTS(entries);
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
131
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
132 g_action_map_add_action_entries(G_ACTION_MAP(group), entries, nentries,
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
133 NULL);
17804
fcf478d290f6 User Nickname now sets the buddy's server_alias, which means that no UI changes are required for supporting this XEP. Also forgot to add usernick.[hc].
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
134 }
41789
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
135
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
136 void
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
137 jabber_nick_append_menu(GMenu *menu) {
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
138 GMenuItem *item = NULL;
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
139
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
140 item = g_menu_item_new(_("Set Nickname..."), "prpl-xmpp.set-nickname");
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
141 g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s",
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
142 "account");
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
143 g_menu_append_item(menu, item);
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
144 g_object_unref(item);
7e73a8cc44e2 xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41314
diff changeset
145 }

mercurial