libpurple/protocols/mxit/roster.c

Tue, 12 Apr 2011 19:55:13 +0000

author
Andrew Victor <andrew.victor@mxit.com>
date
Tue, 12 Apr 2011 19:55:13 +0000
branch
mxit
changeset 31720
4047faf09005
parent 31714
4fb9e95a7c4f
child 31833
ad08957902a0
permissions
-rw-r--r--

Protocol 6.3 change to SubscribeContact packet.

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
29106
51c7b2177e42 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents: 28991
diff changeset
26 #include "internal.h"
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
27 #include "purple.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29 #include "protocol.h"
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,
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
78 "message", _( "Message" ), purple_value_new( PURPLE_TYPE_STRING ),
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 */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
85 type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD, "mood", NULL, FALSE, TRUE, TRUE,
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
86 PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new( PURPLE_TYPE_STRING ),
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
87 NULL);
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[] = {
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
138 {"angry", N_("Angry"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
139 {"excited", N_("Excited"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
140 {"grumpy", N_("Grumpy"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
141 {"happy", N_("Happy"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
142 {"in_love", N_("In love"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
143 {"invincible", N_("Invincible"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
144 {"sad", N_("Sad"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
145 {"hot", N_("Hot"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
146 {"sick", N_("Sick"), NULL},
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
147 {"sleepy", N_("Sleepy"), NULL},
30570
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
148 {"bored", N_("Bored"), NULL},
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
149 {"cold", N_("Cold"), NULL},
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
150 {"confused", N_("Confused"), NULL},
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
151 {"hungry", N_("Hungry"), NULL},
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
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 */
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
186 PurpleMood* mxit_get_moods(PurpleAccount *account)
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 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
297 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
298 PurpleBuddy* newbuddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 /* 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
301 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
302 /* 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
303
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
304 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
305
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 * 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
308 * 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
309 * 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
310 * 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
311 */
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 /* create new buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
314 newbuddy = purple_buddy_new( session->acc, buddy->name, buddy->alias );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315 newbuddy->proto_data = buddy->proto_data;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
316 buddy->proto_data = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
317
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
318 /* remove the buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
319 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
320
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
321 /* add buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
322 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
323
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
324 /* 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
325 contact = newbuddy->proto_data;
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
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
328 /* update the buddy's status (reference: "libpurple/prpl.h") */
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 )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
330 purple_prpl_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 else
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
332 purple_prpl_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, NULL );
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 )
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
336 purple_prpl_got_user_status_deactive( session->acc, newbuddy->name, "mood" );
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
337 else
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
338 purple_prpl_got_user_status( session->acc, newbuddy->name, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
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 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
380 group = purple_find_group( contact->groupname );
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 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
385 buddy = purple_find_buddy_in_group( session->acc, contact->username, group );
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 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
390 buddy = purple_find_buddy( session->acc, contact->username );
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 );
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
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 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
410 purple_blist_alias_buddy( buddy, contact->alias );
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
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
425 /* update the buddy's status (reference: "libpurple/prpl.h") */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
426 purple_prpl_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 )
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
430 purple_prpl_got_user_status_deactive( session->acc, contact->username, "mood" );
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
431 else
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
432 purple_prpl_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
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
461 /* find the buddy information for this contact (reference: "libpurple/blist.h") */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
462 buddy = purple_find_buddy( session->acc, username );
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
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
476 /* validate mood */
30570
b9eca5b5a10d Add the new Moods.
Andrew Victor <andrew.victor@mxit.com>
parents: 30522
diff changeset
477 if (( contact->mood < MXIT_MOOD_NONE ) || ( contact->mood > MXIT_MOOD_STRESSED ))
30176
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
478 contact->mood = MXIT_MOOD_NONE;
b380932e86ea Add support for the standard Mood API.
Andrew Victor <andrew.victor@mxit.com>
parents: 29667
diff changeset
479
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
480 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
481 // 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
482
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
483 /* update status message */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
484 if ( contact->statusMsg ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
485 g_free( contact->statusMsg );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
486 contact->statusMsg = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
487 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
488 if ( 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
489 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
490
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
491 /* update the buddy's status (reference: "libpurple/prpl.h") */
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->statusMsg )
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
493 purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, "message", contact->statusMsg, 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
494 else
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
495 purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, 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
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 /* 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
498 if ( contact->mood == MXIT_MOOD_NONE )
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 purple_prpl_got_user_status_deactive( session->acc, username, "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
500 else
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 purple_prpl_got_user_status( session->acc, username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, 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
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
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
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 /*------------------------------------------------------------------------
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 * 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
507 * 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
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 * @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
510 * @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
511 * @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
512 */
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 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
514 {
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
515 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
516 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
517
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 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
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 /* find the buddy information for this contact (reference: "libpurple/blist.h") */
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 buddy = purple_find_buddy( session->acc, 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
522 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
523 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
524 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
525 }
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
526
5b84b44ed654 Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
527 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
528 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
529 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
530
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
531 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
532 /* 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
533 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 else if ( avatarId[0] != '\0' ) { /* avatar has changed */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
535 if ( contact->avatarId )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
536 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
537 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
538
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
539 /* 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
540 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
541 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
542 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
543 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
544 }
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
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 * 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
549 * 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
550 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
551 * @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
552 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
553 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
554 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555 PurpleBuddy* buddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 GSList* list = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 unsigned int i;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
558
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
559 /* 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
560 * these contacts must have been removed from another client */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
561 list = purple_find_buddies( session->acc, NULL );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
562
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563 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
564 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
565
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
566 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
567 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
568 const gchar* name = purple_buddy_get_name( buddy );
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
569
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
570 /* 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
571 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
572 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
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
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576 /* 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
577 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
578 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
579
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 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
582 * 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
583 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584 * @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
585 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 static void mxit_cb_buddy_auth( gpointer user_data )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
587 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
588 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
589
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
590 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
591
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
592 /* 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
593 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
594
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
595 /* 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
596 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
597
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
598 /* freeup invite object */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
599 if ( invite->contact->msg )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
600 g_free( invite->contact->msg );
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
601 if ( invite->contact->statusMsg )
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
602 g_free( invite->contact->statusMsg );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
603 if ( invite->contact->profile )
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
604 g_free( invite->contact->profile );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 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
606 g_free( invite );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
607 }
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
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 * 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
612 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613 * @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
614 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
615 static void mxit_cb_buddy_deny( gpointer user_data )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
616 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
617 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
618
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
619 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
620
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
621 /* send a deny 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
622 mxit_send_deny_sub( invite->session, invite->contact->username );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
623
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
624 /* 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
625 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
626
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
627 /* freeup invite object */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
628 if ( invite->contact->msg )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
629 g_free( invite->contact->msg );
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
630 if ( invite->contact->statusMsg )
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
631 g_free( invite->contact->statusMsg );
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
632 if ( invite->contact->profile )
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
633 g_free( invite->contact->profile );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
634 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
635 g_free( 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
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 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
640 * 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
641 * 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
642 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
643 * @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
644 * @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
645 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
646 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
647 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
648 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
649
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
650 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
651
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
652 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
653 invite->session = session;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
654 invite->contact = contact;
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 /* 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
657 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
658
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
659 /* (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
660 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
661 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
662
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
663
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
664 /*------------------------------------------------------------------------
31714
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
665 * 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
666 *
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
667 * @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
668 * @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
669 * @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
670 */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
671 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
672 {
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
673 struct contact* con = NULL;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
674 struct contact* match = NULL;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
675 int i;
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 /* 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
678 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
679 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
680 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
681 /* invite found */
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
682 match = con;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
683 break;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
684 }
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
685 }
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
686
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
687 return match;
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
688 }
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
689
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
690
4fb9e95a7c4f * extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents: 31699
diff changeset
691 /*------------------------------------------------------------------------
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
692 * 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
693 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
694 * @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
695 * @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
696 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
697 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
698 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
699 PurpleBuddy* buddy;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
700 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
701
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
702 /* find the buddy */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
703 buddy = purple_find_buddy( session->acc, username );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
704 if ( !buddy ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
705 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
706 return FALSE;
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
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
709 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
710 if ( !contact )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
711 return FALSE;
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 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
714 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
715
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
716
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
717 /*========================================================================================================================
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
718 * Callbacks from libpurple
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
719 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
720
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
721 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
722 * 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
723 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
724 * @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
725 * @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
726 * @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
727 * @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
728 */
31699
3b50aab9ab9a Add the invite message support to MXit prpl.
Andrew Victor <andrew.victor@mxit.com>
parents: 31491
diff changeset
729 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
730 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
731 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
732 GSList* list = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
733 PurpleBuddy* mxbuddy = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
734 unsigned int i;
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
735 const gchar * buddy_name = purple_buddy_get_name( buddy );
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
736 const gchar * buddy_alias = purple_buddy_get_alias( buddy );
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
737 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
738
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
739 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
740
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
741 list = purple_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
742 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
743 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
744 /*
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
745 * 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
746 * 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
747 * 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
748 * 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
749 */
31720
4047faf09005 Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents: 31714
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 */
29667
9c7cdbf30435 struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29106
diff changeset
767 purple_blist_alias_buddy( 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 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
800 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
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 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
818 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
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 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
825 buddy = purple_find_buddy( session->acc, who );
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 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
852 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
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 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
858 buddy = purple_find_buddy( session->acc, who );
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 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
879 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
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