annotate libpurple/protocols/mxit/actions.c @ 31493:dde6f5770cd0

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