Mercurial > pidgin
annotate libpurple/protocols/mxit/actions.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 02 Jun 2012 02:30:49 +0000 |
parents | f75041cb3fec |
children |
rev | line source |
---|---|
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1 /* |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 * MXit Protocol libPurple Plugin |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
4 * -- handle MXit plugin actions -- |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 * Pieter Loubser <libpurple@mxit.com> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
7 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 * <http://www.mxitlifestyle.com> |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 * the Free Software Foundation; either version 2 of the License, or |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 * (at your option) any later version. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 * This program is distributed in the hope that it will be useful, |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 * GNU General Public License for more details. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 * You should have received a copy of the GNU General Public License |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 * along with this program; if not, write to the Free Software |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 |
28770
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
28625
diff
changeset
|
26 #include "internal.h" |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
27 #include "purple.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
28 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 #include "protocol.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
30 #include "mxit.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 #include "roster.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
32 #include "actions.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 #include "splashscreen.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 #include "cipher.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
35 #include "profile.h" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
38 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
39 * The user has selected to change their profile. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
40 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
41 * @param gc The connection object |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 * @param fields The fields from the request pop-up |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
44 static void mxit_profile_cb( PurpleConnection* gc, PurpleRequestFields* fields ) |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 { |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
46 struct MXitSession* session = purple_connection_get_protocol_data( gc ) ; |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
47 PurpleRequestField* field = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 const char* name = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 const char* bday = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 const char* err = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
51 |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
52 purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_cb\n" ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
53 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
54 if ( !PURPLE_CONNECTION_IS_VALID( gc ) ) { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
55 purple_debug_error( MXIT_PLUGIN_ID, "Unable to update profile; account offline.\n" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
56 return; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
57 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
58 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
59 /* validate name */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
60 name = purple_request_fields_get_string( fields, "name" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
61 if ( ( !name ) || ( strlen( name ) < 3 ) ) { |
30306
6d6ac5720853
Clarify error message that it is the Display Name field that is invalid.
andrew.victor@mxit.com
parents:
30288
diff
changeset
|
62 err = _( "The Display Name you entered is invalid." ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
63 goto out; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
64 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
65 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 /* validate birthdate */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 bday = purple_request_fields_get_string( fields, "bday" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 if ( ( !bday ) || ( strlen( bday ) < 10 ) || ( !validateDate( bday ) ) ) { |
28619
cfde83c57a98
The MXit guy seems to like spaces between his parenthesis, so I'll be
Mark Doliner <mark@kingant.net>
parents:
28614
diff
changeset
|
69 err = _( "The birthday you entered is invalid. The correct format is: 'YYYY-MM-DD'." ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 goto out; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 out: |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 if ( !err ) { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 struct MXitProfile* profile = session->profile; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 GString* attributes = g_string_sized_new( 128 ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
77 char attrib[512]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
78 unsigned int acount = 0; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
80 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 /* update name */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 g_strlcpy( profile->nickname, name, sizeof( profile->nickname ) ); |
30286 | 83 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FULLNAME, CP_PROFILE_TYPE_UTF8, profile->nickname ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
84 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
85 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 /* update birthday */ |
30288
d9e94339ca3b
For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents:
30286
diff
changeset
|
88 g_strlcpy( profile->birthday, bday, sizeof( profile->birthday ) ); |
30286 | 89 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
93 /* update gender */ |
28620
04b0ba94d646
Accidentally reversed this logic in an earlier commit
Mark Doliner <mark@kingant.net>
parents:
28619
diff
changeset
|
94 profile->male = ( purple_request_fields_get_choice( fields, "male" ) != 0 ); |
30286 | 95 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_GENDER, CP_PROFILE_TYPE_BOOL, ( profile->male ) ? "1" : "0" ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
96 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 /* update title */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
100 name = purple_request_fields_get_string( fields, "title" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 if ( !name ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
102 profile->title[0] = '\0'; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
103 else |
30288
d9e94339ca3b
For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents:
30286
diff
changeset
|
104 g_strlcpy( profile->title, name, sizeof( profile->title ) ); |
30286 | 105 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_TITLE, CP_PROFILE_TYPE_UTF8, profile->title ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
106 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
107 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
108 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 /* update firstname */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 name = purple_request_fields_get_string( fields, "firstname" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
111 if ( !name ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 profile->firstname[0] = '\0'; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
113 else |
30288
d9e94339ca3b
For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents:
30286
diff
changeset
|
114 g_strlcpy( profile->firstname, name, sizeof( profile->firstname ) ); |
30286 | 115 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FIRSTNAME, CP_PROFILE_TYPE_UTF8, profile->firstname ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
117 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
118 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 /* update lastname */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
120 name = purple_request_fields_get_string( fields, "lastname" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 if ( !name ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
122 profile->lastname[0] = '\0'; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
123 else |
30288
d9e94339ca3b
For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents:
30286
diff
changeset
|
124 g_strlcpy( profile->lastname, name, sizeof( profile->lastname ) ); |
30286 | 125 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_LASTNAME, CP_PROFILE_TYPE_UTF8, profile->lastname ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 /* update email address */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 name = purple_request_fields_get_string( fields, "email" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 if ( !name ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 profile->email[0] = '\0'; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
133 else |
30288
d9e94339ca3b
For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents:
30286
diff
changeset
|
134 g_strlcpy( profile->email, name, sizeof( profile->email ) ); |
30286 | 135 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_EMAIL, CP_PROFILE_TYPE_UTF8, profile->email ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 /* update mobile number */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 name = purple_request_fields_get_string( fields, "mobilenumber" ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 if ( !name ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 profile->mobilenr[0] = '\0'; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 else |
30288
d9e94339ca3b
For safety, rather use g_strlcpy() and snprintf() where possible.
andrew.victor@mxit.com
parents:
30286
diff
changeset
|
144 g_strlcpy( profile->mobilenr, name, sizeof( profile->mobilenr ) ); |
30286 | 145 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_MOBILENR, CP_PROFILE_TYPE_UTF8, profile->mobilenr ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
146 g_string_append( attributes, attrib ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
147 acount++; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
148 |
31489 | 149 /* update about me */ |
150 name = purple_request_fields_get_string( fields, "aboutme" ); | |
151 if ( !name ) | |
152 profile->aboutme[0] = '\0'; | |
153 else | |
154 g_strlcpy( profile->aboutme, name, sizeof( profile->aboutme ) ); | |
155 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_ABOUTME, CP_PROFILE_TYPE_UTF8, profile->aboutme ); | |
156 g_string_append( attributes, attrib ); | |
157 acount++; | |
158 | |
159 /* update where am i */ | |
160 name = purple_request_fields_get_string( fields, "whereami" ); | |
31902
93cb9f408df4
Whitespace changes for coding-style consistency.
andrew.victor@mxit.com
parents:
31881
diff
changeset
|
161 if ( !name ) |
31489 | 162 profile->whereami[0] = '\0'; |
163 else | |
164 g_strlcpy( profile->whereami, name, sizeof( profile->whereami ) ); | |
165 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_WHEREAMI, CP_PROFILE_TYPE_UTF8, profile->whereami ); | |
166 g_string_append( attributes, attrib ); | |
167 acount++; | |
168 | |
169 /* update flags */ | |
170 field = purple_request_fields_get_field( fields, "searchable" ); | |
171 if ( purple_request_field_bool_get_value( field ) ) /* is searchable -> clear not-searchable flag */ | |
172 profile->flags &= ~CP_PROF_NOT_SEARCHABLE; | |
173 else | |
174 profile->flags |= CP_PROF_NOT_SEARCHABLE; | |
175 field = purple_request_fields_get_field( fields, "suggestable" ); | |
176 if ( purple_request_field_bool_get_value( field ) ) /* is suggestable -> clear not-suggestable flag */ | |
177 profile->flags &= ~CP_PROF_NOT_SUGGESTABLE; | |
178 else | |
179 profile->flags |= CP_PROF_NOT_SUGGESTABLE; | |
180 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%i", CP_PROFILE_FLAGS, CP_PROFILE_TYPE_LONG, profile->flags); | |
181 g_string_append( attributes, attrib ); | |
182 acount++; | |
183 | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
184 /* send the profile update to MXit */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
185 mxit_send_extprofile_update( session, NULL, acount, attributes->str ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
186 g_string_free( attributes, TRUE ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
187 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
188 else { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 /* show error to user */ |
28625
363691903201
A few other minor little translation-related fixes
Mark Doliner <mark@kingant.net>
parents:
28620
diff
changeset
|
190 mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "Profile Update Error" ), err ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
192 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
193 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 * Display and update the user's profile. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
198 * @param action The action object |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
200 static void mxit_profile_action( PurplePluginAction* action ) |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
201 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
202 PurpleConnection* gc = (PurpleConnection*) action->context; |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
203 struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 struct MXitProfile* profile = session->profile; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 PurpleRequestFields* fields = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 PurpleRequestField* field = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
209 purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_action\n" ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
211 /* ensure that we actually have the user's profile information */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
212 if ( !profile ) { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
213 /* no profile information yet, so we cannot update */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Profile" ), _( "Your profile information is not yet retrieved. Please try again later." ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 return; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 fields = purple_request_fields_new(); |
31489 | 219 |
220 /* Public information - what other users can see */ | |
221 { | |
222 PurpleRequestFieldGroup* public_group = purple_request_field_group_new( "Public information" ); | |
223 | |
224 /* display name */ | |
225 field = purple_request_field_string_new( "name", _( "Display Name" ), profile->nickname, FALSE ); | |
226 purple_request_field_group_add_field( public_group, field ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
227 |
31489 | 228 /* birthday */ |
229 field = purple_request_field_string_new( "bday", _( "Birthday" ), profile->birthday, FALSE ); | |
230 purple_request_field_group_add_field( public_group, field ); | |
231 if ( profile->flags & CP_PROF_DOBLOCKED ) | |
232 purple_request_field_string_set_editable( field, FALSE ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
233 |
31489 | 234 /* gender */ |
235 field = purple_request_field_choice_new( "male", _( "Gender" ), ( profile->male ) ? 1 : 0 ); | |
236 purple_request_field_choice_add( field, _( "Female" ) ); /* 0 */ | |
237 purple_request_field_choice_add( field, _( "Male" ) ); /* 1 */ | |
238 purple_request_field_group_add_field( public_group, field ); | |
239 | |
240 /* first name */ | |
241 field = purple_request_field_string_new( "firstname", _( "First Name" ), profile->firstname, FALSE ); | |
242 purple_request_field_group_add_field( public_group, field ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
243 |
31489 | 244 /* last name */ |
245 field = purple_request_field_string_new( "lastname", _( "Last Name" ), profile->lastname, FALSE ); | |
246 purple_request_field_group_add_field( public_group, field ); | |
247 | |
248 /* about me */ | |
249 field = purple_request_field_string_new( "aboutme", _( "About Me" ), profile->aboutme, FALSE); | |
250 purple_request_field_group_add_field( public_group, field ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
251 |
31489 | 252 /* where I live */ |
253 field = purple_request_field_string_new( "whereami", _( "Where I Live" ), profile->whereami, FALSE); | |
254 purple_request_field_group_add_field( public_group, field ); | |
255 | |
256 purple_request_fields_add_group( fields, public_group ); | |
257 } | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
258 |
31489 | 259 /* Private information - what only MXit can see */ |
260 { | |
261 PurpleRequestFieldGroup* private_group = purple_request_field_group_new( "Private information" ); | |
262 | |
263 /* title */ | |
264 field = purple_request_field_string_new( "title", _( "Title" ), profile->title, FALSE ); | |
265 purple_request_field_group_add_field( private_group, field ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
266 |
31489 | 267 /* email */ |
268 field = purple_request_field_string_new( "email", _( "Email" ), profile->email, FALSE ); | |
269 purple_request_field_group_add_field( private_group, field ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
270 |
31489 | 271 /* mobile number */ |
272 field = purple_request_field_string_new( "mobilenumber", _( "Mobile Number" ), profile->mobilenr, FALSE ); | |
273 purple_request_field_group_add_field( private_group, field ); | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
274 |
31489 | 275 /* is searchable */ |
276 field = purple_request_field_bool_new( "searchable", _( "Can be searched" ), ( ( profile->flags & CP_PROF_NOT_SEARCHABLE ) == 0) ); | |
277 purple_request_field_group_add_field( private_group, field ); | |
278 | |
279 /* is suggestable */ | |
280 field = purple_request_field_bool_new( "suggestable", _( "Can be suggested" ), ( ( profile->flags & CP_PROF_NOT_SUGGESTABLE ) == 0 ) ); | |
281 purple_request_field_group_add_field( private_group, field ); | |
282 | |
283 purple_request_fields_add_group( fields, private_group ); | |
284 } | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
285 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
286 /* (reference: "libpurple/request.h") */ |
31504
cce18a0ff43a
Due to the new alpha-numeric loginnames and auto-generated userId's the
andrew.victor@mxit.com
parents:
31503
diff
changeset
|
287 purple_request_fields( gc, _( "Profile" ), _( "Update your MXit Profile" ), NULL, fields, _( "Set" ), |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
288 G_CALLBACK( mxit_profile_cb ), _( "Cancel" ), NULL, purple_connection_get_account( gc ), NULL, NULL, gc ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
289 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
290 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
291 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
292 /*------------------------------------------------------------------------ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
293 * The user has selected to change their PIN. |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
294 * |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
295 * @param gc The connection object |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
296 * @param fields The fields from the request pop-up |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
297 */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
298 static void mxit_change_pin_cb( PurpleConnection* gc, PurpleRequestFields* fields ) |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
299 { |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
300 struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
301 const char* pin = NULL; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
302 const char* pin2 = NULL; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
303 const char* err = NULL; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
304 int len; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
305 int i; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
306 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
307 if ( !PURPLE_CONNECTION_IS_VALID( gc ) ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
308 purple_debug_error( MXIT_PLUGIN_ID, "Unable to update PIN; account offline.\n" ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
309 return; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
310 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
311 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
312 /* validate pin */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
313 pin = purple_request_fields_get_string( fields, "pin" ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
314 if ( !pin ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
315 err = _( "The PIN you entered is invalid." ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
316 goto out; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
317 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
318 len = strlen( pin ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
319 if ( ( len < 4 ) || ( len > 10 ) ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
320 err = _( "The PIN you entered has an invalid length [4-10]." ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
321 goto out; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
322 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
323 for ( i = 0; i < len; i++ ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
324 if ( !g_ascii_isdigit( pin[i] ) ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
325 err = _( "The PIN is invalid. It should only consist of digits [0-9]." ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
326 goto out; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
327 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
328 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
329 pin2 = purple_request_fields_get_string( fields, "pin2" ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
330 if ( ( !pin2 ) || ( strcmp( pin, pin2 ) != 0 ) ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
331 err = _( "The two PINs you entered do not match." ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
332 goto out; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
333 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
334 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
335 out: |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
336 if ( !err ) { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
337 /* update PIN in account */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
338 purple_account_set_password( session->acc, pin ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
339 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
340 /* update session object */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
341 g_free( session->encpwd ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
342 session->encpwd = mxit_encrypt_password( session ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
343 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
344 /* send the update request to MXit */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
345 mxit_send_extprofile_update( session, session->encpwd, 0, NULL ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
346 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
347 else { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
348 /* show error to user */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
349 mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "PIN Update Error" ), err ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
350 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
351 } |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
352 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
353 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
354 /*------------------------------------------------------------------------ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
355 * Enable the user to change their PIN. |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
356 * |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
357 * @param action The action object |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
358 */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
359 static void mxit_change_pin_action( PurplePluginAction* action ) |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
360 { |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
361 PurpleConnection* gc = (PurpleConnection*) action->context; |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
362 struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
363 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
364 PurpleRequestFields* fields = NULL; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
365 PurpleRequestFieldGroup* group = NULL; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
366 PurpleRequestField* field = NULL; |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
367 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
368 purple_debug_info( MXIT_PLUGIN_ID, "mxit_change_pin_action\n" ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
369 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
370 fields = purple_request_fields_new(); |
31902
93cb9f408df4
Whitespace changes for coding-style consistency.
andrew.victor@mxit.com
parents:
31881
diff
changeset
|
371 group = purple_request_field_group_new( NULL ); |
93cb9f408df4
Whitespace changes for coding-style consistency.
andrew.victor@mxit.com
parents:
31881
diff
changeset
|
372 purple_request_fields_add_group( fields, group ); |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
373 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
374 /* pin */ |
32245
f75041cb3fec
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
andrew.victor@mxit.com
parents:
31935
diff
changeset
|
375 field = purple_request_field_string_new( "pin", _( "PIN" ), purple_account_get_password( session->acc ), FALSE ); |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
376 purple_request_field_string_set_masked( field, TRUE ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
377 purple_request_field_group_add_field( group, field ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
378 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
379 /* verify pin */ |
32245
f75041cb3fec
Convert libpurple and protocol prpl's to use the purple_account_* accessor functions.
andrew.victor@mxit.com
parents:
31935
diff
changeset
|
380 field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), purple_account_get_password( session->acc ), FALSE ); |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
381 purple_request_field_string_set_masked( field, TRUE ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
382 purple_request_field_group_add_field( group, field ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
383 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
384 /* (reference: "libpurple/request.h") */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
385 purple_request_fields( gc, _( "Change PIN" ), _( "Change MXit PIN" ), NULL, fields, _( "Set" ), |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
386 G_CALLBACK( mxit_change_pin_cb ), _( "Cancel" ), NULL, purple_connection_get_account( gc ), NULL, NULL, gc ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
387 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
388 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
389 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
390 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
391 * Display the current splash-screen, or a notification pop-up if one is not available. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
392 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
393 * @param action The action object |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
394 */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
395 static void mxit_splash_action( PurplePluginAction* action ) |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
396 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
397 PurpleConnection* gc = (PurpleConnection*) action->context; |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
398 struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
399 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
400 if ( splash_current( session ) != NULL ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
401 splash_display( session ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
402 else |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
403 mxit_popup( PURPLE_NOTIFY_MSG_INFO, _( "View Splash" ), _( "There is no splash-screen currently available" ) ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
404 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
405 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
406 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
407 /*------------------------------------------------------------------------ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 * Display info about the plugin. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
409 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
410 * @param action The action object |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
411 */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
412 static void mxit_about_action( PurplePluginAction* action ) |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
413 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
414 char version[256]; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
415 |
31489 | 416 g_snprintf( version, sizeof( version ), |
30002
30d0d4756fac
* Separate the ClientVersion from the supported ProtocolVersion.
andrew.victor@mxit.com
parents:
29996
diff
changeset
|
417 "MXit Client Protocol v%i.%i\n\n" |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
418 "Author:\nPieter Loubser\n\n" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
419 "Contributors:\nAndrew Victor\n\n" |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
420 "Testers:\nBraeme Le Roux\n\n", |
30002
30d0d4756fac
* Separate the ClientVersion from the supported ProtocolVersion.
andrew.victor@mxit.com
parents:
29996
diff
changeset
|
421 ( MXIT_CP_PROTO_VESION / 10 ), ( MXIT_CP_PROTO_VESION % 10 ) ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
422 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
423 mxit_popup( PURPLE_NOTIFY_MSG_INFO, _( "About" ), version ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
424 } |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
425 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
426 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
427 /*------------------------------------------------------------------------ |
31493 | 428 * Request list of suggested friends. |
429 * | |
430 * @param action The action object | |
431 */ | |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
432 static void mxit_suggested_friends_action( PurplePluginAction* action ) |
31493 | 433 { |
434 PurpleConnection* gc = (PurpleConnection*) action->context; | |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
435 struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
31493 | 436 const char* profilelist[] = { |
437 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME, | |
31511 | 438 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR, |
439 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME }; | |
31493 | 440 |
31511 | 441 mxit_send_suggest_friends( session, MXIT_SEARCHRESULTS_MAX, ARRAY_SIZE( profilelist ), profilelist ); |
31493 | 442 } |
443 | |
444 | |
445 /*------------------------------------------------------------------------ | |
446 * Perform contact search. | |
447 * | |
448 * @param action The action object | |
449 */ | |
450 static void mxit_user_search_cb( PurpleConnection *gc, const char *input ) | |
451 { | |
31935
4b15c5c68aa4
Don't access PurpleConnection->proto_data directly, rather use the access functions.
andrew.victor@mxit.com
parents:
31902
diff
changeset
|
452 struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
31493 | 453 const char* profilelist[] = { |
454 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME, | |
31511 | 455 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR, |
456 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME }; | |
31493 | 457 |
31511 | 458 mxit_send_suggest_search( session, MXIT_SEARCHRESULTS_MAX, input, ARRAY_SIZE( profilelist ), profilelist ); |
31493 | 459 } |
460 | |
461 | |
462 /*------------------------------------------------------------------------ | |
463 * Display the search input form. | |
464 * | |
465 * @param action The action object | |
466 */ | |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
467 static void mxit_user_search_action( PurplePluginAction* action ) |
31493 | 468 { |
469 PurpleConnection* gc = (PurpleConnection*) action->context; | |
470 | |
471 purple_request_input( gc, _( "Search for user" ), | |
472 _( "Search for a MXit contact" ), | |
473 _( "Type search information" ), | |
474 NULL, FALSE, FALSE, NULL, | |
31902
93cb9f408df4
Whitespace changes for coding-style consistency.
andrew.victor@mxit.com
parents:
31881
diff
changeset
|
475 _( "_Search" ), G_CALLBACK( mxit_user_search_cb ), |
93cb9f408df4
Whitespace changes for coding-style consistency.
andrew.victor@mxit.com
parents:
31881
diff
changeset
|
476 _( "_Cancel" ), NULL, |
31493 | 477 purple_connection_get_account( gc ), NULL, NULL, |
31902
93cb9f408df4
Whitespace changes for coding-style consistency.
andrew.victor@mxit.com
parents:
31881
diff
changeset
|
478 gc ); |
31493 | 479 } |
480 | |
481 | |
482 /*------------------------------------------------------------------------ | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
483 * Associate actions with the MXit plugin. |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
484 * |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
485 * @param plugin The MXit protocol plugin |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
486 * @param context The connection context (if available) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
487 * @return The list of plugin actions |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
488 */ |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
489 GList* mxit_actions( PurplePlugin* plugin, gpointer context ) |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
490 { |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
491 PurplePluginAction* action = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
492 GList* m = NULL; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
493 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
494 /* display / change profile */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
495 action = purple_plugin_action_new( _( "Change Profile..." ), mxit_profile_action ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
496 m = g_list_append( m, action ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
497 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
498 /* change PIN */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
499 action = purple_plugin_action_new( _( "Change PIN..." ), mxit_change_pin_action ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
500 m = g_list_append( m, action ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
501 |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
502 /* suggested friends */ |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
503 action = purple_plugin_action_new( _( "Suggested friends..." ), mxit_suggested_friends_action ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
504 m = g_list_append( m, action ); |
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
505 |
31507
efed7d3c5574
Search results can contain users and services - change wording.
andrew.victor@mxit.com
parents:
31505
diff
changeset
|
506 /* search for contacts */ |
efed7d3c5574
Search results can contain users and services - change wording.
andrew.victor@mxit.com
parents:
31505
diff
changeset
|
507 action = purple_plugin_action_new( _( "Search for contacts..." ), mxit_user_search_action ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 m = g_list_append( m, action ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
509 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
510 /* display splash-screen */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
511 action = purple_plugin_action_new( _( "View Splash..." ), mxit_splash_action ); |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
512 m = g_list_append( m, action ); |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
513 |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
514 /* display plugin version */ |
31505
67c2d695e8d5
Move the PIN-change option into a separate PluginAction.
andrew.victor@mxit.com
parents:
31504
diff
changeset
|
515 action = purple_plugin_action_new( _( "About..." ), mxit_about_action ); |
31493 | 516 m = g_list_append( m, action ); |
517 | |
28526
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
518 return m; |
69aa4660401a
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
519 } |