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