libpurple/protocols/mxit/roster.c

Mon, 22 Aug 2016 03:38:13 -0400

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Mon, 22 Aug 2016 03:38:13 -0400
branch
meson
changeset 38445
0e98f0dee5bd
parent 37901
41e45e18f3b2
permissions
-rw-r--r--

Add facebook to meson build.

28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * MXit Protocol libPurple Plugin
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4 * -- user roster management (mxit contacts) --
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * Pieter Loubser <libpurple@mxit.com>
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * <http://www.mxitlifestyle.com>
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * (at your option) any later version.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * GNU General Public License for more details.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
33844
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33831
diff changeset
26 #include "internal.h"
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33831
diff changeset
27 #include "debug.h"
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28
36542
30f40ecc4631 Renamed mxit's protocol.[ch] to client.[ch]
Ankit Vani <a@nevitus.org>
parents: 34811
diff changeset
29 #include "client.h"
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 #include "mxit.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31 #include "roster.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 struct contact_invite {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 struct MXitSession* session; /* MXit session object */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36 struct contact* contact; /* The contact performing the invite */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
37 };
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
39
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
40 /*========================================================================================================================
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41 * Presence / Status
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
43
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 /* statuses (reference: libpurple/status.h) */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
45 static struct status
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46 {
30310
da2adcf3b4a0 Some spelling fixes to code comments.
Andrew Victor <andrew.victor@mxit.com>
parents: 30176
diff changeset
47 PurpleStatusPrimitive primitive;
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 int mxit;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49 const char* id;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50 const char* name;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 } const mxit_statuses[] = {
30310
da2adcf3b4a0 Some spelling fixes to code comments.
Andrew Victor <andrew.victor@mxit.com>
parents: 30176
diff changeset
52 /* primitive, no, id, name */
28990
12ef61293cc8 These status strings are accessed from mxit_convert_presence_to_name() for the
Andrew Victor <andrew.victor@mxit.com>
parents: 28945
diff changeset
53 { PURPLE_STATUS_OFFLINE, MXIT_PRESENCE_OFFLINE, "offline", N_( "Offline" ) }, /* 0 */
12ef61293cc8 These status strings are accessed from mxit_convert_presence_to_name() for the
Andrew Victor <andrew.victor@mxit.com>
parents: 28945
diff changeset
54 { PURPLE_STATUS_AVAILABLE, MXIT_PRESENCE_ONLINE, "online", N_( "Available" ) }, /* 1 */
12ef61293cc8 These status strings are accessed from mxit_convert_presence_to_name() for the
Andrew Victor <andrew.victor@mxit.com>
parents: 28945
diff changeset
55 { PURPLE_STATUS_AWAY, MXIT_PRESENCE_AWAY, "away", N_( "Away" ) }, /* 2 */
12ef61293cc8 These status strings are accessed from mxit_convert_presence_to_name() for the
Andrew Victor <andrew.victor@mxit.com>
parents: 28945
diff changeset
56 { PURPLE_STATUS_AVAILABLE, MXIT_PRESENCE_AVAILABLE, "chat", N_( "Chatty" ) }, /* 3 */
12ef61293cc8 These status strings are accessed from mxit_convert_presence_to_name() for the
Andrew Victor <andrew.victor@mxit.com>
parents: 28945
diff changeset
57 { PURPLE_STATUS_UNAVAILABLE, MXIT_PRESENCE_DND, "dnd", N_( "Do Not Disturb" ) } /* 4 */
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 };
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
60
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
62 * Return list of supported statuses. (see status.h)
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
64 * @param account The MXit account object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
65 * @return List of PurpleStatusType
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
67 GList* mxit_status_types( PurpleAccount* account )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69 GList* statuslist = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 PurpleStatusType* type;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71 unsigned int i;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
73 for ( i = 0; i < ARRAY_SIZE( mxit_statuses ); i++ ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
74 const struct status* status = &mxit_statuses[i];
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
76 /* add mxit status (reference: "libpurple/status.h") */
30310
da2adcf3b4a0 Some spelling fixes to code comments.
Andrew Victor <andrew.victor@mxit.com>
parents: 30176
diff changeset
77 type = purple_status_type_new_with_attrs( status->primitive, status->id, _( status->name ), TRUE, TRUE, FALSE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34811
diff changeset
78 "message", _( "Message" ), purple_value_new( G_TYPE_STRING ),
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
79 NULL );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
80
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
81 statuslist = g_list_append( statuslist, type );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
82 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
83
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
84 /* add Mood option */
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
85 type = purple_status_type_new_with_attrs( PURPLE_STATUS_MOOD, "mood", NULL, FALSE, TRUE, TRUE,
35005
bff56dfca65d Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents: 34811
diff changeset
86 PURPLE_MOOD_NAME, _( "Mood Name" ), purple_value_new( G_TYPE_STRING ),
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
87 NULL );
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
88 statuslist = g_list_append( statuslist, type );
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
89
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
90 return statuslist;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
91 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
92
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
95 * Returns the MXit presence code, given the unique status ID.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
97 * @param id The status ID
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 * @return The MXit presence code
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
100 int mxit_convert_presence( const char* id )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 unsigned int i;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
104 for ( i = 0; i < ARRAY_SIZE( mxit_statuses ); i++ ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
105 if ( strcmp( mxit_statuses[i].id, id ) == 0 ) /* status found! */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
106 return mxit_statuses[i].mxit;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
107 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
108
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 return -1;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
110 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
111
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
114 * Returns the MXit presence as a string, given the MXit presence ID.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
116 * @param no The MXit presence I (see above)
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
117 * @return The presence as a text string
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
119 const char* mxit_convert_presence_to_name( short no )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
120 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 unsigned int i;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123 for ( i = 0; i < ARRAY_SIZE( mxit_statuses ); i++ ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
124 if ( mxit_statuses[i].mxit == no ) /* status found! */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
125 return _( mxit_statuses[i].name );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
126 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
127
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 return "";
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
130
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
131
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132 /*========================================================================================================================
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133 * Moods
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
136 /* moods (reference: libpurple/status.h) */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
137 static PurpleMood mxit_moods[] = {
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
138 { "angry", N_( "Angry" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
139 { "excited", N_( "Excited" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
140 { "grumpy", N_( "Grumpy" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
141 { "happy", N_( "Happy" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
142 { "in_love", N_( "In love" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
143 { "invincible", N_( "Invincible" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
144 { "sad", N_( "Sad" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
145 { "hot", N_( "Hot" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
146 { "sick", N_( "Sick" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
147 { "sleepy", N_( "Sleepy" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
148 { "bored", N_( "Bored" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
149 { "cold", N_( "Cold" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
150 { "confused", N_( "Confused" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
151 { "hungry", N_( "Hungry" ), NULL },
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
152 { "stressed", N_( "Stressed" ), NULL },
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
153 /* Mark the last record. */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
154 { NULL, NULL, NULL }
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
155 };
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
156
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
157
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
158 /*------------------------------------------------------------------------
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
159 * Returns the MXit mood code, given the unique mood ID.
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
160 *
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
161 * @param id The mood ID
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
162 * @return The MXit mood code
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
163 */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
164 int mxit_convert_mood( const char* id )
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
165 {
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
166 unsigned int i;
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
167
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
168 /* Mood is being unset */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
169 if ( id == NULL )
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
170 return MXIT_MOOD_NONE;
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
171
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
172 for ( i = 0; i < ARRAY_SIZE( mxit_moods ) - 1; i++ ) {
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
173 if ( strcmp( mxit_moods[i].mood, id ) == 0 ) /* mood found! */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
174 return i + 1; /* because MXIT_MOOD_NONE is 0 */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
175 }
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
177 return -1;
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
178 }
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
179
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
180
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
181 /*------------------------------------------------------------------------
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
182 * Return the list of MXit-supported moods.
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
183 *
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
184 * @param account The MXit account object
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
185 */
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
186 PurpleMood* mxit_get_moods( PurpleAccount *account )
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
187 {
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
188 return mxit_moods;
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
189 }
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
190
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
191
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
192 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
193 * Returns the MXit mood as a string, given the MXit mood's ID.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
195 * @param id The MXit mood ID (see roster.h)
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196 * @return The mood as a text string
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
197 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
198 const char* mxit_convert_mood_to_name( short id )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
200 switch ( id ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201 case MXIT_MOOD_ANGRY :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202 return _( "Angry" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
203 case MXIT_MOOD_EXCITED :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204 return _( "Excited" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205 case MXIT_MOOD_GRUMPY :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206 return _( "Grumpy" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
207 case MXIT_MOOD_HAPPY :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
208 return _( "Happy" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209 case MXIT_MOOD_INLOVE :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
210 return _( "In Love" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
211 case MXIT_MOOD_INVINCIBLE :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
212 return _( "Invincible" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
213 case MXIT_MOOD_SAD :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
214 return _( "Sad" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
215 case MXIT_MOOD_HOT :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
216 return _( "Hot" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
217 case MXIT_MOOD_SICK :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
218 return _( "Sick" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
219 case MXIT_MOOD_SLEEPY :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220 return _( "Sleepy" );
30570
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
221 case MXIT_MOOD_BORED :
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
222 return _( "Bored" );
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
223 case MXIT_MOOD_COLD :
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
224 return _( "Cold" );
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
225 case MXIT_MOOD_CONFUSED :
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
226 return _( "Confused" );
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
227 case MXIT_MOOD_HUNGRY :
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
228 return _( "Hungry" );
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
229 case MXIT_MOOD_STRESSED :
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
230 return _( "Stressed" );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
231 case MXIT_MOOD_NONE :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
232 default :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
233 return "";
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
234 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
235 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
236
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
237
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
238 /*========================================================================================================================
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
239 * Subscription Types
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
240 */
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30570
diff changeset
241
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
242 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
243 * Returns a Contact subscription type as a string.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
244 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
245 * @param subtype The subscription type
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
246 * @return The subscription type as a text string
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
247 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
248 const char* mxit_convert_subtype_to_name( short subtype )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
249 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
250 switch ( subtype ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
251 case MXIT_SUBTYPE_BOTH :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
252 return _( "Both" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
253 case MXIT_SUBTYPE_PENDING :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
254 return _( "Pending" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
255 case MXIT_SUBTYPE_ASK :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
256 return _( "Invited" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
257 case MXIT_SUBTYPE_REJECTED :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
258 return _( "Rejected" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
259 case MXIT_SUBTYPE_DELETED :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
260 return _( "Deleted" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
261 case MXIT_SUBTYPE_NONE :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
262 return _( "None" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
263 default :
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
264 return "";
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
265 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
266 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
267
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
268
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
269 /*========================================================================================================================
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
270 * Calls from the MXit Protocol layer
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
271 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
272
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
273 #if 0
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
274 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
275 * Dump a contact's info the the debug console.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
276 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
277 * @param contact The contact
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
278 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
279 static void dump_contact( struct contact* contact )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
280 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
281 purple_debug_info( MXIT_PLUGIN_ID, "CONTACT: name='%s', alias='%s', group='%s', type='%i', presence='%i', mood='%i'\n",
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
282 contact->username, contact->alias, contact->groupname, contact->type, contact->presence, contact->mood );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
283 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
284 #endif
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
285
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
286
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
287 #if 0
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
288 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
289 * Move a buddy from one group to another
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
290 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
291 * @param buddy the buddy to move between groups
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292 * @param group the new group to move the buddy to
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
293 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
294 static PurpleBuddy* mxit_update_buddy_group( struct MXitSession* session, PurpleBuddy* buddy, PurpleGroup* group )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
295 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296 PurpleGroup* current_group = purple_buddy_get_group( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
297
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 /* make sure the groups actually differs */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299 if ( strcmp( current_group->name, group->name ) != 0 ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 /* groupnames does not match, so we need to make the update */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
301
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
302 struct contact* contact = purple_buddy_get_protocol_data( buddy );
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
303 PurpleBuddy* newbuddy = NULL;
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
304
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
305 purple_debug_info( MXIT_PLUGIN_ID, "Moving '%s' from group '%s' to '%s'\n", buddy->alias, current_group->name, group->name );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
306
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
308 * XXX: libPurple does not currently provide an API to change or rename the group name
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
309 * for a specific buddy. One option is to remove the buddy from the list and re-adding
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
310 * him in the new group, but by doing that makes the buddy go offline and then online
30310
da2adcf3b4a0 Some spelling fixes to code comments.
Andrew Victor <andrew.victor@mxit.com>
parents: 30176
diff changeset
311 * again. This is really not ideal and very irritating, but how else then?
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
312 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
313
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
314 /* create new buddy, and transfer 'contact' data */
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315 newbuddy = purple_buddy_new( session->acc, buddy->name, buddy->alias );
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
316 purple_buddy_set_protocol_data( newbuddy, contact );
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
317 purple_buddy_set_protocol_data( buddy, NULL );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
318
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
319 /* remove the buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
320 purple_blist_remove_buddy( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
321
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
322 /* add buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
323 purple_blist_add_buddy( newbuddy, NULL, group, NULL );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
324
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
325 /* now re-instate his presence again */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
326 if ( contact ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
327
36543
a8c3fecee2d3 Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents: 36542
diff changeset
328 /* update the buddy's status (reference: "libpurple/protocol.h") */
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
329 if ( contact->statusMsg )
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
330 purple_protocol_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
332 purple_protocol_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, NULL );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
333
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
334 /* update the buddy's mood */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
335 if ( contact->mood == MXIT_MOOD_NONE )
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
336 purple_protocol_got_user_status_deactive( session->acc, newbuddy->name, "mood" );
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
337 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
338 purple_protocol_got_user_status( session->acc, newbuddy->name, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
339
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
340 /* update avatar */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
341 if ( contact->avatarId ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
342 mxit_get_avatar( session, newbuddy->name, contact->avatarId );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
343 g_free( contact->avatarId );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
344 contact->avatarId = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
345 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
346 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
347
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
348 return newbuddy;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
349 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
350 else
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
351 return buddy;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
352 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
353 #endif
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
354
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
355
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
356 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
357 * A contact update packet was received from the MXit server, so update the buddy's
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
358 * information.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
359 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
360 * @param session The MXit session object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
361 * @param contact The contact
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
362 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
363 void mxit_update_contact( struct MXitSession* session, struct contact* contact )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
364 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
365 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
366 PurpleGroup* group = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
367 const char* id = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
368
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
369 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_contact: user='%s' alias='%s' group='%s'\n", contact->username, contact->alias, contact->groupname );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
370
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
371 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
372 * libPurple requires all contacts to be in a group.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
373 * So if this MXit contact isn't in a group, pretend it is.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
374 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
375 if ( *contact->groupname == '\0' ) {
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30310
diff changeset
376 g_strlcpy( contact->groupname, MXIT_DEFAULT_GROUP, sizeof( contact->groupname ) );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
377 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
378
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
379 /* find or create a group for this contact */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
380 group = purple_blist_find_group( contact->groupname );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
381 if ( !group )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
382 group = purple_group_new( contact->groupname );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
383
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
384 /* see if the buddy is not in the group already */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
385 buddy = purple_blist_find_buddy_in_group( session->acc, contact->username, group );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
386 if ( !buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
387 /* buddy not found in the group */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
388
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
389 /* lets try finding him in all groups */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
390 buddy = purple_blist_find_buddy( session->acc, contact->username );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
391 if ( buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
392 /* ok, so we found him in another group. to switch him between groups we must delete him and add him again. */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
393 purple_blist_remove_buddy( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
394 buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
395 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
396
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
397 /* create new buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
398 buddy = purple_buddy_new( session->acc, contact->username, contact->alias );
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
399 purple_buddy_set_protocol_data( buddy, contact );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
400
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
401 /* add new buddy to list */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
402 purple_blist_add_buddy( buddy, NULL, group, NULL );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
403 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
404 else {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
405 /* buddy was found in the group */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
406
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
407 gpointer data = NULL;
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
408
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
409 /* now update the buddy's alias */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
410 purple_buddy_set_local_alias( buddy, contact->alias );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
411
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
412 /* replace the buddy's contact struct */
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
413 if ( ( data = purple_buddy_get_protocol_data( buddy ) ) )
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
414 free( data );
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
415 purple_buddy_set_protocol_data( buddy, contact );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
416 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
417
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
418 /* load buddy's avatar id */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
419 id = purple_buddy_icons_get_checksum_for_user( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
420 if ( id )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
421 contact->avatarId = g_strdup( id );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
422 else
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
423 contact->avatarId = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
424
36543
a8c3fecee2d3 Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents: 36542
diff changeset
425 /* update the buddy's status (reference: "libpurple/protocol.h") */
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
426 purple_protocol_got_user_status( session->acc, contact->username, mxit_statuses[contact->presence].id, NULL );
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
427
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
428 /* update the buddy's mood */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
429 if ( contact->mood == MXIT_MOOD_NONE )
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
430 purple_protocol_got_user_status_deactive( session->acc, contact->username, "mood" );
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
431 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
432 purple_protocol_got_user_status( session->acc, contact->username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
433 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
434
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
435
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
436 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
437 * A presence update packet was received from the MXit server, so update the buddy's
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
438 * information.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
439 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
440 * @param session The MXit session object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
441 * @param username The contact which presence to update
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
442 * @param presence The new presence state for the contact
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
443 * @param mood The new mood for the contact
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
444 * @param customMood The custom mood identifier
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
445 * @param statusMsg This is the contact's status message
31491
cf74b88370ea The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents: 31294
diff changeset
446 * @param flags The contact's presence flags.
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
447 */
31491
cf74b88370ea The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents: 31294
diff changeset
448 void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg, int flags )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
449 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
450 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
451 struct contact* contact = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
452
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
453 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: user='%s' presence=%i mood=%i customMood='%s' statusMsg='%s'\n",
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
454 username, presence, mood, customMood, statusMsg );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
455
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
456 if ( ( presence < MXIT_PRESENCE_OFFLINE ) || ( presence > MXIT_PRESENCE_DND ) ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
457 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: invalid presence state %i\n", presence );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
458 return; /* ignore packet */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
459 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
460
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 33852
diff changeset
461 /* find the buddy information for this contact (reference: "libpurple/buddylist.h") */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
462 buddy = purple_blist_find_buddy( session->acc, username );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
463 if ( !buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
464 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: unable to find the buddy '%s'\n", username );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
465 return;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
466 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
467
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
468 contact = purple_buddy_get_protocol_data( buddy );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
469 if ( !contact )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
470 return;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
471
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30570
diff changeset
472 contact->presence = presence;
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
473 contact->mood = mood;
31491
cf74b88370ea The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents: 31294
diff changeset
474 contact->capabilities = flags;
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
475
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
476 g_strlcpy( contact->customMood, customMood, sizeof( contact->customMood ) );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
477 // TODO: Download custom mood frame.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
478
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
479 /* update status message */
37426
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
480 g_free(contact->statusMsg);
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
481 contact->statusMsg = NULL;
31835
ba0a391c3911 * show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31833
diff changeset
482 if ( ( statusMsg ) && ( statusMsg[0] != '\0' ) )
28991
436deb305c4d We need to escape any special "html" characters in a status message, otherwise
Andrew Victor <andrew.victor@mxit.com>
parents: 28990
diff changeset
483 contact->statusMsg = g_markup_escape_text( statusMsg, -1 );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
484
36543
a8c3fecee2d3 Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents: 36542
diff changeset
485 /* update the buddy's status (reference: "libpurple/protocol.h") */
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
486 if ( contact->statusMsg )
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
487 purple_protocol_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL );
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
488 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
489 purple_protocol_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, NULL );
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
490
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
491 /* update the buddy's mood */
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
492 if ( contact->mood == MXIT_MOOD_NONE )
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
493 purple_protocol_got_user_status_deactive( session->acc, username, "mood" );
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
494 else
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 36543
diff changeset
495 purple_protocol_got_user_status( session->acc, username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
496 }
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
497
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
498
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
499 /*------------------------------------------------------------------------
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
500 * Update the buddy's avatar.
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
501 * Either a presence update packet was received from the MXit server, or a profile response.
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
502 *
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
503 * @param session The MXit session object
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
504 * @param username The contact which presence to update
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
505 * @param avatarId This is the contact's avatar id
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
506 */
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
507 void mxit_update_buddy_avatar( struct MXitSession* session, const char* username, const char* avatarId )
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
508 {
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
509 PurpleBuddy* buddy = NULL;
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
510 struct contact* contact = NULL;
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
511
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
512 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_avatar: user='%s' avatar='%s'\n", username, avatarId );
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
513
34706
02cb08146888 Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents: 33852
diff changeset
514 /* find the buddy information for this contact (reference: "libpurple/buddylist.h") */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
515 buddy = purple_blist_find_buddy( session->acc, username );
30522
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
516 if ( !buddy ) {
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
517 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: unable to find the buddy '%s'\n", username );
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
518 return;
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
519 }
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
520
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
521 contact = purple_buddy_get_protocol_data( buddy );
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
522 if ( !contact )
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
523 return;
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
524
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
525 if ( ( contact->avatarId ) && ( g_ascii_strcasecmp( contact->avatarId, avatarId ) == 0 ) ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
526 /* avatar has not changed - do nothing */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
527 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
528 else if ( avatarId[0] != '\0' ) { /* avatar has changed */
37426
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
529 g_free(contact->avatarId);
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
530 contact->avatarId = g_strdup( avatarId );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
531
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
532 /* Send request to download new avatar image */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
533 mxit_get_avatar( session, username, avatarId );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
535 else /* clear current avatar */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
536 purple_buddy_icons_set_for_user( session->acc, username, NULL, 0, NULL );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
537 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
538
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
539
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
540 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
541 * update the blist cached by libPurple. We need to do this to keep
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
542 * libPurple and MXit's rosters in sync with each other.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
543 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
544 * @param session The MXit session object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
545 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
546 void mxit_update_blist( struct MXitSession* session )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
547 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
548 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
549 GSList* list = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
550 unsigned int i;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
551
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
552 /* remove all buddies we did not receive a roster update for.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
553 * these contacts must have been removed from another client */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
554 list = purple_blist_find_buddies( session->acc, NULL );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 for ( i = 0; i < g_slist_length( list ); i++ ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 buddy = g_slist_nth_data( list, i );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
558
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
559 if ( !purple_buddy_get_protocol_data( buddy ) ) {
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
560 const gchar* alias = purple_buddy_get_alias( buddy );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
561 const gchar* name = purple_buddy_get_name( buddy );
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
562
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563 /* this buddy should be removed, because we did not receive him in our roster update from MXit */
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
564 purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", alias, name );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
565 purple_blist_remove_buddy( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
566 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
567 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
568
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
569 /* tell the UI to update the blist */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
570 purple_blist_add_account( session->acc );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
571 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
572
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
573
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
574 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
575 * The user authorized an invite (subscription request).
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
577 * @param user_data Object associated with the invite
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
578 */
33687
0819d40769c8 Add a message to the authorization callbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32221
diff changeset
579 static void mxit_cb_buddy_auth( const char *message, gpointer user_data )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
580 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
581 struct contact_invite* invite = (struct contact_invite*) user_data;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
582
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
583 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_auth '%s'\n", invite->contact->username );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
585 /* send a allow subscription packet to MXit */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 mxit_send_allow_sub( invite->session, invite->contact->username, invite->contact->alias );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
587
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
588 /* remove the invite from our internal invites list */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
589 invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
590
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
591 /* freeup invite object */
37426
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
592 g_free(invite->contact->msg);
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
593 g_free(invite->contact->statusMsg);
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
594 g_free(invite->contact->profile);
35828
261f7d7810dd imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35005
diff changeset
595 if (invite->contact->image)
261f7d7810dd imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35005
diff changeset
596 g_object_unref(invite->contact->image);
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
597 g_free( invite->contact );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
598 g_free( invite );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
599 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
600
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
601
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
602 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
603 * The user rejected an invite (subscription request).
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
604 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 * @param user_data Object associated with the invite
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
606 */
33687
0819d40769c8 Add a message to the authorization callbacks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32221
diff changeset
607 static void mxit_cb_buddy_deny( const char *message, gpointer user_data )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
608 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
609 struct contact_invite* invite = (struct contact_invite*) user_data;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
610
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
611 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_deny '%s'\n", invite->contact->username );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
612
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613 /* send a deny subscription packet to MXit */
33711
909bc3642565 MXit: Enable support for sending a rejection messages when denying an invite request.
Andrew Victor <andrew.victor@mxit.com>
parents: 33710
diff changeset
614 mxit_send_deny_sub( invite->session, invite->contact->username, message );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
615
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
616 /* remove the invite from our internal invites list */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
617 invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
618
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
619 /* freeup invite object */
37426
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
620 g_free(invite->contact->msg);
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
621 g_free(invite->contact->statusMsg);
6fd4989b77e4 The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents: 37135
diff changeset
622 g_free(invite->contact->profile);
35828
261f7d7810dd imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35005
diff changeset
623 if (invite->contact->image)
261f7d7810dd imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 35005
diff changeset
624 g_object_unref(invite->contact->image);
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
625 g_free( invite->contact );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
626 g_free( invite );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
627 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
628
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
629
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
630 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
631 * A new subscription request packet was received from the MXit server.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
632 * Prompt user to accept or reject it.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
633 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
634 * @param session The MXit session object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
635 * @param contact The contact performing the invite
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
636 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
637 void mxit_new_subscription( struct MXitSession* session, struct contact* contact )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
638 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
639 struct contact_invite* invite;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
640
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
641 purple_debug_info( MXIT_PLUGIN_ID, "mxit_new_subscription from '%s' (%s)\n", contact->username, contact->alias );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
642
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
643 invite = g_new0( struct contact_invite, 1 );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
644 invite->session = session;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
645 invite->contact = contact;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
646
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
647 /* add the invite to our internal invites list */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
648 invite->session->invites = g_list_append( invite->session->invites, invite->contact );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
649
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
650 /* (reference: "libpurple/account.h") */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
651 purple_account_request_authorization( session->acc, contact->username, NULL, contact->alias, contact->msg, FALSE, mxit_cb_buddy_auth, mxit_cb_buddy_deny, invite );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
652 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
653
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
654
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
655 /*------------------------------------------------------------------------
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
656 * Return the contact object for a mxit invite
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
657 *
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
658 * @param session The MXit session object
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
659 * @param username The username of the contact
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
660 * @return The contact object for the inviting user
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
661 */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
662 struct contact* get_mxit_invite_contact( struct MXitSession* session, const char* username )
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
663 {
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
664 struct contact* con = NULL;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
665 struct contact* match = NULL;
33845
53109a1846ae MXit: Fix compiler warnings related to "comparison between signed and unsigned integer expressions".
Andrew Victor <andrew.victor@mxit.com>
parents: 33844
diff changeset
666 unsigned int i;
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
667
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
668 /* run through all the invites and try and find the match */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
669 for ( i = 0; i < g_list_length( session->invites ); i++ ) {
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
670 con = g_list_nth_data( session->invites, i );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
671 if ( strcmp( con->username, username ) == 0 ) {
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
672 /* invite found */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
673 match = con;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
674 break;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
675 }
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
676 }
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
677
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
678 return match;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
679 }
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
680
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
681
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
682 /*------------------------------------------------------------------------
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
683 * Return TRUE if this is a MXit Chatroom contact.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
684 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
685 * @param session The MXit session object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
686 * @param username The username of the contact
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
687 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
688 gboolean is_mxit_chatroom_contact( struct MXitSession* session, const char* username )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
689 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
690 PurpleBuddy* buddy;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
691 struct contact* contact = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
692
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
693 /* find the buddy */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
694 buddy = purple_blist_find_buddy( session->acc, username );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
695 if ( !buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
696 purple_debug_warning( MXIT_PLUGIN_ID, "is_mxit_chatroom_contact: unable to find the buddy '%s'\n", username );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
697 return FALSE;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
698 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
699
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
700 contact = purple_buddy_get_protocol_data( buddy );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
701 if ( !contact )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
702 return FALSE;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
703
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
704 return ( contact->type == MXIT_TYPE_CHATROOM );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
705 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
706
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
707
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
708 /*========================================================================================================================
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
709 * Callbacks from libpurple
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
710 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
711
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
712 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
713 * The user has added a buddy to the list, so send an invite request.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
714 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
715 * @param gc The connection object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
716 * @param buddy The new buddy
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
717 * @param group The group of the new buddy
31699
3b50aab9ab9a Add the invite message support to MXit prpl.
Andrew Victor <andrew.victor@mxit.com>
parents: 31491
diff changeset
718 * @param message The invite message
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
719 */
31699
3b50aab9ab9a Add the invite message support to MXit prpl.
Andrew Victor <andrew.victor@mxit.com>
parents: 31491
diff changeset
720 void mxit_add_buddy( PurpleConnection* gc, PurpleBuddy* buddy, PurpleGroup* group, const char* message )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
721 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
722 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
723 GSList* list = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
724 PurpleBuddy* mxbuddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
725 unsigned int i;
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
726 const gchar * buddy_name = purple_buddy_get_name( buddy );
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
727 const gchar * buddy_alias = purple_buddy_get_alias( buddy );
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
728 const gchar * group_name = purple_group_get_name( group );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
729
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
730 purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy '%s' (group='%s')\n", buddy_name, group_name );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
731
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
732 list = purple_blist_find_buddies( session->acc, buddy_name );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
733 if ( g_slist_length( list ) == 1 ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
734 purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 1) (list:%i)\n", g_slist_length( list ) );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
735 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
736 * we only send an invite to MXit when the user is not already inside our
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
737 * blist. this is done because purple does an add_buddy() call when
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
738 * you accept an invite. so in that case the user is already
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
739 * in our blist and ready to be chatted to.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
740 */
31833
ad08957902a0 Adding contacts normally and via search-results works slightly differently
Andrew Victor <andrew.victor@mxit.com>
parents: 31720
diff changeset
741
ad08957902a0 Adding contacts normally and via search-results works slightly differently
Andrew Victor <andrew.victor@mxit.com>
parents: 31720
diff changeset
742 if ( buddy_name[0] == '#' ) {
ad08957902a0 Adding contacts normally and via search-results works slightly differently
Andrew Victor <andrew.victor@mxit.com>
parents: 31720
diff changeset
743 gchar *tmp = (gchar*) purple_base64_decode( buddy_name + 1, NULL );
33816
9eb08b587d95 MXit: Ealier versions of GLib may cause purple_base64_decode() to return NULL.
Andrew Victor <andrew.victor@mxit.com>
parents: 33706
diff changeset
744 if ( tmp ) {
9eb08b587d95 MXit: Ealier versions of GLib may cause purple_base64_decode() to return NULL.
Andrew Victor <andrew.victor@mxit.com>
parents: 33706
diff changeset
745 mxit_send_invite( session, tmp, FALSE, buddy_alias, group_name, message );
9eb08b587d95 MXit: Ealier versions of GLib may cause purple_base64_decode() to return NULL.
Andrew Victor <andrew.victor@mxit.com>
parents: 33706
diff changeset
746 g_free( tmp );
9eb08b587d95 MXit: Ealier versions of GLib may cause purple_base64_decode() to return NULL.
Andrew Victor <andrew.victor@mxit.com>
parents: 33706
diff changeset
747 }
31833
ad08957902a0 Adding contacts normally and via search-results works slightly differently
Andrew Victor <andrew.victor@mxit.com>
parents: 31720
diff changeset
748 }
ad08957902a0 Adding contacts normally and via search-results works slightly differently
Andrew Victor <andrew.victor@mxit.com>
parents: 31720
diff changeset
749 else
ad08957902a0 Adding contacts normally and via search-results works slightly differently
Andrew Victor <andrew.victor@mxit.com>
parents: 31720
diff changeset
750 mxit_send_invite( session, buddy_name, TRUE, buddy_alias, group_name, message );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
751 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
752 else {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
753 purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 2) (list:%i)\n", g_slist_length( list ) );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
754 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
755 * we already have the buddy in our list, so we will only update
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
756 * his information here and not send another invite message
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
757 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
758
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
759 /* find the correct buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
760 for ( i = 0; i < g_slist_length( list ); i++ ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
761 mxbuddy = g_slist_nth_data( list, i );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
762
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
763 if ( purple_buddy_get_protocol_data( mxbuddy ) != NULL ) {
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
764 /* this is our REAL MXit buddy! */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
765
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
766 /* now update the buddy's alias */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
767 purple_buddy_set_local_alias( mxbuddy, buddy_alias );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
768
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
769 /* now update the buddy's group */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
770 // mxbuddy = mxit_update_buddy_group( session, mxbuddy, group );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
771
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
772 /* send the update to the MXit server */
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
773 mxit_send_update_contact( session, purple_buddy_get_name( mxbuddy ), purple_buddy_get_alias( mxbuddy ), group_name );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
774 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
775 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
776 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
777
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
778 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
779 * we remove the buddy here from the buddy list because the MXit server
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
780 * will send us a proper contact update packet if this succeeds. now
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
781 * we do not have to worry about error handling in case of adding an
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
782 * invalid contact. so the user will still see the contact as offline
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
783 * until he eventually accepts the invite.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
784 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
785 purple_blist_remove_buddy( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
786
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
787 g_slist_free( list );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
788 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
789
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
790
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
791 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
792 * The user has removed a buddy from the list.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
793 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
794 * @param gc The connection object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
795 * @param buddy The buddy being removed
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
796 * @param group The group the buddy was in
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
797 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
798 void mxit_remove_buddy( PurpleConnection* gc, PurpleBuddy* buddy, PurpleGroup* group )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
799 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
800 struct MXitSession* session = purple_connection_get_protocol_data( gc );
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
801 const gchar * buddy_name = purple_buddy_get_name( buddy );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
802
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
803 purple_debug_info( MXIT_PLUGIN_ID, "mxit_remove_buddy '%s'\n", buddy_name );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
804
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
805 mxit_send_remove( session, buddy_name );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
806 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
807
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
808
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
809 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
810 * The user changed the buddy's alias.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
811 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
812 * @param gc The connection object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
813 * @param who The username of the buddy
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
814 * @param alias The new alias
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
815 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
816 void mxit_buddy_alias( PurpleConnection* gc, const char* who, const char* alias )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
817 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
818 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
819 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
820 PurpleGroup* group = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
821
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
822 purple_debug_info( MXIT_PLUGIN_ID, "mxit_buddy_alias '%s' to '%s\n", who, alias );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
823
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
824 /* find the buddy */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
825 buddy = purple_blist_find_buddy( session->acc, who );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
826 if ( !buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
827 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_buddy_alias: unable to find the buddy '%s'\n", who );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
828 return;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
829 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
830
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
831 /* find buddy group */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
832 group = purple_buddy_get_group( buddy );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
833 if ( !group ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
834 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_buddy_alias: unable to find the group for buddy '%s'\n", who );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
835 return;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
836 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
837
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
838 mxit_send_update_contact( session, who, alias, purple_group_get_name( group ) );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
839 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
840
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
842 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
843 * The user changed the group for a single buddy.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
844 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
845 * @param gc The connection object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
846 * @param who The username of the buddy
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
847 * @param old_group The old group's name
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
848 * @param new_group The new group's name
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
849 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
850 void mxit_buddy_group( PurpleConnection* gc, const char* who, const char* old_group, const char* new_group )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
851 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
852 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
853 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
854
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
855 purple_debug_info( MXIT_PLUGIN_ID, "mxit_buddy_group from '%s' to '%s'\n", old_group, new_group );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
856
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
857 /* find the buddy */
34728
8efd73063ecf Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
858 buddy = purple_blist_find_buddy( session->acc, who );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
859 if ( !buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
860 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_buddy_group: unable to find the buddy '%s'\n", who );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
861 return;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
862 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
863
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
864 mxit_send_update_contact( session, who, purple_buddy_get_alias( buddy ), new_group );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
865 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
866
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
867
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
868 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
869 * The user has selected to rename a group, so update all contacts in that
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
870 * group.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
871 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
872 * @param gc The connection object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
873 * @param old_name The old group name
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
874 * @param group The updated group object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
875 * @param moved_buddies The buddies affected by the rename
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
876 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
877 void mxit_rename_group( PurpleConnection* gc, const char* old_name, PurpleGroup* group, GList* moved_buddies )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
878 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33816
diff changeset
879 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
880 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
881 GList* item = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
882
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
883 purple_debug_info( MXIT_PLUGIN_ID, "mxit_rename_group from '%s' to '%s\n", old_name, purple_group_get_name( group ) );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
884
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
885 // TODO: Might be more efficient to use the "rename group" command (cmd=29).
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
886
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
887 /* loop through all the contacts in the group and send updates */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
888 item = moved_buddies;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
889 while ( item ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
890 buddy = item->data;
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
891 mxit_send_update_contact( session, purple_buddy_get_name( buddy ), purple_buddy_get_alias( buddy ), purple_group_get_name( group ) );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
892 item = g_list_next( item );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
893 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
894 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
895

mercurial