libpurple/protocols.c

Thu, 22 Feb 2024 06:03:16 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 22 Feb 2024 06:03:16 -0600
changeset 42596
b64b96f3b781
parent 42594
eddde70cedd8
child 42682
f5559cae9029
permissions
-rw-r--r--

Add a favorite property to PurpleContactInfo

This will be used in the future for toggling whether or not contacts are
favorited or starred.

Testing Done:
Ran the unit tests under valgrind.

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

981
00723c9a507c [gaim-migrate @ 991]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
1 /*
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
2 * Purple - Internet Messaging Library
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
981
00723c9a507c [gaim-migrate @ 991]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
4 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8046
c581b20a47d6 [gaim-migrate @ 8730]
Sean Egan <seanegan@pidgin.im>
parents: 7956
diff changeset
7 * source distribution.
6460
fc288e7221ca [gaim-migrate @ 6969]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
12 * any later version.
981
00723c9a507c [gaim-migrate @ 991]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
17 * more details.
981
00723c9a507c [gaim-migrate @ 991]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42557
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
981
00723c9a507c [gaim-migrate @ 991]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
diff changeset
21 */
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: 40128
diff changeset
22
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: 40128
diff changeset
23 #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: 40128
diff changeset
24
42557
e868bfcc092a Only include headers when they're necessary for header files
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
25 #include "protocols.h"
e868bfcc092a Only include headers when they're necessary for header files
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
26
e868bfcc092a Only include headers when they're necessary for header files
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
27 #include "accounts.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
28 #include "debug.h"
24519
d4af3d043211 Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents: 23875
diff changeset
29 #include "network.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
30 #include "notify.h"
39970
cc7d4ff5a205 rename accountopt.[ch] to purpleaccountoption.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 39921
diff changeset
31 #include "purpleaccountoption.h"
40853
d3518ff99fa7 rename conversation.[ch] to purpleconversation.[ch] and split PurpleConversationUiOps out to its own file to avoid circular include issues.
Gary Kramlich <grim@reaperworld.com>
parents: 40807
diff changeset
32 #include "purpleconversation.h"
40992
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
33 #include "purpleconversationmanager.h"
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
34 #include "purplecredentialmanager.h"
41155
922c9e70900c Rename protocol.[ch] to purpleprotocol.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
35 #include "purpleprotocol.h"
40735
cc0679f47fd9 Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
36 #include "purpleprotocolmanager.h"
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
37 #include "purpleprotocolmedia.h"
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
38 #include "purpleprotocolserver.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
39 #include "request.h"
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 40992
diff changeset
40 #include "server.h"
5872
754c63f29b77 [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
41 #include "util.h"
3738
1dea426a205b [gaim-migrate @ 3876]
Rob Flynn <gaim@robflynn.com>
parents: 3733
diff changeset
42
22225
6cd802a8c5ad This adds accessor and mutator API for the PurpleAttentionType struct.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 21720
diff changeset
43 /**************************************************************************/
37075
cf3f735b09b7 Merge gtkdoc-conversion
Ankit Vani <a@nevitus.org>
parents: 35472 36868
diff changeset
44 /* Protocol API */
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
45 /**************************************************************************/
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
46 void
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
47 purple_protocol_got_user_idle(PurpleAccount *account, const char *name,
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
48 gboolean idle, time_t idle_time)
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
49 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
50 PurplePresence *presence;
18177
6733196cafc6 Update the idleness and login-time for all the blistnodes of the same buddy.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16958
diff changeset
51 GSList *list;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42009
diff changeset
52 GDateTime *idle_date_time = NULL;
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
53
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
54 g_return_if_fail(account != NULL);
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
55 g_return_if_fail(name != NULL);
25428
05aef3d5e63e I think it's reasonable for prpls to call purple_prpl_got_user_idle()
Mark Doliner <markdoliner@pidgin.im>
parents: 24519
diff changeset
56 g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account));
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
57
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34656
diff changeset
58 if ((list = purple_blist_find_buddies(account, name)) == NULL)
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
59 return;
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
60
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42009
diff changeset
61 idle_date_time = g_date_time_new_from_unix_local(idle_time);
18177
6733196cafc6 Update the idleness and login-time for all the blistnodes of the same buddy.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16958
diff changeset
62 while (list) {
6733196cafc6 Update the idleness and login-time for all the blistnodes of the same buddy.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16958
diff changeset
63 presence = purple_buddy_get_presence(list->data);
6733196cafc6 Update the idleness and login-time for all the blistnodes of the same buddy.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16958
diff changeset
64 list = g_slist_delete_link(list, list);
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42009
diff changeset
65 purple_presence_set_idle(presence, idle, idle_date_time);
18177
6733196cafc6 Update the idleness and login-time for all the blistnodes of the same buddy.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 16958
diff changeset
66 }
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42009
diff changeset
67 g_date_time_unref(idle_date_time);
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
68 }
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
69
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
70 void
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
71 purple_protocol_got_user_status_with_attributes(PurpleAccount *account,
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
72 const gchar *name,
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
73 const gchar *status_id,
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
74 GHashTable *attributes)
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
75 {
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
76 GSList *list, *l;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
77 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
78 PurplePresence *presence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
79 PurpleStatus *status;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
80 PurpleStatus *old_status;
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
81
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
82 g_return_if_fail(account != NULL);
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
83 g_return_if_fail(name != NULL);
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
84 g_return_if_fail(status_id != NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
85 g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account));
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
86
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
87 if((list = purple_blist_find_buddies(account, name)) == NULL) {
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
88 return;
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
89 }
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
90
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
91 for(l = list; l != NULL; l = l->next) {
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
92 buddy = l->data;
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
93
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
94 presence = purple_buddy_get_presence(buddy);
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
95 status = purple_presence_get_status(presence, status_id);
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
96
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
97 if(NULL == status) {
27786
630525efd6b0 Add a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 27596
diff changeset
98 /*
630525efd6b0 Add a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 27596
diff changeset
99 * TODO: This should never happen, right? We should call
630525efd6b0 Add a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 27596
diff changeset
100 * g_warning() or something.
630525efd6b0 Add a comment
Mark Doliner <markdoliner@pidgin.im>
parents: 27596
diff changeset
101 */
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
102 continue;
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
103 }
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
104
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
105 old_status = purple_presence_get_active_status(presence);
12176
ee1aea253ce3 [gaim-migrate @ 14478]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12126
diff changeset
106
41782
5fb843f4e356 Merge purple_status_set_active_with_attrs{,_dict}
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41781
diff changeset
107 purple_status_set_active_with_attributes(status, TRUE, attributes);
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
108
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34656
diff changeset
109 purple_buddy_update_status(buddy, old_status);
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
110 }
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
111
12126
3b70215e9630 [gaim-migrate @ 14426]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 12108
diff changeset
112 g_slist_free(list);
12654
2e25e75190c4 [gaim-migrate @ 14997]
Mark Doliner <markdoliner@pidgin.im>
parents: 12377
diff changeset
113
27596
bc7058e10c04 Make the comment reflect that we are actually just stopping the typing
Etan Reisner <deryni@pidgin.im>
parents: 26871
diff changeset
114 /* The buddy is no longer online, they are therefore by definition not
bc7058e10c04 Make the comment reflect that we are actually just stopping the typing
Etan Reisner <deryni@pidgin.im>
parents: 26871
diff changeset
115 * still typing to us. */
29544
dc16ec0027ae Use purple_prpl_got_media_caps in purple_prpl_got_user_status to remove media
Michael Ruprecht <maiku@pidgin.im>
parents: 29543
diff changeset
116 if (!purple_status_is_online(status)) {
35501
602747bb4af9 Fix duplicate prefixes
Ankit Vani <a@nevitus.org>
parents: 35499
diff changeset
117 purple_serv_got_typing_stopped(purple_account_get_connection(account), name);
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
118 purple_protocol_got_media_caps(account, name);
29544
dc16ec0027ae Use purple_prpl_got_media_caps in purple_prpl_got_user_status to remove media
Michael Ruprecht <maiku@pidgin.im>
parents: 29543
diff changeset
119 }
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
120 }
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
121
41781
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
122 void
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
123 purple_protocol_got_user_status(PurpleAccount *account, const gchar *name,
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
124 const gchar *status_id, ...)
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
125 {
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
126 GHashTable *attributes = NULL;
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
127 va_list args;
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
128
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
129 va_start(args, status_id);
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
130 attributes = purple_attrs_from_vargs(args);
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
131 va_end(args);
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
132
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
133 purple_protocol_got_user_status_with_attributes(account, name, status_id,
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
134 attributes);
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
135
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
136 g_hash_table_destroy(attributes);
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
137 }
5891e14ae316 Add introspectable versions of purple_protocol_got_{account,user}_status
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41685
diff changeset
138
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
139 void purple_protocol_got_user_status_deactive(PurpleAccount *account, const char *name,
15588
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
140 const char *status_id)
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
141 {
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
142 GSList *list, *l;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
143 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
144 PurplePresence *presence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
145 PurpleStatus *status;
15588
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
146
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
147 g_return_if_fail(account != NULL);
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
148 g_return_if_fail(name != NULL);
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
149 g_return_if_fail(status_id != NULL);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
150 g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account));
15588
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
151
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34656
diff changeset
152 if((list = purple_blist_find_buddies(account, name)) == NULL)
15588
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
153 return;
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
154
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
155 for(l = list; l != NULL; l = l->next) {
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
156 buddy = l->data;
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
157
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
158 presence = purple_buddy_get_presence(buddy);
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
159 status = purple_presence_get_status(presence, status_id);
15588
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
160
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
161 if(NULL == status)
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
162 continue;
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
163
19692
06e6aba21930 Deactivate only an active status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19654
diff changeset
164 if (purple_status_is_active(status)) {
06e6aba21930 Deactivate only an active status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19654
diff changeset
165 purple_status_set_active(status, FALSE);
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34656
diff changeset
166 purple_buddy_update_status(buddy, status);
19692
06e6aba21930 Deactivate only an active status.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19654
diff changeset
167 }
16958
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
168 }
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
169
c95f16df72f6 this should fix 647, and a few others
Nathan Walp <nwalp@pidgin.im>
parents: 15884
diff changeset
170 g_slist_free(list);
15588
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
171 }
e6e89a427ed5 Use the status API to handle mobileness, and convert AIM to use it. This makes mobile buddies prioritze lower in Perons, and ensures the UI is notified of changes in mobileness. Other protocols to follow.
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
172
12304
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
173 static void
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
174 do_protocol_change_account_status(PurpleAccount *account,
41960
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41919
diff changeset
175 G_GNUC_UNUSED PurpleStatus *old_status,
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41919
diff changeset
176 PurpleStatus *new_status)
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
177 {
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
178 PurpleProtocol *protocol;
40735
cc0679f47fd9 Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
179 PurpleProtocolManager *manager;
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
180
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
181 if (purple_status_is_online(new_status) &&
24519
d4af3d043211 Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents: 23875
diff changeset
182 purple_account_is_disconnected(account) &&
d4af3d043211 Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@pidgin.im>
parents: 23875
diff changeset
183 purple_network_is_available())
11718
90804d019837 [gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents: 11628
diff changeset
184 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
185 purple_account_connect(account);
11718
90804d019837 [gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents: 11628
diff changeset
186 return;
90804d019837 [gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents: 11628
diff changeset
187 }
90804d019837 [gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents: 11628
diff changeset
188
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
189 if (!purple_status_is_online(new_status))
14224
d6d41ff969df [gaim-migrate @ 16810]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14097
diff changeset
190 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
191 if (!purple_account_is_disconnected(account))
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
192 purple_account_disconnect(account);
34146
99bad5c80d1e More password wiping, better password management withing account.c, using actual UI name with KWallet
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 34029
diff changeset
193 /* Clear out the unsaved password if we switch to offline status */
40680
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
194 if (!purple_account_get_remember_password(account)) {
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
195 PurpleCredentialManager *manager = NULL;
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
196
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
197 manager = purple_credential_manager_get_default();
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
198
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
199 purple_credential_manager_clear_password_async(manager, account,
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
200 NULL, NULL, NULL);
f9ea6d5e8992 Use PurpleCredentialManager instead of the old keyring api.
Gary Kramlich <grim@reaperworld.com>
parents: 40634
diff changeset
201 }
34019
bc87f596bb4c compile, appears to work too.
Ka-Hing Cheung <khc@pidgin.im>
parents: 34018
diff changeset
202
14224
d6d41ff969df [gaim-migrate @ 16810]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14097
diff changeset
203 return;
d6d41ff969df [gaim-migrate @ 16810]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 14097
diff changeset
204 }
11718
90804d019837 [gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents: 11628
diff changeset
205
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
206 if (purple_account_is_connecting(account))
12108
a74fd0d6b79c [gaim-migrate @ 14408]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11948
diff changeset
207 /*
36637
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36631
diff changeset
208 * We don't need to call the set_status protocol function because
9b0109ae118d Renamed some prpl stuff to protocol stuff.
Ankit Vani <a@nevitus.org>
parents: 36631
diff changeset
209 * the protocol will take care of setting its status during the
12108
a74fd0d6b79c [gaim-migrate @ 14408]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11948
diff changeset
210 * connection process.
a74fd0d6b79c [gaim-migrate @ 14408]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11948
diff changeset
211 */
a74fd0d6b79c [gaim-migrate @ 14408]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11948
diff changeset
212 return;
a74fd0d6b79c [gaim-migrate @ 14408]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 11948
diff changeset
213
40735
cc0679f47fd9 Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
214 manager = purple_protocol_manager_get_default();
cc0679f47fd9 Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
215 protocol = purple_protocol_manager_find(manager,
cc0679f47fd9 Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents: 40708
diff changeset
216 purple_account_get_protocol_id(account));
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
217
41282
c47df057a426 Silence warning from changing status of the demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41176
diff changeset
218 if (!PURPLE_IS_PROTOCOL_SERVER(protocol)) {
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
219 return;
41282
c47df057a426 Silence warning from changing status of the demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41176
diff changeset
220 }
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
221
40708
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
222 if(!purple_account_is_disconnected(account)) {
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
223 purple_protocol_server_set_status(PURPLE_PROTOCOL_SERVER(protocol),
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
224 account, new_status);
53a26c29d26c Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40680
diff changeset
225 }
9949
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
226 }
377cd65fab3d [gaim-migrate @ 10845]
Daniel Atallah <datallah@pidgin.im>
parents: 9460
diff changeset
227
12304
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
228 void
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
229 purple_protocol_change_account_status(PurpleAccount *account,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15657
diff changeset
230 PurpleStatus *old_status, PurpleStatus *new_status)
12304
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
231 {
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
232 g_return_if_fail(account != NULL);
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
233 g_return_if_fail(new_status != NULL);
21720
235394d5c7f4 Pull a bunch of bugfix only changes to im.pidgin.pidgin.2.3.1,
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20115
diff changeset
234 g_return_if_fail(!purple_status_is_exclusive(new_status) || old_status != NULL);
12304
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
235
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
236 do_protocol_change_account_status(account, old_status, new_status);
12304
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
237
36868
1aca7f52f1ef Backed out the previous 4 changesets. GSignals do not seem feasible with pidgin's architecture using any method.
Ankit Vani <a@nevitus.org>
parents: 36867
diff changeset
238 purple_signal_emit(purple_accounts_get_handle(), "account-status-changed",
1aca7f52f1ef Backed out the previous 4 changesets. GSignals do not seem feasible with pidgin's architecture using any method.
Ankit Vani <a@nevitus.org>
parents: 36867
diff changeset
239 account, old_status, new_status);
12304
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
240 }
e849bc5e8d5d [gaim-migrate @ 14608]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 12176
diff changeset
241
10006
800a81666868 [gaim-migrate @ 10923]
Dave West <kat@users.sourceforge.net>
parents: 9949
diff changeset
242 GList *
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
243 purple_protocol_get_statuses(PurpleAccount *account, PurplePresence *presence)
10006
800a81666868 [gaim-migrate @ 10923]
Dave West <kat@users.sourceforge.net>
parents: 9949
diff changeset
244 {
10447
887380ec66f5 [gaim-migrate @ 11712]
Mark Doliner <markdoliner@pidgin.im>
parents: 10052
diff changeset
245 g_return_val_if_fail(account != NULL, NULL);
10006
800a81666868 [gaim-migrate @ 10923]
Dave West <kat@users.sourceforge.net>
parents: 9949
diff changeset
246 g_return_val_if_fail(presence != NULL, NULL);
800a81666868 [gaim-migrate @ 10923]
Dave West <kat@users.sourceforge.net>
parents: 9949
diff changeset
247
40783
4f197d3e42d6 Use g_list_copy_deep instead of manual copy/transform
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40735
diff changeset
248 return g_list_copy_deep(purple_account_get_status_types(account),
4f197d3e42d6 Use g_list_copy_deep instead of manual copy/transform
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40735
diff changeset
249 (GCopyFunc)purple_status_new, presence);
10006
800a81666868 [gaim-migrate @ 10923]
Dave West <kat@users.sourceforge.net>
parents: 9949
diff changeset
250 }
800a81666868 [gaim-migrate @ 10923]
Dave West <kat@users.sourceforge.net>
parents: 9949
diff changeset
251
26495
52846ebe1c7d Don't assume a PurpleMedia instance will be created immediately.
Michael Ruprecht <maiku@pidgin.im>
parents: 26482
diff changeset
252 gboolean
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
253 purple_protocol_initiate_media(PurpleAccount *account,
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
254 const char *who,
26108
8d0fd2f195aa Changed PurpleMediaStreamType to PurpleMediaSessionType.
Michael Ruprecht <maiku@pidgin.im>
parents: 26107
diff changeset
255 PurpleMediaSessionType type)
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
256 {
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
257 PurpleConnection *gc = NULL;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
258 PurpleProtocol *protocol = NULL;
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
259
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
260 if(account) {
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
261 gc = purple_account_get_connection(account);
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
262 }
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
263 if(gc) {
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36620
diff changeset
264 protocol = purple_connection_get_protocol(gc);
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
265 }
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
266
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
267 if(PURPLE_IS_PROTOCOL_MEDIA(protocol)) {
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
268 PurpleProtocolMedia *media = PURPLE_PROTOCOL_MEDIA(protocol);
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
269
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
270 return purple_protocol_media_initiate_session(media, account, who,
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
271 type);
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
272 } else {
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
273 return FALSE;
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
274 }
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
275 }
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
276
26316
950c0d491c0d Change purple_prpl_can_do_media to purple_prpl_get_media_caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 26260
diff changeset
277 PurpleMediaCaps
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
278 purple_protocol_get_media_caps(PurpleAccount *account, const char *who)
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
279 {
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
280 PurpleConnection *gc = NULL;
36544
1bf8b6ef5aea Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
281 PurpleProtocol *protocol = NULL;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 29670
diff changeset
282
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
283 if(account) {
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
284 gc = purple_account_get_connection(account);
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
285 }
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
286 if(gc) {
36623
caaadef03507 Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents: 36620
diff changeset
287 protocol = purple_connection_get_protocol(gc);
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
288 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 29670
diff changeset
289
40525
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
290 if(PURPLE_IS_PROTOCOL_MEDIA(protocol)) {
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
291 return purple_protocol_media_get_caps(PURPLE_PROTOCOL_MEDIA(protocol),
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
292 account, who);
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
293 } else {
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
294 return PURPLE_MEDIA_CAPS_NONE;
96fc115d6c36 Move PurpleProtocolMediaInterface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
295 }
26099
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
296 }
2ba28e840a95 Convert serv_* media functions to purple_prpl_* functions.
Michael Ruprecht <maiku@pidgin.im>
parents: 22251
diff changeset
297
29543
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
298 void
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
299 purple_protocol_got_media_caps(PurpleAccount *account, const char *name)
29543
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
300 {
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
301 GSList *list;
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
302
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
303 g_return_if_fail(account != NULL);
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
304 g_return_if_fail(name != NULL);
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
305
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34656
diff changeset
306 if ((list = purple_blist_find_buddies(account, name)) == NULL)
29543
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
307 return;
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
308
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
309 while (list) {
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
310 PurpleBuddy *buddy = list->data;
29670
c1d3cb9db1d7 update prpl.c to use the new purple_buddy_[gs]et_media_caps api
Gary Kramlich <grim@reaperworld.com>
parents: 29653
diff changeset
311 PurpleMediaCaps oldcaps = purple_buddy_get_media_caps(buddy);
c1d3cb9db1d7 update prpl.c to use the new purple_buddy_[gs]et_media_caps api
Gary Kramlich <grim@reaperworld.com>
parents: 29653
diff changeset
312 PurpleMediaCaps newcaps = 0;
29547
debae7802d68 Essentially normalize the username passed to purple_prpl_got_media_caps.
Michael Ruprecht <maiku@pidgin.im>
parents: 29546
diff changeset
313 const gchar *bname = purple_buddy_get_name(buddy);
29543
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
314 list = g_slist_delete_link(list, list);
29546
5858906c0f7b Add media_caps to PurpleBuddy structure and use it to determine the old caps
Michael Ruprecht <maiku@pidgin.im>
parents: 29544
diff changeset
315
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 29670
diff changeset
316
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36544
diff changeset
317 newcaps = purple_protocol_get_media_caps(account, bname);
29670
c1d3cb9db1d7 update prpl.c to use the new purple_buddy_[gs]et_media_caps api
Gary Kramlich <grim@reaperworld.com>
parents: 29653
diff changeset
318 purple_buddy_set_media_caps(buddy, newcaps);
c1d3cb9db1d7 update prpl.c to use the new purple_buddy_[gs]et_media_caps api
Gary Kramlich <grim@reaperworld.com>
parents: 29653
diff changeset
319
c1d3cb9db1d7 update prpl.c to use the new purple_buddy_[gs]et_media_caps api
Gary Kramlich <grim@reaperworld.com>
parents: 29653
diff changeset
320 if (oldcaps == newcaps)
29546
5858906c0f7b Add media_caps to PurpleBuddy structure and use it to determine the old caps
Michael Ruprecht <maiku@pidgin.im>
parents: 29544
diff changeset
321 continue;
29543
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
322
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
323 purple_signal_emit(purple_blist_get_handle(),
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
324 "buddy-caps-changed", buddy,
29670
c1d3cb9db1d7 update prpl.c to use the new purple_buddy_[gs]et_media_caps api
Gary Kramlich <grim@reaperworld.com>
parents: 29653
diff changeset
325 newcaps, oldcaps);
29543
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
326 }
4e38799c741e Add the purple_media_got_media_caps function in order to signal when a prpl
Michael Ruprecht <maiku@pidgin.im>
parents: 27786
diff changeset
327 }

mercurial