Sat, 21 Sep 2013 17:01:08 +0530
Merged soc.2013.gobjectification branch
|
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 | * -- MXit client protocol implementation -- |
|
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:
33834
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:
33834
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:
33834
diff
changeset
|
28 | #include "version.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
29 | |
|
36542
30f40ecc4631
Renamed mxit's protocol.[ch] to client.[ch]
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
30 | #include "client.h" |
|
28841
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 "chunk.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 | #include "filexfer.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
35 | #include "markup.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 | #include "multimx.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 | #include "splashscreen.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
38 | #include "login.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
39 | #include "formcmds.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
40 | #include "http.h" |
|
33832
7e3903a32a1b
MXit: Need to include MXit's cipher.h since mxit_decrypt_message() is being called.
Andrew Victor <andrew.victor@mxit.com>
parents:
33831
diff
changeset
|
41 | #include "cipher.h" |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
42 | #include "voicevideo.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
45 | #define MXIT_MS_OFFSET 3 |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
46 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
47 | /* configure the right record terminator char to use */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
48 | #define CP_REC_TERM ( ( session->http ) ? CP_HTTP_REC_TERM : CP_SOCK_REC_TERM ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
49 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
50 | |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
51 | /*------------------------------------------------------------------------ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
52 | * return the current timestamp in milliseconds |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
53 | */ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
54 | gint64 mxit_now_milli( void ) |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
55 | { |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
56 | GTimeVal now; |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
57 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
58 | g_get_current_time( &now ); |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
59 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
60 | return ( ( now.tv_sec * 1000 ) + ( now.tv_usec / 1000 ) ); |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
61 | } |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
62 | |
|
28841
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 | * Display a notification popup message to the user. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
67 | * @param type The type of notification: |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
68 | * - info: PURPLE_NOTIFY_MSG_INFO |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
69 | * - warning: PURPLE_NOTIFY_MSG_WARNING |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 | * - error: PURPLE_NOTIFY_MSG_ERROR |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 | * @param heading Heading text |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 | * @param message Message text |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 | void mxit_popup( int type, const char* heading, const char* message ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 | /* (reference: "libpurple/notify.h") */ |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34287
diff
changeset
|
77 | purple_notify_message( NULL, type, _( MXIT_POPUP_WIN_NAME ), heading, message, NULL, NULL, NULL ); |
|
28841
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 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
81 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
82 | * For compatibility with legacy clients, all usernames are sent from MXit with a domain |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 | * appended. For MXit contacts, this domain is set to "@m". This function strips |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
84 | * those fake domains. |
|
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 | * @param username The username of the contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
87 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
88 | void mxit_strip_domain( char* username ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
89 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
90 | if ( g_str_has_suffix( username, "@m" ) ) |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
91 | username[ strlen( username ) - 2 ] = '\0'; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
93 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
94 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
95 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
96 | * Dump a byte buffer to the console for debugging purposes. |
|
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 | * @param buf The data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
99 | * @param len The data length |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
100 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 | void dump_bytes( struct MXitSession* session, const char* buf, int len ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
102 | { |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
103 | char* msg = g_malloc0( len + 1 ); |
|
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
104 | int i; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
105 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
106 | for ( i = 0; i < len; i++ ) { |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
107 | char ch = buf[i]; |
|
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
108 | |
|
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
109 | if ( ch == CP_REC_TERM ) /* record terminator */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 | msg[i] = '!'; |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
111 | else if ( ch == CP_FLD_TERM ) /* field terminator */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 | msg[i] = '^'; |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
113 | else if ( ch == CP_PKT_TERM ) /* packet terminator */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
114 | msg[i] = '@'; |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
115 | else if ( ( ch < 0x20 ) || ( ch > 0x7E ) ) /* non-printable character */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 | msg[i] = '_'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
117 | else |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
118 | msg[i] = ch; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
120 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 | purple_debug_info( MXIT_PLUGIN_ID, "DUMP: '%s'\n", msg ); |
|
33847
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
122 | |
|
7cd76ebbe8d1
MXit: Refactor dump_bytes() not to use a C99-style variable length array.
Andrew Victor <andrew.victor@mxit.com>
parents:
33844
diff
changeset
|
123 | g_free( msg ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
124 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
125 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 | |
|
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 | * Determine if we have an active chat with a specific contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
130 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
131 | * @param who The contact name |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 | * @return Return true if we have an active chat with the contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
133 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
134 | gboolean find_active_chat( const GList* chats, const char* who ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
135 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 | const GList* list = chats; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 | const char* chat = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
138 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 | while ( list ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
140 | chat = (const char*) list->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
141 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
142 | if ( strcmp( chat, who ) == 0 ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
143 | return TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
144 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
145 | list = g_list_next( list ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
146 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
147 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
148 | return FALSE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
149 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
150 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
151 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
152 | /*======================================================================================================================== |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
153 | * Low-level Packet transmission |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
154 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
155 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
156 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
157 | * Remove next packet from transmission queue. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
158 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
159 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
160 | * @return The next packet for transmission (or NULL) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
161 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
162 | static struct tx_packet* pop_tx_packet( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
163 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
164 | struct tx_packet* packet = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
165 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
166 | if ( session->queue.count > 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
167 | /* dequeue the next packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
168 | packet = session->queue.packets[session->queue.rd_i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
169 | session->queue.packets[session->queue.rd_i] = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
170 | session->queue.rd_i = ( session->queue.rd_i + 1 ) % MAX_QUEUE_SIZE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
171 | session->queue.count--; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
172 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
173 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
174 | return packet; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
175 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
176 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
177 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
178 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
179 | * Add packet to transmission queue. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
180 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
181 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
182 | * @param packet The packet to transmit |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
183 | * @return Return TRUE if packet was enqueue, or FALSE if queue is full. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
184 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
185 | static gboolean push_tx_packet( struct MXitSession* session, struct tx_packet* packet ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
186 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
187 | if ( session->queue.count < MAX_QUEUE_SIZE ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
188 | /* enqueue packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 | session->queue.packets[session->queue.wr_i] = packet; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
190 | session->queue.wr_i = ( session->queue.wr_i + 1 ) % MAX_QUEUE_SIZE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 | session->queue.count++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
192 | return TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
193 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 | return FALSE; /* queue is full */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
196 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 | |
|
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 | * Deallocate transmission packet. |
|
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 | * @param packet The packet to deallocate. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
203 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 | static void free_tx_packet( struct tx_packet* packet ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
206 | g_free( packet->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 | g_free( packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 | packet = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
211 | |
|
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 | * Flush all the packets from the tx queue and release the resources. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
214 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
215 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
216 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
217 | static void flush_queue( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
218 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
219 | struct tx_packet* packet; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
220 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
221 | purple_debug_info( MXIT_PLUGIN_ID, "flushing the tx queue\n" ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
222 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
223 | while ( (packet = pop_tx_packet( session ) ) != NULL ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
224 | free_tx_packet( packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
225 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
226 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
227 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
228 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
229 | * TX Step 3: Write the packet data to the TCP connection. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
230 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
231 | * @param fd The file descriptor |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
232 | * @param pktdata The packet data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
233 | * @param pktlen The length of the packet data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
234 | * @return Return -1 on error, otherwise 0 |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
235 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
236 | static int mxit_write_sock_packet( int fd, const char* pktdata, int pktlen ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
237 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
238 | int written; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
239 | int res; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
240 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
241 | written = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
242 | while ( written < pktlen ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
243 | res = write( fd, &pktdata[written], pktlen - written ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
244 | if ( res <= 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
245 | /* error on socket */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
246 | if ( errno == EAGAIN ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
247 | continue; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
248 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
249 | purple_debug_error( MXIT_PLUGIN_ID, "Error while writing packet to MXit server (%i)\n", res ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
250 | return -1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
251 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
252 | written += res; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
253 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
254 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
255 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
256 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
257 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
258 | |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
259 | /** |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
260 | * Callback called for handling a HTTP GET response |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
261 | * |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
262 | * @param http_conn http api object (see http.h) |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
263 | * @param response http api object (see http.h) |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
264 | * @param _session The MXit session object |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
265 | */ |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
266 | static void |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
267 | mxit_cb_http_rx(PurpleHttpConnection *http_conn, PurpleHttpResponse *response, |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
268 | gpointer _session) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
269 | { |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
270 | struct MXitSession *session = _session; |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
271 | const gchar *got_data; |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
272 | size_t got_len; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
273 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34269
diff
changeset
|
274 | if (!purple_http_response_is_successful(response)) { |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
275 | purple_debug_error(MXIT_PLUGIN_ID, "HTTP response error (%s)\n", |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
276 | purple_http_response_get_error(response)); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
277 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
278 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
279 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
280 | /* convert the HTTP result */ |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
281 | got_data = purple_http_response_get_data(response, &got_len); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
282 | memcpy(session->rx_dbuf, got_data, got_len); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
283 | session->rx_i = got_len; |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
284 | |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
285 | mxit_parse_packet(session); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
286 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
287 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
288 | |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
289 | /** |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
290 | * TX Step 3: Write the packet data to the HTTP connection (GET style). |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
291 | * |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
292 | * @param session The MXit session object |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
293 | * @param packet The packet data |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
294 | */ |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
295 | static void |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
296 | mxit_write_http_get(struct MXitSession* session, struct tx_packet* packet) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
297 | { |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
298 | PurpleHttpRequest *req; |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
299 | char *part = NULL; |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
300 | |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
301 | if (packet->datalen > 0) { |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
302 | char *tmp; |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
303 | |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
304 | tmp = g_strndup(packet->data, packet->datalen); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
305 | part = g_strdup(purple_url_encode(tmp)); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
306 | g_free(tmp); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
307 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
308 | |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
309 | req = purple_http_request_new(NULL); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
310 | purple_http_request_set_url_printf(req, "%s?%s%s", session->http_server, |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
311 | purple_url_encode(packet->header), part ? part : ""); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
312 | purple_http_request_header_set(req, "User-Agent", MXIT_HTTP_USERAGENT); |
|
34269
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
313 | purple_http_connection_set_add(session->async_http_reqs, |
|
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
314 | purple_http_request(session->con, req, mxit_cb_http_rx, |
|
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
315 | session)); |
|
34236
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
316 | purple_http_request_unref(req); |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
317 | |
|
65f7a964bab1
HTTP: migrate purple_util_fetch_url_request to new API for mxit prpl
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
318 | g_free(part); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
319 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
320 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
321 | |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
322 | /** |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
323 | * TX Step 3: Write the packet data to the HTTP connection (POST style). |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
324 | * |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
325 | * @param session The MXit session object |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
326 | * @param packet The packet data |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
327 | */ |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
328 | static void |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
329 | mxit_write_http_post(struct MXitSession* session, struct tx_packet* packet) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
330 | { |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
331 | PurpleHttpRequest *req; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
332 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
333 | /* strip off the last '&' from the header */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
334 | packet->header[packet->headerlen - 1] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
335 | packet->headerlen--; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
336 | |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
337 | req = purple_http_request_new(NULL); |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
338 | purple_http_request_set_url_printf(req, "%s?%s", session->http_server, |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
339 | purple_url_encode(packet->header)); |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
340 | purple_http_request_set_method(req, "POST"); |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
341 | purple_http_request_header_set(req, "User-Agent", MXIT_HTTP_USERAGENT); |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
342 | purple_http_request_header_set(req, "Content-Type", |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
343 | "application/octet-stream"); |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
344 | purple_http_request_set_contents(req, packet->data + MXIT_MS_OFFSET, |
|
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
345 | packet->datalen - MXIT_MS_OFFSET); |
|
34269
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
346 | purple_http_connection_set_add(session->async_http_reqs, |
|
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
347 | purple_http_request(session->con, req, mxit_cb_http_rx, |
|
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
348 | session)); |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34236
diff
changeset
|
349 | purple_http_request_unref(req); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
350 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
351 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
352 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
353 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
354 | * TX Step 2: Handle the transmission of the packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
355 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
356 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
357 | * @param packet The packet to transmit |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
358 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
359 | static void mxit_send_packet( struct MXitSession* session, struct tx_packet* packet ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
360 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
361 | int res; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
362 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
363 | if ( !( session->flags & MXIT_FLAG_CONNECTED ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
364 | /* we are not connected so ignore all packets to be send */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
365 | purple_debug_error( MXIT_PLUGIN_ID, "Dropping TX packet (we are not connected)\n" ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
366 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
367 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
368 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
369 | purple_debug_info( MXIT_PLUGIN_ID, "Packet send CMD:%i (%i)\n", packet->cmd, packet->headerlen + packet->datalen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
370 | #ifdef DEBUG_PROTOCOL |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
371 | dump_bytes( session, packet->header, packet->headerlen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
372 | dump_bytes( session, packet->data, packet->datalen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
373 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
374 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
375 | if ( !session->http ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
376 | /* socket connection */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
377 | char data[packet->datalen + packet->headerlen]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
378 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
379 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
380 | /* create raw data buffer */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
381 | memcpy( data, packet->header, packet->headerlen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
382 | memcpy( data + packet->headerlen, packet->data, packet->datalen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
383 | datalen = packet->headerlen + packet->datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
384 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
385 | res = mxit_write_sock_packet( session->fd, data, datalen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
386 | if ( res < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
387 | /* we must have lost the connection, so terminate it so that we can reconnect */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
388 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "We have lost the connection to MXit. Please reconnect." ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
389 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
390 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
391 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
392 | /* http connection */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
393 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
394 | if ( packet->cmd == CP_CMD_MEDIA ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
395 | /* multimedia packets must be send with a HTTP POST */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
396 | mxit_write_http_post( session, packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
397 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
398 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
399 | mxit_write_http_get( session, packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
400 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
401 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
402 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
403 | /* update the timestamp of the last-transmitted packet */ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
404 | session->last_tx = mxit_now_milli(); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
405 | |
|
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 | * we need to remember that we are still waiting for the ACK from |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
408 | * the server on this request |
|
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 | session->outack = packet->cmd; |
|
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 | /* free up the packet resources */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
413 | free_tx_packet( packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
414 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
415 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
416 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
417 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
418 | * TX Step 1: Create a new Tx packet and queue it for sending. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
419 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
420 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
421 | * @param data The packet data (payload) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
422 | * @param datalen The length of the packet data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
423 | * @param cmd The MXit command for this packet |
|
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 | static void mxit_queue_packet( struct MXitSession* session, const char* data, int datalen, int cmd ) |
|
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 | struct tx_packet* packet; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
428 | char header[256]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
429 | int hlen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
430 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
431 | /* create a packet for sending */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
432 | packet = g_new0( struct tx_packet, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
433 | packet->data = g_malloc0( datalen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
434 | packet->cmd = cmd; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
435 | packet->headerlen = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
436 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
437 | /* create generic packet header */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
438 | hlen = g_snprintf( header, sizeof( header ), "id=%s%c", purple_account_get_username( session->acc ), CP_REC_TERM ); /* client mxitid */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
439 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
440 | if ( session->http ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
441 | /* http connection only */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
442 | hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "s=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
443 | if ( session->http_sesid > 0 ) { |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
444 | hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "%u%c", session->http_sesid, CP_FLD_TERM ); /* http session id */ |
|
28841
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 | session->http_seqno++; |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
447 | hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "%u%c", session->http_seqno, CP_REC_TERM ); /* http request sequence id */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
448 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
449 | |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
450 | hlen += g_snprintf( header + hlen, sizeof( header ) - hlen, "cm=%i%c", cmd, CP_REC_TERM ); /* packet command */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
451 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
452 | if ( !session->http ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
453 | /* socket connection only */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
454 | packet->headerlen = g_snprintf( packet->header, sizeof( packet->header ), "ln=%i%c", ( datalen + hlen ), CP_REC_TERM ); /* packet length */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
455 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
456 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
457 | /* copy the header to packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
458 | memcpy( packet->header + packet->headerlen, header, hlen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
459 | packet->headerlen += hlen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
460 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
461 | /* copy payload to packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
462 | if ( datalen > 0 ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
463 | memcpy( packet->data, data, datalen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
464 | packet->datalen = datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
465 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
466 | |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
467 | /* shortcut */ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
468 | if ( ( session->queue.count == 0 ) && ( session->outack == 0 ) ) { |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
469 | /* the queue is empty and there are no outstanding acks so we can write it directly */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
470 | mxit_send_packet( session, packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
471 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
472 | else { |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
473 | /* we need to queue this packet */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
474 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
475 | if ( ( packet->cmd == CP_CMD_PING ) || ( packet->cmd == CP_CMD_POLL ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
476 | /* we do NOT queue HTTP poll nor socket ping packets */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
477 | free_tx_packet( packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
478 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
479 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
480 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
481 | purple_debug_info( MXIT_PLUGIN_ID, "queueing packet for later sending cmd=%i\n", cmd ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
482 | if ( !push_tx_packet( session, packet ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
483 | /* packet could not be queued for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
484 | mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "Message Send Error" ), _( "Unable to process your request at this time" ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
485 | free_tx_packet( packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
486 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
487 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
488 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
489 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
490 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
491 | /*------------------------------------------------------------------------ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
492 | * Manage the packet send queue (send next packet, timeout's, etc). |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
493 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
494 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
495 | */ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
496 | static void mxit_manage_queue( struct MXitSession* session ) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
497 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
498 | struct tx_packet* packet = NULL; |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
499 | gint64 now = mxit_now_milli(); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
500 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
501 | if ( !( session->flags & MXIT_FLAG_CONNECTED ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
502 | /* we are not connected, so ignore the queue */ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
503 | return; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
504 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
505 | else if ( session->outack > 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
506 | /* we are still waiting for an outstanding ACK from the MXit server */ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
507 | if ( session->last_tx <= mxit_now_milli() - ( MXIT_ACK_TIMEOUT * 1000 ) ) { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
508 | /* ack timeout! so we close the connection here */ |
|
30369
283eb4c5e902
For the debug message:
Andrew Victor <andrew.victor@mxit.com>
parents:
30304
diff
changeset
|
509 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_manage_queue: Timeout awaiting ACK for command '%i'\n", session->outack ); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
510 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Timeout while waiting for a response from the MXit server." ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
511 | } |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
512 | return; |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
513 | } |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
514 | |
| 31707 | 515 | /* |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
516 | * the mxit server has flood detection and it prevents you from sending messages to fast. |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
517 | * this is a self defense mechanism, a very annoying feature. so the client must ensure that |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
518 | * it does not send messages too fast otherwise mxit will ignore the user for 30 seconds. |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
519 | * this is what we are trying to avoid here.. |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
520 | */ |
|
31706
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
521 | if ( session->q_fast_timer_id == 0 ) { |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
522 | /* the fast timer has not been set yet */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
523 | if ( session->last_tx > ( now - MXIT_TX_DELAY ) ) { |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
524 | /* we need to wait a little before sending the next packet, so schedule a wakeup call */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
525 | gint64 tdiff = now - ( session->last_tx ); |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
526 | guint delay = ( MXIT_TX_DELAY - tdiff ) + 9; |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
527 | if ( delay <= 0 ) |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
528 | delay = MXIT_TX_DELAY; |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
529 | session->q_fast_timer_id = purple_timeout_add( delay, mxit_manage_queue_fast, session ); |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
530 | } |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
531 | else { |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
532 | /* get the next packet from the queue to send */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
533 | packet = pop_tx_packet( session ); |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
534 | if ( packet != NULL ) { |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
535 | /* there was a packet waiting to be sent to the server, now is the time to do something about it */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
536 | |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
537 | /* send the packet to MXit server */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
538 | mxit_send_packet( session, packet ); |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
539 | } |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
540 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
541 | } |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
542 | } |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
543 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
544 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
545 | /*------------------------------------------------------------------------ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
546 | * Slow callback to manage the packet send queue. |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
547 | * |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
548 | * @param session The MXit session object |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
549 | */ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
550 | gboolean mxit_manage_queue_slow( gpointer user_data ) |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
551 | { |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
552 | struct MXitSession* session = (struct MXitSession*) user_data; |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
553 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
554 | mxit_manage_queue( session ); |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
555 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
556 | /* continue running */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
557 | return TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
558 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
559 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
560 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
561 | /*------------------------------------------------------------------------ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
562 | * Fast callback to manage the packet send queue. |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
563 | * |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
564 | * @param session The MXit session object |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
565 | */ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
566 | gboolean mxit_manage_queue_fast( gpointer user_data ) |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
567 | { |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
568 | struct MXitSession* session = (struct MXitSession*) user_data; |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
569 | |
|
31706
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
570 | session->q_fast_timer_id = 0; |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
571 | mxit_manage_queue( session ); |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
572 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
573 | /* stop running */ |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
574 | return FALSE; |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
575 | } |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
576 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
577 | |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
578 | /*------------------------------------------------------------------------ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 | * Callback to manage HTTP server polling (HTTP connections ONLY) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
581 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
582 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
583 | gboolean mxit_manage_polling( gpointer user_data ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
584 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
585 | struct MXitSession* session = (struct MXitSession*) user_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
586 | gboolean poll = FALSE; |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
587 | gint64 now = mxit_now_milli(); |
|
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
588 | gint64 rxdiff; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
589 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
590 | if ( !( session->flags & MXIT_FLAG_LOGGEDIN ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
591 | /* we only poll if we are actually logged in */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
592 | return TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
593 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
595 | /* calculate the time differences */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 | rxdiff = now - session->last_rx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
597 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
598 | if ( rxdiff < MXIT_HTTP_POLL_MIN ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
599 | /* we received some reply a few moments ago, so reset the poll interval */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
600 | session->http_interval = MXIT_HTTP_POLL_MIN; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
601 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 | else if ( session->http_last_poll < ( now - session->http_interval ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 | /* time to poll again */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
604 | poll = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
605 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
606 | /* back-off some more with the polling */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
607 | session->http_interval = session->http_interval + ( session->http_interval / 2 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 | if ( session->http_interval > MXIT_HTTP_POLL_MAX ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
609 | session->http_interval = MXIT_HTTP_POLL_MAX; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
610 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
611 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
612 | /* debugging */ |
|
33834
5d6efef74ff8
MXit: Cleanup a warning.
Andrew Victor <andrew.victor@mxit.com>
parents:
33833
diff
changeset
|
613 | //purple_debug_info( MXIT_PLUGIN_ID, "POLL TIMER: %i (%i)\n", session->http_interval, rxdiff ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
614 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
615 | if ( poll ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
616 | /* send poll request */ |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
617 | session->http_last_poll = mxit_now_milli(); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
618 | mxit_send_poll( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
619 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
620 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
621 | return TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
622 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
625 | /*======================================================================================================================== |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
626 | * Send MXit operations. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
627 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
628 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 | * Send a ping/keepalive packet to MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
631 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
632 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
633 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 | void mxit_send_ping( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
637 | mxit_queue_packet( session, NULL, 0, CP_CMD_PING ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
638 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
639 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
640 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
641 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
642 | * Send a poll request to the HTTP server (HTTP connections ONLY). |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
643 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
644 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
645 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
646 | void mxit_send_poll( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
647 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
648 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
649 | mxit_queue_packet( session, NULL, 0, CP_CMD_POLL ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
650 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
651 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
652 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
653 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
654 | * Send a logout packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
655 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
656 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
657 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
658 | void mxit_send_logout( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
659 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
660 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
661 | mxit_queue_packet( session, NULL, 0, CP_CMD_LOGOUT ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
662 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
663 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
664 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
665 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
666 | * Send a register packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
667 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
668 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
669 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
670 | void mxit_send_register( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
671 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
672 | 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
|
673 | const char* locale; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
674 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
675 | int datalen; |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
676 | char* clientVersion; |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
677 | unsigned int features = MXIT_CP_FEATURES; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
678 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
679 | locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
680 | |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
681 | /* Voice and Video supported */ |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
682 | if ( mxit_audio_enabled() && mxit_video_enabled() ) |
|
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
683 | features |= ( MXIT_CF_VOICE | MXIT_CF_VIDEO ); |
|
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
684 | else if ( mxit_audio_enabled() ) |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
685 | features |= MXIT_CF_VOICE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
686 | |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
687 | /* generate client version string (eg, P-2.7.10-Y-PURPLE) */ |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
688 | clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM ); |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
689 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
690 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
691 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
692 | "ms=%s%c%s%c%i%c%s%c" /* "ms"=password\1version\1maxreplyLen\1name\1 */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
693 | "%s%c%i%c%s%c%s%c" /* dateOfBirth\1gender\1location\1capabilities\1 */ |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
694 | "%s%c%i%c%s%c%s" /* dc\1features\1dialingcode\1locale */ |
| 31707 | 695 | "%c%i%c%i", /* \1protocolVer\1lastRosterUpdate */ |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
696 | session->encpwd, CP_FLD_TERM, clientVersion, CP_FLD_TERM, CP_MAX_FILESIZE, CP_FLD_TERM, profile->nickname, CP_FLD_TERM, |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30522
diff
changeset
|
697 | profile->birthday, CP_FLD_TERM, ( profile->male ) ? 1 : 0, CP_FLD_TERM, MXIT_DEFAULT_LOC, CP_FLD_TERM, MXIT_CP_CAP, CP_FLD_TERM, |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
698 | session->distcode, CP_FLD_TERM, features, CP_FLD_TERM, session->dialcode, CP_FLD_TERM, locale, |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
699 | CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0 |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
700 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
701 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
702 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
703 | mxit_queue_packet( session, data, datalen, CP_CMD_REGISTER ); |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
704 | |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
705 | g_free( clientVersion ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
706 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
707 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
708 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
709 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
710 | * Send a login packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
711 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
712 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
713 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
714 | void mxit_send_login( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
715 | { |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
716 | const char* splashId; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
717 | const char* locale; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
718 | char data[CP_MAX_PACKET]; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
719 | int datalen; |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
720 | char* clientVersion; |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
721 | unsigned int features = MXIT_CP_FEATURES; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
722 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
723 | locale = purple_account_get_string( session->acc, MXIT_CONFIG_LOCALE, MXIT_DEFAULT_LOCALE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
724 | |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
725 | /* Voice and Video supported */ |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
726 | if ( mxit_audio_enabled() && mxit_video_enabled() ) |
|
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
727 | features |= ( MXIT_CF_VOICE | MXIT_CF_VIDEO ); |
|
33849
5ce3fe28942f
MXit: Fix incorrect return value from mxit_media_caps().
Andrew Victor <andrew.victor@mxit.com>
parents:
33847
diff
changeset
|
728 | else if ( mxit_audio_enabled() ) |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
729 | features |= MXIT_CF_VOICE; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
730 | |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
731 | /* generate client version string (eg, P-2.7.10-Y-PURPLE) */ |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
732 | clientVersion = g_strdup_printf( "%c-%i.%i.%i-%s-%s", MXIT_CP_DISTCODE, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_MICRO_VERSION, MXIT_CP_ARCH, MXIT_CP_PLATFORM ); |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
733 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
734 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
735 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
736 | "ms=%s%c%s%c%i%c" /* "ms"=password\1version\1getContacts\1 */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
737 | "%s%c%s%c%i%c" /* capabilities\1dc\1features\1 */ |
|
30214
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
738 | "%s%c%s%c" /* dialingcode\1locale\1 */ |
|
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
739 | "%i%c%i%c%i", /* maxReplyLen\1protocolVer\1lastRosterUpdate */ |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
740 | session->encpwd, CP_FLD_TERM, clientVersion, CP_FLD_TERM, 1, CP_FLD_TERM, |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
741 | MXIT_CP_CAP, CP_FLD_TERM, session->distcode, CP_FLD_TERM, features, CP_FLD_TERM, |
|
30214
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
742 | session->dialcode, CP_FLD_TERM, locale, CP_FLD_TERM, |
|
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
743 | CP_MAX_FILESIZE, CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0 |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
744 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
745 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
746 | /* include "custom resource" information */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
747 | splashId = splash_current( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
748 | if ( splashId != NULL ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
749 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%ccr=%s", CP_REC_TERM, splashId ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
750 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
751 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
752 | mxit_queue_packet( session, data, datalen, CP_CMD_LOGIN ); |
|
31499
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
753 | |
|
0e6efdfbe212
* Send the MXit Client version as the libpurple version rather than always "5.9.0".
Andrew Victor <andrew.victor@mxit.com>
parents:
31496
diff
changeset
|
754 | g_free( clientVersion ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
755 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
756 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
757 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
758 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
759 | * Send a chat message packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
760 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
761 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
762 | * @param to The username of the recipient |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
763 | * @param msg The message text |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
764 | */ |
|
29216
9284748dd744
Add extra parameter to mxit_send_message() function to indicate if the message should be
Andrew Victor <andrew.victor@mxit.com>
parents:
29215
diff
changeset
|
765 | void mxit_send_message( struct MXitSession* session, const char* to, const char* msg, gboolean parse_markup, gboolean is_command ) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
766 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
767 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
768 | char* markuped_msg; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
769 | int datalen; |
|
29216
9284748dd744
Add extra parameter to mxit_send_message() function to indicate if the message should be
Andrew Victor <andrew.victor@mxit.com>
parents:
29215
diff
changeset
|
770 | int msgtype = ( is_command ? CP_MSGTYPE_COMMAND : CP_MSGTYPE_NORMAL ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
771 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
772 | /* first we need to convert the markup from libPurple to MXit format */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
773 | if ( parse_markup ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
774 | markuped_msg = mxit_convert_markup_tx( msg, &msgtype ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
775 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
776 | markuped_msg = g_strdup( msg ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
777 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
778 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
779 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
780 | "ms=%s%c%s%c%i%c%i", /* "ms"=jid\1msg\1type\1flags */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
781 | to, CP_FLD_TERM, markuped_msg, CP_FLD_TERM, msgtype, CP_FLD_TERM, CP_MSG_MARKUP | CP_MSG_EMOTICON |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
782 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
783 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
784 | /* free the resources */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
785 | g_free( markuped_msg ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
786 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
787 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
788 | mxit_queue_packet( session, data, datalen, CP_CMD_TX_MSG ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
789 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
790 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
791 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
792 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
793 | * Send a extended profile request packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
794 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
795 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
796 | * @param username Username who's profile is being requested (NULL = our own) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
797 | * @param nr_attribs Number of attributes being requested |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
798 | * @param attribute The names of the attributes |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
799 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
800 | void mxit_send_extprofile_request( struct MXitSession* session, const char* username, unsigned int nr_attrib, const char* attribute[] ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
801 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
802 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
803 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
804 | unsigned int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
805 | |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
806 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
807 | "ms=%s%c%i", /* "ms="mxitid\1nr_attributes */ |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
808 | ( username ? username : "" ), CP_FLD_TERM, nr_attrib |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
809 | ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
810 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
811 | /* add attributes */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
812 | for ( i = 0; i < nr_attrib; i++ ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
813 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
814 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
815 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
816 | mxit_queue_packet( session, data, datalen, CP_CMD_EXTPROFILE_GET ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
817 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
818 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
819 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
820 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
821 | * Send an update profile packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
822 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
823 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
824 | * @param password The new password to be used for logging in (optional) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
825 | * @param nr_attrib The number of attributes |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
826 | * @param attributes String containing the attribute-name, attribute-type and value (seperated by '\01') |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
827 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
828 | void mxit_send_extprofile_update( struct MXitSession* session, const char* password, unsigned int nr_attrib, const char* attributes ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
829 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
830 | char data[CP_MAX_PACKET]; |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
831 | gchar** parts = NULL; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
832 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
833 | unsigned int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
834 | |
|
31719
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
835 | if ( attributes ) |
|
a0a1e1fe74ef
Move the PIN-change option into a separate PluginAction.
Andrew Victor <andrew.victor@mxit.com>
parents:
31718
diff
changeset
|
836 | parts = g_strsplit( attributes, "\01", 1 + ( nr_attrib * 3 ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
837 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
838 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
839 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
840 | "ms=%s%c%i", /* "ms"=password\1nr_attibutes */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
841 | ( password ) ? password : "", CP_FLD_TERM, nr_attrib |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
842 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
843 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
844 | /* add attributes */ |
|
33807
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
845 | for ( i = 1; i < nr_attrib * 3; i+=3 ) { |
|
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
846 | if ( parts == NULL || parts[i] == NULL || parts[i + 1] == NULL || parts[i + 2] == NULL ) { |
|
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
847 | purple_debug_error( MXIT_PLUGIN_ID, "Invalid profile update attributes = '%s' - nbr=%u\n", attributes, nr_attrib ); |
|
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
848 | g_strfreev( parts ); |
|
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
849 | return; |
|
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
850 | } |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
851 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, |
|
33820
d4800da4da85
MXit: Rather use snprintf() than sprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33819
diff
changeset
|
852 | "%c%s%c%s%c%s", /* \1name\1type\1value */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
853 | CP_FLD_TERM, parts[i], CP_FLD_TERM, parts[i + 1], CP_FLD_TERM, parts[i + 2] ); |
|
33807
f7939a1534d8
Add some sanity checking to guard against mismatched parameters.
Daniel Atallah <datallah@pidgin.im>
parents:
33706
diff
changeset
|
854 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
855 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
856 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
857 | mxit_queue_packet( session, data, datalen, CP_CMD_EXTPROFILE_SET ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
858 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
859 | /* freeup the memory */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
860 | g_strfreev( parts ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
861 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
862 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
863 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
864 | /*------------------------------------------------------------------------ |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
865 | * Send packet to request list of suggested friends. |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
866 | * |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
867 | * @param session The MXit session object |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
868 | * @param max Maximum number of results to return |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
869 | * @param nr_attribs Number of attributes being requested |
| 31707 | 870 | * @param attribute The names of the attributes |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
871 | */ |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
872 | void mxit_send_suggest_friends( struct MXitSession* session, int max, unsigned int nr_attrib, const char* attribute[] ) |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
873 | { |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
874 | char data[CP_MAX_PACKET]; |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
875 | int datalen; |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
876 | unsigned int i; |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
877 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
878 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
879 | datalen = g_snprintf( data, sizeof( data ), |
|
31704
5c3b94cb6cba
SuggestContacts packets updated.
Andrew Victor <andrew.victor@mxit.com>
parents:
31703
diff
changeset
|
880 | "ms=%i%c%s%c%i%c%i%c%i", /* inputType \1 input \1 maxSuggestions \1 startIndex \1 numAttributes \1 name0 \1 name1 ... \1 nameN */ |
|
5c3b94cb6cba
SuggestContacts packets updated.
Andrew Victor <andrew.victor@mxit.com>
parents:
31703
diff
changeset
|
881 | CP_SUGGEST_FRIENDS, CP_FLD_TERM, "", CP_FLD_TERM, max, CP_FLD_TERM, 0, CP_FLD_TERM, nr_attrib ); |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
882 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
883 | /* add attributes */ |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
884 | for ( i = 0; i < nr_attrib; i++ ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
885 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] ); |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
886 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
887 | /* queue packet for transmission */ |
|
31495
e83a5b4fb633
Was using the incorrect packet type.
Andrew Victor <andrew.victor@mxit.com>
parents:
31492
diff
changeset
|
888 | mxit_queue_packet( session, data, datalen, CP_CMD_SUGGESTCONTACTS ); |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
889 | } |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
890 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
891 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
892 | /*------------------------------------------------------------------------ |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
893 | * Send packet to perform a search for users. |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
894 | * |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
895 | * @param session The MXit session object |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
896 | * @param max Maximum number of results to return |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
897 | * @param text The search text |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
898 | * @param nr_attribs Number of attributes being requested |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
899 | * @param attribute The names of the attributes |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
900 | */ |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
901 | void mxit_send_suggest_search( struct MXitSession* session, int max, const char* text, unsigned int nr_attrib, const char* attribute[] ) |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
902 | { |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
903 | char data[CP_MAX_PACKET]; |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
904 | int datalen; |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
905 | unsigned int i; |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
906 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
907 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
908 | datalen = g_snprintf( data, sizeof( data ), |
|
31704
5c3b94cb6cba
SuggestContacts packets updated.
Andrew Victor <andrew.victor@mxit.com>
parents:
31703
diff
changeset
|
909 | "ms=%i%c%s%c%i%c%i%c%i", /* inputType \1 input \1 maxSuggestions \1 startIndex \1 numAttributes \1 name0 \1 name1 ... \1 nameN */ |
|
5c3b94cb6cba
SuggestContacts packets updated.
Andrew Victor <andrew.victor@mxit.com>
parents:
31703
diff
changeset
|
910 | CP_SUGGEST_SEARCH, CP_FLD_TERM, text, CP_FLD_TERM, max, CP_FLD_TERM, 0, CP_FLD_TERM, nr_attrib ); |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
911 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
912 | /* add attributes */ |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
913 | for ( i = 0; i < nr_attrib; i++ ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
914 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, attribute[i] ); |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
915 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
916 | /* queue packet for transmission */ |
|
31495
e83a5b4fb633
Was using the incorrect packet type.
Andrew Victor <andrew.victor@mxit.com>
parents:
31492
diff
changeset
|
917 | mxit_queue_packet( session, data, datalen, CP_CMD_SUGGESTCONTACTS ); |
|
31492
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
918 | } |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
919 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
920 | |
|
0341b27934f5
Defined User Search request packets.
Andrew Victor <andrew.victor@mxit.com>
parents:
31491
diff
changeset
|
921 | /*------------------------------------------------------------------------ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
922 | * Send a presence update packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
923 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
924 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
925 | * @param presence The presence (as per MXit types) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
926 | * @param statusmsg The status message (can be NULL) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
927 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
928 | void mxit_send_presence( struct MXitSession* session, int presence, const char* statusmsg ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
929 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
930 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
931 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
932 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
933 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
934 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
935 | "ms=%i%c", /* "ms"=show\1status */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
936 | presence, CP_FLD_TERM |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
937 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
938 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
939 | /* append status message (if one is set) */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
940 | if ( statusmsg ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
941 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%s", statusmsg ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
942 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
943 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
944 | mxit_queue_packet( session, data, datalen, CP_CMD_STATUS ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
945 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
946 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
947 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
948 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
949 | * Send a mood update packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
950 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
951 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
952 | * @param mood The mood (as per MXit types) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
953 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
954 | void mxit_send_mood( struct MXitSession* session, int mood ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
955 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
956 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
957 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
958 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
959 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
960 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
961 | "ms=%i", /* "ms"=mood */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
962 | mood |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
963 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
964 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
965 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
966 | mxit_queue_packet( session, data, datalen, CP_CMD_MOOD ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
967 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
968 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
969 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
970 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
971 | * Send an invite contact packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
972 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
973 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
974 | * @param username The username of the contact being invited |
|
31720
4047faf09005
Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
975 | * @param mxitid Indicates the username is a MXitId. |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
976 | * @param alias Our alias for the contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
977 | * @param groupname Group in which contact should be stored. |
|
31699
3b50aab9ab9a
Add the invite message support to MXit prpl.
Andrew Victor <andrew.victor@mxit.com>
parents:
31501
diff
changeset
|
978 | * @param message Invite message |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
979 | */ |
|
31720
4047faf09005
Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
980 | void mxit_send_invite( struct MXitSession* session, const char* username, gboolean mxitid, const char* alias, const char* groupname, const char* message ) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
981 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
982 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
983 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
984 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
985 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
986 | datalen = g_snprintf( data, sizeof( data ), |
|
31720
4047faf09005
Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
987 | "ms=%s%c%s%c%s%c%i%c%s%c%i", /* "ms"=group \1 username \1 alias \1 type \1 msg \1 isuserid */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
988 | groupname, CP_FLD_TERM, username, CP_FLD_TERM, alias, |
|
31720
4047faf09005
Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
989 | CP_FLD_TERM, MXIT_TYPE_MXIT, CP_FLD_TERM, |
|
4047faf09005
Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
990 | ( message ? message : "" ), CP_FLD_TERM, |
|
4047faf09005
Protocol 6.3 change to SubscribeContact packet.
Andrew Victor <andrew.victor@mxit.com>
parents:
31719
diff
changeset
|
991 | ( mxitid ? 0 : 1 ) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
992 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
993 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
994 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
995 | mxit_queue_packet( session, data, datalen, CP_CMD_INVITE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
996 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
997 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
998 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
999 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1000 | * Send a remove contact packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1001 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1002 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1003 | * @param username The username of the contact being removed |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1004 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1005 | void mxit_send_remove( struct MXitSession* session, const char* username ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1006 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1007 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1008 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1009 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1010 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1011 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1012 | "ms=%s", /* "ms"=username */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1013 | username |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1014 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1015 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1016 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1017 | mxit_queue_packet( session, data, datalen, CP_CMD_REMOVE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1018 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1019 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1020 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1021 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1022 | * Send an accept subscription (invite) packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1023 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1024 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1025 | * @param username The username of the contact being accepted |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1026 | * @param alias Our alias for the contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1027 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1028 | void mxit_send_allow_sub( struct MXitSession* session, const char* username, const char* alias ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1029 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1030 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1031 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1032 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1033 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1034 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1035 | "ms=%s%c%s%c%s", /* "ms"=username\1group\1alias */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1036 | username, CP_FLD_TERM, "", CP_FLD_TERM, alias |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1037 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1038 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1039 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1040 | mxit_queue_packet( session, data, datalen, CP_CMD_ALLOW ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1041 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1042 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1043 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1044 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1045 | * Send an deny subscription (invite) packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1046 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1047 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1048 | * @param username The username of the contact being denied |
|
33706
d6b2b231d0cf
MXit does support including a message when rejecting a subscription request.
Andrew Victor <andrew.victor@mxit.com>
parents:
33679
diff
changeset
|
1049 | * @param reason The message describing the reason for the rejection (can be NULL). |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1050 | */ |
|
33706
d6b2b231d0cf
MXit does support including a message when rejecting a subscription request.
Andrew Victor <andrew.victor@mxit.com>
parents:
33679
diff
changeset
|
1051 | void mxit_send_deny_sub( struct MXitSession* session, const char* username, const char* reason ) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1052 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1053 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1054 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1055 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1056 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1057 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1058 | "ms=%s", /* "ms"=username */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1059 | username |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1060 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1061 | |
|
33706
d6b2b231d0cf
MXit does support including a message when rejecting a subscription request.
Andrew Victor <andrew.victor@mxit.com>
parents:
33679
diff
changeset
|
1062 | /* append reason (if one is set) */ |
|
d6b2b231d0cf
MXit does support including a message when rejecting a subscription request.
Andrew Victor <andrew.victor@mxit.com>
parents:
33679
diff
changeset
|
1063 | if ( reason ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1064 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, reason ); |
|
33706
d6b2b231d0cf
MXit does support including a message when rejecting a subscription request.
Andrew Victor <andrew.victor@mxit.com>
parents:
33679
diff
changeset
|
1065 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1066 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1067 | mxit_queue_packet( session, data, datalen, CP_CMD_DENY ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1068 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1069 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1070 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1071 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1072 | * Send an update contact packet to the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1073 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1074 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1075 | * @param username The username of the contact being denied |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1076 | * @param alias Our alias for the contact |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1077 | * @param groupname Group in which contact should be stored. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1078 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1079 | void mxit_send_update_contact( struct MXitSession* session, const char* username, const char* alias, const char* groupname ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1080 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1081 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1082 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1083 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1084 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1085 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1086 | "ms=%s%c%s%c%s", /* "ms"=groupname\1username\1alias */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1087 | groupname, CP_FLD_TERM, username, CP_FLD_TERM, alias |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1088 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1089 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1090 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1091 | mxit_queue_packet( session, data, datalen, CP_CMD_UPDATE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1092 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1093 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1094 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1095 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1096 | * Send a splash-screen click event packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1097 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1098 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1099 | * @param splashid The identifier of the splash-screen |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1100 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1101 | void mxit_send_splashclick( struct MXitSession* session, const char* splashid ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1102 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1103 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1104 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1105 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1106 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1107 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1108 | "ms=%s", /* "ms"=splashId */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1109 | splashid |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1110 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1111 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1112 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1113 | mxit_queue_packet( session, data, datalen, CP_CMD_SPLASHCLICK ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1114 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1115 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1116 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1117 | /*------------------------------------------------------------------------ |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1118 | * Send a message event packet. |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1119 | * |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1120 | * @param session The MXit session object |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1121 | * @param to The username of the original sender (ie, recipient of the event) |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1122 | * @param id The identifier of the event (received in message) |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1123 | * @param event Identified the type of event |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1124 | */ |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
1125 | void mxit_send_msgevent( struct MXitSession* session, const char* to, const char* id, int event ) |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1126 | { |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1127 | char data[CP_MAX_PACKET]; |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1128 | int datalen; |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1129 | |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1130 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_msgevent: to=%s id=%s event=%i\n", to, id, event ); |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1131 | |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1132 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1133 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1134 | "ms=%s%c%s%c%i", /* "ms"=contactAddress \1 id \1 event */ |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1135 | to, CP_FLD_TERM, id, CP_FLD_TERM, event |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1136 | ); |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1137 | |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1138 | /* queue packet for transmission */ |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1139 | mxit_queue_packet( session, data, datalen, CP_CMD_MSGEVENT ); |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1140 | } |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1141 | |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1142 | |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1143 | /*------------------------------------------------------------------------ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1144 | * Send packet to create a MultiMX room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1145 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1146 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1147 | * @param groupname Name of the room to create |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1148 | * @param nr_usernames Number of users in initial invite |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1149 | * @param usernames The usernames of the users in the initial invite |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1150 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1151 | void mxit_send_groupchat_create( struct MXitSession* session, const char* groupname, int nr_usernames, const char* usernames[] ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1152 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1153 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1154 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1155 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1156 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1157 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1158 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1159 | "ms=%s%c%i", /* "ms"=roomname\1nr_jids\1jid0\1..\1jidN */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1160 | groupname, CP_FLD_TERM, nr_usernames |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1161 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1162 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1163 | /* add usernames */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1164 | for ( i = 0; i < nr_usernames; i++ ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1165 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, usernames[i] ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1166 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1167 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1168 | mxit_queue_packet( session, data, datalen, CP_CMD_GRPCHAT_CREATE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1169 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1170 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1171 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1172 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1173 | * Send packet to invite users to existing MultiMX room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1174 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1175 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1176 | * @param roomid The unique RoomID for the MultiMx room. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1177 | * @param nr_usernames Number of users being invited |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1178 | * @param usernames The usernames of the users being invited |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1179 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1180 | void mxit_send_groupchat_invite( struct MXitSession* session, const char* roomid, int nr_usernames, const char* usernames[] ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1181 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1182 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1183 | int datalen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1184 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1185 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1186 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1187 | datalen = g_snprintf( data, sizeof( data ), |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1188 | "ms=%s%c%i", /* "ms"=roomid\1nr_jids\1jid0\1..\1jidN */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1189 | roomid, CP_FLD_TERM, nr_usernames |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1190 | ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1191 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1192 | /* add usernames */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1193 | for ( i = 0; i < nr_usernames; i++ ) |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1194 | datalen += g_snprintf( data + datalen, sizeof( data ) - datalen, "%c%s", CP_FLD_TERM, usernames[i] ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1195 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1196 | /* queue packet for transmission */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1197 | mxit_queue_packet( session, data, datalen, CP_CMD_GRPCHAT_INVITE ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1198 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1199 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1200 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1201 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1202 | * Send a "send file direct" multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1203 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1204 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1205 | * @param username The username of the recipient |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1206 | * @param filename The name of the file being sent |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1207 | * @param buf The content of the file |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1208 | * @param buflen The length of the file contents |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1209 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1210 | void mxit_send_file( struct MXitSession* session, const char* username, const char* filename, const unsigned char* buf, int buflen ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1211 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1212 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1213 | int datalen = 0; |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1214 | gchar* chunk; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1215 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1216 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1217 | purple_debug_info( MXIT_PLUGIN_ID, "SENDING FILE '%s' of %i bytes to user '%s'\n", filename, buflen, username ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1218 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1219 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1220 | datalen = g_snprintf( data, sizeof( data ), "ms=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1221 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1222 | /* map chunk header over data buffer */ |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1223 | chunk = &data[datalen]; |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1224 | |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1225 | size = mxit_chunk_create_senddirect( chunk_data( chunk ), username, filename, buf, buflen ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1226 | if ( size < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1227 | purple_debug_error( MXIT_PLUGIN_ID, "Error creating senddirect chunk (%i)\n", size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1228 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1229 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1230 | |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1231 | set_chunk_type( chunk, CP_CHUNK_DIRECT_SND ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1232 | set_chunk_length( chunk, size ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1233 | datalen += MXIT_CHUNK_HEADER_SIZE + size; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1234 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1235 | /* send the byte stream to the mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1236 | mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1237 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1238 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1239 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1240 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1241 | * Send a "reject file" multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1242 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1243 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1244 | * @param fileid A unique ID that identifies this file |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1245 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1246 | void mxit_send_file_reject( struct MXitSession* session, const char* fileid ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1247 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1248 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1249 | int datalen = 0; |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1250 | gchar* chunk; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1251 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1252 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1253 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_reject\n" ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1254 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1255 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1256 | datalen = g_snprintf( data, sizeof( data ), "ms=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1257 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1258 | /* map chunk header over data buffer */ |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1259 | chunk = &data[datalen]; |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1260 | |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1261 | size = mxit_chunk_create_reject( chunk_data( chunk ), fileid ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1262 | if ( size < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1263 | purple_debug_error( MXIT_PLUGIN_ID, "Error creating reject chunk (%i)\n", size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1264 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1265 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1266 | |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1267 | set_chunk_type( chunk, CP_CHUNK_REJECT ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1268 | set_chunk_length( chunk, size ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1269 | datalen += MXIT_CHUNK_HEADER_SIZE + size; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1270 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1271 | /* send the byte stream to the mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1272 | mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1273 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1274 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1275 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1276 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1277 | * Send a "get file" multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1278 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1279 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1280 | * @param fileid A unique ID that identifies this file |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1281 | * @param filesize The number of bytes to retrieve |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1282 | * @param offset Offset in file at which to start retrieving |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1283 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1284 | void mxit_send_file_accept( struct MXitSession* session, const char* fileid, int filesize, int offset ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1285 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1286 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1287 | int datalen = 0; |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1288 | gchar* chunk; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1289 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1290 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1291 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_accept\n" ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1292 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1293 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1294 | datalen = g_snprintf( data, sizeof( data ), "ms=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1295 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1296 | /* map chunk header over data buffer */ |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1297 | chunk = &data[datalen]; |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1298 | |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1299 | size = mxit_chunk_create_get( chunk_data(chunk), fileid, filesize, offset ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1300 | if ( size < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1301 | purple_debug_error( MXIT_PLUGIN_ID, "Error creating getfile chunk (%i)\n", size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1302 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1303 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1304 | |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1305 | set_chunk_type( chunk, CP_CHUNK_GET ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1306 | set_chunk_length( chunk, size ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1307 | datalen += MXIT_CHUNK_HEADER_SIZE + size; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1308 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1309 | /* send the byte stream to the mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1310 | mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1311 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1312 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1313 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1314 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1315 | * Send a "received file" multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1316 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1317 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1318 | * @param status The status of the file-transfer |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1319 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1320 | void mxit_send_file_received( struct MXitSession* session, const char* fileid, short status ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1321 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1322 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1323 | int datalen = 0; |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1324 | gchar* chunk; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1325 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1326 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1327 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_send_file_received\n" ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1328 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1329 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1330 | datalen = g_snprintf( data, sizeof( data ), "ms=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1331 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1332 | /* map chunk header over data buffer */ |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1333 | chunk = &data[datalen]; |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1334 | |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1335 | size = mxit_chunk_create_received( chunk_data(chunk), fileid, status ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1336 | if ( size < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1337 | purple_debug_error( MXIT_PLUGIN_ID, "Error creating received chunk (%i)\n", size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1338 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1339 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1340 | |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30203
diff
changeset
|
1341 | set_chunk_type( chunk, CP_CHUNK_RECEIVED ); |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1342 | set_chunk_length( chunk, size ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1343 | datalen += MXIT_CHUNK_HEADER_SIZE + size; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1344 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1345 | /* send the byte stream to the mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1346 | mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1347 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1348 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1349 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1350 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1351 | * Send a "set avatar" multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1352 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1353 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1354 | * @param data The avatar data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1355 | * @param buflen The length of the avatar data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1356 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1357 | void mxit_set_avatar( struct MXitSession* session, const unsigned char* avatar, int avatarlen ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1358 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1359 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1360 | int datalen = 0; |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1361 | gchar* chunk; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1362 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1363 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1364 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_set_avatar: %i bytes\n", avatarlen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1365 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1366 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1367 | datalen = g_snprintf( data, sizeof( data ), "ms=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1368 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1369 | /* map chunk header over data buffer */ |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1370 | chunk = &data[datalen]; |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1371 | |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1372 | size = mxit_chunk_create_set_avatar( chunk_data(chunk), avatar, avatarlen ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1373 | if ( size < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1374 | purple_debug_error( MXIT_PLUGIN_ID, "Error creating set avatar chunk (%i)\n", size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1375 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1376 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1377 | |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1378 | set_chunk_type( chunk, CP_CHUNK_SET_AVATAR ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1379 | set_chunk_length( chunk, size ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1380 | datalen += MXIT_CHUNK_HEADER_SIZE + size; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1381 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1382 | /* send the byte stream to the mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1383 | mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1384 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1385 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1386 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1387 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1388 | * Send a "get avatar" multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1389 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1390 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1391 | * @param mxitId The username who's avatar to request |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1392 | * @param avatarId The id of the avatar image (as string) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1393 | * @param data The avatar data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1394 | * @param buflen The length of the avatar data |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1395 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1396 | void mxit_get_avatar( struct MXitSession* session, const char* mxitId, const char* avatarId ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1397 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1398 | char data[CP_MAX_PACKET]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1399 | int datalen = 0; |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1400 | gchar* chunk; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1401 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1402 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1403 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_get_avatar: %s\n", mxitId ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1404 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1405 | /* convert the packet to a byte stream */ |
|
33830
36a1ce60ce7b
MXit: Rather use g_snprintf().
Andrew Victor <andrew.victor@mxit.com>
parents:
33821
diff
changeset
|
1406 | datalen = g_snprintf( data, sizeof( data ), "ms=" ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1407 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1408 | /* map chunk header over data buffer */ |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1409 | chunk = &data[datalen]; |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1410 | |
|
30788
da428f8d1f97
* removed unneeded variable passing.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
30522
diff
changeset
|
1411 | size = mxit_chunk_create_get_avatar( chunk_data(chunk), mxitId, avatarId ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1412 | if ( size < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1413 | purple_debug_error( MXIT_PLUGIN_ID, "Error creating get avatar chunk (%i)\n", size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1414 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1415 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1416 | |
|
28988
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1417 | set_chunk_type( chunk, CP_CHUNK_GET_AVATAR ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1418 | set_chunk_length( chunk, size ); |
|
e59ddd6a3942
The "packed" attribute on the raw_chunk data-structure seems to be a GCC extension.
Andrew Victor <andrew.victor@mxit.com>
parents:
28961
diff
changeset
|
1419 | datalen += MXIT_CHUNK_HEADER_SIZE + size; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1420 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1421 | /* send the byte stream to the mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1422 | mxit_queue_packet( session, data, datalen, CP_CMD_MEDIA ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1423 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1424 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1425 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1426 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1427 | * Process a login message packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1428 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1429 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1430 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1431 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1432 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1433 | static void mxit_parse_cmd_login( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1434 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1435 | PurpleStatus* status; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1436 | int presence; |
|
29215
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1437 | const char* statusmsg; |
|
33611
c5bf67fcaad0
MXit: Remove all reference to Hidden Number since it's no longer supported.
Andrew Victor <andrew.victor@mxit.com>
parents:
33555
diff
changeset
|
1438 | const char* profilelist[] = { CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1439 | CP_PROFILE_TITLE, CP_PROFILE_FIRSTNAME, CP_PROFILE_LASTNAME, CP_PROFILE_EMAIL, |
|
33555
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
33554
diff
changeset
|
1440 | CP_PROFILE_MOBILENR, CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME, CP_PROFILE_RELATIONSHIP, CP_PROFILE_FLAGS }; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1441 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1442 | purple_account_set_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1443 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1444 | /* we were not yet logged in so we need to complete the login sequence here */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1445 | session->flags |= MXIT_FLAG_LOGGEDIN; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1446 | purple_connection_update_progress( session->con, _( "Successfully Logged In..." ), 3, 4 ); |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1447 | purple_connection_set_state( session->con, PURPLE_CONNECTION_CONNECTED ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1448 | |
|
30167
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1449 | /* save extra info if this is a HTTP connection */ |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1450 | if ( session->http ) { |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1451 | /* save the http server to use for this session */ |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1452 | g_strlcpy( session->http_server, records[1]->fields[3]->data, sizeof( session->http_server ) ); |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1453 | |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1454 | /* save the session id */ |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1455 | session->http_sesid = atoi( records[0]->fields[0]->data ); |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1456 | } |
|
bdf1bd968a91
When logging-in with the HTTP protocol, we need to save the HTTP info
Andrew Victor <andrew.victor@mxit.com>
parents:
29216
diff
changeset
|
1457 | |
|
31718
c2de8a92e675
Due to the new alpha-numeric loginnames and auto-generated userId's the
Andrew Victor <andrew.victor@mxit.com>
parents:
31714
diff
changeset
|
1458 | /* extract UserId (from protocol 5.9) */ |
|
30215
a6860a140f6e
Save the user's MXitId received in the login-response packet to the Session.
Andrew Victor <andrew.victor@mxit.com>
parents:
30214
diff
changeset
|
1459 | if ( records[1]->fcount >= 9 ) |
|
30371
a307496582ab
Implemented new naming conventions
Pieter Loubser <pieter.loubser@mxit.com>
parents:
30369
diff
changeset
|
1460 | session->uid = g_strdup( records[1]->fields[8]->data ); |
|
30215
a6860a140f6e
Save the user's MXitId received in the login-response packet to the Session.
Andrew Victor <andrew.victor@mxit.com>
parents:
30214
diff
changeset
|
1461 | |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1462 | /* extract VoIP server (from protocol 6.2) */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1463 | if ( records[1]->fcount >= 11 ) |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1464 | g_strlcpy( session->voip_server, records[1]->fields[10]->data, sizeof( session->voip_server ) ); |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1465 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1466 | /* display the current splash-screen */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1467 | if ( splash_popup_enabled( session ) ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1468 | splash_display( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1469 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1470 | /* update presence status */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1471 | status = purple_account_get_active_status( session->acc ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1472 | presence = mxit_convert_presence( purple_status_get_id( status ) ); |
|
29215
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1473 | statusmsg = purple_status_get_attr_string( status, "message" ); |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1474 | |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1475 | if ( ( presence != MXIT_PRESENCE_ONLINE ) || ( statusmsg ) ) { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1476 | /* when logging into MXit, your default presence is online. but with the UI, one can change |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1477 | * the presence to whatever. in the case where its changed to a different presence setting |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1478 | * we need to send an update to the server, otherwise the user's presence will be out of |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1479 | * sync between the UI and MXit. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1480 | */ |
|
29215
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1481 | char* statusmsg1 = purple_markup_strip_html( statusmsg ); |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1482 | char* statusmsg2 = g_strndup( statusmsg1, CP_MAX_STATUS_MSG ); |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1483 | |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1484 | mxit_send_presence( session, presence, statusmsg2 ); |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1485 | |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1486 | g_free( statusmsg1 ); |
|
794a1a1acd40
The default state on the MXit server when connecting is Available (with no status message),
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
1487 | g_free( statusmsg2 ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1488 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1489 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1490 | /* retrieve our MXit profile */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1491 | mxit_send_extprofile_request( session, NULL, ARRAY_SIZE( profilelist ), profilelist ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1492 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1493 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1494 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1495 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1496 | * Process a received message packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1497 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1498 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1499 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1500 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1501 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1502 | static void mxit_parse_cmd_message( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1503 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1504 | struct RXMsgData* mx = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1505 | char* message = NULL; |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1506 | char* sender = NULL; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1507 | int msglen = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1508 | int msgflags = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1509 | int msgtype = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1510 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1511 | if ( ( rcount == 1 ) || ( records[0]->fcount < 2 ) || ( records[1]->fcount == 0 ) || ( records[1]->fields[0]->len == 0 ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1512 | /* packet contains no message or an empty message */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1513 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1514 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1515 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1516 | message = records[1]->fields[0]->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1517 | msglen = strlen( message ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1518 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1519 | /* strip off dummy domain */ |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1520 | sender = records[0]->fields[0]->data; |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1521 | mxit_strip_domain( sender ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1522 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1523 | #ifdef DEBUG_PROTOCOL |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1524 | purple_debug_info( MXIT_PLUGIN_ID, "Message received from '%s'\n", sender ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1525 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1526 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1527 | /* decode message flags (if any) */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1528 | if ( records[0]->fcount >= 5 ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1529 | msgflags = atoi( records[0]->fields[4]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1530 | msgtype = atoi( records[0]->fields[2]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1531 | |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1532 | if ( msgflags & CP_MSG_PWD_ENCRYPTED ) { |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1533 | /* this is a password encrypted message. we do not currently support those so ignore it */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1534 | PurpleBuddy* buddy; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1535 | const char* name; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1536 | char msg[128]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1537 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34703
diff
changeset
|
1538 | buddy = purple_blist_find_buddy( session->acc, sender ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1539 | if ( buddy ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1540 | name = purple_buddy_get_alias( buddy ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1541 | else |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1542 | name = sender; |
|
28945
f94c51ec07d9
Mark a bunch of mxit strings for translation
Mark Doliner <markdoliner@pidgin.im>
parents:
28942
diff
changeset
|
1543 | g_snprintf( msg, sizeof( msg ), _( "%s sent you an encrypted message, but it is not supported on this client." ), name ); |
|
f94c51ec07d9
Mark a bunch of mxit strings for translation
Mark Doliner <markdoliner@pidgin.im>
parents:
28942
diff
changeset
|
1544 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Message Error" ), msg ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1545 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1546 | } |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1547 | else if ( msgflags & CP_MSG_TL_ENCRYPTED ) { |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1548 | /* this is a transport-layer encrypted message. */ |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1549 | message = mxit_decrypt_message( session, message ); |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1550 | if ( !message ) { |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1551 | /* could not be decrypted */ |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1552 | serv_got_im( session->con, sender, _( "An encrypted message was received which could not be decrypted." ), PURPLE_MESSAGE_ERROR, time( NULL ) ); |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1553 | return; |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1554 | } |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1555 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1556 | |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1557 | if ( msgflags & CP_MSG_NOTIFY_DELIVERY ) { |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1558 | /* delivery notification is requested */ |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1559 | if ( records[0]->fcount >= 4 ) |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1560 | mxit_send_msgevent( session, sender, records[0]->fields[3]->data, CP_MSGEVENT_DELIVERED ); |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1561 | } |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
1562 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1563 | /* create and initialise new markup struct */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1564 | mx = g_new0( struct RXMsgData, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1565 | mx->msg = g_string_sized_new( msglen ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1566 | mx->session = session; |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1567 | mx->from = g_strdup( sender ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1568 | mx->timestamp = atoi( records[0]->fields[1]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1569 | mx->got_img = FALSE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1570 | mx->chatid = -1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1571 | mx->img_count = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1572 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1573 | /* update list of active chats */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1574 | if ( !find_active_chat( session->active_chats, mx->from ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1575 | session->active_chats = g_list_append( session->active_chats, g_strdup( mx->from ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1576 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1577 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1578 | if ( is_multimx_contact( session, mx->from ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1579 | /* this is a MultiMx chatroom message */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1580 | multimx_message_received( mx, message, msglen, msgtype, msgflags ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1581 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1582 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1583 | mxit_parse_markup( mx, message, msglen, msgtype, msgflags ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1584 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1585 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1586 | /* we are now done parsing the message */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1587 | mx->converted = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1588 | if ( mx->img_count == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1589 | /* we have all the data we need for this message to be displayed now. */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1590 | mxit_show_message( mx ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1591 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1592 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1593 | /* this means there are still images outstanding for this message and |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1594 | * still need to wait for them before we can display the message. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1595 | * so the image received callback function will eventually display |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1596 | * the message. */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1597 | } |
|
33679
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1598 | |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1599 | /* cleanup */ |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1600 | if ( msgflags & CP_MSG_TL_ENCRYPTED ) |
|
4074275c1007
MXit: Backport the password and transport-layer encryption code from 3.0.0.
Andrew Victor <andrew.victor@mxit.com>
parents:
33616
diff
changeset
|
1601 | g_free( message ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1602 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1603 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1604 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1605 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1606 | * Process a received subscription request packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1607 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1608 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1609 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1610 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1611 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1612 | static void mxit_parse_cmd_new_sub( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1613 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1614 | struct contact* contact; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1615 | struct record* rec; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1616 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1617 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1618 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_parse_cmd_new_sub (%i recs)\n", rcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1619 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1620 | for ( i = 0; i < rcount; i++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1621 | rec = records[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1622 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1623 | if ( rec->fcount < 4 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1624 | purple_debug_error( MXIT_PLUGIN_ID, "BAD SUBSCRIPTION RECORD! %i fields\n", rec->fcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1625 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1626 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1627 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1628 | /* build up a new contact info struct */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1629 | contact = g_new0( struct contact, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1630 | |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1631 | g_strlcpy( contact->username, rec->fields[0]->data, sizeof( contact->username ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1632 | mxit_strip_domain( contact->username ); /* remove dummy domain */ |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1633 | g_strlcpy( contact->alias, rec->fields[1]->data, sizeof( contact->alias ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1634 | contact->type = atoi( rec->fields[2]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1635 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1636 | if ( rec->fcount >= 5 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1637 | /* there is a personal invite message attached */ |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32186
diff
changeset
|
1638 | if ( ( rec->fields[4]->data ) && ( *rec->fields[4]->data ) ) |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1639 | contact->msg = strdup( rec->fields[4]->data ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1640 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1641 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1642 | /* handle the subscription */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1643 | if ( contact-> type == MXIT_TYPE_MULTIMX ) { /* subscription to a MultiMX room */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1644 | char* creator = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1645 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1646 | if ( rec->fcount >= 6 ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1647 | creator = rec->fields[5]->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1648 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1649 | multimx_invite( session, contact, creator ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1650 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1651 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1652 | mxit_new_subscription( session, contact ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1653 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1654 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1655 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1656 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1657 | /*------------------------------------------------------------------------ |
|
33893
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1658 | * Parse the received presence value, and ensure that it is supported. |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1659 | * |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1660 | * @param value The received presence value. |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1661 | * @return A valid presence value. |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1662 | */ |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1663 | static short mxit_parse_presence( const char* value ) |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1664 | { |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1665 | short presence = atoi( value ); |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1666 | |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1667 | /* ensure that the presence value is valid */ |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1668 | switch ( presence ) { |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1669 | case MXIT_PRESENCE_OFFLINE : |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1670 | case MXIT_PRESENCE_ONLINE : |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1671 | case MXIT_PRESENCE_AWAY : |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1672 | case MXIT_PRESENCE_DND : |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1673 | return presence; |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1674 | |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1675 | default : |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1676 | return MXIT_PRESENCE_ONLINE; |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1677 | } |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1678 | } |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1679 | |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1680 | |
|
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1681 | /*------------------------------------------------------------------------ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1682 | * Process a received contact update packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1683 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1684 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1685 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1686 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1687 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1688 | static void mxit_parse_cmd_contact( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1689 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1690 | struct contact* contact = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1691 | struct record* rec; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1692 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1693 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1694 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_parse_cmd_contact (%i recs)\n", rcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1695 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1696 | for ( i = 0; i < rcount; i++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1697 | rec = records[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1698 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1699 | if ( rec->fcount < 6 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1700 | purple_debug_error( MXIT_PLUGIN_ID, "BAD CONTACT RECORD! %i fields\n", rec->fcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1701 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1702 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1703 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1704 | /* build up a new contact info struct */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1705 | contact = g_new0( struct contact, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1706 | |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1707 | g_strlcpy( contact->groupname, rec->fields[0]->data, sizeof( contact->groupname ) ); |
|
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1708 | g_strlcpy( contact->username, rec->fields[1]->data, sizeof( contact->username ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1709 | mxit_strip_domain( contact->username ); /* remove dummy domain */ |
|
30521
44e7b773d9d9
For safety, rather use g_strlcpy() and snprintf() where possible.
Andrew Victor <andrew.victor@mxit.com>
parents:
30520
diff
changeset
|
1710 | g_strlcpy( contact->alias, rec->fields[2]->data, sizeof( contact->alias ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1711 | |
|
33893
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1712 | contact->presence = mxit_parse_presence( rec->fields[3]->data ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1713 | contact->type = atoi( rec->fields[4]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1714 | contact->mood = atoi( rec->fields[5]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1715 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1716 | if ( rec->fcount > 6 ) { |
|
30214
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
1717 | /* added in protocol 5.9 - flags & subtype */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1718 | contact->flags = atoi( rec->fields[6]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1719 | contact->subtype = rec->fields[7]->data[0]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1720 | } |
|
30214
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
1721 | if ( rec->fcount > 8 ) { |
|
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
1722 | /* added in protocol 6.0 - reject message */ |
|
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
1723 | contact->msg = g_strdup( rec->fields[8]->data ); |
|
4425992b8c92
* Separate the ClientVersion from the supported ProtocolVersion.
Andrew Victor <andrew.victor@mxit.com>
parents:
30212
diff
changeset
|
1724 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1725 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1726 | /* add the contact to the buddy list */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1727 | if ( contact-> type == MXIT_TYPE_MULTIMX ) /* contact is a MultiMX room */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1728 | multimx_created( session, contact ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1729 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1730 | mxit_update_contact( session, contact ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1731 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1732 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1733 | if ( !( session->flags & MXIT_FLAG_FIRSTROSTER ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1734 | session->flags |= MXIT_FLAG_FIRSTROSTER; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1735 | mxit_update_blist( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1736 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1737 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1738 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1739 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1740 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1741 | * Process a received presence update packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1742 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1743 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1744 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1745 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1746 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1747 | static void mxit_parse_cmd_presence( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1748 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1749 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1750 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1751 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_parse_cmd_presence (%i recs)\n", rcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1752 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1753 | for ( i = 0; i < rcount; i++ ) { |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1754 | struct record* rec = records[i]; |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1755 | int flags = 0; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1756 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1757 | if ( rec->fcount < 6 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1758 | purple_debug_error( MXIT_PLUGIN_ID, "BAD PRESENCE RECORD! %i fields\n", rec->fcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1759 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1760 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1761 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1762 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1763 | * The format of the record is: |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1764 | * contactAddressN \1 presenceN \1 moodN \1 customMoodN \1 statusMsgN \1 avatarIdN [ \1 flagsN ] |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1765 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1766 | mxit_strip_domain( rec->fields[0]->data ); /* contactAddress */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1767 | |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1768 | if ( rec->fcount >= 7 ) /* flags field is included */ |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1769 | flags = atoi( rec->fields[6]->data ); |
|
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1770 | |
|
33893
7395c02a2960
MXit: Ensure that the presence value received from the server is valid.
Andrew Victor <andrew.victor@mxit.com>
parents:
33849
diff
changeset
|
1771 | mxit_update_buddy_presence( session, rec->fields[0]->data, mxit_parse_presence( rec->fields[1]->data ), atoi( rec->fields[2]->data ), |
|
31491
cf74b88370ea
The initial protocol infrastructure for MXit Voice/Video support.
Andrew Victor <andrew.victor@mxit.com>
parents:
31294
diff
changeset
|
1772 | rec->fields[3]->data, rec->fields[4]->data, flags ); |
|
30522
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1773 | mxit_update_buddy_avatar( session, rec->fields[0]->data, rec->fields[5]->data ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1774 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1775 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1776 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1777 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1778 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1779 | * Process a received extended profile packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1780 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1781 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1782 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1783 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1784 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1785 | static void mxit_parse_cmd_extprofile( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1786 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1787 | const char* mxitId = records[0]->fields[0]->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1788 | struct MXitProfile* profile = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1789 | int count; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1790 | int i; |
|
30522
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1791 | const char* avatarId = NULL; |
|
31841
b106342b765f
When retrieving the users current Status-Message via profile packets,
Andrew Victor <andrew.victor@mxit.com>
parents:
31835
diff
changeset
|
1792 | char* statusMsg = NULL; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1793 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1794 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_parse_cmd_extprofile: profile for '%s'\n", mxitId ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1795 | |
|
30520
f9beda76a902
When setting an Avatar image via the Gallery bot, the MXit server pushes
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
1796 | if ( ( records[0]->fields[0]->len == 0 ) || ( session->uid && ( strcmp( session->uid, records[0]->fields[0]->data ) == 0 ) ) ) { |
|
f9beda76a902
When setting an Avatar image via the Gallery bot, the MXit server pushes
Andrew Victor <andrew.victor@mxit.com>
parents:
30519
diff
changeset
|
1797 | /* No UserId or Our UserId provided, so this must be our own profile information */ |
|
30212
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1798 | if ( session->profile == NULL ) |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1799 | session->profile = g_new0( struct MXitProfile, 1 ); |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1800 | profile = session->profile; |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1801 | } |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1802 | else { |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1803 | /* is a buddy's profile */ |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1804 | profile = g_new0( struct MXitProfile, 1 ); |
|
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1805 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1806 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1807 | /* set the count for attributes */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1808 | count = atoi( records[0]->fields[1]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1809 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1810 | for ( i = 0; i < count; i++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1811 | char* fname; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1812 | char* fvalue; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1813 | char* fstatus; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1814 | int f = ( i * 3 ) + 2; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1815 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1816 | fname = records[0]->fields[f]->data; /* field name */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1817 | fvalue = records[0]->fields[f + 1]->data; /* field value */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1818 | fstatus = records[0]->fields[f + 2]->data; /* field status */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1819 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1820 | /* first check the status on the returned attribute */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1821 | if ( fstatus[0] != '0' ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1822 | /* error: attribute requested was NOT found */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1823 | purple_debug_error( MXIT_PLUGIN_ID, "Bad profile status on attribute '%s' \n", fname ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1824 | continue; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1825 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1826 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1827 | if ( strcmp( CP_PROFILE_BIRTHDATE, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1828 | /* birthdate */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1829 | if ( records[0]->fields[f + 1]->len > 10 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1830 | fvalue[10] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1831 | records[0]->fields[f + 1]->len = 10; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1832 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1833 | memcpy( profile->birthday, fvalue, records[0]->fields[f + 1]->len ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1834 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1835 | else if ( strcmp( CP_PROFILE_GENDER, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1836 | /* gender */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1837 | profile->male = ( fvalue[0] == '1' ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1838 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1839 | else if ( strcmp( CP_PROFILE_FULLNAME, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1840 | /* nickname */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1841 | g_strlcpy( profile->nickname, fvalue, sizeof( profile->nickname ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1842 | } |
|
30522
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1843 | else if ( strcmp( CP_PROFILE_STATUS, fname ) == 0 ) { |
|
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1844 | /* status message - just keep a reference to the value */ |
|
31841
b106342b765f
When retrieving the users current Status-Message via profile packets,
Andrew Victor <andrew.victor@mxit.com>
parents:
31835
diff
changeset
|
1845 | statusMsg = g_markup_escape_text( fvalue, -1 ); |
|
30522
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1846 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1847 | else if ( strcmp( CP_PROFILE_AVATAR, fname ) == 0 ) { |
|
30522
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1848 | /* avatar id - just keep a reference to the value */ |
|
5b84b44ed654
Since a buddy's avatar information is distributed as part of their online
Andrew Victor <andrew.victor@mxit.com>
parents:
30521
diff
changeset
|
1849 | avatarId = fvalue; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1850 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1851 | else if ( strcmp( CP_PROFILE_TITLE, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1852 | /* title */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1853 | g_strlcpy( profile->title, fvalue, sizeof( profile->title ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1854 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1855 | else if ( strcmp( CP_PROFILE_FIRSTNAME, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1856 | /* first name */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1857 | g_strlcpy( profile->firstname, fvalue, sizeof( profile->firstname ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1858 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1859 | else if ( strcmp( CP_PROFILE_LASTNAME, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1860 | /* last name */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1861 | g_strlcpy( profile->lastname, fvalue, sizeof( profile->lastname ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1862 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1863 | else if ( strcmp( CP_PROFILE_EMAIL, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1864 | /* email address */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1865 | g_strlcpy( profile->email, fvalue, sizeof( profile->email ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1866 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1867 | else if ( strcmp( CP_PROFILE_MOBILENR, fname ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1868 | /* mobile number */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1869 | g_strlcpy( profile->mobilenr, fvalue, sizeof( profile->mobilenr ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1870 | } |
|
30211
6c81374b615e
* Show the buddy's registration country in their profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30203
diff
changeset
|
1871 | else if ( strcmp( CP_PROFILE_REGCOUNTRY, fname ) == 0 ) { |
|
6c81374b615e
* Show the buddy's registration country in their profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30203
diff
changeset
|
1872 | /* registered country */ |
|
6c81374b615e
* Show the buddy's registration country in their profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30203
diff
changeset
|
1873 | g_strlcpy( profile->regcountry, fvalue, sizeof( profile->regcountry ) ); |
|
6c81374b615e
* Show the buddy's registration country in their profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30203
diff
changeset
|
1874 | } |
|
30519
de9e72446479
A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30371
diff
changeset
|
1875 | else if ( strcmp( CP_PROFILE_FLAGS, fname ) == 0 ) { |
|
de9e72446479
A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30371
diff
changeset
|
1876 | /* profile flags */ |
|
33833
19081badb425
MXit: Replace strtoll() with g_ascii_strtoll().
Andrew Victor <andrew.victor@mxit.com>
parents:
33832
diff
changeset
|
1877 | profile->flags = g_ascii_strtoll( fvalue, NULL, 10 ); |
|
30519
de9e72446479
A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30371
diff
changeset
|
1878 | } |
|
de9e72446479
A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30371
diff
changeset
|
1879 | else if ( strcmp( CP_PROFILE_LASTSEEN, fname ) == 0 ) { |
|
de9e72446479
A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30371
diff
changeset
|
1880 | /* last seen online */ |
|
33833
19081badb425
MXit: Replace strtoll() with g_ascii_strtoll().
Andrew Victor <andrew.victor@mxit.com>
parents:
33832
diff
changeset
|
1881 | profile->lastonline = g_ascii_strtoll( fvalue, NULL, 10 ); |
|
30519
de9e72446479
A few changes to the Profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
30371
diff
changeset
|
1882 | } |
|
31703
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1883 | else if ( strcmp( CP_PROFILE_WHEREAMI, fname ) == 0 ) { |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1884 | /* where am I */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1885 | g_strlcpy( profile->whereami, fvalue, sizeof( profile->whereami ) ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1886 | } |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1887 | else if ( strcmp( CP_PROFILE_ABOUTME, fname ) == 0) { |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1888 | /* about me */ |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1889 | g_strlcpy( profile->aboutme, fvalue, sizeof( profile->aboutme ) ); |
|
7bddd313fb98
Extensions to the user profile.
Andrew Victor <andrew.victor@mxit.com>
parents:
31699
diff
changeset
|
1890 | } |
|
33555
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
33554
diff
changeset
|
1891 | else if ( strcmp( CP_PROFILE_RELATIONSHIP, fname ) == 0) { |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
33554
diff
changeset
|
1892 | /* relatinship status */ |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
33554
diff
changeset
|
1893 | profile->relationship = strtol( fvalue, NULL, 10 ); |
|
8feb2763abe9
MXit: Add support for the Relationship Status profile attribute.
Andrew Victor <andrew.victor@mxit.com>
parents:
33554
diff
changeset
|
1894 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1895 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1896 | /* invalid profile attribute */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1897 | purple_debug_error( MXIT_PLUGIN_ID, "Invalid profile attribute received '%s' \n", fname ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1898 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1899 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1900 | |
|
30212
a813a8aa034e
When our avatar image is changed, the MXit server will push an ExtendedProfile-Response packet
Andrew Victor <andrew.victor@mxit.com>
parents:
30211
diff
changeset
|
1901 | if ( profile != session->profile ) { |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1902 | /* not our own profile */ |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1903 | struct contact* contact = NULL; |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1904 | |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1905 | contact = get_mxit_invite_contact( session, mxitId ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1906 | if ( contact ) { |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1907 | /* this is an invite, so update its profile info */ |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32186
diff
changeset
|
1908 | if ( ( statusMsg ) && ( *statusMsg ) ) { |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1909 | /* update the status message */ |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1910 | if ( contact->statusMsg ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1911 | g_free( contact->statusMsg ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1912 | contact->statusMsg = strdup( statusMsg ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1913 | } |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1914 | else |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1915 | contact->statusMsg = NULL; |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1916 | if ( contact->profile ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1917 | g_free( contact->profile ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1918 | contact->profile = profile; |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32186
diff
changeset
|
1919 | if ( ( avatarId ) && ( *avatarId ) ) { |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1920 | /* avatar must be requested for this invite before we can display it */ |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1921 | mxit_get_avatar( session, mxitId, avatarId ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1922 | if ( contact->avatarId ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1923 | g_free( contact->avatarId ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1924 | contact->avatarId = strdup( avatarId ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1925 | } |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1926 | else { |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1927 | /* display what we have */ |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1928 | contact->avatarId = NULL; |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1929 | mxit_show_profile( session, mxitId, profile ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1930 | } |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1931 | } |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1932 | else { |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1933 | /* this is a contact */ |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1934 | if ( avatarId ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1935 | mxit_update_buddy_avatar( session, mxitId, avatarId ); |
|
31835
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1936 | |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
32186
diff
changeset
|
1937 | if ( ( statusMsg ) && ( *statusMsg ) ) { |
|
31835
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1938 | /* update the status message */ |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1939 | PurpleBuddy* buddy = NULL; |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1940 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34703
diff
changeset
|
1941 | buddy = purple_blist_find_buddy( session->acc, mxitId ); |
|
31835
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1942 | if ( buddy ) { |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1943 | contact = purple_buddy_get_protocol_data( buddy ); |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1944 | if ( contact ) { |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1945 | if ( contact->statusMsg ) |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1946 | g_free( contact->statusMsg ); |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1947 | contact->statusMsg = strdup( statusMsg ); |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1948 | } |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1949 | } |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1950 | } |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1951 | |
|
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
1952 | /* show the profile */ |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1953 | mxit_show_profile( session, mxitId, profile ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1954 | g_free( profile ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
1955 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1956 | } |
|
31841
b106342b765f
When retrieving the users current Status-Message via profile packets,
Andrew Victor <andrew.victor@mxit.com>
parents:
31835
diff
changeset
|
1957 | |
|
b106342b765f
When retrieving the users current Status-Message via profile packets,
Andrew Victor <andrew.victor@mxit.com>
parents:
31835
diff
changeset
|
1958 | g_free( statusMsg ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1959 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1960 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1961 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1962 | /*------------------------------------------------------------------------ |
| 31707 | 1963 | * Process a received suggest-contacts packet. |
| 1964 | * | |
| 1965 | * @param session The MXit session object | |
| 1966 | * @param records The packet's data records | |
| 1967 | * @param rcount The number of data records | |
| 1968 | */ | |
| 1969 | static void mxit_parse_cmd_suggestcontacts( struct MXitSession* session, struct record** records, int rcount ) | |
| 1970 | { | |
|
31711
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1971 | GList* entries = NULL; |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1972 | int searchType; |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1973 | int maxResults; |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1974 | int count; |
| 31707 | 1975 | int i; |
| 1976 | ||
| 1977 | /* | |
| 1978 | * searchType \1 numSuggestions \1 total \1 numAttributes \1 name0 \1 name1 \1 ... \1 nameN \0 | |
| 1979 | * userid \1 contactType \1 value0 \1 value1 ... valueN \0 | |
| 1980 | * ... | |
| 1981 | * userid \1 contactType \1 value0 \1 value1 ... valueN | |
| 1982 | */ | |
| 1983 | ||
|
31711
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1984 | /* the type of results */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1985 | searchType = atoi( records[0]->fields[0]->data ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1986 | |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1987 | /* the maximum number of results */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1988 | maxResults = atoi( records[0]->fields[2]->data ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1989 | |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1990 | /* set the count for attributes */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1991 | count = atoi( records[0]->fields[3]->data ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1992 | |
| 31707 | 1993 | for ( i = 1; i < rcount; i ++ ) { |
| 1994 | struct record* rec = records[i]; | |
| 1995 | struct MXitProfile* profile = g_new0( struct MXitProfile, 1 ); | |
|
31711
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1996 | int j; |
| 31707 | 1997 | |
| 1998 | g_strlcpy( profile->userid, rec->fields[0]->data, sizeof( profile->userid ) ); | |
|
31711
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
1999 | // TODO: ContactType - User or Service |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2000 | |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2001 | for ( j = 0; j < count; j++ ) { |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2002 | char* fname; |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2003 | char* fvalue = ""; |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2004 | |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2005 | fname = records[0]->fields[4 + j]->data; /* field name */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2006 | if ( records[i]->fcount > ( 2 + j ) ) |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2007 | fvalue = records[i]->fields[2 + j]->data; /* field value */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2008 | |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2009 | purple_debug_info( MXIT_PLUGIN_ID, " %s: field='%s' value='%s'\n", profile->userid, fname, fvalue ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2010 | |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2011 | if ( strcmp( CP_PROFILE_BIRTHDATE, fname ) == 0 ) { |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2012 | /* birthdate */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2013 | g_strlcpy( profile->birthday, fvalue, sizeof( profile->birthday ) ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2014 | } |
|
31843
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2015 | else if ( strcmp( CP_PROFILE_FIRSTNAME, fname ) == 0 ) { |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2016 | /* first name */ |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2017 | g_strlcpy( profile->firstname, fvalue, sizeof( profile->firstname ) ); |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2018 | } |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2019 | else if ( strcmp( CP_PROFILE_LASTNAME, fname ) == 0 ) { |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2020 | /* last name */ |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2021 | g_strlcpy( profile->lastname, fvalue, sizeof( profile->lastname ) ); |
|
407e4bcd243b
Also show FirstName and LastName in search-results and friend-suggestions.
Andrew Victor <andrew.victor@mxit.com>
parents:
31841
diff
changeset
|
2022 | } |
|
31711
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2023 | else if ( strcmp( CP_PROFILE_GENDER, fname ) == 0 ) { |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2024 | /* gender */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2025 | profile->male = ( fvalue[0] == '1' ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2026 | } |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2027 | else if ( strcmp( CP_PROFILE_FULLNAME, fname ) == 0 ) { |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2028 | /* nickname */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2029 | g_strlcpy( profile->nickname, fvalue, sizeof( profile->nickname ) ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2030 | } |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2031 | else if ( strcmp( CP_PROFILE_WHEREAMI, fname ) == 0 ) { |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2032 | /* where am I */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2033 | g_strlcpy( profile->whereami, fvalue, sizeof( profile->whereami ) ); |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2034 | } |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2035 | /* ignore other attibutes */ |
|
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2036 | } |
| 31707 | 2037 | |
| 2038 | entries = g_list_append( entries, profile ); | |
| 2039 | } | |
| 2040 | ||
| 2041 | /* display */ | |
|
31711
21baa608701d
* More enhancements to user-searching.
Andrew Victor <andrew.victor@mxit.com>
parents:
31707
diff
changeset
|
2042 | mxit_show_search_results( session, searchType, maxResults, entries ); |
| 31707 | 2043 | |
| 2044 | /* cleanup */ | |
| 2045 | g_list_foreach( entries, (GFunc)g_free, NULL ); | |
| 2046 | } | |
| 2047 | ||
|
33554
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2048 | /*------------------------------------------------------------------------ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2049 | * Process a received message event packet. |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2050 | * |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2051 | * @param session The MXit session object |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2052 | * @param records The packet's data records |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2053 | * @param rcount The number of data records |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2054 | */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2055 | static void mxit_parse_cmd_msgevent( struct MXitSession* session, struct record** records, int rcount ) |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2056 | { |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2057 | int event; |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2058 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2059 | /* |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
2060 | * contactAddress \1 dateTime \1 id \1 event |
|
33554
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2061 | */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2062 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2063 | /* strip off dummy domain */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2064 | mxit_strip_domain( records[0]->fields[0]->data ); |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2065 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2066 | event = atoi( records[0]->fields[3]->data ); |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2067 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2068 | switch ( event ) { |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2069 | case CP_MSGEVENT_TYPING : /* user is typing */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2070 | case CP_MSGEVENT_ANGRY : /* user is typing angrily */ |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34640
diff
changeset
|
2071 | serv_got_typing( session->con, records[0]->fields[0]->data, 0, PURPLE_IM_TYPING ); |
|
33554
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2072 | break; |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2073 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2074 | case CP_MSGEVENT_STOPPED : /* user has stopped typing */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2075 | serv_got_typing_stopped( session->con, records[0]->fields[0]->data ); |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2076 | break; |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2077 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2078 | case CP_MSGEVENT_ERASING : /* user is erasing text */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2079 | case CP_MSGEVENT_DELIVERED : /* message was delivered */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2080 | case CP_MSGEVENT_DISPLAYED : /* message was viewed */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2081 | /* these are currently not supported by libPurple */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2082 | break; |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2083 | |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2084 | default: |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2085 | purple_debug_error( MXIT_PLUGIN_ID, "Unknown message event received (%i)\n", event ); |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2086 | } |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2087 | } |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2088 | |
| 31707 | 2089 | |
| 2090 | /*------------------------------------------------------------------------ | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2091 | * Return the length of a multimedia chunk |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2092 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2093 | * @return The actual chunk data length in bytes |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2094 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2095 | static int get_chunk_len( const char* chunkdata ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2096 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2097 | int* sizeptr; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2098 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2099 | sizeptr = (int*) &chunkdata[1]; /* we skip the first byte (type field) */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2100 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2101 | return ntohl( *sizeptr ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2102 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2103 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2104 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2105 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2106 | * Process a received multimedia packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2107 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2108 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2109 | * @param records The packet's data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2110 | * @param rcount The number of data records |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2111 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2112 | static void mxit_parse_cmd_media( struct MXitSession* session, struct record** records, int rcount ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2113 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2114 | char type; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2115 | int size; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2116 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2117 | type = records[0]->fields[0]->data[0]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2118 | size = get_chunk_len( records[0]->fields[0]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2119 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2120 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_parse_cmd_media (%i records) (%i bytes)\n", rcount, size ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2121 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2122 | /* supported chunked data types */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2123 | switch ( type ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2124 | case CP_CHUNK_CUSTOM : /* custom resource */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2125 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2126 | struct cr_chunk chunk; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2127 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2128 | /* decode the chunked data */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2129 | memset( &chunk, 0, sizeof( struct cr_chunk ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2130 | mxit_chunk_parse_cr( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2131 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2132 | purple_debug_info( MXIT_PLUGIN_ID, "chunk info id=%s handle=%s op=%i\n", chunk.id, chunk.handle, chunk.operation ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2133 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2134 | /* this is a splash-screen operation */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2135 | if ( strcmp( chunk.handle, HANDLE_SPLASH2 ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2136 | if ( chunk.operation == CR_OP_UPDATE ) { /* update the splash-screen */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2137 | struct splash_chunk *splash = chunk.resources->data; // TODO: Fix - assuming 1st resource is splash |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2138 | gboolean clickable = ( g_list_length( chunk.resources ) > 1 ); // TODO: Fix - if 2 resources, then is clickable |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2139 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2140 | if ( splash != NULL ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2141 | splash_update( session, chunk.id, splash->data, splash->datalen, clickable ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2142 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2143 | else if ( chunk.operation == CR_OP_REMOVE ) /* remove the splash-screen */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2144 | splash_remove( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2145 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2146 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2147 | /* cleanup custom resources */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2148 | g_list_foreach( chunk.resources, (GFunc)g_free, NULL ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2149 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2150 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2151 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2152 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2153 | case CP_CHUNK_OFFER : /* file offer */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2154 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2155 | struct offerfile_chunk chunk; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2156 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2157 | /* decode the chunked data */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2158 | memset( &chunk, 0, sizeof( struct offerfile_chunk ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2159 | mxit_chunk_parse_offer( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2160 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2161 | /* process the offer */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2162 | mxit_xfer_rx_offer( session, chunk.username, chunk.filename, chunk.filesize, chunk.fileid ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2163 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2164 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2165 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2166 | case CP_CHUNK_GET : /* get file response */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2167 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2168 | struct getfile_chunk chunk; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2169 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2170 | /* decode the chunked data */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2171 | memset( &chunk, 0, sizeof( struct getfile_chunk ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2172 | mxit_chunk_parse_get( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2173 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2174 | /* process the getfile */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2175 | mxit_xfer_rx_file( session, chunk.fileid, chunk.data, chunk.length ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2176 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2177 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2178 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2179 | case CP_CHUNK_GET_AVATAR : /* get avatars */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2180 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2181 | struct getavatar_chunk chunk; |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2182 | struct contact* contact = NULL; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2183 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2184 | /* decode the chunked data */ |
|
31722
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2185 | memset( &chunk, 0, sizeof( struct getavatar_chunk ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2186 | mxit_chunk_parse_get_avatar( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2187 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2188 | /* update avatar image */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2189 | if ( chunk.data ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2190 | purple_debug_info( MXIT_PLUGIN_ID, "updating avatar for contact '%s'\n", chunk.mxitid ); |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2191 | |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2192 | contact = get_mxit_invite_contact( session, chunk.mxitid ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2193 | if ( contact ) { |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2194 | /* this is an invite (add image to the internal image store) */ |
| 33661 | 2195 | contact->imgid = purple_imgstore_new_with_id( g_memdup( chunk.data, chunk.length ), chunk.length, NULL ); |
|
31835
ba0a391c3911
* show a contact's status message when his offline (with get-info)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31722
diff
changeset
|
2196 | /* show the profile */ |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2197 | mxit_show_profile( session, chunk.mxitid, contact->profile ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2198 | } |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2199 | else { |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2200 | /* this is a contact's avatar, so update it */ |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
2201 | purple_buddy_icons_set_for_user( session->acc, chunk.mxitid, g_memdup( chunk.data, chunk.length ), chunk.length, chunk.avatarid ); |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2202 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2203 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2204 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2205 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2206 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2207 | case CP_CHUNK_SET_AVATAR : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2208 | /* this is a reply packet to a set avatar request. no action is required */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2209 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2210 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2211 | case CP_CHUNK_DIRECT_SND : |
|
31722
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2212 | /* this is a ack for a file send. */ |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2213 | { |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2214 | struct sendfile_chunk chunk; |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2215 | |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2216 | memset( &chunk, 0, sizeof( struct sendfile_chunk ) ); |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2217 | mxit_chunk_parse_sendfile( &records[0]->fields[0]->data[sizeof( char ) + sizeof( int )], records[0]->fields[0]->len, &chunk ); |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2218 | |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2219 | purple_debug_info( MXIT_PLUGIN_ID, "file-send send to '%s' [status=%i message='%s']\n", chunk.username, chunk.status, chunk.statusmsg ); |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2220 | |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2221 | if ( chunk.status != 0 ) /* not success */ |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2222 | mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "File Send Failed" ), chunk.statusmsg ); |
|
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2223 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2224 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2225 | |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
30203
diff
changeset
|
2226 | case CP_CHUNK_RECEIVED : |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2227 | /* this is a ack for a file received. no action is required */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2228 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2229 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2230 | default : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2231 | purple_debug_error( MXIT_PLUGIN_ID, "Unsupported chunked data packet type received (%i)\n", type ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2232 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2233 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2234 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2235 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2236 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2237 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2238 | * Handle a redirect sent from the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2239 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2240 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2241 | * @param url The redirect information |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2242 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2243 | static void mxit_perform_redirect( struct MXitSession* session, const char* url ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2244 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2245 | gchar** parts; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2246 | gchar** host; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2247 | int type; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2248 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2249 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_perform_redirect: %s\n", url ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2250 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2251 | /* tokenize the URL string */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2252 | parts = g_strsplit( url, ";", 0 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2253 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2254 | /* Part 1: protocol://host:port */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2255 | host = g_strsplit( parts[0], ":", 4 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2256 | if ( strcmp( host[0], "socket" ) == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2257 | /* redirect to a MXit socket proxy */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2258 | g_strlcpy( session->server, &host[1][2], sizeof( session->server ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2259 | session->port = atoi( host[2] ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2260 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2261 | else { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2262 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Cannot perform redirect using the specified protocol" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2263 | goto redirect_fail; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2264 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2265 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2266 | /* Part 2: type of redirect */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2267 | type = atoi( parts[1] ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2268 | if ( type == CP_REDIRECT_PERMANENT ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2269 | /* permanent redirect, so save new MXit server and port */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2270 | purple_account_set_string( session->acc, MXIT_CONFIG_SERVER_ADDR, session->server ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2271 | purple_account_set_int( session->acc, MXIT_CONFIG_SERVER_PORT, session->port ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2272 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2273 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2274 | /* Part 3: message (optional) */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2275 | if ( parts[2] != NULL ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2276 | purple_connection_notice( session->con, parts[2] ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2277 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2278 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_perform_redirect: %s redirect to %s:%i\n", |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2279 | ( type == CP_REDIRECT_PERMANENT ) ? "Permanent" : "Temporary", session->server, session->port ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2280 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2281 | /* perform the re-connect to the new MXit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2282 | mxit_reconnect( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2283 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2284 | redirect_fail: |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2285 | g_strfreev( parts ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2286 | g_strfreev( host ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2287 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2288 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2289 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2290 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2291 | * Process a success response received from the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2292 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2293 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2294 | * @param packet The received packet |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2295 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2296 | static int process_success_response( struct MXitSession* session, struct rx_packet* packet ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2297 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2298 | /* ignore ping/poll packets */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2299 | if ( ( packet->cmd != CP_CMD_PING ) && ( packet->cmd != CP_CMD_POLL ) ) |
|
31501
4a96cf0f177a
* do not send requests too fast to the mxit server or they will start ignoring you.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31499
diff
changeset
|
2300 | session->last_rx = mxit_now_milli(); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2301 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2302 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2303 | * when we pass the packet records to the next level for parsing |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2304 | * we minus 3 records because 1) the first record is the packet |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2305 | * type 2) packet reply status 3) the last record is bogus |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2306 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2307 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2308 | /* packet command */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2309 | switch ( packet->cmd ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2310 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2311 | case CP_CMD_REGISTER : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2312 | /* fall through, when registeration successful, MXit will auto login */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2313 | case CP_CMD_LOGIN : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2314 | /* login response */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2315 | if ( !( session->flags & MXIT_FLAG_LOGGEDIN ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2316 | mxit_parse_cmd_login( session, &packet->records[2], packet->rcount - 3 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2317 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2318 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2319 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2320 | case CP_CMD_LOGOUT : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2321 | /* logout response */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2322 | session->flags &= ~MXIT_FLAG_LOGGEDIN; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2323 | purple_account_disconnect( session->acc ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2324 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2325 | /* note: |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2326 | * we do not prompt the user here for a reconnect, because this could be the user |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2327 | * logging in with his phone. so we just disconnect the account otherwise |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2328 | * mxit will start to bounce between the phone and pidgin. also could be a valid |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2329 | * disconnect selected by the user. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2330 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2331 | return -1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2332 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2333 | case CP_CMD_CONTACT : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2334 | /* contact update */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2335 | mxit_parse_cmd_contact( session, &packet->records[2], packet->rcount - 3 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2336 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2337 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2338 | case CP_CMD_PRESENCE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2339 | /* presence update */ |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33830
diff
changeset
|
2340 | mxit_parse_cmd_presence( session, &packet->records[2], packet->rcount - 3 ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2341 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2342 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2343 | case CP_CMD_RX_MSG : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2344 | /* incoming message (no bogus record) */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2345 | mxit_parse_cmd_message( session, &packet->records[2], packet->rcount - 2 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2346 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2347 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2348 | case CP_CMD_NEW_SUB : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2349 | /* new subscription request */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2350 | mxit_parse_cmd_new_sub( session, &packet->records[2], packet->rcount - 3 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2351 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2352 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2353 | case CP_CMD_MEDIA : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2354 | /* multi-media message */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2355 | mxit_parse_cmd_media( session, &packet->records[2], packet->rcount - 2 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2356 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2357 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2358 | case CP_CMD_EXTPROFILE_GET : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2359 | /* profile update */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2360 | mxit_parse_cmd_extprofile( session, &packet->records[2], packet->rcount - 2 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2361 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2362 | |
| 31707 | 2363 | case CP_CMD_SUGGESTCONTACTS : |
| 2364 | /* suggest contacts */ | |
| 2365 | mxit_parse_cmd_suggestcontacts( session, &packet->records[2], packet->rcount - 2 ); | |
| 2366 | break; | |
| 2367 | ||
|
33554
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2368 | case CP_CMD_GOT_MSGEVENT : |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2369 | /* received message event */ |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2370 | mxit_parse_cmd_msgevent( session, &packet->records[2], packet->rcount - 2 ); |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2371 | break; |
|
4a87c767a037
MXit: Add support for typing notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
31847
diff
changeset
|
2372 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2373 | case CP_CMD_MOOD : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2374 | /* mood update */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2375 | case CP_CMD_UPDATE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2376 | /* update contact information */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2377 | case CP_CMD_ALLOW : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2378 | /* allow subscription ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2379 | case CP_CMD_DENY : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2380 | /* deny subscription ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2381 | case CP_CMD_INVITE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2382 | /* invite contact ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2383 | case CP_CMD_REMOVE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2384 | /* remove contact ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2385 | case CP_CMD_TX_MSG : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2386 | /* outgoing message ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2387 | case CP_CMD_STATUS : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2388 | /* presence update ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2389 | case CP_CMD_GRPCHAT_CREATE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2390 | /* create groupchat */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2391 | case CP_CMD_GRPCHAT_INVITE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2392 | /* groupchat invite */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2393 | case CP_CMD_PING : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2394 | /* ping reply */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2395 | case CP_CMD_POLL : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2396 | /* HTTP poll reply */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2397 | case CP_CMD_EXTPROFILE_SET : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2398 | /* profile update */ |
|
31722
9e4e8315893d
* Handle response to SendFile chunk packet, and display the error message
Andrew Victor <andrew.victor@mxit.com>
parents:
31720
diff
changeset
|
2399 | // TODO: Protocol 6.2 indicates status for each attribute, and current value. |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2400 | case CP_CMD_SPLASHCLICK : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2401 | /* splash-screen clickthrough */ |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
2402 | case CP_CMD_MSGEVENT : |
|
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
2403 | /* event message */ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2404 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2405 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2406 | default : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2407 | /* unknown packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2408 | purple_debug_error( MXIT_PLUGIN_ID, "Received unknown client packet (cmd = %i)\n", packet->cmd ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2409 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2410 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2411 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2412 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2413 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2414 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2415 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2416 | * Process an error response received from the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2417 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2418 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2419 | * @param packet The received packet |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2420 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2421 | static int process_error_response( struct MXitSession* session, struct rx_packet* packet ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2422 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2423 | char errmsg[256]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2424 | const char* errdesc; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2425 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2426 | /* set the error description to be shown to the user */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2427 | if ( packet->errmsg ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2428 | errdesc = packet->errmsg; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2429 | else |
|
28945
f94c51ec07d9
Mark a bunch of mxit strings for translation
Mark Doliner <markdoliner@pidgin.im>
parents:
28942
diff
changeset
|
2430 | errdesc = _( "An internal MXit server error occurred." ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2431 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2432 | purple_debug_info( MXIT_PLUGIN_ID, "Error Reply %i:%s\n", packet->errcode, errdesc ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2433 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2434 | if ( packet->errcode == MXIT_ERRCODE_LOGGEDOUT ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2435 | /* we are not currently logged in, so we need to reconnect */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2436 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( errdesc ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2437 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2438 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2439 | /* packet command */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2440 | switch ( packet->cmd ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2441 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2442 | case CP_CMD_REGISTER : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2443 | case CP_CMD_LOGIN : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2444 | if ( packet->errcode == MXIT_ERRCODE_REDIRECT ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2445 | mxit_perform_redirect( session, packet->errmsg ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2446 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2447 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2448 | else { |
|
33821
062af32ae5b7
It is safer to use g_snprintf() for text strings.
Andrew Victor <andrew.victor@mxit.com>
parents:
33820
diff
changeset
|
2449 | g_snprintf( errmsg, sizeof( errmsg ), _( "Login error: %s (%i)" ), errdesc, packet->errcode ); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2450 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, errmsg ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2451 | return -1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2452 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2453 | case CP_CMD_LOGOUT : |
|
33821
062af32ae5b7
It is safer to use g_snprintf() for text strings.
Andrew Victor <andrew.victor@mxit.com>
parents:
33820
diff
changeset
|
2454 | g_snprintf( errmsg, sizeof( errmsg ), _( "Logout error: %s (%i)" ), errdesc, packet->errcode ); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2455 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NAME_IN_USE, _( errmsg ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2456 | return -1; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2457 | case CP_CMD_CONTACT : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2458 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Contact Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2459 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2460 | case CP_CMD_RX_MSG : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2461 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Message Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2462 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2463 | case CP_CMD_TX_MSG : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2464 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Message Sending Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2465 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2466 | case CP_CMD_STATUS : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2467 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Status Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2468 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2469 | case CP_CMD_MOOD : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2470 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Mood Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2471 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2472 | case CP_CMD_KICK : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2473 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2474 | * the MXit server sends this packet if we were idle for too long. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2475 | * to stop the server from closing this connection we need to resend |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2476 | * the login packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2477 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2478 | mxit_send_login( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2479 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2480 | case CP_CMD_INVITE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2481 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Invitation Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2482 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2483 | case CP_CMD_REMOVE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2484 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Contact Removal Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2485 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2486 | case CP_CMD_ALLOW : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2487 | case CP_CMD_DENY : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2488 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Subscription Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2489 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2490 | case CP_CMD_UPDATE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2491 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Contact Update Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2492 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2493 | case CP_CMD_MEDIA : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2494 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "File Transfer Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2495 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2496 | case CP_CMD_GRPCHAT_CREATE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2497 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Cannot create MultiMx room" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2498 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2499 | case CP_CMD_GRPCHAT_INVITE : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2500 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "MultiMx Invitation Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2501 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2502 | case CP_CMD_EXTPROFILE_GET : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2503 | case CP_CMD_EXTPROFILE_SET : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2504 | mxit_popup( PURPLE_NOTIFY_MSG_WARNING, _( "Profile Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2505 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2506 | case CP_CMD_SPLASHCLICK : |
|
30203
05aeaba91b78
Add support for message delivery notification.
Andrew Victor <andrew.victor@mxit.com>
parents:
30167
diff
changeset
|
2507 | case CP_CMD_MSGEVENT : |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2508 | /* ignore error */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2509 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2510 | case CP_CMD_PING : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2511 | case CP_CMD_POLL : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2512 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2513 | default : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2514 | mxit_popup( PURPLE_NOTIFY_MSG_ERROR, _( "Error" ), _( errdesc ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2515 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2516 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2517 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2518 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2519 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2520 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2521 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2522 | /*======================================================================================================================== |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2523 | * Low-level Packet receive |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2524 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2525 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2526 | #ifdef DEBUG_PROTOCOL |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2527 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2528 | * Dump a received packet structure. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2529 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2530 | * @param p The received packet |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2531 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2532 | static void dump_packet( struct rx_packet* p ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2533 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2534 | struct record* r = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2535 | struct field* f = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2536 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2537 | int j; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2538 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2539 | purple_debug_info( MXIT_PLUGIN_ID, "PACKET DUMP: (%i records)\n", p->rcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2540 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2541 | for ( i = 0; i < p->rcount; i++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2542 | r = p->records[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2543 | purple_debug_info( MXIT_PLUGIN_ID, "RECORD: (%i fields)\n", r->fcount ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2544 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2545 | for ( j = 0; j < r->fcount; j++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2546 | f = r->fields[j]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2547 | purple_debug_info( MXIT_PLUGIN_ID, "\tFIELD: (len=%i) '%s' \n", f->len, f->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2548 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2549 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2550 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2551 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2552 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2553 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2554 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2555 | * Free up memory used by a packet structure. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2556 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2557 | * @param p The received packet |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2558 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2559 | static void free_rx_packet( struct rx_packet* p ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2560 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2561 | struct record* r = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2562 | struct field* f = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2563 | int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2564 | int j; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2565 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2566 | for ( i = 0; i < p->rcount; i++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2567 | r = p->records[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2568 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2569 | for ( j = 0; j < r->fcount; j++ ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2570 | g_free( f ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2571 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2572 | g_free( r->fields ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2573 | g_free( r ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2574 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2575 | g_free( p->records ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2576 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2577 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2578 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2579 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2580 | * Add a new field to a record. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2581 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2582 | * @param r Parent record object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2583 | * @return The newly created field |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2584 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2585 | static struct field* add_field( struct record* r ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2586 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2587 | struct field* field; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2588 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2589 | field = g_new0( struct field, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2590 | |
|
31799
bd26fd17a865
mxit/protocols: Use g_realloc, as these are freed with g_free
Paul Aurich <darkrain42@pidgin.im>
parents:
31722
diff
changeset
|
2591 | r->fields = g_realloc( r->fields, sizeof( struct field* ) * ( r->fcount + 1 ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2592 | r->fields[r->fcount] = field; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2593 | r->fcount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2594 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2595 | return field; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2596 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2597 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2598 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2599 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2600 | * Add a new record to a packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2601 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2602 | * @param p The packet object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2603 | * @return The newly created record |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2604 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2605 | static struct record* add_record( struct rx_packet* p ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2606 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2607 | struct record* rec; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2608 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2609 | rec = g_new0( struct record, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2610 | |
|
31799
bd26fd17a865
mxit/protocols: Use g_realloc, as these are freed with g_free
Paul Aurich <darkrain42@pidgin.im>
parents:
31722
diff
changeset
|
2611 | p->records = g_realloc( p->records, sizeof( struct record* ) * ( p->rcount + 1 ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2612 | p->records[p->rcount] = rec; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2613 | p->rcount++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2614 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2615 | return rec; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2616 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2617 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2618 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2619 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2620 | * Parse the received byte stream into a proper client protocol packet. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2621 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2622 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2623 | * @return Success (0) or Failure (!0) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2624 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2625 | int mxit_parse_packet( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2626 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2627 | struct rx_packet packet; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2628 | struct record* rec; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2629 | struct field* field; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2630 | gboolean pbreak; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2631 | unsigned int i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2632 | int res = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2633 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2634 | #ifdef DEBUG_PROTOCOL |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2635 | purple_debug_info( MXIT_PLUGIN_ID, "Received packet (%i bytes)\n", session->rx_i ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2636 | dump_bytes( session, session->rx_dbuf, session->rx_i ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2637 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2638 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2639 | i = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2640 | while ( i < session->rx_i ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2641 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2642 | /* create first record and field */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2643 | rec = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2644 | field = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2645 | memset( &packet, 0x00, sizeof( struct rx_packet ) ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2646 | rec = add_record( &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2647 | pbreak = FALSE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2648 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2649 | /* break up the received packet into fields and records for easy parsing */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2650 | while ( ( i < session->rx_i ) && ( !pbreak ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2651 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2652 | switch ( session->rx_dbuf[i] ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2653 | case CP_SOCK_REC_TERM : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2654 | /* new record */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2655 | if ( packet.rcount == 1 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2656 | /* packet command */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2657 | packet.cmd = atoi( packet.records[0]->fields[0]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2658 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2659 | else if ( packet.rcount == 2 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2660 | /* special case: binary multimedia packets should not be parsed here */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2661 | if ( packet.cmd == CP_CMD_MEDIA ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2662 | /* add the chunked to new record */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2663 | rec = add_record( &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2664 | field = add_field( rec ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2665 | field->data = &session->rx_dbuf[i + 1]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2666 | field->len = session->rx_i - i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2667 | /* now skip the binary data */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2668 | res = get_chunk_len( field->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2669 | /* determine if we have more packets */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2670 | if ( res + 6 + i < session->rx_i ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2671 | /* we have more than one packet in this stream */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2672 | i += res + 6; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2673 | pbreak = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2674 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2675 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2676 | i = session->rx_i; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2677 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2678 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2679 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2680 | else if ( !field ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2681 | field = add_field( rec ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2682 | field->data = &session->rx_dbuf[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2683 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2684 | session->rx_dbuf[i] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2685 | rec = add_record( &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2686 | field = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2687 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2688 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2689 | case CP_FLD_TERM : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2690 | /* new field */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2691 | session->rx_dbuf[i] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2692 | if ( !field ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2693 | field = add_field( rec ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2694 | field->data = &session->rx_dbuf[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2695 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2696 | field = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2697 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2698 | case CP_PKT_TERM : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2699 | /* packet is done! */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2700 | session->rx_dbuf[i] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2701 | pbreak = TRUE; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2702 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2703 | default : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2704 | /* skip non special characters */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2705 | if ( !field ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2706 | field = add_field( rec ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2707 | field->data = &session->rx_dbuf[i]; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2708 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2709 | field->len++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2710 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2711 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2712 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2713 | i++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2714 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2715 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2716 | if ( packet.rcount < 2 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2717 | /* bad packet */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2718 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "Invalid packet received from MXit." ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2719 | free_rx_packet( &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2720 | continue; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2721 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2722 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2723 | session->rx_dbuf[session->rx_i] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2724 | packet.errcode = atoi( packet.records[1]->fields[0]->data ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2725 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2726 | purple_debug_info( MXIT_PLUGIN_ID, "Packet received CMD:%i (%i)\n", packet.cmd, packet.errcode ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2727 | #ifdef DEBUG_PROTOCOL |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2728 | /* debug */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2729 | dump_packet( &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2730 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2731 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2732 | /* reset the out ack */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2733 | if ( session->outack == packet.cmd ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2734 | /* outstanding ack received from mxit server */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2735 | session->outack = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2736 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2737 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2738 | /* check packet status */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2739 | if ( packet.errcode != MXIT_ERRCODE_SUCCESS ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2740 | /* error reply! */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2741 | if ( ( packet.records[1]->fcount > 1 ) && ( packet.records[1]->fields[1]->data ) ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2742 | packet.errmsg = packet.records[1]->fields[1]->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2743 | else |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2744 | packet.errmsg = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2745 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2746 | res = process_error_response( session, &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2747 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2748 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2749 | /* success reply! */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2750 | res = process_success_response( session, &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2751 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2752 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2753 | /* free up the packet resources */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2754 | free_rx_packet( &packet ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2755 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2756 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2757 | if ( session->outack == 0 ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2758 | mxit_manage_queue( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2759 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2760 | return res; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2761 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2762 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2763 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2764 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2765 | * Callback when data is received from the MXit server. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2766 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2767 | * @param user_data The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2768 | * @param source The file-descriptor on which data was received |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2769 | * @param cond Condition which caused the callback (PURPLE_INPUT_READ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2770 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2771 | void mxit_cb_rx( gpointer user_data, gint source, PurpleInputCondition cond ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2772 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2773 | struct MXitSession* session = (struct MXitSession*) user_data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2774 | char ch; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2775 | int res; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2776 | int len; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2777 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2778 | if ( session->rx_state == RX_STATE_RLEN ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2779 | /* we are reading in the packet length */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2780 | len = read( session->fd, &ch, 1 ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2781 | if ( len < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2782 | /* connection error */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2783 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x01)" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2784 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2785 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2786 | else if ( len == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2787 | /* connection closed */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2788 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x02)" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2789 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2790 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2791 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2792 | /* byte read */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2793 | if ( ch == CP_REC_TERM ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2794 | /* the end of the length record found */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2795 | session->rx_lbuf[session->rx_i] = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2796 | session->rx_res = atoi( &session->rx_lbuf[3] ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2797 | if ( session->rx_res > CP_MAX_PACKET ) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2798 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x03)" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2799 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2800 | session->rx_state = RX_STATE_DATA; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2801 | session->rx_i = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2802 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2803 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2804 | /* still part of the packet length record */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2805 | session->rx_lbuf[session->rx_i] = ch; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2806 | session->rx_i++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2807 | if ( session->rx_i >= sizeof( session->rx_lbuf ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2808 | /* malformed packet length record (too long) */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2809 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x04)" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2810 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2811 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2812 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2813 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2814 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2815 | else if ( session->rx_state == RX_STATE_DATA ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2816 | /* we are reading in the packet data */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2817 | len = read( session->fd, &session->rx_dbuf[session->rx_i], session->rx_res ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2818 | if ( len < 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2819 | /* connection error */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2820 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x05)" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2821 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2822 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2823 | else if ( len == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2824 | /* connection closed */ |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
32154
diff
changeset
|
2825 | purple_connection_error( session->con, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, _( "A connection error occurred to MXit. (read stage 0x06)" ) ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2826 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2827 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2828 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2829 | /* data read */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2830 | session->rx_i += len; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2831 | session->rx_res -= len; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2832 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2833 | if ( session->rx_res == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2834 | /* ok, so now we have read in the whole packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2835 | session->rx_state = RX_STATE_PROC; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2836 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2837 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2838 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2839 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2840 | if ( session->rx_state == RX_STATE_PROC ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2841 | /* we have a full packet, which we now need to process */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2842 | res = mxit_parse_packet( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2843 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2844 | if ( res == 0 ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2845 | /* we are still logged in */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2846 | session->rx_state = RX_STATE_RLEN; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2847 | session->rx_res = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2848 | session->rx_i = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2849 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2850 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2851 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2852 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2853 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2854 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2855 | * Log the user off MXit and close the connection |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2856 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2857 | * @param session The MXit session object |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2858 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2859 | void mxit_close_connection( struct MXitSession* session ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2860 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2861 | purple_debug_info( MXIT_PLUGIN_ID, "mxit_close_connection\n" ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2862 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2863 | if ( !( session->flags & MXIT_FLAG_CONNECTED ) ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2864 | /* we are already closed */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2865 | return; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2866 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2867 | else if ( session->flags & MXIT_FLAG_LOGGEDIN ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2868 | /* we are currently logged in so we need to send a logout packet */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2869 | if ( !session->http ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2870 | mxit_send_logout( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2871 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2872 | session->flags &= ~MXIT_FLAG_LOGGEDIN; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2873 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2874 | session->flags &= ~MXIT_FLAG_CONNECTED; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2875 | |
|
33815
094a4b10e8d5
Maintain list of outstanding async calls made so that it can be canceled when the account is disconnected.
Pieter Loubser <pieter.loubser@mxit.com>
parents:
33807
diff
changeset
|
2876 | /* cancel all outstanding async calls */ |
|
34269
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
2877 | purple_http_connection_set_destroy(session->async_http_reqs); |
|
26b4c9a54166
HTTP: Use PurpleHttpConnectionSet instead of GSLists of PurpleHttpConnection structs
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
2878 | session->async_http_reqs = NULL; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2879 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2880 | /* remove the input cb function */ |
|
32680
91e18f0129dc
MXit: Move "inpa" input watcher from PurpleConnection into PurpleConnection->proto_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32623
diff
changeset
|
2881 | if ( session->inpa ) { |
|
91e18f0129dc
MXit: Move "inpa" input watcher from PurpleConnection into PurpleConnection->proto_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32623
diff
changeset
|
2882 | purple_input_remove( session->inpa ); |
|
91e18f0129dc
MXit: Move "inpa" input watcher from PurpleConnection into PurpleConnection->proto_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32623
diff
changeset
|
2883 | session->inpa = 0; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2884 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2885 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2886 | /* remove HTTP poll timer */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2887 | if ( session->http_timer_id > 0 ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2888 | purple_timeout_remove( session->http_timer_id ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2889 | |
|
31706
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2890 | /* remove slow queue manager timer */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2891 | if ( session->q_slow_timer_id > 0 ) |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2892 | purple_timeout_remove( session->q_slow_timer_id ); |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2893 | |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2894 | /* remove fast queue manager timer */ |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2895 | if ( session->q_fast_timer_id > 0 ) |
|
a86fb9e2b8d4
* fixed crash caused by entering a wrong password (tx queue management)
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31704
diff
changeset
|
2896 | purple_timeout_remove( session->q_fast_timer_id ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2897 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2898 | /* remove all groupchat rooms */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2899 | while ( session->rooms != NULL ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2900 | struct multimx* multimx = (struct multimx *) session->rooms->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2901 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2902 | session->rooms = g_list_remove( session->rooms, multimx ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2903 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2904 | free( multimx ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2905 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2906 | g_list_free( session->rooms ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2907 | session->rooms = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2908 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2909 | /* remove all rx chats names */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2910 | while ( session->active_chats != NULL ) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2911 | char* chat = (char*) session->active_chats->data; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2912 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2913 | session->active_chats = g_list_remove( session->active_chats, chat ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2914 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2915 | g_free( chat ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2916 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2917 | g_list_free( session->active_chats ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2918 | session->active_chats = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2919 | |
|
31714
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2920 | /* clear the internal invites */ |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2921 | while ( session->invites != NULL ) { |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2922 | struct contact* contact = (struct contact*) session->invites->data; |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2923 | |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2924 | session->invites = g_list_remove( session->invites, contact ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2925 | |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2926 | if ( contact->msg ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2927 | g_free( contact->msg ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2928 | if ( contact->statusMsg ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2929 | g_free( contact->statusMsg ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2930 | if ( contact->profile ) |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2931 | g_free( contact->profile ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2932 | g_free( contact ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2933 | } |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2934 | g_list_free( session->invites ); |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2935 | session->invites = NULL; |
|
4fb9e95a7c4f
* extended the profile information shown for pending invites
Pieter Loubser <pieter.loubser@mxit.com>
parents:
31711
diff
changeset
|
2936 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2937 | /* free profile information */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2938 | if ( session->profile ) |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2939 | free( session->profile ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2940 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2941 | /* free custom emoticons */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2942 | mxit_free_emoticon_cache( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2943 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2944 | /* free allocated memory */ |
|
30371
a307496582ab
Implemented new naming conventions
Pieter Loubser <pieter.loubser@mxit.com>
parents:
30369
diff
changeset
|
2945 | if ( session->uid ) |
|
a307496582ab
Implemented new naming conventions
Pieter Loubser <pieter.loubser@mxit.com>
parents:
30369
diff
changeset
|
2946 | g_free( session->uid ); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2947 | g_free( session->encpwd ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2948 | session->encpwd = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2949 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2950 | /* flush all the commands still in the queue */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2951 | flush_queue( session ); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2952 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2953 |