libpurple/protocols/mxit/actions.c

Sat, 13 Apr 2013 12:24:43 -0400

author
Daniel Atallah <datallah@pidgin.im>
date
Sat, 13 Apr 2013 12:24:43 -0400
changeset 33880
2f2dd47bf56b
parent 33852
368feedc80cf
child 34148
62a874e41930
permissions
-rw-r--r--

Merge with release-2.x.y

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 * -- handle MXit plugin actions --
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * Pieter Loubser <libpurple@mxit.com>
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * <http://www.mxitlifestyle.com>
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * (at your option) any later version.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * GNU General Public License for more details.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
33844
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33833
diff changeset
26 #include "internal.h"
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33833
diff changeset
27 #include "debug.h"
e8edfd4e26ae MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents: 33833
diff changeset
28 #include "request.h"
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 #include "protocol.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31 #include "mxit.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32 #include "roster.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33 #include "actions.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 #include "splashscreen.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 #include "cipher.h"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36 #include "profile.h"
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 * The user has selected to change their profile.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 * @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
43 * @param fields The fields from the request pop-up
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
45 static void mxit_profile_cb( PurpleConnection* gc, PurpleRequestFields* fields )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
47 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 PurpleRequestField* field = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49 const char* name = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50 const char* bday = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 const char* err = NULL;
33555
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
52 GList* entry = NULL;
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
53
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
54 purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_cb\n" );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
56 if ( !PURPLE_CONNECTION_IS_VALID( gc ) ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
57 purple_debug_error( MXIT_PLUGIN_ID, "Unable to update profile; account offline.\n" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 return;
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 /* validate name */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
62 name = purple_request_fields_get_string( fields, "name" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63 if ( ( !name ) || ( strlen( name ) < 3 ) ) {
30569
1a384006a38e Clarify error message that it is the Display Name field that is invalid.
Andrew Victor <andrew.victor@mxit.com>
parents: 30521
diff changeset
64 err = _( "The Display Name you entered is invalid." );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
65 goto out;
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
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 /* validate birthdate */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69 bday = purple_request_fields_get_string( fields, "bday" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 if ( ( !bday ) || ( strlen( bday ) < 10 ) || ( !validateDate( bday ) ) ) {
28952
f2b3a5b27437 The MXit guy seems to like spaces between his parenthesis, so I'll be
Mark Doliner <markdoliner@pidgin.im>
parents: 28945
diff changeset
71 err = _( "The birthday you entered is invalid. The correct format is: 'YYYY-MM-DD'." );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72 goto out;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
73 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
74
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75 out:
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
76 if ( !err ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
77 struct MXitProfile* profile = session->profile;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
78 GString* attributes = g_string_sized_new( 128 );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
79 char attrib[512];
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
80 unsigned int acount = 0;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
81
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 /* update name */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
84 g_strlcpy( profile->nickname, name, sizeof( profile->nickname ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
85 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FULLNAME, CP_PROFILE_TYPE_UTF8, profile->nickname );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
86 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
87 acount++;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
88
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
89 /* update birthday */
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30519
diff changeset
90 g_strlcpy( profile->birthday, bday, sizeof( profile->birthday ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
91 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
92 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93 acount++;
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 /* update gender */
28953
dd3ffb65a2d9 Accidentally reversed this logic in an earlier commit
Mark Doliner <markdoliner@pidgin.im>
parents: 28952
diff changeset
96 profile->male = ( purple_request_fields_get_choice( fields, "male" ) != 0 );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
97 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_GENDER, CP_PROFILE_TYPE_BOOL, ( profile->male ) ? "1" : "0" );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 acount++;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
100
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 /* update title */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 name = purple_request_fields_get_string( fields, "title" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103 if ( !name )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
104 profile->title[0] = '\0';
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
105 else
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30519
diff changeset
106 g_strlcpy( profile->title, name, sizeof( profile->title ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
107 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_TITLE, CP_PROFILE_TYPE_UTF8, profile->title );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
108 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 acount++;
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 /* update firstname */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112 name = purple_request_fields_get_string( fields, "firstname" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 if ( !name )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
114 profile->firstname[0] = '\0';
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115 else
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30519
diff changeset
116 g_strlcpy( profile->firstname, name, sizeof( profile->firstname ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
117 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FIRSTNAME, CP_PROFILE_TYPE_UTF8, profile->firstname );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
119 acount++;
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 /* update lastname */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122 name = purple_request_fields_get_string( fields, "lastname" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123 if ( !name )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
124 profile->lastname[0] = '\0';
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
125 else
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30519
diff changeset
126 g_strlcpy( profile->lastname, name, sizeof( profile->lastname ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
127 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_LASTNAME, CP_PROFILE_TYPE_UTF8, profile->lastname );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 acount++;
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 /* update email address */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132 name = purple_request_fields_get_string( fields, "email" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133 if ( !name )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 profile->email[0] = '\0';
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135 else
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30519
diff changeset
136 g_strlcpy( profile->email, name, sizeof( profile->email ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
137 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_EMAIL, CP_PROFILE_TYPE_UTF8, profile->email );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
138 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
139 acount++;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
140
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
141 /* update mobile number */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
142 name = purple_request_fields_get_string( fields, "mobilenumber" );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
143 if ( !name )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
144 profile->mobilenr[0] = '\0';
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
145 else
30521
44e7b773d9d9 For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents: 30519
diff changeset
146 g_strlcpy( profile->mobilenr, name, sizeof( profile->mobilenr ) );
30519
de9e72446479 A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 30371
diff changeset
147 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_MOBILENR, CP_PROFILE_TYPE_UTF8, profile->mobilenr );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
148 g_string_append( attributes, attrib );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
149 acount++;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
150
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
151 /* update about me */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
152 name = purple_request_fields_get_string( fields, "aboutme" );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
153 if ( !name )
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
154 profile->aboutme[0] = '\0';
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
155 else
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
156 g_strlcpy( profile->aboutme, name, sizeof( profile->aboutme ) );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
157 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_ABOUTME, CP_PROFILE_TYPE_UTF8, profile->aboutme );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
158 g_string_append( attributes, attrib );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
159 acount++;
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
160
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
161 /* update where am i */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
162 name = purple_request_fields_get_string( fields, "whereami" );
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
163 if ( !name )
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
164 profile->whereami[0] = '\0';
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
165 else
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
166 g_strlcpy( profile->whereami, name, sizeof( profile->whereami ) );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
167 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_WHEREAMI, CP_PROFILE_TYPE_UTF8, profile->whereami );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
168 g_string_append( attributes, attrib );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
169 acount++;
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
170
33555
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
171 /* relationship status */
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
172 field = purple_request_fields_get_field( fields, "relationship" );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
173 entry = g_list_first( purple_request_field_list_get_selected( field ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
174 profile->relationship = atoi( purple_request_field_list_get_data( field, entry->data ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
175 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%i", CP_PROFILE_RELATIONSHIP, CP_PROFILE_TYPE_SHORT, profile->relationship );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
176 g_string_append( attributes, attrib );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
177 acount++;
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
178
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
179 /* update flags */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
180 field = purple_request_fields_get_field( fields, "searchable" );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
181 if ( purple_request_field_bool_get_value( field ) ) /* is searchable -> clear not-searchable flag */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
182 profile->flags &= ~CP_PROF_NOT_SEARCHABLE;
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
183 else
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
184 profile->flags |= CP_PROF_NOT_SEARCHABLE;
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
185 field = purple_request_fields_get_field( fields, "suggestable" );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
186 if ( purple_request_field_bool_get_value( field ) ) /* is suggestable -> clear not-suggestable flag */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
187 profile->flags &= ~CP_PROF_NOT_SUGGESTABLE;
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
188 else
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
189 profile->flags |= CP_PROF_NOT_SUGGESTABLE;
33833
19081badb425 MXit: Replace strtoll() with g_ascii_strtoll().
Andrew Victor <andrew.victor@mxit.com>
parents: 33831
diff changeset
190 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%" G_GINT64_FORMAT, CP_PROFILE_FLAGS, CP_PROFILE_TYPE_LONG, profile->flags);
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
191 g_string_append( attributes, attrib );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
192 acount++;
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
193
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 /* send the profile update to MXit */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
195 mxit_send_extprofile_update( session, NULL, acount, attributes->str );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196 g_string_free( attributes, TRUE );
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 else {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199 /* show error to user */
28957
72b74fb2c159 A few other minor little translation-related fixes
Mark Doliner <markdoliner@pidgin.im>
parents: 28953
diff changeset
200 mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "Profile Update Error" ), err );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
203
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205 /*------------------------------------------------------------------------
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206 * Display and update the user's profile.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
207 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
208 * @param action The action object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209 */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
210 static void mxit_profile_action( PurplePluginAction* action )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
211 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
212 PurpleConnection* gc = (PurpleConnection*) action->context;
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
213 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
214 struct MXitProfile* profile = session->profile;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
215
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
216 PurpleRequestFields* fields = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
217 PurpleRequestField* field = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
218
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
219 purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_action\n" );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221 /* ensure that we actually have the user's profile information */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
222 if ( !profile ) {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
223 /* no profile information yet, so we cannot update */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
224 mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Profile" ), _( "Your profile information is not yet retrieved. Please try again later." ) );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
225 return;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
226 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
227
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
228 fields = purple_request_fields_new();
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
229
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
230 /* Public information - what other users can see */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
231 {
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
232 PurpleRequestFieldGroup* public_group = purple_request_field_group_new( "Public information" );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
233
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
234 /* display name */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
235 field = purple_request_field_string_new( "name", _( "Display Name" ), profile->nickname, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
236 purple_request_field_group_add_field( public_group, field );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
237
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
238 /* birthday */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
239 field = purple_request_field_string_new( "bday", _( "Birthday" ), profile->birthday, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
240 purple_request_field_group_add_field( public_group, field );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
241 if ( profile->flags & CP_PROF_DOBLOCKED )
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
242 purple_request_field_string_set_editable( field, FALSE );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
243
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
244 /* gender */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
245 field = purple_request_field_choice_new( "male", _( "Gender" ), ( profile->male ) ? 1 : 0 );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
246 purple_request_field_choice_add( field, _( "Female" ) ); /* 0 */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
247 purple_request_field_choice_add( field, _( "Male" ) ); /* 1 */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
248 purple_request_field_group_add_field( public_group, field );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
249
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
250 /* first name */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
251 field = purple_request_field_string_new( "firstname", _( "First Name" ), profile->firstname, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
252 purple_request_field_group_add_field( public_group, field );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
253
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
254 /* last name */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
255 field = purple_request_field_string_new( "lastname", _( "Last Name" ), profile->lastname, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
256 purple_request_field_group_add_field( public_group, field );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
257
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
258 /* about me */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
259 field = purple_request_field_string_new( "aboutme", _( "About Me" ), profile->aboutme, FALSE);
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
260 purple_request_field_group_add_field( public_group, field );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
261
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
262 /* where I live */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
263 field = purple_request_field_string_new( "whereami", _( "Where I Live" ), profile->whereami, FALSE);
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
264 purple_request_field_group_add_field( public_group, field );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
265
33555
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
266 /* relationship status */
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
267 field = purple_request_field_list_new( "relationship", _( "Relationship Status" ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
268 purple_request_field_list_set_multi_select( field, FALSE );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
269 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_UNKNOWN ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_UNKNOWN ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
270 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DONTSAY ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DONTSAY ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
271 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SINGLE ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SINGLE ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
272 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_INVOLVED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_INVOLVED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
273 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_ENGAGED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_ENGAGED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
274 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_MARRIED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_MARRIED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
275 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_COMPLICATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_COMPLICATED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
276 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_WIDOWED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_WIDOWED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
277 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SEPARATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SEPARATED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
278 purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DIVORCED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DIVORCED ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
279 purple_request_field_list_add_selected( field, mxit_relationship_to_name( profile->relationship ) );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
280 purple_request_field_group_add_field( public_group, field );
8feb2763abe9 MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents: 31725
diff changeset
281
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
282 purple_request_fields_add_group( fields, public_group );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
283 }
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
284
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
285 /* Private information - what only MXit can see */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
286 {
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
287 PurpleRequestFieldGroup* private_group = purple_request_field_group_new( "Private information" );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
288
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
289 /* title */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
290 field = purple_request_field_string_new( "title", _( "Title" ), profile->title, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
291 purple_request_field_group_add_field( private_group, field );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
293 /* email */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
294 field = purple_request_field_string_new( "email", _( "Email" ), profile->email, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
295 purple_request_field_group_add_field( private_group, field );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
297 /* mobile number */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
298 field = purple_request_field_string_new( "mobilenumber", _( "Mobile Number" ), profile->mobilenr, FALSE );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
299 purple_request_field_group_add_field( private_group, field );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
301 /* is searchable */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
302 field = purple_request_field_bool_new( "searchable", _( "Can be searched" ), ( ( profile->flags & CP_PROF_NOT_SEARCHABLE ) == 0) );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
303 purple_request_field_group_add_field( private_group, field );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
304
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
305 /* is suggestable */
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
306 field = purple_request_field_bool_new( "suggestable", _( "Can be suggested" ), ( ( profile->flags & CP_PROF_NOT_SUGGESTABLE ) == 0 ) );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
307 purple_request_field_group_add_field( private_group, field );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
308
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
309 purple_request_fields_add_group( fields, private_group );
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
310 }
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 /* (reference: "libpurple/request.h") */
31718
c2de8a92e675 Due to the new alpha-numeric loginnames and auto-generated userId's the
Andrew Victor <andrew.victor@mxit.com>
parents: 31717
diff changeset
313 purple_request_fields( gc, _( "Profile" ), _( "Update your MXit Profile" ), NULL, fields, _( "Set" ),
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
314 G_CALLBACK( mxit_profile_cb ), _( "Cancel" ), NULL, purple_connection_get_account( gc ), NULL, NULL, gc );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
315 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
316
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
317
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
318 /*------------------------------------------------------------------------
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
319 * The user has selected to change their PIN.
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
320 *
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
321 * @param gc The connection object
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
322 * @param fields The fields from the request pop-up
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
323 */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
324 static void mxit_change_pin_cb( PurpleConnection* gc, PurpleRequestFields* fields )
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
325 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
326 struct MXitSession* session = purple_connection_get_protocol_data( gc );
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
327 const char* pin = NULL;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
328 const char* pin2 = NULL;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
329 const char* err = NULL;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
330 int len;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
331 int i;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
332
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
333 if ( !PURPLE_CONNECTION_IS_VALID( gc ) ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
334 purple_debug_error( MXIT_PLUGIN_ID, "Unable to update PIN; account offline.\n" );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
335 return;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
336 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
337
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
338 /* validate pin */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
339 pin = purple_request_fields_get_string( fields, "pin" );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
340 if ( !pin ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
341 err = _( "The PIN you entered is invalid." );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
342 goto out;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
343 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
344 len = strlen( pin );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
345 if ( ( len < 4 ) || ( len > 10 ) ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
346 err = _( "The PIN you entered has an invalid length [4-10]." );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
347 goto out;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
348 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
349 for ( i = 0; i < len; i++ ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
350 if ( !g_ascii_isdigit( pin[i] ) ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
351 err = _( "The PIN is invalid. It should only consist of digits [0-9]." );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
352 goto out;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
353 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
354 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
355 pin2 = purple_request_fields_get_string( fields, "pin2" );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
356 if ( ( !pin2 ) || ( strcmp( pin, pin2 ) != 0 ) ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
357 err = _( "The two PINs you entered do not match." );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
358 goto out;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
359 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
360
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
361 out:
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
362 if ( !err ) {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
363 /* update PIN in account */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
364 purple_account_set_password( session->acc, pin );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
365
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
366 /* update session object */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
367 g_free( session->encpwd );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
368 session->encpwd = mxit_encrypt_password( session );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
369
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
370 /* send the update request to MXit */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
371 mxit_send_extprofile_update( session, session->encpwd, 0, NULL );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
372 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
373 else {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
374 /* show error to user */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
375 mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "PIN Update Error" ), err );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
376 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
377 }
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
378
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
379
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
380 /*------------------------------------------------------------------------
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
381 * Enable the user to change their PIN.
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
382 *
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
383 * @param action The action object
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
384 */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
385 static void mxit_change_pin_action( PurplePluginAction* action )
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
386 {
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
387 PurpleConnection* gc = (PurpleConnection*) action->context;
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
388 struct MXitSession* session = purple_connection_get_protocol_data( gc );
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
389
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
390 PurpleRequestFields* fields = NULL;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
391 PurpleRequestFieldGroup* group = NULL;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
392 PurpleRequestField* field = NULL;
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
393
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
394 purple_debug_info( MXIT_PLUGIN_ID, "mxit_change_pin_action\n" );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
395
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
396 fields = purple_request_fields_new();
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
397 group = purple_request_field_group_new( NULL );
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
398 purple_request_fields_add_group( fields, group );
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
399
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
400 /* pin */
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
401 field = purple_request_field_string_new( "pin", _( "PIN" ), purple_account_get_password( session->acc ), FALSE );
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
402 purple_request_field_string_set_masked( field, TRUE );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
403 purple_request_field_group_add_field( group, field );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
404
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
405 /* verify pin */
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
406 field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), purple_account_get_password( session->acc ), FALSE );
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
407 purple_request_field_string_set_masked( field, TRUE );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
408 purple_request_field_group_add_field( group, field );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
409
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
410 /* (reference: "libpurple/request.h") */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
411 purple_request_fields( gc, _( "Change PIN" ), _( "Change MXit PIN" ), NULL, fields, _( "Set" ),
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
412 G_CALLBACK( mxit_change_pin_cb ), _( "Cancel" ), NULL, purple_connection_get_account( gc ), NULL, NULL, gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
413 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
414
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
415
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 * Display the current splash-screen, or a notification pop-up if one is not available.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
418 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
419 * @param action The action object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
420 */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
421 static void mxit_splash_action( PurplePluginAction* action )
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
422 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
423 PurpleConnection* gc = (PurpleConnection*) action->context;
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
424 struct MXitSession* session = purple_connection_get_protocol_data( gc );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
425
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
426 if ( splash_current( session ) != NULL )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
427 splash_display( session );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
428 else
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
429 mxit_popup( PURPLE_NOTIFY_MSG_INFO, _( "View Splash" ), _( "There is no splash-screen currently available" ) );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
430 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
431
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
432
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 * Display info about the plugin.
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 * @param action The action object
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
437 */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
438 static void mxit_about_action( PurplePluginAction* action )
28841
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 char version[256];
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
441
31703
7bddd313fb98 Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents: 31498
diff changeset
442 g_snprintf( version, sizeof( version ),
30214
4425992b8c92 * Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents: 30208
diff changeset
443 "MXit Client Protocol v%i.%i\n\n"
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
444 "Author:\nPieter Loubser\n\n"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
445 "Contributors:\nAndrew Victor\n\n"
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
446 "Testers:\nBraeme Le Roux\n\n",
30214
4425992b8c92 * Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents: 30208
diff changeset
447 ( MXIT_CP_PROTO_VESION / 10 ), ( MXIT_CP_PROTO_VESION % 10 ) );
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 mxit_popup( PURPLE_NOTIFY_MSG_INFO, _( "About" ), version );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
450 }
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
451
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
452
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
453 /*------------------------------------------------------------------------
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
454 * Request list of suggested friends.
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
455 *
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
456 * @param action The action object
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
457 */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
458 static void mxit_suggested_friends_action( PurplePluginAction* action )
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
459 {
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
460 PurpleConnection* gc = (PurpleConnection*) action->context;
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
461 struct MXitSession* session = purple_connection_get_protocol_data( gc );
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
462 const char* profilelist[] = {
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
463 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME,
31725
7efc5967d62e Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31721
diff changeset
464 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR,
7efc5967d62e Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31721
diff changeset
465 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
466
31725
7efc5967d62e Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31721
diff changeset
467 mxit_send_suggest_friends( session, MXIT_SEARCHRESULTS_MAX, ARRAY_SIZE( profilelist ), profilelist );
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
468 }
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
469
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
470
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
471 /*------------------------------------------------------------------------
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
472 * Perform contact search.
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
473 *
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
474 * @param action The action object
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
475 */
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
476 static void mxit_user_search_cb( PurpleConnection *gc, const char *input )
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
477 {
33829
837d3061532b MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents: 33611
diff changeset
478 struct MXitSession* session = purple_connection_get_protocol_data( gc );
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
479 const char* profilelist[] = {
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
480 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME,
31725
7efc5967d62e Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31721
diff changeset
481 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR,
7efc5967d62e Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31721
diff changeset
482 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
483
31725
7efc5967d62e Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31721
diff changeset
484 mxit_send_suggest_search( session, MXIT_SEARCHRESULTS_MAX, input, ARRAY_SIZE( profilelist ), profilelist );
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
485 }
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
486
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
487
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
488 /*------------------------------------------------------------------------
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
489 * Display the search input form.
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
490 *
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
491 * @param action The action object
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
492 */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
493 static void mxit_user_search_action( PurplePluginAction* action )
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
494 {
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
495 PurpleConnection* gc = (PurpleConnection*) action->context;
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
496
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
497 purple_request_input( gc, _( "Search for user" ),
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
498 _( "Search for a MXit contact" ),
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
499 _( "Type search information" ),
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
500 NULL, FALSE, FALSE, NULL,
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
501 _( "_Search" ), G_CALLBACK( mxit_user_search_cb ),
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
502 _( "_Cancel" ), NULL,
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
503 purple_connection_get_account( gc ), NULL, NULL,
33831
d160ede64878 MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents: 33829
diff changeset
504 gc );
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
505 }
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
506
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
507
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
508 /*------------------------------------------------------------------------
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
509 * Associate actions with the MXit plugin.
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
510 *
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
511 * @param plugin The MXit protocol plugin
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
512 * @param context The connection context (if available)
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
513 * @return The list of plugin actions
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
514 */
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
515 GList* mxit_actions( PurplePlugin* plugin, gpointer context )
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
516 {
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
517 PurplePluginAction* action = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
518 GList* m = NULL;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
519
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
520 /* display / change profile */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
521 action = purple_plugin_action_new( _( "Change Profile..." ), mxit_profile_action );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
522 m = g_list_append( m, action );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
523
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
524 /* change PIN */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
525 action = purple_plugin_action_new( _( "Change PIN..." ), mxit_change_pin_action );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
526 m = g_list_append( m, action );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
527
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
528 /* suggested friends */
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
529 action = purple_plugin_action_new( _( "Suggested friends..." ), mxit_suggested_friends_action );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
530 m = g_list_append( m, action );
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
531
31721
a339d998187c Search results can contain users and services - change wording.
Andrew Victor <andrew.victor@mxit.com>
parents: 31719
diff changeset
532 /* search for contacts */
a339d998187c Search results can contain users and services - change wording.
Andrew Victor <andrew.victor@mxit.com>
parents: 31719
diff changeset
533 action = purple_plugin_action_new( _( "Search for contacts..." ), mxit_user_search_action );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 m = g_list_append( m, action );
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
535
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
536 /* display splash-screen */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
537 action = purple_plugin_action_new( _( "View Splash..." ), mxit_splash_action );
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
538 m = g_list_append( m, action );
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 /* display plugin version */
31719
a0a1e1fe74ef Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents: 31718
diff changeset
541 action = purple_plugin_action_new( _( "About..." ), mxit_about_action );
31707
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
542 m = g_list_append( m, action );
a5adda59bea4 Searching.
Andrew Victor <andrew.victor@mxit.com>
parents: 31703
diff changeset
543
28841
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
544 return m;
6b9568572bcb Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
545 }

mercurial