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