annotate libpurple/protocols/mxit/roster.c @ 30720:8c586dbcae2d

Since a buddy's avatar information is distributed as part of their online presence information, if they have changed their avatar while we were offline (and they're now offline) we won't see the change until we're both online at the same time. So when the user requests to view a buddy's profile, we now also request their current AvatarId - if it is different to what Pidgin has cached, we request the new image. Move buddy's avatar processing out of mxit_update_buddy_presence() and into new function mxit_update_buddy_avatar(). The buddy avatar updating is called when we receive a buddy's presence update or when we request the buddies profile.
author andrew.victor@mxit.com
date Tue, 20 Jul 2010 09:46:28 +0000
parents d9e94339ca3b
children 18a903a3b474
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
69aa4660401a 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
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 *
69aa4660401a 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) --
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 *
69aa4660401a 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>
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
69aa4660401a 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.
69aa4660401a 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>
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 *
69aa4660401a 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
69aa4660401a 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
69aa4660401a 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
69aa4660401a 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.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 *
69aa4660401a 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,
69aa4660401a 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
69aa4660401a 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
69aa4660401a 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.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 *
69aa4660401a 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
69aa4660401a 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
69aa4660401a 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
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
29152
259bbfb423d4 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents: 29039
diff changeset
26 #include "internal.h"
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
27 #include "purple.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29 #include "protocol.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 #include "mxit.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31 #include "roster.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 struct contact_invite {
69aa4660401a 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 */
69aa4660401a 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 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
37 };
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
39
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
40 /*========================================================================================================================
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41 * Presence / Status
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
43
69aa4660401a 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) */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
45 static struct status
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46 {
30709
d7325448badb Some spelling fixes to code comments.
andrew.victor@mxit.com
parents: 30351
diff changeset
47 PurpleStatusPrimitive primitive;
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 int mxit;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49 const char* id;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50 const char* name;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 } const mxit_statuses[] = {
30709
d7325448badb Some spelling fixes to code comments.
andrew.victor@mxit.com
parents: 30351
diff changeset
52 /* primitive, no, id, name */
29038
cc391f752b05 These status strings are accessed from mxit_convert_presence_to_name() for the
andrew.victor@mxit.com
parents: 28994
diff changeset
53 { PURPLE_STATUS_OFFLINE, MXIT_PRESENCE_OFFLINE, "offline", N_( "Offline" ) }, /* 0 */
cc391f752b05 These status strings are accessed from mxit_convert_presence_to_name() for the
andrew.victor@mxit.com
parents: 28994
diff changeset
54 { PURPLE_STATUS_AVAILABLE, MXIT_PRESENCE_ONLINE, "online", N_( "Available" ) }, /* 1 */
cc391f752b05 These status strings are accessed from mxit_convert_presence_to_name() for the
andrew.victor@mxit.com
parents: 28994
diff changeset
55 { PURPLE_STATUS_AWAY, MXIT_PRESENCE_AWAY, "away", N_( "Away" ) }, /* 2 */
cc391f752b05 These status strings are accessed from mxit_convert_presence_to_name() for the
andrew.victor@mxit.com
parents: 28994
diff changeset
56 { PURPLE_STATUS_AVAILABLE, MXIT_PRESENCE_AVAILABLE, "chat", N_( "Chatty" ) }, /* 3 */
cc391f752b05 These status strings are accessed from mxit_convert_presence_to_name() for the
andrew.victor@mxit.com
parents: 28994
diff changeset
57 { PURPLE_STATUS_UNAVAILABLE, MXIT_PRESENCE_DND, "dnd", N_( "Do Not Disturb" ) } /* 4 */
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 };
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
60
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61 /*------------------------------------------------------------------------
69aa4660401a 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)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63 *
69aa4660401a 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
69aa4660401a 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
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66 */
69aa4660401a 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 )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69 GList* statuslist = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 PurpleStatusType* type;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71 unsigned int i;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72
69aa4660401a 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++ ) {
69aa4660401a 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];
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75
69aa4660401a 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") */
30709
d7325448badb Some spelling fixes to code comments.
andrew.victor@mxit.com
parents: 30351
diff changeset
77 type = purple_status_type_new_with_attrs( status->primitive, status->id, _( status->name ), TRUE, TRUE, FALSE,
28903
69aa4660401a 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 ),
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
79 NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
80
69aa4660401a 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 );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
82 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
83
30351
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
84 /* add Mood option */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
85 type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD, "mood", NULL, FALSE, TRUE, TRUE,
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
86 PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new( PURPLE_TYPE_STRING ),
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
87 NULL);
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
88 statuslist = g_list_append( statuslist, type );
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
89
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
90 return statuslist;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
91 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
92
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 /*------------------------------------------------------------------------
69aa4660401a 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.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96 *
69aa4660401a 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
69aa4660401a 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
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 */
69aa4660401a 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 )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 unsigned int i;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103
69aa4660401a 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++ ) {
69aa4660401a 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! */
69aa4660401a 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;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
107 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
108
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 return -1;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
110 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
111
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 /*------------------------------------------------------------------------
69aa4660401a 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.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115 *
69aa4660401a 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)
69aa4660401a 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
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118 */
69aa4660401a 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 )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
120 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 unsigned int i;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122
69aa4660401a 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++ ) {
69aa4660401a 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! */
69aa4660401a 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 );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
126 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
127
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 return "";
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
130
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
131
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132 /*========================================================================================================================
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133 * Moods
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135
30351
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
136 /* moods (reference: libpurple/status.h) */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
137 static PurpleMood mxit_moods[] = {
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
138 {"angry", N_("Angry"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
139 {"excited", N_("Excited"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
140 {"grumpy", N_("Grumpy"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
141 {"happy", N_("Happy"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
142 {"in_love", N_("In love"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
143 {"invincible", N_("Invincible"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
144 {"sad", N_("Sad"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
145 {"hot", N_("Hot"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
146 {"sick", N_("Sick"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
147 {"sleepy", N_("Sleepy"), NULL},
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
148 /* Mark the last record. */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
149 { NULL, NULL, NULL }
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
150 };
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
151
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
152
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
153 /*------------------------------------------------------------------------
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
154 * Returns the MXit mood code, given the unique mood ID.
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
155 *
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
156 * @param id The mood ID
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
157 * @return The MXit mood code
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
158 */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
159 int mxit_convert_mood( const char* id )
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
160 {
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
161 unsigned int i;
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
162
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
163 /* Mood is being unset */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
164 if ( id == NULL )
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
165 return MXIT_MOOD_NONE;
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
166
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
167 for ( i = 0; i < ARRAY_SIZE( mxit_moods ) - 1; i++ ) {
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
168 if ( strcmp( mxit_moods[i].mood, id ) == 0 ) /* mood found! */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
169 return i + 1; /* because MXIT_MOOD_NONE is 0 */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
170 }
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
171
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
172 return -1;
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
173 }
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
174
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
175
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
176 /*------------------------------------------------------------------------
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
177 * Return the list of MXit-supported moods.
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
178 *
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
179 * @param account The MXit account object
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
180 */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
181 PurpleMood* mxit_get_moods(PurpleAccount *account)
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
182 {
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
183 return mxit_moods;
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
184 }
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
185
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
186
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
187 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
188 * Returns the MXit mood as a string, given the MXit mood's ID.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
189 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
190 * @param id The MXit mood ID (see roster.h)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
191 * @return The mood as a text string
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
192 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
193 const char* mxit_convert_mood_to_name( short id )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
195 switch ( id ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196 case MXIT_MOOD_ANGRY :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
197 return _( "Angry" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
198 case MXIT_MOOD_EXCITED :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199 return _( "Excited" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
200 case MXIT_MOOD_GRUMPY :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201 return _( "Grumpy" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202 case MXIT_MOOD_HAPPY :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
203 return _( "Happy" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204 case MXIT_MOOD_INLOVE :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205 return _( "In Love" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206 case MXIT_MOOD_INVINCIBLE :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
207 return _( "Invincible" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
208 case MXIT_MOOD_SAD :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209 return _( "Sad" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
210 case MXIT_MOOD_HOT :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
211 return _( "Hot" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
212 case MXIT_MOOD_SICK :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
213 return _( "Sick" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
214 case MXIT_MOOD_SLEEPY :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
215 return _( "Sleepy" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
216 case MXIT_MOOD_NONE :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
217 default :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
218 return "";
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
219 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
222
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
223 /*========================================================================================================================
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
224 * Subscription Types
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
225 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
226
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
227 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
228 * Returns a Contact subscription type as a string.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
229 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
230 * @param subtype The subscription type
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
231 * @return The subscription type as a text string
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
232 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
233 const char* mxit_convert_subtype_to_name( short subtype )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
234 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
235 switch ( subtype ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
236 case MXIT_SUBTYPE_BOTH :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
237 return _( "Both" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
238 case MXIT_SUBTYPE_PENDING :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
239 return _( "Pending" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
240 case MXIT_SUBTYPE_ASK :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
241 return _( "Invited" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
242 case MXIT_SUBTYPE_REJECTED :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
243 return _( "Rejected" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
244 case MXIT_SUBTYPE_DELETED :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
245 return _( "Deleted" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
246 case MXIT_SUBTYPE_NONE :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
247 return _( "None" );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
248 default :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
249 return "";
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
250 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
251 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
252
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
253
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
254 /*========================================================================================================================
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
255 * Calls from the MXit Protocol layer
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
256 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
257
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
258 #if 0
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
259 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
260 * Dump a contact's info the the debug console.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
261 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
262 * @param contact The contact
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
263 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
264 static void dump_contact( struct contact* contact )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
265 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
266 purple_debug_info( MXIT_PLUGIN_ID, "CONTACT: name='%s', alias='%s', group='%s', type='%i', presence='%i', mood='%i'\n",
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
267 contact->username, contact->alias, contact->groupname, contact->type, contact->presence, contact->mood );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
268 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
269 #endif
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
270
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
271
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
272 #if 0
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
273 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
274 * Move a buddy from one group to another
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
275 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
276 * @param buddy the buddy to move between groups
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
277 * @param group the new group to move the buddy to
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
278 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
279 static PurpleBuddy* mxit_update_buddy_group( struct MXitSession* session, PurpleBuddy* buddy, PurpleGroup* group )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
280 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
281 struct contact* contact = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
282 PurpleGroup* current_group = purple_buddy_get_group( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
283 PurpleBuddy* newbuddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
284
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
285 /* make sure the groups actually differs */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
286 if ( strcmp( current_group->name, group->name ) != 0 ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
287 /* groupnames does not match, so we need to make the update */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
288
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
289 purple_debug_info( MXIT_PLUGIN_ID, "Moving '%s' from group '%s' to '%s'\n", buddy->alias, current_group->name, group->name );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
290
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
291 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292 * XXX: libPurple does not currently provide an API to change or rename the group name
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
293 * for a specific buddy. One option is to remove the buddy from the list and re-adding
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
294 * him in the new group, but by doing that makes the buddy go offline and then online
30709
d7325448badb Some spelling fixes to code comments.
andrew.victor@mxit.com
parents: 30351
diff changeset
295 * again. This is really not ideal and very irritating, but how else then?
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
297
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 /* create new buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299 newbuddy = purple_buddy_new( session->acc, buddy->name, buddy->alias );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 newbuddy->proto_data = buddy->proto_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
301 buddy->proto_data = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
302
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
303 /* remove the buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
304 purple_blist_remove_buddy( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
305
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
306 /* add buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307 purple_blist_add_buddy( newbuddy, NULL, group, NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
308
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
309 /* now re-instate his presence again */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
310 contact = newbuddy->proto_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
311 if ( contact ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
312
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
313 /* update the buddy's status (reference: "libpurple/prpl.h") */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
314 if ( contact->statusMsg )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315 purple_prpl_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
316 else
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
317 purple_prpl_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
318
30351
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
319 /* update the buddy's mood */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
320 if ( contact->mood == MXIT_MOOD_NONE )
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
321 purple_prpl_got_user_status_deactive( session->acc, newbuddy->name, "mood" );
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
322 else
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
323 purple_prpl_got_user_status( session->acc, newbuddy->name, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
324
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
325 /* update avatar */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
326 if ( contact->avatarId ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
327 mxit_get_avatar( session, newbuddy->name, contact->avatarId );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
328 g_free( contact->avatarId );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
329 contact->avatarId = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
330 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
332
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
333 return newbuddy;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
334 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
335 else
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
336 return buddy;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
337 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
338 #endif
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
339
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
340
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
341 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
342 * A contact update packet was received from the MXit server, so update the buddy's
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
343 * information.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
344 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
345 * @param session The MXit session object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
346 * @param contact The contact
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
347 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
348 void mxit_update_contact( struct MXitSession* session, struct contact* contact )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
349 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
350 PurpleBuddy* buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
351 PurpleGroup* group = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
352 const char* id = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
353
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
354 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_contact: user='%s' alias='%s' group='%s'\n", contact->username, contact->alias, contact->groupname );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
355
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
356 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
357 * libPurple requires all contacts to be in a group.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
358 * So if this MXit contact isn't in a group, pretend it is.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
359 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
360 if ( *contact->groupname == '\0' ) {
30719
d9e94339ca3b For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents: 30709
diff changeset
361 g_strlcpy( contact->groupname, MXIT_DEFAULT_GROUP, sizeof( contact->groupname ) );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
362 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
363
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
364 /* find or create a group for this contact */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
365 group = purple_find_group( contact->groupname );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
366 if ( !group )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
367 group = purple_group_new( contact->groupname );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
368
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
369 /* see if the buddy is not in the group already */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
370 buddy = purple_find_buddy_in_group( session->acc, contact->username, group );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
371 if ( !buddy ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
372 /* buddy not found in the group */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
373
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
374 /* lets try finding him in all groups */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
375 buddy = purple_find_buddy( session->acc, contact->username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
376 if ( buddy ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
377 /* ok, so we found him in another group. to switch him between groups we must delete him and add him again. */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
378 purple_blist_remove_buddy( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
379 buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
380 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
381
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
382 /* create new buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
383 buddy = purple_buddy_new( session->acc, contact->username, contact->alias );
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
384 purple_buddy_set_protocol_data(buddy, contact);
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
385
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
386 /* add new buddy to list */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
387 purple_blist_add_buddy( buddy, NULL, group, NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
388 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
389 else {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
390 /* buddy was found in the group */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
391
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
392 gpointer data = NULL;
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
393
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
394 /* now update the buddy's alias */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
395 purple_blist_alias_buddy( buddy, contact->alias );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
396
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
397 /* replace the buddy's contact struct */
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
398 if ( ( data = purple_buddy_get_protocol_data( buddy ) ) )
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
399 free( data );
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
400 purple_buddy_set_protocol_data( buddy, contact );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
401 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
402
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
403 /* load buddy's avatar id */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
404 id = purple_buddy_icons_get_checksum_for_user( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
405 if ( id )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
406 contact->avatarId = g_strdup( id );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
407 else
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
408 contact->avatarId = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
409
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
410 /* update the buddy's status (reference: "libpurple/prpl.h") */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
411 purple_prpl_got_user_status( session->acc, contact->username, mxit_statuses[contact->presence].id, NULL );
30351
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
412
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
413 /* update the buddy's mood */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
414 if ( contact->mood == MXIT_MOOD_NONE )
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
415 purple_prpl_got_user_status_deactive( session->acc, contact->username, "mood" );
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
416 else
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
417 purple_prpl_got_user_status( session->acc, contact->username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
418 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
419
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
420
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
421 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
422 * A presence update packet was received from the MXit server, so update the buddy's
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
423 * information.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
424 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
425 * @param session The MXit session object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
426 * @param username The contact which presence to update
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
427 * @param presence The new presence state for the contact
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
428 * @param mood The new mood for the contact
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
429 * @param customMood The custom mood identifier
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
430 * @param statusMsg This is the contact's status message
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
431 */
30720
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
432 void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg )
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
433 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
434 PurpleBuddy* buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
435 struct contact* contact = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
436
30720
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
437 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: user='%s' presence=%i mood=%i customMood='%s' statusMsg='%s'\n",
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
438 username, presence, mood, customMood, statusMsg );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
439
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
440 if ( ( presence < MXIT_PRESENCE_OFFLINE ) || ( presence > MXIT_PRESENCE_DND ) ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
441 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: invalid presence state %i\n", presence );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
442 return; /* ignore packet */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
443 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
444
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
445 /* find the buddy information for this contact (reference: "libpurple/blist.h") */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
446 buddy = purple_find_buddy( session->acc, username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
447 if ( !buddy ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
448 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: unable to find the buddy '%s'\n", username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
449 return;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
450 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
451
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
452 contact = purple_buddy_get_protocol_data( buddy );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
453 if ( !contact )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
454 return;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
455
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
456 contact->presence = presence;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
457 contact->mood = mood;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
458
30351
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
459 /* validate mood */
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
460 if (( contact->mood < MXIT_MOOD_NONE ) || ( contact->mood > MXIT_MOOD_SLEEPY ))
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
461 contact->mood = MXIT_MOOD_NONE;
085020c013eb Add support for the standard Mood API.
andrew.victor@mxit.com
parents: 29725
diff changeset
462
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
463 g_strlcpy( contact->customMood, customMood, sizeof( contact->customMood ) );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
464 // TODO: Download custom mood frame.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
465
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
466 /* update status message */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
467 if ( contact->statusMsg ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
468 g_free( contact->statusMsg );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
469 contact->statusMsg = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
470 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
471 if ( statusMsg[0] != '\0' )
29039
bbc3eac0ee95 We need to escape any special "html" characters in a status message, otherwise
andrew.victor@mxit.com
parents: 29038
diff changeset
472 contact->statusMsg = g_markup_escape_text( statusMsg, -1 );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
473
30720
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
474 /* update the buddy's status (reference: "libpurple/prpl.h") */
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
475 if ( contact->statusMsg )
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
476 purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
477 else
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
478 purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, NULL );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
479
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
480 /* update the buddy's mood */
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
481 if ( contact->mood == MXIT_MOOD_NONE )
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
482 purple_prpl_got_user_status_deactive( session->acc, username, "mood" );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
483 else
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
484 purple_prpl_got_user_status( session->acc, username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
485 }
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
486
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
487
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
488 /*------------------------------------------------------------------------
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
489 * Update the buddy's avatar.
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
490 * Either a presence update packet was received from the MXit server, or a profile response.
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
491 *
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
492 * @param session The MXit session object
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
493 * @param username The contact which presence to update
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
494 * @param avatarId This is the contact's avatar id
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
495 */
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
496 void mxit_update_buddy_avatar( struct MXitSession* session, const char* username, const char* avatarId )
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
497 {
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
498 PurpleBuddy* buddy = NULL;
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
499 struct contact* contact = NULL;
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
500
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
501 purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_avatar: user='%s' avatar='%s'\n", username, avatarId );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
502
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
503 /* find the buddy information for this contact (reference: "libpurple/blist.h") */
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
504 buddy = purple_find_buddy( session->acc, username );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
505 if ( !buddy ) {
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
506 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: unable to find the buddy '%s'\n", username );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
507 return;
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
508 }
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
509
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
510 contact = purple_buddy_get_protocol_data( buddy );
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
511 if ( !contact )
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
512 return;
8c586dbcae2d Since a buddy's avatar information is distributed as part of their online
andrew.victor@mxit.com
parents: 30719
diff changeset
513
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
514 if ( ( contact->avatarId ) && ( g_ascii_strcasecmp( contact->avatarId, avatarId ) == 0 ) ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
515 /* avatar has not changed - do nothing */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
516 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
517 else if ( avatarId[0] != '\0' ) { /* avatar has changed */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
518 if ( contact->avatarId )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
519 g_free( contact->avatarId );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
520 contact->avatarId = g_strdup( avatarId );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
521
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
522 /* Send request to download new avatar image */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
523 mxit_get_avatar( session, username, avatarId );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
524 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
525 else /* clear current avatar */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
526 purple_buddy_icons_set_for_user( session->acc, username, NULL, 0, NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
527 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
528
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
529
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
530 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
531 * update the blist cached by libPurple. We need to do this to keep
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
532 * libPurple and MXit's rosters in sync with each other.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
533 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 * @param session The MXit session object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
535 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
536 void mxit_update_blist( struct MXitSession* session )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
537 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
538 PurpleBuddy* buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
539 GSList* list = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
540 unsigned int i;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
541
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
542 /* remove all buddies we did not receive a roster update for.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
543 * these contacts must have been removed from another client */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
544 list = purple_find_buddies( session->acc, NULL );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
545
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
546 for ( i = 0; i < g_slist_length( list ); i++ ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
547 buddy = g_slist_nth_data( list, i );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
548
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
549 if ( !purple_buddy_get_protocol_data( buddy ) ) {
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
550 const gchar *alias = purple_buddy_get_alias( buddy );
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
551 const gchar *name = purple_buddy_get_name( buddy );
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
552
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
553 /* this buddy should be removed, because we did not receive him in our roster update from MXit */
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
554 purple_debug_info( MXIT_PLUGIN_ID, "Removed 'old' buddy from the blist '%s' (%s)\n", alias, name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555 purple_blist_remove_buddy( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
558
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
559 /* tell the UI to update the blist */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
560 purple_blist_add_account( session->acc );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
561 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
562
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
564 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
565 * The user authorized an invite (subscription request).
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
566 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
567 * @param user_data Object associated with the invite
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
568 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
569 static void mxit_cb_buddy_auth( gpointer user_data )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
570 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
571 struct contact_invite* invite = (struct contact_invite*) user_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
572
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
573 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_auth '%s'\n", invite->contact->username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
574
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
575 /* send a allow subscription packet to MXit */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576 mxit_send_allow_sub( invite->session, invite->contact->username, invite->contact->alias );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
577
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
578 /* freeup invite object */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
579 if ( invite->contact->msg )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
580 g_free( invite->contact->msg );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
581 g_free( invite->contact );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
582 g_free( invite );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
583 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
585
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
587 * The user rejected an invite (subscription request).
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
588 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
589 * @param user_data Object associated with the invite
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
590 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
591 static void mxit_cb_buddy_deny( gpointer user_data )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
592 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
593 struct contact_invite* invite = (struct contact_invite*) user_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
594
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
595 purple_debug_info( MXIT_PLUGIN_ID, "mxit_cb_buddy_deny '%s'\n", invite->contact->username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
596
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
597 /* send a deny subscription packet to MXit */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
598 mxit_send_deny_sub( invite->session, invite->contact->username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
599
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
600 /* freeup invite object */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
601 if ( invite->contact->msg )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
602 g_free( invite->contact->msg );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
603 g_free( invite->contact );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
604 g_free( invite );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
606
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
607
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
608 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
609 * A new subscription request packet was received from the MXit server.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
610 * Prompt user to accept or reject it.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
611 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
612 * @param session The MXit session object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613 * @param contact The contact performing the invite
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
614 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
615 void mxit_new_subscription( struct MXitSession* session, struct contact* contact )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
616 {
69aa4660401a 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;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
618
69aa4660401a 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_new_subscription from '%s' (%s)\n", contact->username, contact->alias );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
620
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
621 invite = g_new0( struct contact_invite, 1 );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
622 invite->session = session;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
623 invite->contact = contact;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
624
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
625 /* (reference: "libpurple/account.h") */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
626 purple_account_request_authorization( session->acc, contact->username, NULL, contact->alias, contact->msg, FALSE, mxit_cb_buddy_auth, mxit_cb_buddy_deny, invite );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
627 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
628
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
629
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
630 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
631 * Return TRUE if this is a MXit Chatroom contact.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
632 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
633 * @param session The MXit session object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
634 * @param username The username of the contact
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
635 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
636 gboolean is_mxit_chatroom_contact( struct MXitSession* session, const char* username )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
637 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
638 PurpleBuddy* buddy;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
639 struct contact* contact = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
640
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
641 /* find the buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
642 buddy = purple_find_buddy( session->acc, username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
643 if ( !buddy ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
644 purple_debug_warning( MXIT_PLUGIN_ID, "is_mxit_chatroom_contact: unable to find the buddy '%s'\n", username );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
645 return FALSE;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
646 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
647
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
648 contact = purple_buddy_get_protocol_data( buddy );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
649 if ( !contact )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
650 return FALSE;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
651
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
652 return ( contact->type == MXIT_TYPE_CHATROOM );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
653 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
654
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
655
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
656 /*========================================================================================================================
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
657 * Callbacks from libpurple
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
658 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
659
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
660 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
661 * The user has added a buddy to the list, so send an invite request.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
662 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
663 * @param gc The connection object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
664 * @param buddy The new buddy
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
665 * @param group The group of the new buddy
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
666 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
667 void mxit_add_buddy( PurpleConnection* gc, PurpleBuddy* buddy, PurpleGroup* group )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
668 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
669 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
670 GSList* list = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
671 PurpleBuddy* mxbuddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
672 unsigned int i;
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
673 const gchar * buddy_name = purple_buddy_get_name( buddy );
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
674 const gchar * buddy_alias = purple_buddy_get_alias( buddy );
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
675 const gchar * group_name = purple_group_get_name( group );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
676
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
677 purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy '%s' (group='%s')\n", buddy_name, group_name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
678
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
679 list = purple_find_buddies( session->acc, buddy_name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
680 if ( g_slist_length( list ) == 1 ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
681 purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 1) (list:%i)\n", g_slist_length( list ) );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
682 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
683 * we only send an invite to MXit when the user is not already inside our
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
684 * blist. this is done because purple does an add_buddy() call when
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
685 * you accept an invite. so in that case the user is already
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
686 * in our blist and ready to be chatted to.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
687 */
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
688 mxit_send_invite( session, buddy_name, buddy_alias, group_name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
689 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
690 else {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
691 purple_debug_info( MXIT_PLUGIN_ID, "mxit_add_buddy (scenario 2) (list:%i)\n", g_slist_length( list ) );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
692 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
693 * we already have the buddy in our list, so we will only update
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
694 * his information here and not send another invite message
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
695 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
696
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
697 /* find the correct buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
698 for ( i = 0; i < g_slist_length( list ); i++ ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
699 mxbuddy = g_slist_nth_data( list, i );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
700
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
701 if ( purple_buddy_get_protocol_data( mxbuddy ) != NULL ) {
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
702 /* this is our REAL MXit buddy! */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
703
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
704 /* now update the buddy's alias */
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
705 purple_blist_alias_buddy( mxbuddy, buddy_alias );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
706
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
707 /* now update the buddy's group */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
708 // mxbuddy = mxit_update_buddy_group( session, mxbuddy, group );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
709
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
710 /* send the update to the MXit server */
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
711 mxit_send_update_contact( session, purple_buddy_get_name( mxbuddy ), purple_buddy_get_alias( mxbuddy ), group_name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
712 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
713 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
714 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
715
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
716 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
717 * we remove the buddy here from the buddy list because the MXit server
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
718 * will send us a proper contact update packet if this succeeds. now
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
719 * we do not have to worry about error handling in case of adding an
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
720 * invalid contact. so the user will still see the contact as offline
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
721 * until he eventually accepts the invite.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
722 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
723 purple_blist_remove_buddy( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
724
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
725 g_slist_free( list );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
726 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
727
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
728
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
729 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
730 * The user has removed a buddy from the list.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
731 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
732 * @param gc The connection object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
733 * @param buddy The buddy being removed
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
734 * @param group The group the buddy was in
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
735 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
736 void mxit_remove_buddy( PurpleConnection* gc, PurpleBuddy* buddy, PurpleGroup* group )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
737 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
738 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
739 const gchar * buddy_name = purple_buddy_get_name( buddy );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
740
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
741 purple_debug_info( MXIT_PLUGIN_ID, "mxit_remove_buddy '%s'\n", buddy_name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
742
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
743 mxit_send_remove( session, buddy_name );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
744 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
745
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
746
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
747 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
748 * The user changed the buddy's alias.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
749 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
750 * @param gc The connection object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
751 * @param who The username of the buddy
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
752 * @param alias The new alias
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
753 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
754 void mxit_buddy_alias( PurpleConnection* gc, const char* who, const char* alias )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
755 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
756 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
757 PurpleBuddy* buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
758 PurpleGroup* group = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
759
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
760 purple_debug_info( MXIT_PLUGIN_ID, "mxit_buddy_alias '%s' to '%s\n", who, alias );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
761
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
762 /* find the buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
763 buddy = purple_find_buddy( session->acc, who );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
764 if ( !buddy ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
765 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_buddy_alias: unable to find the buddy '%s'\n", who );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
766 return;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
767 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
768
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
769 /* find buddy group */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
770 group = purple_buddy_get_group( buddy );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
771 if ( !group ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
772 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_buddy_alias: unable to find the group for buddy '%s'\n", who );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
773 return;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
774 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
775
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
776 mxit_send_update_contact( session, who, alias, purple_group_get_name( group ) );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
777 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
778
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
779
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
780 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
781 * The user changed the group for a single buddy.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
782 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
783 * @param gc The connection object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
784 * @param who The username of the buddy
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
785 * @param old_group The old group's name
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
786 * @param new_group The new group's name
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
787 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
788 void mxit_buddy_group( PurpleConnection* gc, const char* who, const char* old_group, const char* new_group )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
789 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
790 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
791 PurpleBuddy* buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
792
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
793 purple_debug_info( MXIT_PLUGIN_ID, "mxit_buddy_group from '%s' to '%s'\n", old_group, new_group );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
794
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
795 /* find the buddy */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
796 buddy = purple_find_buddy( session->acc, who );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
797 if ( !buddy ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
798 purple_debug_warning( MXIT_PLUGIN_ID, "mxit_buddy_group: unable to find the buddy '%s'\n", who );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
799 return;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
800 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
801
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
802 mxit_send_update_contact( session, who, purple_buddy_get_alias( buddy ), new_group );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
803 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
804
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
805
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
806 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
807 * The user has selected to rename a group, so update all contacts in that
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
808 * group.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
809 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
810 * @param gc The connection object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
811 * @param old_name The old group name
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
812 * @param group The updated group object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
813 * @param moved_buddies The buddies affected by the rename
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
814 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
815 void mxit_rename_group( PurpleConnection* gc, const char* old_name, PurpleGroup* group, GList* moved_buddies )
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
816 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
817 struct MXitSession* session = (struct MXitSession*) gc->proto_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
818 PurpleBuddy* buddy = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
819 GList* item = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
820
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
821 purple_debug_info( MXIT_PLUGIN_ID, "mxit_rename_group from '%s' to '%s\n", old_name, purple_group_get_name( group ) );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
822
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
823 // TODO: Might be more efficient to use the "rename group" command (cmd=29).
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
824
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
825 /* loop through all the contacts in the group and send updates */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
826 item = moved_buddies;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
827 while ( item ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
828 buddy = item->data;
29725
ecc6217baa1e struct hiding updates for mxit
Gary Kramlich <grim@reaperworld.com>
parents: 29152
diff changeset
829 mxit_send_update_contact( session, purple_buddy_get_name( buddy ), purple_buddy_get_alias( buddy ), purple_group_get_name( group ) );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
830 item = g_list_next( item );
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
831 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
832 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
833