Tue, 20 May 2014 12:46:02 +0200
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 | * MXit Protocol libPurple Plugin |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
4 | * -- handle MXit plugin actions -- |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 | * Pieter Loubser <libpurple@mxit.com> |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
7 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
8 | * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 | * <http://www.mxitlifestyle.com> |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 | * This program is free software; you can redistribute it and/or modify |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 | * it under the terms of the GNU General Public License as published by |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 | * the Free Software Foundation; either version 2 of the License, or |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 | * (at your option) any later version. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 | * This program is distributed in the hope that it will be useful, |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 | * GNU General Public License for more details. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 | * You should have received a copy of the GNU General Public License |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 | * along with this program; if not, write to the Free Software |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 | |
|
33844
e8edfd4e26ae
MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents:
33833
diff
changeset
|
26 | #include "internal.h" |
|
e8edfd4e26ae
MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents:
33833
diff
changeset
|
27 | #include "debug.h" |
|
e8edfd4e26ae
MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents:
33833
diff
changeset
|
28 | #include "request.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
30 | #include "protocol.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 | #include "mxit.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
32 | #include "roster.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 | #include "actions.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 | #include "splashscreen.h" |
|
35679
0c337fe8f655
Mxit: fix cipher.h conflict
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35047
diff
changeset
|
35 | #include "cipher-mxit.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 | #include "profile.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
38 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
39 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
40 | * The user has selected to change their profile. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
41 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 | * @param gc The connection object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 | * @param fields The fields from the request pop-up |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 | */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
45 | static void mxit_profile_cb( PurpleConnection* gc, PurpleRequestFields* fields ) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 | { |
|
33829
837d3061532b
MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents:
33611
diff
changeset
|
47 | struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 | PurpleRequestField* field = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 | const char* name = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 | const char* bday = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
51 | const char* err = NULL; |
|
33555
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
52 | GList* entry = NULL; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
53 | |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
54 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_profile_cb\n" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
55 | |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35679
diff
changeset
|
56 | PURPLE_ASSERT_CONNECTION_IS_VALID(gc); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
57 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
58 | /* validate name */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
59 | 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
|
60 | 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
|
61 | 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
|
62 | goto out; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
63 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
64 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
65 | /* validate birthdate */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 | 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
|
67 | 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
|
68 | 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
|
69 | goto out; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 | out: |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 | if ( !err ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 | 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
|
75 | 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
|
76 | char attrib[512]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
77 | 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
|
78 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
79 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
80 | /* update name */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 | 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
|
82 | 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
|
83 | 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
|
84 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
85 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
86 | /* update birthday */ |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
91 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 | /* update gender */ |
|
28953
dd3ffb65a2d9
Accidentally reversed this logic in an earlier commit
Mark Doliner <markdoliner@pidgin.im>
parents:
28952
diff
changeset
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 | /* update title */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 | 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
|
100 | if ( !name ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 | 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
|
102 | else |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
107 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
108 | /* update firstname */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 | 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
|
110 | if ( !name ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
111 | 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
|
112 | else |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
117 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
118 | /* update lastname */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 | 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
|
120 | if ( !name ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 | 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
|
122 | else |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
128 | /* update email address */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 | 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
|
130 | if ( !name ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 | 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
|
132 | else |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 | /* update mobile number */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 | 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
|
140 | if ( !name ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 | 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
|
142 | else |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | acount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
147 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
148 | /* update about me */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
149 | name = purple_request_fields_get_string( fields, "aboutme" ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
150 | if ( !name ) |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
151 | profile->aboutme[0] = '\0'; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
152 | else |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
153 | g_strlcpy( profile->aboutme, name, sizeof( profile->aboutme ) ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
154 | 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
|
155 | g_string_append( attributes, attrib ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
156 | acount++; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
157 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
158 | /* update where am i */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
159 | name = purple_request_fields_get_string( fields, "whereami" ); |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33829
diff
changeset
|
160 | if ( !name ) |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
161 | profile->whereami[0] = '\0'; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
162 | else |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
163 | g_strlcpy( profile->whereami, name, sizeof( profile->whereami ) ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
164 | 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
|
165 | g_string_append( attributes, attrib ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
166 | acount++; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
167 | |
|
33555
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
168 | /* relationship status */ |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
169 | field = purple_request_fields_get_field( fields, "relationship" ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
170 | entry = g_list_first( purple_request_field_list_get_selected( field ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
171 | profile->relationship = atoi( purple_request_field_list_get_data( field, entry->data ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
172 | g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%i", CP_PROFILE_RELATIONSHIP, CP_PROFILE_TYPE_SHORT, profile->relationship ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
173 | g_string_append( attributes, attrib ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
174 | acount++; |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
175 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
176 | /* update flags */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
177 | field = purple_request_fields_get_field( fields, "searchable" ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
178 | 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
|
179 | profile->flags &= ~CP_PROF_NOT_SEARCHABLE; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
180 | else |
|
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 | field = purple_request_fields_get_field( fields, "suggestable" ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
183 | 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
|
184 | profile->flags &= ~CP_PROF_NOT_SUGGESTABLE; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
185 | else |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
186 | profile->flags |= CP_PROF_NOT_SUGGESTABLE; |
|
33833
19081badb425
MXit: Replace strtoll() with g_ascii_strtoll().
Andrew Victor <andrew.victor@mxit.com>
parents:
33831
diff
changeset
|
187 | g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%" G_GINT64_FORMAT, CP_PROFILE_FLAGS, CP_PROFILE_TYPE_LONG, profile->flags); |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
188 | g_string_append( attributes, attrib ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
189 | acount++; |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
190 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 | /* send the profile update to MXit */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
192 | 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
|
193 | 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
|
194 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 | /* show error to user */ |
|
28957
72b74fb2c159
A few other minor little translation-related fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
28953
diff
changeset
|
197 | 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
|
198 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 | } |
|
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 | * 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
|
204 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 | * @param action The action object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 | */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
207 | 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
|
208 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 | PurpleConnection* gc = (PurpleConnection*) action->context; |
|
33829
837d3061532b
MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents:
33611
diff
changeset
|
210 | 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
|
211 | 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
|
212 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
213 | PurpleRequestFields* fields = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 | PurpleRequestField* field = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 | |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
216 | 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
|
217 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 | /* ensure that we actually have the user's profile information */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
219 | if ( !profile ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
220 | /* no profile information yet, so we cannot update */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
221 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Profile" ), _( "Your profile information is not yet retrieved. Please try again later." ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
222 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
223 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
224 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
225 | fields = purple_request_fields_new(); |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
226 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
227 | /* Public information - what other users can see */ |
|
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 | 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
|
230 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
231 | /* display name */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
232 | 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
|
233 | 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
|
234 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
235 | /* birthday */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
236 | 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
|
237 | 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
|
238 | if ( profile->flags & CP_PROF_DOBLOCKED ) |
|
34495
641bff383b0a
Request API: replace purple_request_field_string_set_editable with purple_request_field_set_sensitive
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34338
diff
changeset
|
239 | purple_request_field_set_sensitive( field, FALSE ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
240 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
241 | /* gender */ |
|
34338
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
242 | field = purple_request_field_choice_new( "male", _( "Gender" ), GINT_TO_POINTER(profile->male ? 1 : 0)); |
|
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
243 | purple_request_field_choice_add( field, _( "Female" ), GINT_TO_POINTER(0)); |
|
c652670afac5
Request API refactoring: custom PURPLE_REQUEST_CHOICE values, instead of indexes
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
244 | purple_request_field_choice_add( field, _( "Male" ), GINT_TO_POINTER(1)); |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
245 | 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
|
246 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
247 | /* first name */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
248 | 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
|
249 | 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
|
250 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
251 | /* last name */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
252 | 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
|
253 | 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
|
254 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
255 | /* about me */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
256 | 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
|
257 | 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
|
258 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
259 | /* where I live */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
260 | 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
|
261 | 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
|
262 | |
|
33555
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
263 | /* relationship status */ |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
264 | field = purple_request_field_list_new( "relationship", _( "Relationship Status" ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
265 | purple_request_field_list_set_multi_select( field, FALSE ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
266 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_UNKNOWN ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_UNKNOWN ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
267 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DONTSAY ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DONTSAY ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
268 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SINGLE ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SINGLE ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
269 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_INVOLVED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_INVOLVED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
270 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_ENGAGED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_ENGAGED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
271 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_MARRIED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_MARRIED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
272 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_COMPLICATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_COMPLICATED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
273 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_WIDOWED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_WIDOWED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
274 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_SEPARATED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_SEPARATED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
275 | purple_request_field_list_add_icon( field, mxit_relationship_to_name( MXIT_RELATIONSHIP_DIVORCED ), NULL, g_strdup_printf( "%i", MXIT_RELATIONSHIP_DIVORCED ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
276 | purple_request_field_list_add_selected( field, mxit_relationship_to_name( profile->relationship ) ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
277 | purple_request_field_group_add_field( public_group, field ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
31725
diff
changeset
|
278 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
279 | purple_request_fields_add_group( fields, public_group ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
280 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
281 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
282 | /* Private information - what only MXit can see */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
283 | { |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
284 | 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
|
285 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
286 | /* title */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
287 | 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
|
288 | 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
|
289 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
290 | /* email */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
291 | 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
|
292 | 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
|
293 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
294 | /* mobile number */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
295 | 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
|
296 | 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
|
297 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
298 | /* is searchable */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
299 | 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
|
300 | 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
|
301 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
302 | /* is suggestable */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
303 | 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
|
304 | 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
|
305 | |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
306 | purple_request_fields_add_group( fields, private_group ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
307 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
308 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
309 | /* (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
|
310 | purple_request_fields( gc, _( "Profile" ), _( "Update your MXit Profile" ), NULL, fields, _( "Set" ), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
311 | G_CALLBACK( mxit_profile_cb ), _( "Cancel" ), NULL, purple_request_cpar_from_connection(gc), gc ); |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
312 | } |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
313 | |
|
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 | * 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
|
317 | * |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
318 | * @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
|
319 | * @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
|
320 | */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
321 | 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
|
322 | { |
|
33829
837d3061532b
MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents:
33611
diff
changeset
|
323 | 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
|
324 | const char* pin = NULL; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
325 | const char* pin2 = NULL; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
326 | const char* err = NULL; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
327 | int len; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
328 | int i; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
329 | |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35679
diff
changeset
|
330 | PURPLE_ASSERT_CONNECTION_IS_VALID(gc); |
|
31719
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 | /* validate pin */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
333 | 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
|
334 | if ( !pin ) { |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
335 | 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
|
336 | goto out; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
337 | } |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
338 | len = strlen( pin ); |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
339 | 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
|
340 | 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
|
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 | 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
|
344 | 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
|
345 | 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
|
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 | } |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
349 | 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
|
350 | 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
|
351 | 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
|
352 | goto out; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
353 | } |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
354 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
355 | out: |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
356 | if ( !err ) { |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
357 | /* update PIN in account */ |
|
34029
059c1270db1f
Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34028
diff
changeset
|
358 | purple_account_set_password( session->acc, pin, NULL, NULL ); |
|
31719
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 | /* update session object */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
361 | g_free( session->encpwd ); |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
362 | 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
|
363 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
364 | /* 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
|
365 | 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
|
366 | } |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
367 | else { |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
368 | /* show error to user */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
369 | 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
|
370 | } |
|
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 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
373 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
374 | /*------------------------------------------------------------------------ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
375 | * 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
|
376 | * |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
377 | * @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
|
378 | */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
379 | 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
|
380 | { |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
381 | PurpleConnection* gc = (PurpleConnection*) action->context; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
382 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
383 | PurpleRequestFields* fields = NULL; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
384 | PurpleRequestFieldGroup* group = NULL; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
385 | PurpleRequestField* field = NULL; |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
386 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
387 | 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
|
388 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
389 | fields = purple_request_fields_new(); |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33829
diff
changeset
|
390 | group = purple_request_field_group_new( NULL ); |
|
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33829
diff
changeset
|
391 | 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
|
392 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
393 | /* pin */ |
|
34024
9155cf9d26fa
Fix MXit plugin compile.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32623
diff
changeset
|
394 | field = purple_request_field_string_new( "pin", _( "PIN" ), purple_connection_get_password( gc ), FALSE ); |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
395 | 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
|
396 | 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
|
397 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
398 | /* verify pin */ |
|
34024
9155cf9d26fa
Fix MXit plugin compile.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32623
diff
changeset
|
399 | field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), purple_connection_get_password( gc ), FALSE ); |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
400 | 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
|
401 | 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
|
402 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
403 | /* (reference: "libpurple/request.h") */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
404 | purple_request_fields( gc, _( "Change PIN" ), _( "Change MXit PIN" ), NULL, fields, _( "Set" ), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
405 | G_CALLBACK( mxit_change_pin_cb ), _( "Cancel" ), NULL, purple_request_cpar_from_connection(gc), gc ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
406 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
407 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
409 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
410 | * 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
|
411 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
412 | * @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
|
413 | */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
414 | 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
|
415 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
416 | PurpleConnection* gc = (PurpleConnection*) action->context; |
|
33829
837d3061532b
MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents:
33611
diff
changeset
|
417 | 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
|
418 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
419 | 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
|
420 | splash_display( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
421 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
422 | 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
|
423 | } |
|
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 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
426 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
427 | * 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
|
428 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
429 | * @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
|
430 | */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
431 | 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
|
432 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
433 | char version[256]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
434 | |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31498
diff
changeset
|
435 | g_snprintf( version, sizeof( version ), |
|
30214
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30208
diff
changeset
|
436 | "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
|
437 | "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
|
438 | "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
|
439 | "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
|
440 | ( 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
|
441 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
442 | 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
|
443 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
444 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
445 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
446 | /*------------------------------------------------------------------------ |
| 31707 | 447 | * Request list of suggested friends. |
| 448 | * | |
| 449 | * @param action The action object | |
| 450 | */ | |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
451 | static void mxit_suggested_friends_action( PurplePluginAction* action ) |
| 31707 | 452 | { |
| 453 | PurpleConnection* gc = (PurpleConnection*) action->context; | |
|
33829
837d3061532b
MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents:
33611
diff
changeset
|
454 | struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
| 31707 | 455 | const char* profilelist[] = { |
| 456 | 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
|
457 | 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
|
458 | CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME }; |
| 31707 | 459 | |
|
31725
7efc5967d62e
Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31721
diff
changeset
|
460 | mxit_send_suggest_friends( session, MXIT_SEARCHRESULTS_MAX, ARRAY_SIZE( profilelist ), profilelist ); |
| 31707 | 461 | } |
| 462 | ||
| 463 | ||
| 464 | /*------------------------------------------------------------------------ | |
| 465 | * Perform contact search. | |
| 466 | * | |
| 467 | * @param action The action object | |
| 468 | */ | |
| 469 | static void mxit_user_search_cb( PurpleConnection *gc, const char *input ) | |
| 470 | { | |
|
33829
837d3061532b
MXit: Use the accessor functions were available.
Andrew Victor <andrew.victor@mxit.com>
parents:
33611
diff
changeset
|
471 | struct MXitSession* session = purple_connection_get_protocol_data( gc ); |
| 31707 | 472 | const char* profilelist[] = { |
| 473 | 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
|
474 | 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
|
475 | CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME }; |
| 31707 | 476 | |
|
31725
7efc5967d62e
Improve searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31721
diff
changeset
|
477 | mxit_send_suggest_search( session, MXIT_SEARCHRESULTS_MAX, input, ARRAY_SIZE( profilelist ), profilelist ); |
| 31707 | 478 | } |
| 479 | ||
| 480 | ||
| 481 | /*------------------------------------------------------------------------ | |
| 482 | * Display the search input form. | |
| 483 | * | |
| 484 | * @param action The action object | |
| 485 | */ | |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
486 | static void mxit_user_search_action( PurplePluginAction* action ) |
| 31707 | 487 | { |
| 488 | PurpleConnection* gc = (PurpleConnection*) action->context; | |
| 489 | ||
| 490 | purple_request_input( gc, _( "Search for user" ), | |
| 491 | _( "Search for a MXit contact" ), | |
| 492 | _( "Type search information" ), | |
| 493 | NULL, FALSE, FALSE, NULL, | |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33829
diff
changeset
|
494 | _( "_Search" ), G_CALLBACK( mxit_user_search_cb ), |
|
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33829
diff
changeset
|
495 | _( "_Cancel" ), NULL, |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34149
diff
changeset
|
496 | purple_request_cpar_from_connection(gc), |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33829
diff
changeset
|
497 | gc ); |
| 31707 | 498 | } |
| 499 | ||
| 500 | ||
| 501 | /*------------------------------------------------------------------------ | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 | * 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
|
503 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 | * @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
|
505 | * @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
|
506 | * @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
|
507 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 | 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
|
509 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
510 | PurplePluginAction* action = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
511 | GList* m = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
512 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
513 | /* display / change profile */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
514 | 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
|
515 | 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
|
516 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
517 | /* change PIN */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
518 | 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
|
519 | 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
|
520 | |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
521 | /* suggested friends */ |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
522 | 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
|
523 | 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
|
524 | |
|
31721
a339d998187c
Search results can contain users and services - change wording.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
525 | /* search for contacts */ |
|
a339d998187c
Search results can contain users and services - change wording.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
526 | 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
|
527 | 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
|
528 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
529 | /* display splash-screen */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
530 | 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
|
531 | 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
|
532 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
533 | /* display plugin version */ |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
534 | action = purple_plugin_action_new( _( "About..." ), mxit_about_action ); |
| 31707 | 535 | m = g_list_append( m, action ); |
| 536 | ||
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
537 | return m; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
538 | } |