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