Mercurial > pidgin
annotate libpurple/protocols/myspace/myspace.c @ 17656:61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
cached buddy list information. Allows getting info for not only online users,
but also offline users, and users not on buddy list (by username or uid).
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Thu, 21 Jun 2007 05:50:41 +0000 |
parents | 60f614824207 |
children | f903418147f6 |
rev | line source |
---|---|
16394 | 1 /* MySpaceIM Protocol Plugin |
2 * | |
3 * \author Jeff Connelly | |
4 * | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@homing.pidgin.im> |
16394 | 6 * |
16396 | 7 * Based on Purple's "C Plugin HOWTO" hello world example. |
16394 | 8 * |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
9 * Code also drawn from mockprpl: |
16396 | 10 * http://snarfed.org/space/purple+mock+protocol+plugin |
16394 | 11 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
12 * | |
16396 | 13 * and some constructs also based on existing Purple plugins, which are: |
14 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> | |
16394 | 15 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
16 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> | |
17 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
18 * | |
19 * This program is free software; you can redistribute it and/or modify | |
20 * it under the terms of the GNU General Public License as published by | |
21 * the Free Software Foundation; either version 2 of the License, or | |
22 * (at your option) any later version. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, | |
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 * GNU General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program; if not, write to the Free Software | |
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
32 */ | |
33 | |
16396 | 34 #define PURPLE_PLUGIN |
16394 | 35 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
36 #include "message.h" |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
37 #include "persist.h" |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
38 #include "myspace.h" |
16394 | 39 |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
40 /** |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
41 * Load the plugin. |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
42 */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
43 gboolean msim_load(PurplePlugin *plugin) |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
44 { |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
45 #ifdef MSIM_USE_PURPLE_RC4 |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
46 /* If compiled to use RC4 from libpurple, check if it is really there. */ |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
47 if (!purple_ciphers_find_cipher("rc4")) |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
48 { |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
49 purple_debug_error("msim", "compiled with MSIM_USE_PURPLE_RC4 but rc4 not in libpurple - not loading MySpaceIM plugin!\n"); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
50 purple_notify_error(plugin, _("Missing Cipher"), |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
51 _("The RC4 cipher could not be found"), |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
52 _("Recompile without MSIM_USE_PURPLE_RC4, or upgrade " |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
53 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
54 "plugin will not be loaded.")); |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
55 return FALSE; |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
56 } |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
57 #endif |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
58 return TRUE; |
16394 | 59 } |
60 | |
61 /** | |
62 * Get possible user status types. Based on mockprpl. | |
63 * | |
64 * @return GList of status types. | |
65 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
66 GList *msim_status_types(PurpleAccount *acct) |
16394 | 67 { |
68 GList *types; | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
69 PurpleStatusType *status; |
16394 | 70 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
71 purple_debug_info("myspace", "returning status types\n"); |
16394 | 72 |
73 types = NULL; | |
74 | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
75 /* TODO: Fix these: |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
76 * |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
77 * g_log: purple_presence_get_active_status: assertion `presence != NULL' failed |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
78 * g_log: purple_status_get_name: assertion `status != NULL' failed |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
79 * [...] |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
80 * |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
81 * and |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
82 * g_log: purple_presence_set_status_active: assertion `status != NULL' failed |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
83 * [...] |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
84 */ |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
85 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
86 types = g_list_append(types, status); |
16394 | 87 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
88 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
89 types = g_list_append(types, status); |
16394 | 90 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
91 status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
92 types = g_list_append(types, status); |
16394 | 93 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
94 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
95 types = g_list_append(types, status); |
16394 | 96 |
97 return types; | |
98 } | |
99 | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
100 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
101 * Return the icon name for a buddy and account. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
102 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
103 * @param acct The account to find the icon for, or NULL for protocol icon. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
104 * @param buddy The buddy to find the icon for, or NULL for the account icon. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
105 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
106 * @return The base icon name string. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
107 */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
108 const gchar *msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
109 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
110 /* Use a MySpace icon submitted by hbons at |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
111 * http://developer.pidgin.im/wiki/MySpaceIM. */ |
16406
f62023eddfc6
Add and use MySpaceIM icon uploaded by hbons (48x48 original and resized 22x22 and 16x16 versions).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
112 return "myspace"; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
113 } |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
114 |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
115 /* Replacement codes to be replaced with associated replacement text, |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
116 * used for protocol message escaping / unescaping. */ |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
117 static gchar* msim_replacement_code[] = { "/1", "/2", NULL }; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
118 static gchar* msim_replacement_text[] = { "/", "\\", NULL }; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
119 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
120 /** |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
121 * Unescape or escape a protocol message. |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
122 * |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
123 * @param msg The message to be unescaped or escaped. WILL BE FREED. |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
124 * @param escape TRUE to escape, FALSE to unescape. |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
125 * |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
126 * @return The unescaped or escaped message. Caller must g_free(). |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
127 */ |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
128 gchar *msim_unescape_or_escape(gchar *msg, gboolean escape) |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
129 { |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
130 gchar *tmp, *code, *text; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
131 guint i; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
132 |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
133 /* Replace each code in msim_replacement_code with |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
134 * corresponding entry in msim_replacement_text. */ |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
135 for (i = 0; (code = msim_replacement_code[i]) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
136 && (text = msim_replacement_text[i]); ++i) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
137 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
138 if (escape) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
139 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
140 tmp = str_replace(msg, text, code); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
141 } |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
142 else |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
143 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
144 tmp = str_replace(msg, code, text); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
145 } |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
146 g_free(msg); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
147 msg = tmp; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
148 } |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
149 |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
150 return msg; |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
151 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
152 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
153 /** |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
154 * Escape a protocol message. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
155 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
156 * @return The escaped message. Caller must g_free(). |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
157 */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
158 gchar *msim_escape(const gchar *msg) |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
159 { |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
160 return msim_unescape_or_escape(g_strdup(msg), TRUE); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
161 } |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
162 |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
163 gchar *msim_unescape(const gchar *msg) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
164 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
165 return msim_unescape_or_escape(g_strdup(msg), FALSE); |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
166 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
167 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
168 /** |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
169 * Replace 'old' with 'new' in 'str'. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
170 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
171 * @param str The original string. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
172 * @param old The substring of 'str' to replace. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
173 * @param new The replacement for 'old' within 'str'. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
174 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
175 * @return A _new_ string, based on 'str', with 'old' replaced |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
176 * by 'new'. Must be g_free()'d by caller. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
177 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
178 * This string replace method is based on |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
179 * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
180 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
181 */ |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
182 gchar *str_replace(const gchar *str, const gchar *old, const gchar *new) |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
183 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
184 gchar **items; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
185 gchar *ret; |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
186 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
187 items = g_strsplit(str, old, -1); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
188 ret = g_strjoinv(new, items); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
189 g_free(items); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
190 return ret; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
191 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
192 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
193 |
16735
52357f6392a4
Add partial implementation of MsimMessage (not used anywhere yet).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
194 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
195 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
196 #ifdef MSIM_DEBUG_MSG |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
197 void print_hash_item(gpointer key, gpointer value, gpointer user_data) |
16394 | 198 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
199 purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
16394 | 200 } |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
201 #endif |
16394 | 202 |
203 /** | |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
204 * Send raw data to the server. |
16394 | 205 * |
206 * @param session | |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
207 * @param msg The raw data to send. |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
208 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
209 * @return TRUE if succeeded, FALSE if not. |
16394 | 210 * |
211 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
212 gboolean msim_send_raw(MsimSession *session, const gchar *msg) |
16394 | 213 { |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
214 int total_bytes_sent, total_bytes; |
16730
a2e9890a57e0
Implement msim_pack(), msim_sendh(), msim_send().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16729
diff
changeset
|
215 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
216 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
16394 | 217 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
218 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
219 g_return_val_if_fail(msg != NULL, FALSE); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
220 |
16394 | 221 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
222 /* Loop until all data is sent, or a failure occurs. */ |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
223 total_bytes_sent = 0; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
224 total_bytes = strlen(msg); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
225 do |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
226 { |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
227 int bytes_sent; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
228 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
229 bytes_sent = send(session->fd, msg + total_bytes_sent, |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
230 total_bytes - total_bytes_sent, 0); |
16394 | 231 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
232 if (bytes_sent < 0) |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
233 { |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
234 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
235 msg, g_strerror(errno)); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
236 return FALSE; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
237 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
238 total_bytes_sent += bytes_sent; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
239 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
240 } while(total_bytes_sent < total_bytes); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
241 return TRUE; |
16394 | 242 } |
243 | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
244 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
245 * Start logging in to the MSIM servers. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
246 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
247 * @param acct Account information to use to login. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
248 */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
249 void msim_login(PurpleAccount *acct) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
250 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
251 PurpleConnection *gc; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
252 const gchar *host; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
253 int port; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
254 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
255 g_return_if_fail(acct != NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
256 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
257 purple_debug_info("myspace", "logging in %s\n", acct->username); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
258 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
259 gc = purple_account_get_connection(acct); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
260 gc->proto_data = msim_session_new(acct); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
261 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
262 /* 1. connect to server */ |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
263 purple_connection_update_progress(gc, _("Connecting"), |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
264 0, /* which connection step this is */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
265 4); /* total number of steps */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
266 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
267 host = purple_account_get_string(acct, "server", MSIM_SERVER); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
268 port = purple_account_get_int(acct, "port", MSIM_PORT); |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
269 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
270 /* From purple.sf.net/api: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
271 * """Note that this function name can be misleading--although it is called |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
272 * "proxy connect," it is used for establishing any outgoing TCP connection, |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
273 * whether through a proxy or not.""" */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
274 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
275 /* Calls msim_connect_cb when connected. */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
276 if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
277 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
278 /* TODO: try other ports if in auto mode, then save |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
279 * working port and try that first next time. */ |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
280 purple_connection_error(gc, _("Couldn't create socket")); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
281 return; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
282 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
283 } |
16394 | 284 /** |
285 * Process a login challenge, sending a response. | |
286 * | |
287 * @param session | |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
288 * @param msg Login challenge message. |
16394 | 289 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
290 * @return TRUE if successful, FALSE if not |
16394 | 291 */ |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
292 gboolean msim_login_challenge(MsimSession *session, MsimMessage *msg) |
16394 | 293 { |
16396 | 294 PurpleAccount *account; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
295 const gchar *response; |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
296 guint response_len; |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
297 gchar *nc; |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
298 gsize nc_len; |
16394 | 299 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
300 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
301 g_return_val_if_fail(msg != NULL, FALSE); |
16394 | 302 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
303 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
16394 | 304 |
305 account = session->account; | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
306 |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
307 g_return_val_if_fail(account != NULL, FALSE); |
16394 | 308 |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
309 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
16394 | 310 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
311 purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
16394 | 312 |
313 if (nc_len != 0x40) | |
314 { | |
16396 | 315 purple_debug_info("msim", "bad nc length: %x != 0x40\n", nc_len); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
316 purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
317 return FALSE; |
16394 | 318 } |
319 | |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
320 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
16394 | 321 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
322 response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
16394 | 323 |
324 g_free(nc); | |
325 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
326 return msim_send(session, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
327 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
328 /* This is actually user's email address. */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
329 "username", MSIM_TYPE_STRING, g_strdup(account->username), |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
330 /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
331 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
332 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
333 "reconn", MSIM_TYPE_INTEGER, 0, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
334 "status", MSIM_TYPE_INTEGER, 100, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
335 "id", MSIM_TYPE_INTEGER, 1, |
16731
2e0bd3e6f2c7
Incomplete attempt at using msim_send() instead of msim_send_raw().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16730
diff
changeset
|
336 NULL); |
16394 | 337 } |
338 | |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
339 #ifndef MSIM_USE_PURPLE_RC4 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
340 /* No RC4 in this version of libpurple, so bring our own. */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
341 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
342 /* |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
343 Unix SMB/CIFS implementation. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
344 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
345 a partial implementation of RC4 designed for use in the |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
346 SMB authentication protocol |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
347 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
348 Copyright (C) Andrew Tridgell 1998 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
349 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
350 $Id: crypt-rc4.c 12116 2004-09-27 23:29:22Z guy $ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
351 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
352 This program is free software; you can redistribute it and/or modify |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
353 it under the terms of the GNU General Public License as published by |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
354 the Free Software Foundation; either version 2 of the License, or |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
355 (at your option) any later version. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
356 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
357 This program is distributed in the hope that it will be useful, |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
358 but WITHOUT ANY WARRANTY; without even the implied warranty of |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
359 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
360 GNU General Public License for more details. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
361 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
362 You should have received a copy of the GNU General Public License |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
363 along with this program; if not, write to the Free Software |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
364 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
365 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
366 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
367 Modified by Jeff Connelly for MySpaceIM Gaim plugin. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
368 */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
369 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
370 #include <glib.h> |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
371 #include <string.h> |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
372 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
373 /* Perform RC4 on a block of data using specified key. "data" is a pointer |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
374 to the block to be processed. Output is written to same memory as input, |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
375 so caller may need to make a copy before calling this function, since |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
376 the input will be overwritten. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
377 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
378 Taken from Samba source code. Modified to allow us to maintain state |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
379 between calls to crypt_rc4. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
380 */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
381 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
382 void crypt_rc4_init(rc4_state_struct *rc4_state, |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
383 const guchar *key, int key_len) |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
384 { |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
385 int ind; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
386 unsigned gchar j = 0; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
387 unsigned gchar *s_box; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
388 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
389 memset(rc4_state, 0, sizeof(rc4_state_struct)); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
390 s_box = rc4_state->s_box; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
391 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
392 for (ind = 0; ind < 256; ind++) |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
393 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
394 s_box[ind] = (guchar)ind; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
395 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
396 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
397 for( ind = 0; ind < 256; ind++) |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
398 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
399 guchar tc; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
400 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
401 j += (s_box[ind] + key[ind%key_len]); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
402 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
403 tc = s_box[ind]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
404 s_box[ind] = s_box[j]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
405 s_box[j] = tc; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
406 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
407 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
408 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
409 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
410 void crypt_rc4(rc4_state_struct *rc4_state, guchar *data, int data_len) |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
411 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
412 guchar *s_box; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
413 guchar index_i; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
414 guchar index_j; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
415 int ind; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
416 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
417 /* retrieve current state from the state struct (so we can resume where |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
418 we left off) */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
419 index_i = rc4_state->index_i; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
420 index_j = rc4_state->index_j; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
421 s_box = rc4_state->s_box; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
422 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
423 for( ind = 0; ind < data_len; ind++) |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
424 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
425 guchar tc; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
426 guchar t; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
427 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
428 index_i++; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
429 index_j += s_box[index_i]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
430 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
431 tc = s_box[index_i]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
432 s_box[index_i] = s_box[index_j]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
433 s_box[index_j] = tc; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
434 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
435 t = s_box[index_i] + s_box[index_j]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
436 data[ind] = data[ind] ^ s_box[t]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
437 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
438 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
439 /* Store the updated state */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
440 rc4_state->index_i = index_i; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
441 rc4_state->index_j = index_j; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
442 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
443 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
444 #endif /* !MSIM_USE_PURPLE_RC4 */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
445 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
446 |
16394 | 447 /** |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
448 * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
449 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
450 * @param nonce The base64 encoded nonce ('nc') field from the server. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
451 * @param email User's email address (used as login name). |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
452 * @param password User's cleartext password. |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
453 * @param response_len Will be written with response length. |
16394 | 454 * |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
455 * @return Binary login challenge response, ready to send to the server. Must be g_free()'d |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
456 * when finished. |
16394 | 457 */ |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
458 const gchar *msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
459 const gchar *email, const gchar *password, guint *response_len) |
16394 | 460 { |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
461 PurpleCipherContext *key_context; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
462 PurpleCipher *sha1; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
463 #ifdef MSIM_USE_PURPLE_RC4 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
464 PurpleCipherContext *rc4; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
465 #else |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
466 rc4_state_struct rc4; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
467 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
468 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
469 guchar hash_pw[HASH_SIZE]; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
470 guchar key[HASH_SIZE]; |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
471 gchar *password_utf16le; |
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
472 guchar *data; |
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
473 guchar *data_out; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
474 size_t data_len, data_out_len; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
475 gsize conv_bytes_read, conv_bytes_written; |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
476 GError *conv_error; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
477 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
478 int i; |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
479 #endif |
16394 | 480 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
481 /* Convert ASCII password to UTF16 little endian */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
482 purple_debug_info("msim", "converting password to UTF-16LE\n"); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
483 conv_error = NULL; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
484 password_utf16le = g_convert(password, -1, "UTF-16LE", "UTF-8", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
485 &conv_bytes_read, &conv_bytes_written, &conv_error); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
486 g_assert(conv_bytes_read == strlen(password)); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
487 if (conv_error != NULL) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
488 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
489 purple_debug_error("msim", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
490 "g_convert password UTF8->UTF16LE failed: %s", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
491 conv_error->message); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
492 g_error_free(conv_error); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
493 } |
16394 | 494 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
495 /* Compute password hash */ |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
496 purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
497 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
498 g_free(password_utf16le); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
499 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
500 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
501 purple_debug_info("msim", "pwhash = "); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
502 for (i = 0; i < sizeof(hash_pw); i++) |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
503 purple_debug_info("msim", "%.2x ", hash_pw[i]); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
504 purple_debug_info("msim", "\n"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
505 #endif |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
506 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
507 /* key = sha1(sha1(pw) + nonce2) */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
508 sha1 = purple_ciphers_find_cipher("sha1"); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
509 key_context = purple_cipher_context_new(sha1, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
510 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
511 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
512 purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
513 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
514 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
515 purple_debug_info("msim", "key = "); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
516 for (i = 0; i < sizeof(key); i++) |
16394 | 517 { |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
518 purple_debug_info("msim", "%.2x ", key[i]); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
519 } |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
520 purple_debug_info("msim", "\n"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
521 #endif |
16394 | 522 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
523 #ifdef MSIM_USE_PURPLE_RC4 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
524 rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
16394 | 525 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
526 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
527 * but only first 0x10 used for the RC4 key. */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
528 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
529 purple_cipher_context_set_key(rc4, key); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
530 #endif |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
531 |
17652
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
532 /* TODO: obtain IPs of network interfaces */ |
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
533 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
534 /* rc4 encrypt: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
535 * nonce1+email+IP list */ |
17652
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
536 |
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
537 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
538 data = g_new0(guchar, data_len); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
539 memcpy(data, nonce, NONCE_SIZE); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
540 memcpy(data + NONCE_SIZE, email, strlen(email)); |
17652
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
541 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
542 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
543 #ifdef MSIM_USE_PURPLE_RC4 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
544 data_out = g_new0(guchar, data_len); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
545 |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
546 purple_cipher_context_encrypt(rc4, (const guchar *)data, |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
547 data_len, data_out, &data_out_len); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
548 purple_cipher_context_destroy(rc4); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
549 #else |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
550 /* Use our own RC4 code */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
551 purple_debug_info("msim", "Using non-purple RC4 cipher code in this version\n"); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
552 crypt_rc4_init(&rc4, key, 0x10); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
553 crypt_rc4(&rc4, data, data_len); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
554 data_out_len = data_len; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
555 data_out = data; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
556 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
557 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
558 g_assert(data_out_len == data_len); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
559 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
560 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
561 purple_debug_info("msim", "response=<%s>\n", data_out); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
562 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
563 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
564 *response_len = data_out_len; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
565 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
566 return (const gchar *)data_out; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
567 } |
16394 | 568 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
569 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
570 * Schedule an IM to be sent once the user ID is looked up. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
571 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
572 * @param gc Connection. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
573 * @param who A user id, email, or username to send the message to. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
574 * @param message Instant message text to send. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
575 * @param flags Flags. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
576 * |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
577 * @return 1 if successful or postponed, -1 if failed |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
578 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
579 * Allows sending to a user by username, email address, or userid. If |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
580 * a username or email address is given, the userid must be looked up. |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
581 * This function does that by calling msim_postprocess_outgoing(). |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
582 */ |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
583 int msim_send_im(PurpleConnection *gc, const gchar *who, |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
584 const gchar *message, PurpleMessageFlags flags) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
585 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
586 MsimSession *session; |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
587 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
588 g_return_val_if_fail(gc != NULL, 0); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
589 g_return_val_if_fail(who != NULL, 0); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
590 g_return_val_if_fail(message != NULL, 0); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
591 |
17300
176b1ba4bafe
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17299
diff
changeset
|
592 /* 'flags' has many options, not used here. */ |
176b1ba4bafe
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17299
diff
changeset
|
593 |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
594 session = gc->proto_data; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
595 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
596 if (msim_send_bm(session, who, message, MSIM_BM_INSTANT)) |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
597 { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
598 /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
599 * return 1 even if the message could not be sent, since I don't know if |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
600 * it has failed yet--because the IM is only sent after the userid is |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
601 * retrieved from the server (which happens after this function returns). |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
602 */ |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
603 return 1; |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
604 } else { |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
605 return -1; |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
606 } |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
607 /* |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
608 * In MySpace, you login with your email address, but don't talk to other |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
609 * users using their email address. So there is currently an asymmetry in the |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
610 * IM windows when using this plugin: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
611 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
612 * you@example.com: hello |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
613 * some_other_user: what's going on? |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
614 * you@example.com: just coding a prpl |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
615 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
616 * TODO: Make the sent IM's appear as from the user's username, instead of |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
617 * their email address. Purple uses the login (in MSIM, the email)--change this. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
618 */ |
16394 | 619 } |
620 | |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
621 /** Send a buddy message of a given type. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
622 * |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
623 * @param session |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
624 * @param who Username to send message to. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
625 * @param text Message text to send. Not freed; will be copied. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
626 * @param type A MSIM_BM_* constant. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
627 * |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
628 * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
629 */ |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
630 gboolean msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, int type) |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
631 { |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
632 gboolean rc; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
633 MsimMessage *msg; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
634 const gchar *from_username; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
635 |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
636 from_username = session->account->username; |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
637 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
638 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
639 type, from_username, who, text); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
640 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
641 msg = msim_msg_new(TRUE, |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
642 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
643 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
644 /* 't' will be inserted here */ |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
645 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
646 "msg", MSIM_TYPE_STRING, g_strdup(text), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
647 NULL); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
648 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
649 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
650 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
651 msim_msg_free(msg); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
652 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
653 return rc; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
654 } |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
655 |
16394 | 656 /** |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
657 * Handle an incoming instant message. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
658 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
659 * @param session The session |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
660 * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
661 * Should also contain username in _username from preprocessing. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
662 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
663 * @return TRUE if successful. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
664 */ |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
665 gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
666 { |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
667 gchar *username; |
17655
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
668 gchar *msg_text; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
669 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
670 username = msim_msg_get_string(msg, "_username"); |
17655
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
671 msg_text = msim_msg_get_string(msg, "msg"); |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
672 |
17655
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
673 /* TODO: replace msim-markup with gtkimhtml. */ |
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
674 |
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
675 serv_got_im(session->gc, username, msg_text, PURPLE_MESSAGE_RECV, time(NULL)); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
676 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
677 g_free(username); |
17655
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
678 g_free(msg_text); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
679 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
680 return TRUE; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
681 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
682 |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
683 /** |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
684 * Handle an unrecognized message. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
685 */ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
686 void msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
687 { |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
688 /* TODO: Some more context, outwardly equivalent to a backtrace, for helping figure |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
689 * out what this msg is for. But not too much information so that a user |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
690 * posting this dump reveals confidential information. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
691 */ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
692 /* TODO: dump unknown msgs to file, so user can send them to me |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
693 * if they wish, to help add support for new messages (inspired |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
694 * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
695 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
696 purple_debug_info("msim", "Unrecognized message on account for %s\n", session->account->username); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
697 if (note) |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
698 { |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
699 purple_debug_info("msim", "(Note: %s)\n", note); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
700 } |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
701 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
702 msim_msg_dump("Unrecognized message dump: %s\n", msg); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
703 } |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
704 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
705 /** |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
706 * Handle an incoming action message. |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
707 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
708 * @param session |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
709 * @param msg |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
710 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
711 * @return TRUE if successful. |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
712 * |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
713 * UNTESTED |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
714 */ |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
715 gboolean msim_incoming_action(MsimSession *session, MsimMessage *msg) |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
716 { |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
717 gchar *msg_text, *username; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
718 gboolean rc; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
719 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
720 msg_text = msim_msg_get_string(msg, "msg"); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
721 username = msim_msg_get_string(msg, "_username"); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
722 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
723 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", msg_text, username); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
724 |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
725 if (strcmp(msg_text, "%typing%") == 0) |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
726 { |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
727 /* TODO: find out if msim repeatedly sends typing messages, so we can give it a timeout. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
728 * Right now, there does seem to be an inordinately amount of time between typing/ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
729 * stopped-typing notifications. */ |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
730 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
731 rc = TRUE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
732 } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
733 serv_got_typing_stopped(session->gc, username); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
734 rc = TRUE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
735 } else { |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
736 msim_unrecognized(session, msg, "got to msim_incoming_action but unrecognized value for 'msg'"); |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
737 rc = FALSE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
738 } |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
739 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
740 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
741 g_free(msg_text); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
742 g_free(username); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
743 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
744 return rc; |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
745 } |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
746 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
747 /** |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
748 * Handle when our user starts or stops typing to another user. |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
749 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
750 * @param gc |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
751 * @param name The buddy name to which our user is typing to |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
752 * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
753 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
754 */ |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
755 unsigned int msim_send_typing(PurpleConnection *gc, const gchar *name, PurpleTypingState state) |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
756 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
757 const gchar *typing_str; |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
758 MsimSession *session; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
759 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
760 session = (MsimSession *)gc->proto_data; |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
761 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
762 switch (state) |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
763 { |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
764 case PURPLE_TYPING: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
765 typing_str = "%typing%"; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
766 break; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
767 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
768 case PURPLE_TYPED: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
769 case PURPLE_NOT_TYPING: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
770 default: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
771 typing_str = "%stoptyping%"; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
772 break; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
773 } |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
774 |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
775 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
776 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
777 return 0; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
778 } |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
779 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
780 /** Callback for msim_get_info(), for when user info is received. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
781 void msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, gpointer data) |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
782 { |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
783 GHashTable *body; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
784 gchar *body_str; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
785 MsimMessage *msg; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
786 gchar *user; |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
787 PurpleNotifyUserInfo *user_info; |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
788 PurpleBuddy *buddy; |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
789 gchar *song; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
790 |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
791 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
792 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for orthogonality. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
793 msg = (MsimMessage *)data; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
794 user = g_strdup(msim_msg_get_string(msg, "user")); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
795 purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
796 msim_msg_free(msg); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
797 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
798 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
799 body_str = msim_msg_get_string(user_info_msg, "body"); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
800 body = msim_parse_body(body_str); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
801 g_free(body_str); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
802 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
803 buddy = purple_find_buddy(session->account, user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
804 /* Note: don't assume buddy is non-NULL; will be if lookup random user not on blist. */ |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
805 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
806 user_info = purple_notify_user_info_new(); |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
807 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
808 /* Identification */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
809 purple_notify_user_info_add_pair(user_info, _("User"), user); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
810 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
811 /* note: g_hash_table_lookup does not create a new string! */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
812 purple_notify_user_info_add_pair(user_info, _("User ID"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
813 g_strdup(g_hash_table_lookup(body, "UserID"))); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
814 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
815 /* a/s/l...the vitals */ |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
816 purple_notify_user_info_add_pair(user_info, _("Age"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
817 g_strdup(g_hash_table_lookup(body, "Age"))); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
818 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
819 purple_notify_user_info_add_pair(user_info, _("Gender"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
820 g_strdup(g_hash_table_lookup(body, "Gender"))); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
821 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
822 purple_notify_user_info_add_pair(user_info, _("Location"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
823 g_strdup(g_hash_table_lookup(body, "Location"))); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
824 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
825 /* Other information */ |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
826 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
827 /* Headline comes from buddy status messages */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
828 if (buddy && purple_blist_node_get_string(&buddy->node, "Headline")) |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
829 purple_notify_user_info_add_pair(user_info, "Headline", |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
830 purple_blist_node_get_string(&buddy->node, "Headline")); |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
831 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
832 song = g_strdup_printf("%s - %s", |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
833 (gchar *)g_hash_table_lookup(body, "BandName"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
834 (gchar *)g_hash_table_lookup(body, "SongName")); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
835 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
836 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
837 purple_notify_user_info_add_pair(user_info, _("Song"), song); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
838 /* Do not free song - used by user_info. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
839 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
840 /* Total friends only available if looked up by uid, not username. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
841 if (g_hash_table_lookup(body, "TotalFriends")) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
842 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
843 g_strdup(g_hash_table_lookup(body, "TotalFriends"))); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
844 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
845 purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
846 purple_debug_info("msim", "msim_get_info_cb: username=%s\n", user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
847 //purple_notify_user_info_destroy(user_info); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
848 /* Do not free username, since it will be used by user_info. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
849 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
850 //g_hash_table_destroy(body); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
851 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
852 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
853 /** Retrieve a user's profile. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
854 void msim_get_info(PurpleConnection *gc, const gchar *user) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
855 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
856 PurpleBuddy *buddy; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
857 MsimSession *session; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
858 guint uid; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
859 gchar *user_to_lookup; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
860 MsimMessage *user_msg; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
861 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
862 session = (MsimSession *)gc->proto_data; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
863 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
864 /* Obtain uid of buddy. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
865 buddy = purple_find_buddy(session->account, user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
866 if (buddy) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
867 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
868 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
869 if (!uid) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
870 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
871 PurpleNotifyUserInfo *user_info; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
872 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
873 user_info = purple_notify_user_info_new(); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
874 purple_notify_user_info_add_pair(user_info, NULL, |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
875 _("This buddy appears to not have a userid stored in the buddy list, can't look up. Is the user really on the buddy list?")); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
876 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
877 purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
878 purple_notify_user_info_destroy(user_info); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
879 return; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
880 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
881 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
882 user_to_lookup = g_strdup_printf("%d", uid); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
883 } else { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
884 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
885 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
886 user_to_lookup = g_strdup(user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
887 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
888 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
889 /* Pass the username to msim_get_info_cb(), because since we lookup |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
890 * by userid, the userinfo message will only contain the uid (not |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
891 * the username). |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
892 */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
893 user_msg = msim_msg_new(TRUE, |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
894 "user", MSIM_TYPE_STRING, g_strdup(user), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
895 NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
896 purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
897 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
898 msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
899 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
900 g_free(user_to_lookup); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
901 } |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
902 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
903 /** After a uid is resolved to username, tag it with the username and submit for processing. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
904 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
905 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
906 * @param userinfo Response messsage to resolving request. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
907 * @param data MsimMessage *, the message to attach information to. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
908 */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
909 static void msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, gpointer data) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
910 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
911 gchar *body_str; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
912 GHashTable *body; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
913 gchar *username; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
914 MsimMessage *msg; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
915 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
916 body_str = msim_msg_get_string(userinfo, "body"); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
917 g_return_if_fail(body_str != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
918 body = msim_parse_body(body_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
919 g_return_if_fail(body != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
920 g_free(body_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
921 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
922 username = g_hash_table_lookup(body, "UserName"); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
923 g_return_if_fail(username != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
924 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
925 msg = (MsimMessage *)data; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
926 /* Special elements name beginning with '_', we'll use internally within the |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
927 * program (did not come from the wire). */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
928 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
929 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
930 msim_process(session, msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
931 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
932 /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
933 //XXX msim_msg_free(msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
934 g_hash_table_destroy(body); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
935 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
936 |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
937 #ifdef _MSIM_UID2USERNAME_WORKS |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
938 /* Lookup a username by userid, from buddy list. |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
939 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
940 * @param wanted_uid |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
941 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
942 * @return Username of wanted_uid, if on blist, or NULL. Static string. |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
943 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
944 * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
945 */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
946 static const gchar *msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
947 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
948 GSList *buddies, *buddies_head; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
949 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
950 for (buddies = buddies_head = purple_find_buddies(session->account, NULL); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
951 buddies; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
952 buddies = g_slist_next(buddies)) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
953 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
954 PurpleBuddy *buddy; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
955 guint uid; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
956 gchar *name; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
957 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
958 buddy = buddies->data; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
959 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
960 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
961 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
962 /* name = buddy->name; */ /* crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
963 /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
964 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
965 /* XXX Is this right? Memory corruption here somehow. Happens only |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
966 * when return one of these values. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
967 name = purple_buddy_get_name(buddy); /* crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
968 /* return name; */ /* crash (with above) */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
969 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
970 /* name = NULL; */ /* no crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
971 /* return NULL; */ /* no crash (with anything) */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
972 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
973 /* crash = |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
974 *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
975 ======= Backtrace: ========= |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
976 /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
977 /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
978 /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
979 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
980 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
981 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
982 /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
983 /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
984 /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
985 /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
986 pidgin(main+0x8be)[0x46b45e] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
987 /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
988 pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
989 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
990 or: |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
991 *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
992 (gdb) bt |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
993 #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
994 #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
995 #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
996 #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
997 #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
998 #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
999 #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1000 #7 0x00002b407810969f in msim_parse ( |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1001 raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1002 at message.c:648 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1003 #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1004 source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1005 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1006 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1007 Why is it crashing in msim_parse()'s g_strdup()? |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1008 */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1009 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1010 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1011 purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1012 name, uid, wanted_uid); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1013 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1014 if (uid == wanted_uid) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1015 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1016 g_slist_free(buddies_head); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1017 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1018 return name; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1019 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1020 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1021 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1022 g_slist_free(buddies_head); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1023 return NULL; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1024 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1025 |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1026 #endif |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1027 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1028 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1029 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1030 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1031 * @param msg MsimMessage *, freed by caller. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1032 */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1033 gboolean msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1034 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1035 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1036 { |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1037 guint uid; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1038 const gchar *username; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1039 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1040 /* 'f' = userid message is from, in buddy messages */ |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1041 uid = msim_msg_get_integer(msg, "f"); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1042 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1043 /* TODO: Make caching work. Currently it is commented out because |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1044 * it crashes for unknown reasons, memory realloc error. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1045 //#define _MSIM_UID2USERNAME_WORKS |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1046 #ifdef _MSIM_UID2USERNAME_WORKS |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1047 username = msim_uid2username_from_blist(session, uid); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1048 #else |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1049 username = NULL; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1050 #endif |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1051 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1052 if (username) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1053 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1054 /* Know username already, use it. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1055 purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1056 username); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1057 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1058 return msim_process(session, msg); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1059 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1060 } else { |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1061 gchar *from; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1062 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1063 /* Send lookup request. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1064 /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1065 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1066 from = msim_msg_get_string(msg, "f"); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1067 msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1068 g_free(from); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1069 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1070 /* indeterminate */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1071 return TRUE; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1072 } |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1073 } else { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1074 /* Nothing to resolve - send directly to processing. */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1075 return msim_process(session, msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1076 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1077 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1078 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1079 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1080 * Process a message. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1081 * |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1082 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1083 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1084 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1085 * @return TRUE if successful. FALSE if processing failed. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1086 */ |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1087 gboolean msim_process(MsimSession *session, MsimMessage *msg) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1088 { |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1089 g_return_val_if_fail(session != NULL, -1); |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1090 g_return_val_if_fail(msg != NULL, -1); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1091 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
1092 #ifdef MSIM_DEBUG_MSG |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1093 { |
17298
9c5b1dc7404f
Change msim_msg_debug_string() to msim_msg_dump(), which prints the string
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17297
diff
changeset
|
1094 msim_msg_dump("ready to process: %s\n", msg); |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1095 } |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1096 #endif |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1097 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1098 if (msim_msg_get(msg, "nc")) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1099 { |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1100 return msim_login_challenge(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1101 } else if (msim_msg_get(msg, "sesskey")) { |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1102 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1103 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1104 |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
1105 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
1106 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1107 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1108 /* Comes with: proof,profileid,userid,uniquenick -- all same values |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1109 * some of the time, but can vary. This is our own user ID. */ |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1110 session->userid = msim_msg_get_integer(msg, "userid"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1111 |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1112 /* TODO: fake our own userid being online */ |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1113 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1114 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1115 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1116 return TRUE; |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1117 } else if (msim_msg_get(msg, "bm")) { |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1118 guint bm; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1119 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1120 bm = msim_msg_get_integer(msg, "bm"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1121 switch (bm) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1122 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1123 case MSIM_BM_STATUS: |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1124 return msim_status(session, msg); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1125 case MSIM_BM_INSTANT: |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1126 return msim_incoming_im(session, msg); |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1127 case MSIM_BM_ACTION: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1128 return msim_incoming_action(session, msg); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1129 default: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1130 /* Not really an IM, but show it for informational |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1131 * purposes during development. */ |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1132 return msim_incoming_im(session, msg); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1133 } |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1134 } else if (msim_msg_get(msg, "rid")) { |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1135 return msim_process_reply(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1136 } else if (msim_msg_get(msg, "error")) { |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1137 return msim_error(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1138 } else if (msim_msg_get(msg, "ka")) { |
17650
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1139 /* TODO: Setup a timer, if keep-alive is not received within ~3 minutes, then |
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1140 * disconnect the user. As it stands, if Internet connection goes out (this |
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1141 * just happened here), msimprpl will appear to be connected forever, while |
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1142 * other plugins (oscar, etc.) will time out. Msimprpl should timeout too. */ |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1143 purple_debug_info("msim", "msim_process: got keep alive\n"); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1144 return TRUE; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1145 } else { |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
1146 msim_unrecognized(session, msg, "in msim_process"); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1147 return FALSE; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1148 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1149 } |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1150 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1151 /** Store an field of information about a buddy. */ |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1152 void msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1153 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1154 PurpleBuddy *buddy; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1155 gchar *key_str, *value_str; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1156 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1157 buddy = (PurpleBuddy *)user_data; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1158 key_str = (gchar *)key; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1159 value_str = (gchar *)value; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1160 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1161 if (strcmp(key_str, "UserID") == 0 || |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1162 strcmp(key_str, "Age") == 0 || |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1163 strcmp(key_str, "TotalFriends") == 0) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1164 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1165 /* Certain fields get set as integers, instead of strings, for |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1166 * convenience. May not be the best way to do it, but having at least |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1167 * UserID as an integer is convenient...until it overflows! */ |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1168 purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1169 } else { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1170 purple_blist_node_set_string(&buddy->node, key_str, value_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1171 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1172 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1173 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1174 /** Save buddy information to the buddy list from a user info reply message. |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1175 * |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1176 * @param session |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1177 * @param msg The user information reply, with any amount of information. |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1178 * |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1179 * The information is saved to the buddy's blist node, which ends up in blist.xml. |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1180 */ |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1181 gboolean msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1182 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1183 GHashTable *body; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1184 gchar *username, *body_str, *uid; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1185 PurpleBuddy *buddy; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1186 guint rid; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1187 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1188 rid = msim_msg_get_integer(msg, "rid"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1189 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1190 g_return_val_if_fail(rid != 0, FALSE); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1191 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1192 body_str = msim_msg_get_string(msg, "body"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1193 g_return_val_if_fail(body_str != NULL, FALSE); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1194 body = msim_parse_body(body_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1195 g_free(body_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1196 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1197 /* TODO: implement a better hash-like interface, and use it. */ |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1198 username = g_hash_table_lookup(body, "UserName"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1199 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1200 if (!username) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1201 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1202 purple_debug_info("msim", |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1203 "msim_process_reply: not caching body, no UserName\n"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1204 return FALSE; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1205 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1206 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1207 uid = g_hash_table_lookup(body, "UserID"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1208 g_return_val_if_fail(uid, FALSE); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1209 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1210 purple_debug_info("msim", "associating uid %d with username %s\n", uid, username); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1211 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1212 buddy = purple_find_buddy(session->account, username); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1213 if (buddy) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1214 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1215 g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1216 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1217 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1218 return TRUE; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1219 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1220 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1221 /** |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1222 * Process a persistance message reply from the server. |
16394 | 1223 * |
1224 * @param session | |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1225 * @param msg Message reply from server. |
16394 | 1226 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1227 * @return TRUE if successful. |
16394 | 1228 */ |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1229 gboolean msim_process_reply(MsimSession *session, MsimMessage *msg) |
16394 | 1230 { |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1231 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1232 g_return_val_if_fail(msg != NULL, FALSE); |
16394 | 1233 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1234 if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
16394 | 1235 { |
1236 MSIM_USER_LOOKUP_CB cb; | |
1237 gpointer data; | |
1238 guint rid; | |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1239 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1240 msim_store_buddy_info(session, msg); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1241 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1242 rid = msim_msg_get_integer(msg, "rid"); |
16394 | 1243 |
1244 /* If a callback is registered for this userid lookup, call it. */ | |
1245 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); | |
1246 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
1247 | |
1248 if (cb) | |
1249 { | |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1250 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1251 "msim_process_body: calling callback now\n"); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1252 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1253 cb(session, msim_msg_clone(msg), data); |
16394 | 1254 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
1255 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
1256 } else { | |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1257 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1258 "msim_process_body: no callback for rid %d\n", rid); |
16394 | 1259 } |
1260 } | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1261 |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1262 return TRUE; |
16394 | 1263 } |
1264 | |
1265 /** | |
1266 * Handle an error from the server. | |
1267 * | |
1268 * @param session | |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1269 * @param msg The message. |
16394 | 1270 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1271 * @return TRUE if successfully reported error. |
16394 | 1272 */ |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1273 gboolean msim_error(MsimSession *session, MsimMessage *msg) |
16394 | 1274 { |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1275 gchar *errmsg, *full_errmsg; |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1276 guint err; |
16394 | 1277 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1278 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1279 g_return_val_if_fail(msg != NULL, FALSE); |
16394 | 1280 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1281 err = msim_msg_get_integer(msg, "err"); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1282 errmsg = msim_msg_get_string(msg, "errmsg"); |
16394 | 1283 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1284 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, errmsg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1285 |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1286 g_free(errmsg); |
16394 | 1287 |
16396 | 1288 purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
16394 | 1289 |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1290 purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
16394 | 1291 full_errmsg, NULL); |
1292 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1293 /* Destroy session if fatal. */ |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1294 if (msim_msg_get(msg, "fatal")) |
16394 | 1295 { |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1296 purple_debug_info("msim", "fatal error, closing\n"); |
16396 | 1297 purple_connection_error(session->gc, full_errmsg); |
17329
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1298 |
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1299 msim_close(session->gc); |
16394 | 1300 } |
1301 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1302 return TRUE; |
16394 | 1303 } |
1304 | |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1305 /** |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1306 * Process incoming status messages. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1307 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1308 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1309 * @param msg Status update message. Caller frees. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1310 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1311 * @return TRUE if successful. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1312 */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1313 gboolean msim_status(MsimSession *session, MsimMessage *msg) |
16394 | 1314 { |
16396 | 1315 PurpleBuddyList *blist; |
1316 PurpleBuddy *buddy; | |
1317 //PurpleStatus *status; | |
16394 | 1318 gchar **status_array; |
1319 GList *list; | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1320 gchar *status_headline; |
16394 | 1321 gchar *status_str; |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1322 gint i, status_code, purple_status_code; |
16394 | 1323 gchar *username; |
1324 | |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1325 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1326 g_return_val_if_fail(msg != NULL, FALSE); |
17305
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17304
diff
changeset
|
1327 |
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17304
diff
changeset
|
1328 status_str = msim_msg_get_string(msg, "msg"); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1329 g_return_val_if_fail(status_str != NULL, FALSE); |
16394 | 1330 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1331 msim_msg_dump("msim_status msg=%s\n", msg); |
16394 | 1332 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1333 /* Helpfully looked up by msim_incoming_resolve() for us. */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1334 username = msim_msg_get_string(msg, "_username"); |
16394 | 1335 /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
1336 * the buddy list, if the UserID was stored along with it. */ | |
1337 | |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1338 if (username == NULL) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1339 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1340 g_free(status_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1341 g_return_val_if_fail(NULL, FALSE); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1342 } |
16394 | 1343 |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1344 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1345 "msim_status_cb: updating status for <%s> to <%s>\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1346 username, status_str); |
16394 | 1347 |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1348 /* TODO: generic functions to split into a GList, part of MsimMessage */ |
16394 | 1349 status_array = g_strsplit(status_str, "|", 0); |
1350 for (list = NULL, i = 0; | |
1351 status_array[i]; | |
1352 i++) | |
1353 { | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1354 /* Note: this adds the 0th ordinal too, which might not be a value |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1355 * at all (the 0 in the 0|1|2|3... status fields, but 0 always appears blank). |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1356 */ |
16394 | 1357 list = g_list_append(list, status_array[i]); |
1358 } | |
1359 | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1360 /* Example fields: |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1361 * |s|0|ss|Offline |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1362 * |s|1|ss|:-)|ls||ip|0|p|0 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1363 * |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1364 * TODO: write list support in MsimMessage, and use it here. |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1365 */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1366 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1367 status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1368 purple_debug_info("msim", "msim_status_cb: %s's status code = %d\n", username, status_code); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1369 status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
16394 | 1370 |
16396 | 1371 blist = purple_get_blist(); |
16394 | 1372 |
1373 /* Add buddy if not found */ | |
16396 | 1374 buddy = purple_find_buddy(session->account, username); |
16394 | 1375 if (!buddy) |
1376 { | |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1377 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1378 "msim_status: making new buddy for %s\n", username); |
16396 | 1379 buddy = purple_buddy_new(session->account, username, NULL); |
16394 | 1380 |
16396 | 1381 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1382 |
17299
c6305f8845d8
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17298
diff
changeset
|
1383 /* All buddies on list should have 'uid' integer associated with them. */ |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1384 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1385 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1386 msim_store_buddy_info(session, msg); |
16394 | 1387 } else { |
16396 | 1388 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
16394 | 1389 } |
1390 | |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1391 purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1392 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1393 /* Set user status */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1394 switch (status_code) |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1395 { |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1396 case 1: purple_status_code = PURPLE_STATUS_AVAILABLE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1397 break; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1398 case 0: purple_status_code = PURPLE_STATUS_OFFLINE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1399 break; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1400 default: |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1401 purple_debug_info("msim", "msim_status_cb for %s, unknown status code %d\n", |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1402 username, status_code); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1403 purple_status_code = PURPLE_STATUS_AVAILABLE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1404 } |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1405 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
16394 | 1406 |
1407 g_strfreev(status_array); | |
17305
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17304
diff
changeset
|
1408 g_free(status_str); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1409 g_free(username); |
16394 | 1410 g_list_free(list); |
1411 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1412 return TRUE; |
16394 | 1413 } |
1414 | |
17331
b33a6f16356a
Update several outdated TODO comments.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17330
diff
changeset
|
1415 /** Add a buddy to user's buddy list. */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1416 void msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1417 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1418 MsimSession *session; |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1419 MsimMessage *msg; |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1420 /* MsimMessage *msg_blocklist; */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1421 |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1422 session = (MsimSession *)gc->proto_data; |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1423 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1424 group ? group->name : "(no group)"); |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1425 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1426 msg = msim_msg_new(TRUE, |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1427 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
1428 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1429 /* "newprofileid" will be inserted here with uid. */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1430 "reason", MSIM_TYPE_STRING, g_strdup(""), |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1431 NULL); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1432 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1433 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1434 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1435 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1436 msim_msg_free(msg); |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1437 return; |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1438 } |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1439 msim_msg_free(msg); |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1440 |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1441 /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1442 * buddy list since Purple adds it locally. */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1443 |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1444 /* TODO: Update blocklist. */ |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1445 #if 0 |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1446 msg_blocklist = msim_msg_new(TRUE, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1447 "persist", MSIM_TYPE_INTEGER, 1, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1448 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1449 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1450 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1451 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1452 /* TODO: Use msim_new_reply_callback to get rid. */ |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1453 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1454 "body", MSIM_TYPE_STRING, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1455 g_strdup_printf("ContactID=<uid>\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1456 "GroupName=%s\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1457 "Position=1000\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1458 "Visibility=1\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1459 "NickName=\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1460 "NameSelect=0", |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1461 "Friends" /*group->name*/ )); |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1462 |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1463 if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1464 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1465 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1466 msim_msg_free(msg_blocklist); |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1467 return; |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1468 } |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1469 msim_msg_free(msg_blocklist); |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1470 #endif |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1471 } |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1472 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1473 /** Perform actual postprocessing on a message, adding userid as specified. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1474 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1475 * @param msg The message to postprocess. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1476 * @param uid_before Name of field where to insert new field before, or NULL for end. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1477 * @param uid_field_name Name of field to add uid to. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1478 * @param uid The userid to insert. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1479 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1480 * If the field named by uid_field_name already exists, then its string contents will |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1481 * be used for the field, except "<uid>" will be replaced by the userid. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1482 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1483 * If the field named by uid_field_name does not exist, it will be added before the |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1484 * field named by uid_before, as an integer, with the userid. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1485 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1486 * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1487 */ |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
1488 MsimMessage *msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, const gchar *uid_field_name, guint uid) |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1489 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1490 purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n", |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1491 uid_field_name, uid_before, uid); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1492 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1493 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1494 /* First, check - if the field already exists, treat it as a format string. */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1495 if (msim_msg_get(msg, uid_field_name)) |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1496 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1497 MsimMessageElement *elem; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1498 gchar *fmt_string; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1499 gchar *uid_str; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1500 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1501 /* Warning: this probably violates the encapsulation of MsimMessage */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1502 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1503 elem = msim_msg_get(msg, uid_field_name); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1504 g_return_val_if_fail(elem->type == MSIM_TYPE_STRING, NULL); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1505 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1506 /* Get the raw string, not with msim_msg_get_string() since that copies it. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1507 * Want the original string so can free it. */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1508 fmt_string = (gchar *)(elem->data); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1509 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1510 uid_str = g_strdup_printf("%d", uid); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1511 elem->data = str_replace(fmt_string, "<uid>", uid_str); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1512 g_free(uid_str); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1513 g_free(fmt_string); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1514 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1515 purple_debug_info("msim", "msim_postprocess_outgoing_cb: formatted new string, %s\n", |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1516 elem->data); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1517 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1518 } else { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1519 /* Otherwise, insert new field into outgoing message. */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1520 msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1521 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1522 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1523 return msg; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1524 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1525 |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1526 /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1527 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1528 * @param session |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1529 * @param userinfo The user information reply message, containing the user ID |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1530 * @param data The message to postprocess and send. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1531 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1532 * The data message should contain these fields: |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1533 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1534 * _uid_field_name: string, name of field to add with userid from userinfo message |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1535 * _uid_before: string, name of field before field to insert, or NULL for end |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1536 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1537 * |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1538 */ |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1539 void msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1540 { |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1541 gchar *body_str; |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1542 GHashTable *body; |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1543 gchar *uid, *uid_field_name, *uid_before; |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1544 MsimMessage *msg; |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1545 |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1546 msg = (MsimMessage *)data; |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1547 |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1548 msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1549 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1550 /* Obtain userid from userinfo message. */ |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1551 body_str = msim_msg_get_string(userinfo, "body"); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1552 g_return_if_fail(body_str != NULL); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1553 body = msim_parse_body(body_str); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1554 g_free(body_str); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1555 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1556 uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1557 g_hash_table_destroy(body); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1558 |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1559 uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1560 uid_before = msim_msg_get_string(msg, "_uid_before"); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1561 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1562 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1563 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1564 /* Send */ |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1565 if (!msim_msg_send(session, msg)) |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1566 { |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1567 purple_debug_info("msim", "msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1568 } |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1569 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1570 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1571 /* Free field names AFTER sending message, because MsimMessage does NOT copy |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1572 * field names - instead, treats them as static strings (which they usually are). |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1573 */ |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1574 g_free(uid_field_name); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1575 g_free(uid_before); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1576 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1577 //msim_msg_free(msg); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1578 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1579 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1580 /** Postprocess and send a message. |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1581 * |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1582 * @param session |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1583 * @param msg Message to postprocess. Will NOT be freed. |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1584 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1585 * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1586 * @param uid_before Name of existing field to insert username field before. Static string. |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1587 * |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1588 * @return Postprocessed message. |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1589 */ |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
1590 gboolean msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, const gchar *username, |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
1591 const gchar *uid_field_name, const gchar *uid_before) |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1592 { |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1593 PurpleBuddy *buddy; |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1594 guint uid; |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1595 gboolean rc; |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1596 |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1597 /* Store information for msim_postprocess_outgoing_cb(). */ |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1598 purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n", |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1599 username, uid_field_name, uid_before); |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1600 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1601 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1602 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1603 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1604 |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1605 /* First, try the most obvious. If numeric userid is given, use that directly. */ |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1606 if (msim_is_userid(username)) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1607 { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1608 uid = atol(username); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1609 } else { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1610 /* Next, see if on buddy list and know uid. */ |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1611 buddy = purple_find_buddy(session->account, username); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1612 if (buddy) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1613 { |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1614 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1615 } else { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1616 uid = 0; |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1617 } |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1618 |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1619 if (!buddy || !uid) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1620 { |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1621 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1622 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1623 username); |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1624 msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1625 /* TODO: where is cloned message freed? Should be in _cb. */ |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
1626 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1627 return TRUE; /* not sure of status yet - haven't sent! */ |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
1628 } |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1629 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1630 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1631 /* Already have uid, postprocess and send msg immediately. */ |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1632 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1633 username, uid); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1634 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1635 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1636 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1637 msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1638 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1639 rc = msim_msg_send(session, msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1640 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1641 //msim_msg_free(msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1642 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1643 return rc; |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1644 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1645 |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1646 /** Remove a buddy from the user's buddy list. */ |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1647 void msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1648 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1649 MsimSession *session; |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1650 MsimMessage *delbuddy_msg; |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1651 MsimMessage *persist_msg; |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1652 MsimMessage *blocklist_msg; |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1653 |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1654 session = (MsimSession *)gc->proto_data; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1655 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1656 delbuddy_msg = msim_msg_new(TRUE, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1657 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
1658 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1659 /* 'delprofileid' with uid will be inserted here. */ |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1660 NULL); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1661 /* TODO: free msg */ |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1662 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1663 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1664 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1665 return; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1666 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1667 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1668 persist_msg = msim_msg_new(TRUE, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1669 "persist", MSIM_TYPE_INTEGER, 1, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
1670 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1671 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1672 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1673 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
17317
e9dfd3a5d4b6
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17316
diff
changeset
|
1674 "uid", MSIM_TYPE_INTEGER, session->userid, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1675 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1676 /* <uid> will be replaced by postprocessing */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1677 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1678 NULL); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1679 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1680 /* TODO: free msg */ |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1681 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1682 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1683 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1684 return; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1685 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1686 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1687 blocklist_msg = msim_msg_new(TRUE, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1688 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1689 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1690 /* TODO: MsimMessage lists */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1691 "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1692 NULL); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1693 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1694 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1695 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1696 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1697 return; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1698 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
1699 |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1700 /* TODO: update blocklist */ |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1701 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1702 |
17324
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1703 /** Return whether the buddy can be messaged while offline. |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1704 * |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1705 * I always return TRUE, to allow sending to buddies whose status has not yet |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1706 * been received. The protocol _does_ support offline messages, but not this plugin. |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1707 * TODO: Real offline message support. |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1708 */ |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1709 gboolean msim_offline_message(const PurpleBuddy *buddy) |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1710 { |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1711 return TRUE; |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1712 } |
16394 | 1713 |
1714 | |
1715 /** | |
1716 * Callback when input available. | |
1717 * | |
16396 | 1718 * @param gc_uncasted A PurpleConnection pointer. |
16394 | 1719 * @param source File descriptor. |
16396 | 1720 * @param cond PURPLE_INPUT_READ |
16394 | 1721 * |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1722 * Reads the input, and calls msim_preprocess_incoming() to handle it. |
16394 | 1723 */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
1724 void msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
16394 | 1725 { |
16396 | 1726 PurpleConnection *gc; |
1727 PurpleAccount *account; | |
16394 | 1728 MsimSession *session; |
1729 gchar *end; | |
1730 int n; | |
1731 | |
1732 g_return_if_fail(gc_uncasted != NULL); | |
1733 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ | |
1734 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
1735 gc = (PurpleConnection *)(gc_uncasted); |
16396 | 1736 account = purple_connection_get_account(gc); |
16394 | 1737 session = gc->proto_data; |
1738 | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1739 g_return_if_fail(cond == PURPLE_INPUT_READ); |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1740 g_return_if_fail(MSIM_SESSION_VALID(session)); |
16394 | 1741 |
1742 /* Only can handle so much data at once... | |
1743 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. | |
1744 * Should be large enough to hold the largest protocol message. | |
1745 */ | |
1746 if (session->rxoff == MSIM_READ_BUF_SIZE) | |
1747 { | |
16396 | 1748 purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
16394 | 1749 MSIM_READ_BUF_SIZE); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1750 purple_connection_error(gc, _("Read buffer full")); |
17329
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1751 |
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1752 msim_close(session->gc); |
16394 | 1753 return; |
1754 } | |
1755 | |
16396 | 1756 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1757 session->rxoff, MSIM_READ_BUF_SIZE, |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1758 MSIM_READ_BUF_SIZE - session->rxoff); |
16394 | 1759 |
1760 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds | |
1761 * the file descriptor, but it sometimes differs from the 'source' parameter. | |
1762 */ | |
1763 n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); | |
1764 | |
1765 if (n < 0 && errno == EAGAIN) | |
1766 { | |
1767 return; | |
1768 } | |
1769 else if (n < 0) | |
1770 { | |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1771 purple_connection_error(gc, _("Read error")); |
16396 | 1772 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
16394 | 1773 "error=%s, source=%d, fd=%d (%X))\n", |
1774 n, strerror(errno), source, session->fd, session->fd); | |
17329
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1775 |
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1776 msim_close(session->gc); |
16394 | 1777 return; |
1778 } | |
1779 else if (n == 0) | |
1780 { | |
16396 | 1781 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1782 purple_connection_error(gc, _("Server has disconnected")); |
16394 | 1783 return; |
1784 } | |
1785 | |
1786 /* Null terminate */ | |
1787 session->rxbuf[session->rxoff + n] = 0; | |
1788 | |
1789 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ | |
1790 if (strlen(session->rxbuf + session->rxoff) != n) | |
1791 { | |
1792 /* Occurs after login, but it is not a null byte. */ | |
16396 | 1793 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1794 "--null byte encountered?\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1795 strlen(session->rxbuf + session->rxoff), n); |
16396 | 1796 //purple_connection_error(gc, "Invalid message - null byte on input"); |
16394 | 1797 return; |
1798 } | |
1799 | |
1800 session->rxoff += n; | |
16396 | 1801 purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
16394 | 1802 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
1803 #ifdef MSIM_DEBUG_RXBUF |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1804 purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1805 #endif |
16394 | 1806 |
1807 /* Look for \\final\\ end markers. If found, process message. */ | |
1808 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) | |
1809 { | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1810 MsimMessage *msg; |
16394 | 1811 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
1812 #ifdef MSIM_DEBUG_RXBUF |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1813 purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1814 #endif |
16394 | 1815 *end = 0; |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1816 msg = msim_parse(g_strdup(session->rxbuf)); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1817 if (!msg) |
16394 | 1818 { |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1819 purple_debug_info("msim", "msim_input_cb: couldn't parse <%s>\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1820 session->rxbuf); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1821 purple_connection_error(gc, _("Unparseable message")); |
16394 | 1822 } |
1823 else | |
1824 { | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1825 /* Process message and then free it (processing function should |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1826 * clone message if it wants to keep it afterwards.) */ |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1827 if (!msim_preprocess_incoming(session, msg)) |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1828 { |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1829 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1830 } |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1831 msim_msg_free(msg); |
16394 | 1832 } |
1833 | |
1834 /* Move remaining part of buffer to beginning. */ | |
1835 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); | |
1836 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), | |
1837 MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); | |
1838 | |
1839 /* Clear end of buffer */ | |
1840 //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); | |
1841 } | |
1842 } | |
1843 | |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1844 /* Setup a callback, to be called when a reply is received with the returned rid. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1845 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1846 * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1847 * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1848 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1849 * @return The request/reply ID, used to link replies with requests. Put the rid in your request. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1850 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1851 * TODO: Make more generic and more specific: |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1852 * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1853 * 2) data - make it an MsimMessage? |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1854 */ |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1855 guint msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, gpointer data) |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1856 { |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1857 guint rid; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1858 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1859 rid = session->next_rid++; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1860 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1861 g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1862 g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1863 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1864 return rid; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1865 } |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1866 |
16394 | 1867 /** |
1868 * Callback when connected. Sets up input handlers. | |
1869 * | |
16396 | 1870 * @param data A PurpleConnection pointer. |
16394 | 1871 * @param source File descriptor. |
1872 * @param error_message | |
1873 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
1874 void msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
16394 | 1875 { |
16396 | 1876 PurpleConnection *gc; |
16394 | 1877 MsimSession *session; |
1878 | |
1879 g_return_if_fail(data != NULL); | |
1880 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
1881 gc = (PurpleConnection *)data; |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
1882 session = (MsimSession *)gc->proto_data; |
16394 | 1883 |
1884 if (source < 0) | |
1885 { | |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1886 purple_connection_error(gc, _("Couldn't connect to host")); |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1887 purple_connection_error(gc, g_strdup_printf(_("Couldn't connect to host: %s (%d)"), |
16394 | 1888 error_message, source)); |
1889 return; | |
1890 } | |
1891 | |
1892 session->fd = source; | |
1893 | |
16396 | 1894 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
16394 | 1895 } |
1896 | |
1897 /* Session methods */ | |
1898 | |
1899 /** | |
1900 * Create a new MSIM session. | |
1901 * | |
1902 * @param acct The account to create the session from. | |
1903 * | |
1904 * @return Pointer to a new session. Free with msim_session_destroy. | |
1905 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
1906 MsimSession *msim_session_new(PurpleAccount *acct) |
16394 | 1907 { |
1908 MsimSession *session; | |
1909 | |
1910 g_return_val_if_fail(acct != NULL, NULL); | |
1911 | |
1912 session = g_new0(MsimSession, 1); | |
1913 | |
1914 session->magic = MSIM_SESSION_STRUCT_MAGIC; | |
1915 session->account = acct; | |
16396 | 1916 session->gc = purple_account_get_connection(acct); |
16394 | 1917 session->fd = -1; |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1918 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1919 /* TODO: Remove. */ |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1920 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1921 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1922 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
17303
ceba4fc06c41
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17300
diff
changeset
|
1923 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1924 they could be integers inside gpointers |
17303
ceba4fc06c41
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17300
diff
changeset
|
1925 or strings, so I don't freed them. |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1926 Figure this out, once free cache. */ |
16394 | 1927 session->rxoff = 0; |
1928 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); | |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1929 session->next_rid = 1; |
16394 | 1930 |
1931 return session; | |
1932 } | |
1933 | |
1934 /** | |
1935 * Free a session. | |
1936 * | |
1937 * @param session The session to destroy. | |
1938 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
1939 void msim_session_destroy(MsimSession *session) |
16394 | 1940 { |
1941 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
1942 | |
1943 session->magic = -1; | |
1944 | |
1945 g_free(session->rxbuf); | |
1946 | |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1947 /* TODO: Remove. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1948 g_hash_table_destroy(session->user_lookup_cb); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1949 g_hash_table_destroy(session->user_lookup_cb_data); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1950 |
16394 | 1951 g_free(session); |
1952 } | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1953 |
16394 | 1954 |
1955 | |
1956 /** | |
1957 * Close the connection. | |
1958 * | |
1959 * @param gc The connection. | |
1960 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
1961 void msim_close(PurpleConnection *gc) |
16394 | 1962 { |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1963 MsimSession *session; |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1964 |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1965 purple_debug_info("msim", "msim_close: destroying session\n"); |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1966 |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1967 session = (MsimSession *)gc->proto_data; |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1968 |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1969 g_return_if_fail(gc != NULL); |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1970 g_return_if_fail(session != NULL); |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1971 g_return_if_fail(MSIM_SESSION_VALID(session)); |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1972 |
17329
4205f33b658f
Fix crash when re-logging in.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17326
diff
changeset
|
1973 purple_input_remove(session->gc->inpa); |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1974 msim_session_destroy(session); |
16394 | 1975 } |
1976 | |
1977 | |
1978 /** | |
1979 * Check if a string is a userid (all numeric). | |
1980 * | |
1981 * @param user The user id, email, or name. | |
1982 * | |
1983 * @return TRUE if is userid, FALSE if not. | |
1984 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
1985 gboolean msim_is_userid(const gchar *user) |
16394 | 1986 { |
1987 g_return_val_if_fail(user != NULL, FALSE); | |
1988 | |
1989 return strspn(user, "0123456789") == strlen(user); | |
1990 } | |
1991 | |
1992 /** | |
1993 * Check if a string is an email address (contains an @). | |
1994 * | |
1995 * @param user The user id, email, or name. | |
1996 * | |
1997 * @return TRUE if is an email, FALSE if not. | |
1998 * | |
1999 * This function is not intended to be used as a generic | |
2000 * means of validating email addresses, but to distinguish | |
2001 * between a user represented by an email address from | |
2002 * other forms of identification. | |
2003 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2004 gboolean msim_is_email(const gchar *user) |
16394 | 2005 { |
2006 g_return_val_if_fail(user != NULL, FALSE); | |
2007 | |
2008 return strchr(user, '@') != NULL; | |
2009 } | |
2010 | |
2011 | |
2012 /** | |
2013 * Asynchronously lookup user information, calling callback when receive result. | |
2014 * | |
2015 * @param session | |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2016 * @param user The user id, email address, or username. Not freed. |
16394 | 2017 * @param cb Callback, called with user information when available. |
2018 * @param data An arbitray data pointer passed to the callback. | |
2019 */ | |
17299
c6305f8845d8
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17298
diff
changeset
|
2020 /* TODO: change to not use callbacks */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2021 void msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data) |
16394 | 2022 { |
2023 gchar *field_name; | |
2024 guint rid, cmd, dsn, lid; | |
2025 | |
2026 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
2027 g_return_if_fail(user != NULL); | |
2028 g_return_if_fail(cb != NULL); | |
2029 | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2030 purple_debug_info("msim", "msim_lookup_userid: " |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2031 "asynchronously looking up <%s>\n", user); |
16394 | 2032 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2033 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2034 |
16394 | 2035 /* TODO: check if this user's info was cached and fresh; if so return immediately */ |
2036 #if 0 | |
2037 /* If already know userid, then call callback immediately */ | |
2038 cached_userid = g_hash_table_lookup(session->userid_cache, who); | |
2039 if (cached_userid && !by_userid) | |
2040 { | |
2041 cb(cached_userid, NULL, NULL, data); | |
2042 return; | |
2043 } | |
2044 #endif | |
2045 | |
2046 /* Setup callback. Response will be associated with request using 'rid'. */ | |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2047 rid = msim_new_reply_callback(session, cb, data); |
16394 | 2048 |
2049 /* Send request */ | |
2050 | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2051 cmd = MSIM_CMD_GET; |
16394 | 2052 |
2053 if (msim_is_userid(user)) | |
2054 { | |
2055 field_name = "UserID"; | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2056 dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2057 lid = MG_MYSPACE_INFO_BY_ID_LID; |
16394 | 2058 } else if (msim_is_email(user)) { |
2059 field_name = "Email"; | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2060 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2061 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
16394 | 2062 } else { |
2063 field_name = "UserName"; | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2064 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2065 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
16394 | 2066 } |
2067 | |
2068 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2069 g_return_if_fail(msim_send(session, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2070 "persist", MSIM_TYPE_INTEGER, 1, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
2071 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2072 "cmd", MSIM_TYPE_INTEGER, 1, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2073 "dsn", MSIM_TYPE_INTEGER, dsn, |
17317
e9dfd3a5d4b6
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17316
diff
changeset
|
2074 "uid", MSIM_TYPE_INTEGER, session->userid, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2075 "lid", MSIM_TYPE_INTEGER, lid, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2076 "rid", MSIM_TYPE_INTEGER, rid, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2077 /* TODO: dictionary field type */ |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2078 "body", MSIM_TYPE_STRING, g_strdup_printf("%s=%s", field_name, user), |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2079 NULL)); |
16394 | 2080 } |
2081 | |
2082 | |
2083 /** | |
2084 * Obtain the status text for a buddy. | |
2085 * | |
2086 * @param buddy The buddy to obtain status text for. | |
2087 * | |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
2088 * @return Status text, or NULL if error. Caller g_free()'s. |
16394 | 2089 * |
2090 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2091 char *msim_status_text(PurpleBuddy *buddy) |
16394 | 2092 { |
2093 MsimSession *session; | |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2094 const gchar *display_name, *headline; |
16394 | 2095 |
2096 g_return_val_if_fail(buddy != NULL, NULL); | |
2097 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2098 session = (MsimSession *)buddy->account->gc->proto_data; |
16727
cd4a6bd9f69e
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16726
diff
changeset
|
2099 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
16394 | 2100 |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2101 display_name = headline = NULL; |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2102 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2103 /* Retrieve display name and/or headline, depending on user preference. */ |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2104 if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2105 { |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2106 display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2107 } |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2108 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2109 if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2110 { |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2111 headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2112 } |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2113 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2114 /* Return appropriate combination of display name and/or headline, or neither. */ |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2115 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2116 if (display_name && headline) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2117 return g_strconcat(display_name, " ", headline, NULL); |
16394 | 2118 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2119 if (display_name) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2120 return g_strdup(display_name); |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2121 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2122 if (headline) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2123 return g_strdup(headline); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2124 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2125 return NULL; |
16394 | 2126 } |
2127 | |
2128 /** | |
2129 * Obtain the tooltip text for a buddy. | |
2130 * | |
2131 * @param buddy Buddy to obtain tooltip text on. | |
2132 * @param user_info Variable modified to have the tooltip text. | |
2133 * @param full TRUE if should obtain full tooltip text. | |
2134 * | |
2135 */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2136 void msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full) |
16394 | 2137 { |
2138 g_return_if_fail(buddy != NULL); | |
2139 g_return_if_fail(user_info != NULL); | |
2140 | |
16396 | 2141 if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
16394 | 2142 { |
2143 MsimSession *session; | |
2144 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2145 session = (MsimSession *)buddy->account->gc->proto_data; |
16394 | 2146 |
16727
cd4a6bd9f69e
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16726
diff
changeset
|
2147 g_return_if_fail(MSIM_SESSION_VALID(session)); |
16394 | 2148 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2149 /* TODO: if (full), do something different */ |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2150 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2151 /* TODO: move to buddy profile |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2152 purple_notify_user_info_add_pair(user_info, "User ID", |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2153 g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "UserID"))); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2154 */ |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2155 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2156 /* Already shown in status text. |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2157 purple_notify_user_info_add_pair(user_info, "Display Name", |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2158 purple_blist_node_get_string(&buddy->node, "DisplayName")); */ |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2159 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2160 /* Useful to identify the account the tooltip refers to. Other prpls show this. */ |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2161 purple_notify_user_info_add_pair(user_info, _("User Name"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2162 (purple_blist_node_get_string(&buddy->node, "UserName"))); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2163 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2164 /* a/s/l...the vitals */ |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2165 purple_notify_user_info_add_pair(user_info, _("Age"), |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2166 g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "Age"))); |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2167 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2168 purple_notify_user_info_add_pair(user_info, _("Gender"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2169 (purple_blist_node_get_string(&buddy->node, "Gender"))); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2170 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2171 purple_notify_user_info_add_pair(user_info, _("Location"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2172 (purple_blist_node_get_string(&buddy->node, "Location"))); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2173 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2174 /* Other information */ |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2175 if (purple_blist_node_get_string(&buddy->node, "Headline")) |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2176 purple_notify_user_info_add_pair(user_info, _("Headline"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2177 (purple_blist_node_get_string(&buddy->node, "Headline"))); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2178 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2179 purple_notify_user_info_add_pair(user_info, _("Song"), |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2180 g_strdup_printf("%s - %s", |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2181 purple_blist_node_get_string(&buddy->node, "BandName"), |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2182 purple_blist_node_get_string(&buddy->node, "SongName"))); |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2183 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2184 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2185 g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "TotalFriends"))); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2186 |
16394 | 2187 } |
2188 } | |
2189 | |
16396 | 2190 /** Callbacks called by Purple, to access this plugin. */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2191 PurplePluginProtocolInfo prpl_info = |
16394 | 2192 { |
2193 OPT_PROTO_MAIL_CHECK,/* options - TODO: myspace will notify of mail */ | |
2194 NULL, /* user_splits */ | |
2195 NULL, /* protocol_options */ | |
2196 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ | |
2197 msim_list_icon, /* list_icon */ | |
2198 NULL, /* list_emblems */ | |
2199 msim_status_text, /* status_text */ | |
2200 msim_tooltip_text, /* tooltip_text */ | |
2201 msim_status_types, /* status_types */ | |
2202 NULL, /* blist_node_menu */ | |
2203 NULL, /* chat_info */ | |
2204 NULL, /* chat_info_defaults */ | |
2205 msim_login, /* login */ | |
2206 msim_close, /* close */ | |
2207 msim_send_im, /* send_im */ | |
2208 NULL, /* set_info */ | |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
2209 msim_send_typing, /* send_typing */ |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
2210 msim_get_info, /* get_info */ |
16394 | 2211 NULL, /* set_away */ |
2212 NULL, /* set_idle */ | |
2213 NULL, /* change_passwd */ | |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2214 msim_add_buddy, /* add_buddy */ |
16394 | 2215 NULL, /* add_buddies */ |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2216 msim_remove_buddy, /* remove_buddy */ |
16394 | 2217 NULL, /* remove_buddies */ |
2218 NULL, /* add_permit */ | |
2219 NULL, /* add_deny */ | |
2220 NULL, /* rem_permit */ | |
2221 NULL, /* rem_deny */ | |
2222 NULL, /* set_permit_deny */ | |
2223 NULL, /* join_chat */ | |
2224 NULL, /* reject chat invite */ | |
2225 NULL, /* get_chat_name */ | |
2226 NULL, /* chat_invite */ | |
2227 NULL, /* chat_leave */ | |
2228 NULL, /* chat_whisper */ | |
2229 NULL, /* chat_send */ | |
2230 NULL, /* keepalive */ | |
2231 NULL, /* register_user */ | |
2232 NULL, /* get_cb_info */ | |
2233 NULL, /* get_cb_away */ | |
2234 NULL, /* alias_buddy */ | |
2235 NULL, /* group_buddy */ | |
2236 NULL, /* rename_group */ | |
2237 NULL, /* buddy_free */ | |
2238 NULL, /* convo_closed */ | |
2239 NULL, /* normalize */ | |
2240 NULL, /* set_buddy_icon */ | |
2241 NULL, /* remove_group */ | |
2242 NULL, /* get_cb_real_name */ | |
2243 NULL, /* set_chat_topic */ | |
2244 NULL, /* find_blist_chat */ | |
2245 NULL, /* roomlist_get_list */ | |
2246 NULL, /* roomlist_cancel */ | |
2247 NULL, /* roomlist_expand_category */ | |
2248 NULL, /* can_receive_file */ | |
2249 NULL, /* send_file */ | |
2250 NULL, /* new_xfer */ | |
17324
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2251 msim_offline_message, /* offline_message */ |
16394 | 2252 NULL, /* whiteboard_prpl_ops */ |
2253 NULL, /* send_raw */ | |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2254 NULL, /* roomlist_room_serialize */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2255 NULL, /* _purple_reserved1 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2256 NULL, /* _purple_reserved2 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2257 NULL, /* _purple_reserved3 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2258 NULL /* _purple_reserved4 */ |
16394 | 2259 }; |
2260 | |
2261 | |
2262 | |
2263 /** Based on MSN's plugin info comments. */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2264 PurplePluginInfo info = |
16394 | 2265 { |
16396 | 2266 PURPLE_PLUGIN_MAGIC, |
2267 PURPLE_MAJOR_VERSION, | |
2268 PURPLE_MINOR_VERSION, | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2269 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2270 NULL, /**< ui_requirement */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2271 0, /**< flags */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2272 NULL, /**< dependencies */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2273 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
16394 | 2274 |
2275 "prpl-myspace", /**< id */ | |
2276 "MySpaceIM", /**< name */ | |
17647
04a00333546a
Add script to produce tarballs and zip archives for releases, for v0.8.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17332
diff
changeset
|
2277 "0.8", /**< version */ |
16394 | 2278 /** summary */ |
2279 "MySpaceIM Protocol Plugin", | |
2280 /** description */ | |
2281 "MySpaceIM Protocol Plugin", | |
17655
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17654
diff
changeset
|
2282 "Jeff Connelly <jeff2@homing.pidgin.im>", /**< author */ |
16394 | 2283 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
2284 | |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
2285 msim_load, /**< load */ |
16394 | 2286 NULL, /**< unload */ |
2287 NULL, /**< destroy */ | |
2288 NULL, /**< ui_info */ | |
2289 &prpl_info, /**< extra_info */ | |
2290 NULL, /**< prefs_info */ | |
2291 | |
2292 /* msim_actions */ | |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2293 NULL, |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2294 |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2295 NULL, /**< reserved1 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2296 NULL, /**< reserved2 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2297 NULL, /**< reserved3 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2298 NULL /**< reserved4 */ |
16394 | 2299 }; |
2300 | |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2301 |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
2302 #ifdef MSIM_SELF_TEST |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2303 /** Test functions. |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2304 * Used to test or try out the internal workings of msimprpl. If you're reading |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2305 * this code for the first time, these functions can be instructive in how |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2306 * msimprpl is architected. |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2307 */ |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
2308 void msim_test_all(void) __attribute__((__noreturn__())); |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2309 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2310 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2311 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2312 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2313 failures += msim_test_msg(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2314 failures += msim_test_escaping(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2315 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2316 if (failures) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2317 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2318 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2319 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2320 else |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2321 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2322 purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2323 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2324 exit(0); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2325 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2326 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2327 /** Test MsimMessage for basic functionality. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2328 int msim_test_msg(void) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2329 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2330 MsimMessage *msg, *msg_cloned; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2331 gchar *packed, *packed_expected, *packed_cloned; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2332 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2333 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2334 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2335 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2336 purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2337 msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2338 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2339 /* Append some new elements. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2340 msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2341 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2342 msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2343 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2344 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2345 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2346 msim_msg_dump("msg debug str=%s\n", msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2347 packed = msim_msg_pack(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2348 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2349 purple_debug_info("msim", "msg packed=%s\n", packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2350 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2351 packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2352 "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2353 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2354 if (0 != strcmp(packed, packed_expected)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2355 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2356 purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2357 ++failures, packed, packed_expected); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2358 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2359 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2360 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2361 msg_cloned = msim_msg_clone(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2362 packed_cloned = msim_msg_pack(msg_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2363 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2364 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2365 if (0 != strcmp(packed, packed_cloned)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2366 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2367 purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2368 ++failures, packed_cloned, packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2369 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2370 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2371 g_free(packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2372 g_free(packed_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2373 msim_msg_free(msg_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2374 msim_msg_free(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2375 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2376 return failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2377 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2378 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2379 /** Test protocol-level escaping/unescaping. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2380 int msim_test_escaping(void) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2381 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2382 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2383 gchar *raw, *escaped, *unescaped, *expected; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2384 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2385 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2386 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2387 purple_debug_info("msim", "\n\nTesting escaping\n"); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2388 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2389 raw = "hello/world\\hello/world"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2390 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2391 escaped = msim_escape(raw); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2392 purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2393 expected = "hello/1world/2hello/1world"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2394 if (0 != strcmp(escaped, expected)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2395 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2396 purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2397 ++failures, escaped, expected); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2398 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2399 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2400 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2401 unescaped = msim_unescape(escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2402 g_free(escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2403 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2404 if (0 != strcmp(raw, unescaped)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2405 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2406 purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2407 ++failures, raw, unescaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2408 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2409 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2410 return failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2411 } |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
2412 #endif |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2413 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2414 /** Initialize plugin. */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2415 void init_plugin(PurplePlugin *plugin) |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2416 { |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2417 PurpleAccountOption *option; |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2418 #ifdef MSIM_SELF_TEST |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2419 msim_test_all(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2420 #endif /* MSIM_SELF_TEST */ |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2421 |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2422 /* TODO: default to automatically try different ports. Make the user be |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2423 * able to set the first port to try (like LastConnectedPort in Windows client). */ |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2424 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2425 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2426 |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2427 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2428 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2429 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2430 option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2431 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2432 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2433 option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2434 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
2435 } |
16394 | 2436 |
16396 | 2437 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |