Mon, 02 Jul 2007 05:13:11 +0000
Fix typo to allow font face to be displayed correctly on incoming messages.
Disable font size on incoming instant messages, until I get it working.
Add OPT_PROTO_POINTSIZE to make it (hopefully) easier, and remove the function
to convert from point size to libpurple size, since with this flag it should
be possible to specify point size directly.
| 16322 | 1 | /* MySpaceIM Protocol Plugin |
| 2 | * | |
| 3 | * \author Jeff Connelly | |
| 4 | * | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
5 | * Copyright (C) 2007, Jeff Connelly <jeff2@homing.pidgin.im> |
| 16322 | 6 | * |
| 16324 | 7 | * Based on Purple's "C Plugin HOWTO" hello world example. |
| 16322 | 8 | * |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
9 | * Code also drawn from mockprpl: |
| 16324 | 10 | * http://snarfed.org/space/purple+mock+protocol+plugin |
| 16322 | 11 | * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
| 12 | * | |
| 16324 | 13 | * and some constructs also based on existing Purple plugins, which are: |
| 14 | * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> | |
| 16322 | 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 | ||
| 16324 | 34 | #define PURPLE_PLUGIN |
| 16322 | 35 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
36 | #include "message.h" |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
37 | #include "persist.h" |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
38 | #include "myspace.h" |
| 16322 | 39 | |
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
40 | /** |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
41 | * Load the plugin. |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
42 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
43 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
44 | msim_load(PurplePlugin *plugin) |
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
45 | { |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
46 | #ifdef MSIM_USE_PURPLE_RC4 |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
47 | /* If compiled to use RC4 from libpurple, check if it is really there. */ |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
48 | if (!purple_ciphers_find_cipher("rc4")) |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
49 | { |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
50 | purple_debug_error("msim", "compiled with MSIM_USE_PURPLE_RC4 but rc4 not in libpurple - not loading MySpaceIM plugin!\n"); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
51 | purple_notify_error(plugin, _("Missing Cipher"), |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
52 | _("The RC4 cipher could not be found"), |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
53 | _("Recompile without MSIM_USE_PURPLE_RC4, or upgrade " |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
54 | "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
55 | "plugin will not be loaded.")); |
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
56 | return FALSE; |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
57 | } |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
58 | #endif |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
59 | return TRUE; |
| 16322 | 60 | } |
| 61 | ||
| 62 | /** | |
| 63 | * Get possible user status types. Based on mockprpl. | |
| 64 | * | |
| 65 | * @return GList of status types. | |
| 66 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
67 | GList * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
68 | msim_status_types(PurpleAccount *acct) |
| 16322 | 69 | { |
| 70 | GList *types; | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
71 | PurpleStatusType *status; |
| 16322 | 72 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
73 | purple_debug_info("myspace", "returning status types\n"); |
| 16322 | 74 | |
| 75 | types = NULL; | |
| 76 | ||
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
77 | status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
78 | types = g_list_append(types, status); |
| 16322 | 79 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
80 | status = purple_status_type_new_full(PURPLE_STATUS_AWAY, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
81 | types = g_list_append(types, status); |
| 16322 | 82 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
83 | status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
84 | types = g_list_append(types, status); |
| 16322 | 85 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
86 | status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
87 | types = g_list_append(types, status); |
| 16322 | 88 | |
| 89 | return types; | |
| 90 | } | |
| 91 | ||
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
92 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
93 | * Return the icon name for a buddy and account. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
94 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
95 | * @param acct The account to find the icon for, or NULL for protocol icon. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
96 | * @param buddy The buddy to find the icon for, or NULL for the account icon. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
97 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
98 | * @return The base icon name string. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
99 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
100 | const gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
101 | msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
102 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
103 | /* Use a MySpace icon submitted by hbons at |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
104 | * http://developer.pidgin.im/wiki/MySpaceIM. */ |
|
16334
ff6947265141
Add and use MySpaceIM icon uploaded by hbons (48x48 original and resized 22x22 and 16x16 versions).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16333
diff
changeset
|
105 | return "myspace"; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
106 | } |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
107 | |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
108 | /* Replacement codes to be replaced with associated replacement text, |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
109 | * used for protocol message escaping / unescaping. */ |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
110 | static gchar* msim_replacement_code[] = { "/1", "/2", NULL }; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
111 | static gchar* msim_replacement_text[] = { "/", "\\", NULL }; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
112 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
113 | /** |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
114 | * Unescape or escape a protocol message. |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
115 | * |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
116 | * @param msg The message to be unescaped or escaped. WILL BE FREED. |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
117 | * @param escape TRUE to escape, FALSE to unescape. |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
118 | * |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
119 | * @return The unescaped or escaped message. Caller must g_free(). |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
120 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
121 | gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
122 | msim_unescape_or_escape(gchar *msg, gboolean escape) |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
123 | { |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
124 | gchar *tmp, *code, *text; |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
125 | guint i; |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
126 | |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
127 | /* Replace each code in msim_replacement_code with |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
128 | * corresponding entry in msim_replacement_text. */ |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
129 | for (i = 0; (code = msim_replacement_code[i]) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
130 | && (text = msim_replacement_text[i]); ++i) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
131 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
132 | if (escape) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
133 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
134 | tmp = str_replace(msg, text, code); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
135 | } |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
136 | else |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
137 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
138 | tmp = str_replace(msg, code, text); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
139 | } |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
140 | g_free(msg); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
141 | msg = tmp; |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
142 | } |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
143 | |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
144 | return msg; |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
145 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
146 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
147 | /** |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
148 | * Escape a protocol message. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
149 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
150 | * @return The escaped message. Caller must g_free(). |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
151 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
152 | gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
153 | msim_escape(const gchar *msg) |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
154 | { |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
155 | return msim_unescape_or_escape(g_strdup(msg), TRUE); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
156 | } |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
157 | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
158 | gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
159 | msim_unescape(const gchar *msg) |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
160 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
161 | return msim_unescape_or_escape(g_strdup(msg), FALSE); |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
162 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
163 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
164 | /** |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
165 | * Replace 'old' with 'new' in 'str'. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
166 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
167 | * @param str The original string. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
168 | * @param old The substring of 'str' to replace. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
169 | * @param new The replacement for 'old' within 'str'. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
170 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
171 | * @return A _new_ string, based on 'str', with 'old' replaced |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
172 | * by 'new'. Must be g_free()'d by caller. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
173 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
174 | * This string replace method is based on |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
175 | * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
176 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
177 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
178 | gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
179 | str_replace(const gchar *str, const gchar *old, const gchar *new) |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
180 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
181 | gchar **items; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
182 | gchar *ret; |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
183 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
184 | items = g_strsplit(str, old, -1); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
185 | ret = g_strjoinv(new, items); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
186 | g_free(items); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
187 | return ret; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
188 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
189 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
190 | #ifdef MSIM_DEBUG_MSG |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
191 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
192 | print_hash_item(gpointer key, gpointer value, gpointer user_data) |
| 16322 | 193 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
194 | purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
| 16322 | 195 | } |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
196 | #endif |
| 16322 | 197 | |
| 198 | /** | |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
199 | * Send raw data (given as a NUL-terminated string) to the server. |
| 16322 | 200 | * |
| 201 | * @param session | |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
202 | * @param msg The raw data to send, in a NUL-terminated string. |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
203 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
204 | * @return TRUE if succeeded, FALSE if not. |
| 16322 | 205 | * |
| 206 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
207 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
208 | msim_send_raw(MsimSession *session, const gchar *msg) |
| 16322 | 209 | { |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
210 | purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
| 16322 | 211 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
212 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
213 | g_return_val_if_fail(msg != NULL, FALSE); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
214 | |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
215 | return msim_send_really_raw(session->gc, msg, strlen(msg)) == |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
216 | strlen(msg); |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
217 | } |
| 16322 | 218 | |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
219 | /** Send raw data to the server, possibly with embedded NULs. |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
220 | * |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
221 | * Used in prpl_info struct, so that plugins can have the most possible |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
222 | * control of what is sent over the connection. Inside this prpl, |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
223 | * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
224 | * |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
225 | * @param gc PurpleConnection |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
226 | * @param buf Buffer to send |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
227 | * @param total_bytes Size of buffer to send |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
228 | * |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
229 | * @return Bytes successfully sent. |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
230 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
231 | int |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
232 | msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
233 | { |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
234 | int total_bytes_sent; |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
235 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
236 | /* Loop until all data is sent, or a failure occurs. */ |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
237 | total_bytes_sent = 0; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
238 | do |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
239 | { |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
240 | int bytes_sent; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
241 | |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
242 | bytes_sent = send(((MsimSession*)(gc->proto_data))->fd, |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
243 | buf + total_bytes_sent, total_bytes - total_bytes_sent, 0); |
| 16322 | 244 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
245 | if (bytes_sent < 0) |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
246 | { |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
247 | purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
248 | buf, g_strerror(errno)); |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
249 | return total_bytes_sent; |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
250 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
251 | total_bytes_sent += bytes_sent; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
252 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
253 | } while(total_bytes_sent < total_bytes); |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
254 | |
|
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
255 | return total_bytes_sent; |
| 16322 | 256 | } |
| 257 | ||
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
258 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
259 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
260 | * Start logging in to the MSIM servers. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
261 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
262 | * @param acct Account information to use to login. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
263 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
264 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
265 | msim_login(PurpleAccount *acct) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
266 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
267 | PurpleConnection *gc; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
268 | const gchar *host; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
269 | int port; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
270 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
271 | g_return_if_fail(acct != NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
272 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
273 | purple_debug_info("myspace", "logging in %s\n", acct->username); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
274 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
275 | gc = purple_account_get_connection(acct); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
276 | gc->proto_data = msim_session_new(acct); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
277 | |
|
17998
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
278 | if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
279 | { |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
280 | gchar *str; |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
281 | |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
282 | |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
283 | /* TODO: Find out why >8 is problematic. The web site lets you have |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
284 | * long passwords, but reportedly the official IM client does not |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
285 | * allow more than 8 characters to be entered. Just entering the first |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
286 | * 8 does not, on first try, appear to work. */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
287 | /* Note: official client lets you have 10 characters in password. */ |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
288 | str = g_strdup_printf( |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
289 | _("Sorry, passwords over %d characters in length (yours is " |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
290 | "%d) are currently not supported by the MySpaceIM plugin."), |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
291 | MSIM_MAX_PASSWORD_LENGTH, |
|
17998
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
292 | (int)strlen(acct->password)); |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
293 | |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
294 | /* Notify an error message also, because this is important! */ |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
295 | purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL); |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
296 | |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
297 | purple_connection_error(gc, str); |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
298 | |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
299 | g_free(str); |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
300 | } |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
301 | |
|
e739eb3e0567
Fail with our own error message if an entered password is greater than 8
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17997
diff
changeset
|
302 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
303 | /* 1. connect to server */ |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
304 | purple_connection_update_progress(gc, _("Connecting"), |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
305 | 0, /* which connection step this is */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
306 | 4); /* total number of steps */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
307 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
308 | host = purple_account_get_string(acct, "server", MSIM_SERVER); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
309 | port = purple_account_get_int(acct, "port", MSIM_PORT); |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
310 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
311 | /* From purple.sf.net/api: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
312 | * """Note that this function name can be misleading--although it is called |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
313 | * "proxy connect," it is used for establishing any outgoing TCP connection, |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
314 | * whether through a proxy or not.""" */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
315 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
316 | /* Calls msim_connect_cb when connected. */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
317 | if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
318 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
319 | /* TODO: try other ports if in auto mode, then save |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
320 | * working port and try that first next time. */ |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
321 | purple_connection_error(gc, _("Couldn't create socket")); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
322 | return; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
323 | } |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
324 | } |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
325 | |
| 16322 | 326 | /** |
| 327 | * Process a login challenge, sending a response. | |
| 328 | * | |
| 329 | * @param session | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
330 | * @param msg Login challenge message. |
| 16322 | 331 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
332 | * @return TRUE if successful, FALSE if not |
| 16322 | 333 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
334 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
335 | msim_login_challenge(MsimSession *session, MsimMessage *msg) |
| 16322 | 336 | { |
| 16324 | 337 | PurpleAccount *account; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
338 | const gchar *response; |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
339 | guint response_len; |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
340 | gchar *nc; |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
341 | gsize nc_len; |
| 16322 | 342 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
343 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
344 | g_return_val_if_fail(msg != NULL, FALSE); |
| 16322 | 345 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
346 | g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
| 16322 | 347 | |
| 348 | account = session->account; | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
349 | |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
350 | g_return_val_if_fail(account != NULL, FALSE); |
| 16322 | 351 | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
352 | purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
| 16322 | 353 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
354 | purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
| 16322 | 355 | |
| 356 | if (nc_len != 0x40) | |
| 357 | { | |
| 16324 | 358 | purple_debug_info("msim", "bad nc length: %x != 0x40\n", nc_len); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
359 | purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
360 | return FALSE; |
| 16322 | 361 | } |
| 362 | ||
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
363 | purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
| 16322 | 364 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
365 | response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
| 16322 | 366 | |
| 367 | g_free(nc); | |
| 368 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
369 | return msim_send(session, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
370 | "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
371 | /* This is actually user's email address. */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
372 | "username", MSIM_TYPE_STRING, g_strdup(account->username), |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
373 | /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
374 | "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
375 | "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
376 | "reconn", MSIM_TYPE_INTEGER, 0, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
377 | "status", MSIM_TYPE_INTEGER, 100, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
378 | "id", MSIM_TYPE_INTEGER, 1, |
|
17898
d08d6d221276
Incomplete attempt at using msim_send() instead of msim_send_raw().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17897
diff
changeset
|
379 | NULL); |
| 16322 | 380 | } |
| 381 | ||
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
382 | #ifndef MSIM_USE_PURPLE_RC4 |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
383 | /* No RC4 in this version of libpurple, so bring our own. */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
384 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
385 | /* |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
386 | Unix SMB/CIFS implementation. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
387 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
388 | a partial implementation of RC4 designed for use in the |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
389 | SMB authentication protocol |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
390 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
391 | Copyright (C) Andrew Tridgell 1998 |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
392 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
393 | $Id: crypt-rc4.c 12116 2004-09-27 23:29:22Z guy $ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
394 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
395 | This program is free software; you can redistribute it and/or modify |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
396 | it under the terms of the GNU General Public License as published by |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
397 | the Free Software Foundation; either version 2 of the License, or |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
398 | (at your option) any later version. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
399 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
400 | This program is distributed in the hope that it will be useful, |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
401 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
402 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
403 | GNU General Public License for more details. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
404 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
405 | You should have received a copy of the GNU General Public License |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
406 | along with this program; if not, write to the Free Software |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
407 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
408 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
409 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
410 | Modified by Jeff Connelly for MySpaceIM Gaim plugin. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
411 | */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
412 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
413 | #include <glib.h> |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
414 | #include <string.h> |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
415 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
416 | /* Perform RC4 on a block of data using specified key. "data" is a pointer |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
417 | to the block to be processed. Output is written to same memory as input, |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
418 | so caller may need to make a copy before calling this function, since |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
419 | the input will be overwritten. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
420 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
421 | Taken from Samba source code. Modified to allow us to maintain state |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
422 | between calls to crypt_rc4. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
423 | */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
424 | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
425 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
426 | crypt_rc4_init(rc4_state_struct *rc4_state, |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
427 | const guchar *key, int key_len) |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
428 | { |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
429 | int ind; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
430 | unsigned gchar j = 0; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
431 | unsigned gchar *s_box; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
432 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
433 | memset(rc4_state, 0, sizeof(rc4_state_struct)); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
434 | s_box = rc4_state->s_box; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
435 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
436 | for (ind = 0; ind < 256; ind++) |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
437 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
438 | s_box[ind] = (guchar)ind; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
439 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
440 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
441 | for( ind = 0; ind < 256; ind++) |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
442 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
443 | guchar tc; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
444 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
445 | j += (s_box[ind] + key[ind%key_len]); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
446 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
447 | tc = s_box[ind]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
448 | s_box[ind] = s_box[j]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
449 | s_box[j] = tc; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
450 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
451 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
452 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
453 | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
454 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
455 | crypt_rc4(rc4_state_struct *rc4_state, guchar *data, int data_len) |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
456 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
457 | guchar *s_box; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
458 | guchar index_i; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
459 | guchar index_j; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
460 | int ind; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
461 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
462 | /* retrieve current state from the state struct (so we can resume where |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
463 | we left off) */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
464 | index_i = rc4_state->index_i; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
465 | index_j = rc4_state->index_j; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
466 | s_box = rc4_state->s_box; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
467 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
468 | for( ind = 0; ind < data_len; ind++) |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
469 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
470 | guchar tc; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
471 | guchar t; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
472 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
473 | index_i++; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
474 | index_j += s_box[index_i]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
475 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
476 | tc = s_box[index_i]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
477 | s_box[index_i] = s_box[index_j]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
478 | s_box[index_j] = tc; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
479 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
480 | t = s_box[index_i] + s_box[index_j]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
481 | data[ind] = data[ind] ^ s_box[t]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
482 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
483 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
484 | /* Store the updated state */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
485 | rc4_state->index_i = index_i; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
486 | rc4_state->index_j = index_j; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
487 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
488 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
489 | #endif /* !MSIM_USE_PURPLE_RC4 */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
490 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
491 | |
| 16322 | 492 | /** |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
493 | * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
494 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
495 | * @param nonce The base64 encoded nonce ('nc') field from the server. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
496 | * @param email User's email address (used as login name). |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
497 | * @param password User's cleartext password. |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
498 | * @param response_len Will be written with response length. |
| 16322 | 499 | * |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
500 | * @return Binary login challenge response, ready to send to the server. Must be g_free()'d |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
501 | * when finished. |
| 16322 | 502 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
503 | const gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
504 | msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
505 | const gchar *email, const gchar *password, guint *response_len) |
| 16322 | 506 | { |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
507 | PurpleCipherContext *key_context; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
508 | PurpleCipher *sha1; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
509 | #ifdef MSIM_USE_PURPLE_RC4 |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
510 | PurpleCipherContext *rc4; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
511 | #else |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
512 | rc4_state_struct rc4; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
513 | #endif |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
514 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
515 | guchar hash_pw[HASH_SIZE]; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
516 | guchar key[HASH_SIZE]; |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
517 | gchar *password_utf16le; |
|
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
518 | guchar *data; |
|
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
519 | guchar *data_out; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
520 | size_t data_len, data_out_len; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
521 | gsize conv_bytes_read, conv_bytes_written; |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
522 | GError *conv_error; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
523 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
524 | int i; |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
525 | #endif |
| 16322 | 526 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
527 | /* Convert ASCII password to UTF16 little endian */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
528 | purple_debug_info("msim", "converting password to UTF-16LE\n"); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
529 | conv_error = NULL; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
530 | password_utf16le = g_convert(password, -1, "UTF-16LE", "UTF-8", |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
531 | &conv_bytes_read, &conv_bytes_written, &conv_error); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
532 | g_assert(conv_bytes_read == strlen(password)); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
533 | if (conv_error != NULL) |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
534 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
535 | purple_debug_error("msim", |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
536 | "g_convert password UTF8->UTF16LE failed: %s", |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
537 | conv_error->message); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
538 | g_error_free(conv_error); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
539 | } |
| 16322 | 540 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
541 | /* Compute password hash */ |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
542 | purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
543 | conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
544 | g_free(password_utf16le); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
545 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
546 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
547 | purple_debug_info("msim", "pwhash = "); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
548 | for (i = 0; i < sizeof(hash_pw); i++) |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
549 | purple_debug_info("msim", "%.2x ", hash_pw[i]); |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
550 | purple_debug_info("msim", "\n"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
551 | #endif |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
552 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
553 | /* key = sha1(sha1(pw) + nonce2) */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
554 | sha1 = purple_ciphers_find_cipher("sha1"); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
555 | key_context = purple_cipher_context_new(sha1, NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
556 | purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
557 | purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
558 | purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
559 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
560 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
561 | purple_debug_info("msim", "key = "); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
562 | for (i = 0; i < sizeof(key); i++) |
| 16322 | 563 | { |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
564 | purple_debug_info("msim", "%.2x ", key[i]); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
565 | } |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
566 | purple_debug_info("msim", "\n"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
567 | #endif |
| 16322 | 568 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
569 | #ifdef MSIM_USE_PURPLE_RC4 |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
570 | rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
| 16322 | 571 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
572 | /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
573 | * but only first 0x10 used for the RC4 key. */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
574 | purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
575 | purple_cipher_context_set_key(rc4, key); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
576 | #endif |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
577 | |
|
17985
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
578 | /* TODO: obtain IPs of network interfaces */ |
|
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
579 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
580 | /* rc4 encrypt: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
581 | * nonce1+email+IP list */ |
|
17985
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
582 | |
|
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
583 | data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
584 | data = g_new0(guchar, data_len); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
585 | memcpy(data, nonce, NONCE_SIZE); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
586 | memcpy(data + NONCE_SIZE, email, strlen(email)); |
|
17985
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
587 | memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
588 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
589 | #ifdef MSIM_USE_PURPLE_RC4 |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
590 | data_out = g_new0(guchar, data_len); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
591 | |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
592 | purple_cipher_context_encrypt(rc4, (const guchar *)data, |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
593 | data_len, data_out, &data_out_len); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
594 | purple_cipher_context_destroy(rc4); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
595 | #else |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
596 | /* Use our own RC4 code */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
597 | purple_debug_info("msim", "Using non-purple RC4 cipher code in this version\n"); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
598 | crypt_rc4_init(&rc4, key, 0x10); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
599 | crypt_rc4(&rc4, data, data_len); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
600 | data_out_len = data_len; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
601 | data_out = data; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
602 | #endif |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
603 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
604 | g_assert(data_out_len == data_len); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
605 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
606 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
607 | purple_debug_info("msim", "response=<%s>\n", data_out); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
608 | #endif |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
609 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
610 | *response_len = data_out_len; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
611 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
612 | return (const gchar *)data_out; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
613 | } |
| 16322 | 614 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
615 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
616 | * Schedule an IM to be sent once the user ID is looked up. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
617 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
618 | * @param gc Connection. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
619 | * @param who A user id, email, or username to send the message to. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
620 | * @param message Instant message text to send. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
621 | * @param flags Flags. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
622 | * |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
623 | * @return 1 if successful or postponed, -1 if failed |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
624 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
625 | * Allows sending to a user by username, email address, or userid. If |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
626 | * a username or email address is given, the userid must be looked up. |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
627 | * This function does that by calling msim_postprocess_outgoing(). |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
628 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
629 | int |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
630 | msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
631 | PurpleMessageFlags flags) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
632 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
633 | MsimSession *session; |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
634 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
635 | g_return_val_if_fail(gc != NULL, 0); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
636 | g_return_val_if_fail(who != NULL, 0); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
637 | g_return_val_if_fail(message != NULL, 0); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
638 | |
|
17944
62750b952935
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17943
diff
changeset
|
639 | /* 'flags' has many options, not used here. */ |
|
62750b952935
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17943
diff
changeset
|
640 | |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
641 | session = gc->proto_data; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
642 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
643 | if (msim_send_bm(session, who, message, MSIM_BM_INSTANT)) |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
644 | { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
645 | /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
646 | * return 1 even if the message could not be sent, since I don't know if |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
647 | * it has failed yet--because the IM is only sent after the userid is |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
648 | * retrieved from the server (which happens after this function returns). |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
649 | */ |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
650 | return 1; |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
651 | } else { |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
652 | return -1; |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
653 | } |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
654 | /* |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
655 | * In MySpace, you login with your email address, but don't talk to other |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
656 | * users using their email address. So there is currently an asymmetry in the |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
657 | * IM windows when using this plugin: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
658 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
659 | * you@example.com: hello |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
660 | * some_other_user: what's going on? |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
661 | * you@example.com: just coding a prpl |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
662 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
663 | * TODO: Make the sent IM's appear as from the user's username, instead of |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
664 | * their email address. Purple uses the login (in MSIM, the email)--change this. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
665 | */ |
| 16322 | 666 | } |
| 667 | ||
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
668 | /** Send a buddy message of a given type. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
669 | * |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
670 | * @param session |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
671 | * @param who Username to send message to. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
672 | * @param text Message text to send. Not freed; will be copied. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
673 | * @param type A MSIM_BM_* constant. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
674 | * |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
675 | * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
676 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
677 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
678 | msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
679 | int type) |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
680 | { |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
681 | gboolean rc; |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
682 | MsimMessage *msg; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
683 | const gchar *from_username; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
684 | |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
685 | from_username = session->account->username; |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
686 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
687 | purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
688 | type, from_username, who, text); |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
689 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
690 | msg = msim_msg_new(TRUE, |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
691 | "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
692 | "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
693 | /* 't' will be inserted here */ |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
694 | "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
695 | "msg", MSIM_TYPE_STRING, g_strdup(text), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
696 | NULL); |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
697 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
698 | rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
699 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
700 | msim_msg_free(msg); |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
701 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
702 | return rc; |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
703 | } |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
704 | |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
705 | /** Convert a msim markup font height to points. */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
706 | static guint |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
707 | msim_font_height_to_point(guint height) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
708 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
709 | /* See also: libpurple/protocols/bonjour/jabber.c |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
710 | * _font_size_ichat_to_purple */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
711 | switch (height) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
712 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
713 | case 11: return 8; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
714 | case 12: return 9; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
715 | case 13: return 10; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
716 | case 14: |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
717 | case 15: return 11; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
718 | case 16: return 12; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
719 | case 17: |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
720 | case 18: return 13; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
721 | case 19: return 14; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
722 | case 20: return 15; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
723 | case 21: return 16; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
724 | default: return 12; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
725 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
726 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
727 | |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
728 | /** Convert the msim markup <f> (font) tag into HTML. */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
729 | static void msim_markup_f_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
730 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
731 | const gchar *face, *height_str, *decor_str; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
732 | GString *gs_end, *gs_begin; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
733 | guint decor, height; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
734 | |
|
18011
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
735 | face = xmlnode_get_attrib(root, "f"); |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
736 | height_str = xmlnode_get_attrib(root, "h"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
737 | decor_str = xmlnode_get_attrib(root, "s"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
738 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
739 | if (height_str) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
740 | height = atol(height_str); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
741 | else |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
742 | height = 12; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
743 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
744 | if (decor_str) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
745 | decor = atol(decor_str); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
746 | else |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
747 | decor = 0; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
748 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
749 | gs_begin = g_string_new(""); |
|
18011
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
750 | #ifdef MSIM_FONT_SIZE_WORKS |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
751 | /* TODO: get font size working */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
752 | if (!face) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
753 | g_string_printf(gs_begin, "<font size='%d'>", |
|
18011
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
754 | msim_font_height_to_point(height)); |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
755 | else |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
756 | g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
|
18011
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
757 | msim_font_height_to_point(height)); |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
758 | #else |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
759 | if (face) |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
760 | { |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
761 | g_string_printf(gs_begin, "<font face='%s'>", face); |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
762 | } else { |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
763 | g_string_printf(gs_begin, "<font>"); |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
764 | } |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
765 | #endif |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
766 | |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
767 | |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
768 | /* No support for font-size CSS? */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
769 | /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
770 | msim_font_height_to_point(height)); */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
771 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
772 | gs_end = g_string_new("</font>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
773 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
774 | if (decor & 1) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
775 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
776 | g_string_append(gs_begin, "<b>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
777 | g_string_prepend(gs_end, "</b>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
778 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
779 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
780 | if (decor & 2) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
781 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
782 | g_string_append(gs_begin, "<i>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
783 | g_string_append(gs_end, "</i>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
784 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
785 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
786 | if (decor & 4) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
787 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
788 | g_string_append(gs_begin, "<u>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
789 | g_string_append(gs_end, "</u>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
790 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
791 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
792 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
793 | *begin = gs_begin->str; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
794 | *end = gs_end->str; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
795 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
796 | |
|
18010
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
797 | /** Convert a msim markup color to a color suitable for libpurple. |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
798 | * |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
799 | * @param msim Either a color name, or an rgb(x,y,z) code. |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
800 | * |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
801 | * @return A new string, either a color name or #rrggbb code. Must g_free(). |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
802 | */ |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
803 | static char *msim_color_to_purple(const char *msim) |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
804 | { |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
805 | guint red, green, blue; |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
806 | |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
807 | if (!msim) |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
808 | return g_strdup("black"); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
809 | |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
810 | if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
811 | { |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
812 | /* Color name. */ |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
813 | return g_strdup(msim); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
814 | } |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
815 | /* TODO: rgba (alpha). */ |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
816 | |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
817 | return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
818 | } |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
819 | |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
820 | /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
821 | static void msim_markup_p_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
822 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
823 | /* Just pass through unchanged. |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
824 | * |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
825 | * Note: attributes currently aren't passed, if there are any. */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
826 | *begin = g_strdup("<p>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
827 | *end = g_strdup("</p>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
828 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
829 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
830 | /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
831 | static void msim_markup_c_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
832 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
833 | const gchar *color; |
|
18010
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
834 | gchar *purple_color; |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
835 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
836 | color = xmlnode_get_attrib(root, "v"); |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
837 | if (!color) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
838 | { |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
839 | purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
840 | *begin = g_strdup(""); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
841 | *end = g_strdup(""); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
842 | /* TODO: log as unrecognized */ |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
843 | return; |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
844 | } |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
845 | |
|
18010
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
846 | purple_color = msim_color_to_purple(color); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
847 | |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
848 | *begin = g_strdup_printf("<font color='%s'>", purple_color); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
849 | |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
850 | g_free(purple_color); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
851 | |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
852 | /* *begin = g_strdup_printf("<span style='color: %s'>", color); */ |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
853 | *end = g_strdup("</font>"); |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
854 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
855 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
856 | /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
857 | static void msim_markup_b_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
858 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
859 | const gchar *color; |
|
18010
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
860 | gchar *purple_color; |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
861 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
862 | color = xmlnode_get_attrib(root, "v"); |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
863 | if (!color) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
864 | { |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
865 | *begin = g_strdup(""); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
866 | *end = g_strdup(""); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
867 | purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
868 | /* TODO: log as unrecognized. */ |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
869 | return; |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
870 | } |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
871 | |
|
18010
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
872 | purple_color = msim_color_to_purple(color); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
873 | |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
874 | /* TODO: find out how to set background color. */ |
|
18010
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
875 | *begin = g_strdup_printf("<span style='background-color: %s'>", |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
876 | purple_color); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
877 | g_free(purple_color); |
|
3b1fc616ee59
Add msim_color_to_purple() to convert msim markup color to a color for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18009
diff
changeset
|
878 | |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
879 | *end = g_strdup("</p>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
880 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
881 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
882 | /** Convert the msim markup <i> tag (emoticon image) into HTML. TODO: Test */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
883 | static void msim_markup_i_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
884 | { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
885 | const gchar *name; |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
886 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
887 | name = xmlnode_get_attrib(root, "n"); |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
888 | if (!name) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
889 | { |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
890 | purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
891 | *begin = g_strdup(""); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
892 | *end = g_strdup(""); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
893 | /* TODO: log as unrecognized */ |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
894 | return; |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
895 | } |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
896 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
897 | /* TODO: Support these emoticons: |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
898 | * |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
899 | * bigsmile growl mad scared tongue devil happy messed sidefrown upset |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
900 | * frazzled heart nerd sinister wink geek laugh oops smirk worried |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
901 | * googles mohawk pirate straight kiss |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
902 | */ |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
903 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
904 | *begin = g_strdup_printf("<img id='%s'>", name); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
905 | *end = g_strdup("</p>"); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
906 | } |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
907 | |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
908 | |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
909 | /** Convert an xmlnode of msim markup to an HTML string. |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
910 | * @return An HTML string. Caller frees. |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
911 | */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
912 | static gchar *msim_markup_xmlnode_to_html(xmlnode *root) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
913 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
914 | xmlnode *node; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
915 | gchar *begin, *inner, *end; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
916 | gchar *final; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
917 | |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
918 | if (!root || !root->name) |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
919 | return g_strdup(""); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
920 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
921 | purple_debug_info("msim", "msim_markup_xmlnode_to_html: got root=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
922 | root->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
923 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
924 | begin = inner = end = NULL; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
925 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
926 | if (!strcmp(root->name, "f")) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
927 | { |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
928 | msim_markup_f_to_html(root, &begin, &end); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
929 | } else if (!strcmp(root->name, "p")) { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
930 | msim_markup_p_to_html(root, &begin, &end); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
931 | } else if (!strcmp(root->name, "c")) { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
932 | msim_markup_c_to_html(root, &begin, &end); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
933 | } else if (!strcmp(root->name, "b")) { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
934 | msim_markup_b_to_html(root, &begin, &end); |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
935 | } else if (!strcmp(root->name, "i")) { |
|
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
936 | msim_markup_i_to_html(root, &begin, &end); |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
937 | } else { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
938 | purple_debug_info("msim", "msim_markup_xmlnode_to_html: " |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
939 | "unknown tag name=%s, ignoring", root->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
940 | begin = g_strdup(""); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
941 | end = g_strdup(""); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
942 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
943 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
944 | /* Loop over all child nodes. */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
945 | for (node = root->child; node != NULL; node = node->next) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
946 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
947 | switch (node->type) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
948 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
949 | case XMLNODE_TYPE_ATTRIB: |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
950 | /* Attributes handled above. */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
951 | break; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
952 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
953 | case XMLNODE_TYPE_TAG: |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
954 | /* A tag or tag with attributes. Recursively descend. */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
955 | inner = msim_markup_xmlnode_to_html(node); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
956 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
957 | purple_debug_info("msim", " ** node name=%s\n", node->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
958 | break; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
959 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
960 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
961 | case XMLNODE_TYPE_DATA: |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
962 | /* Literal text. */ |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
963 | inner = g_new0(char, node->data_sz + 1); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
964 | strncpy(inner, node->data, node->data_sz); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
965 | inner[node->data_sz + 1] = 0; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
966 | |
|
18011
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
967 | purple_debug_info("msim", " ** node data=%s\n", inner); |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
968 | break; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
969 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
970 | default: |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
971 | purple_debug_info("msim", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
972 | "msim_markup_xmlnode_to_html: strange node\n"); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
973 | inner = g_strdup(""); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
974 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
975 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
976 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
977 | final = g_strconcat(begin, inner, end, NULL); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
978 | g_free(begin); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
979 | g_free(inner); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
980 | g_free(end); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
981 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
982 | purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
983 | final); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
984 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
985 | return final; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
986 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
987 | |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
988 | /** Convert MySpaceIM markup to Purple (HTML) markup. |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
989 | * |
|
18001
cb5747cb6992
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17998
diff
changeset
|
990 | * @return Purple markup string, must be g_free()'d. */ |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
991 | gchar * |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
992 | msim_markup_to_html(const gchar *raw) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
993 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
994 | xmlnode *root; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
995 | gchar *str; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
996 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
997 | root = xmlnode_from_str(raw, -1); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
998 | if (!root) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
999 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1000 | purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1001 | "%s as XML, returning raw\n", raw); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1002 | return g_strdup(raw); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1003 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1004 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1005 | str = msim_markup_xmlnode_to_html(root); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1006 | purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1007 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1008 | xmlnode_free(root); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1009 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1010 | return g_strdup(str); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1011 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1012 | |
| 16322 | 1013 | /** |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1014 | * Handle an incoming instant message. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1015 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1016 | * @param session The session |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
1017 | * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
|
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
1018 | * Should also contain username in _username from preprocessing. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1019 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1020 | * @return TRUE if successful. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1021 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1022 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1023 | msim_incoming_im(MsimSession *session, MsimMessage *msg) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1024 | { |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1025 | gchar *username, *msg_msim_markup, *msg_purple_markup; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1026 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
1027 | username = msim_msg_get_string(msg, "_username"); |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1028 | msg_msim_markup = msim_msg_get_string(msg, "msg"); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1029 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1030 | msg_purple_markup = msim_markup_to_html(msg_msim_markup); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1031 | g_free(msg_msim_markup); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1032 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1033 | serv_got_im(session->gc, username, msg_purple_markup, |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1034 | PURPLE_MESSAGE_RECV, time(NULL)); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1035 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
1036 | g_free(username); |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
1037 | g_free(msg_purple_markup); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1038 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
1039 | return TRUE; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1040 | } |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1041 | |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1042 | /** |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1043 | * Handle an unrecognized message. |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1044 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1045 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1046 | msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1047 | { |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1048 | /* TODO: Some more context, outwardly equivalent to a backtrace, for helping figure |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1049 | * out what this msg is for. But not too much information so that a user |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1050 | * posting this dump reveals confidential information. |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1051 | */ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1052 | /* TODO: dump unknown msgs to file, so user can send them to me |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1053 | * if they wish, to help add support for new messages (inspired |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1054 | * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1055 | |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1056 | purple_debug_info("msim", "Unrecognized message on account for %s\n", session->account->username); |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1057 | if (note) |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1058 | { |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1059 | purple_debug_info("msim", "(Note: %s)\n", note); |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1060 | } |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1061 | |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1062 | msim_msg_dump("Unrecognized message dump: %s\n", msg); |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1063 | } |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1064 | |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1065 | /** |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1066 | * Handle an incoming action message. |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1067 | * |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1068 | * @param session |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1069 | * @param msg |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1070 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1071 | * @return TRUE if successful. |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1072 | * |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1073 | * UNTESTED |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1074 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1075 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1076 | msim_incoming_action(MsimSession *session, MsimMessage *msg) |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1077 | { |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1078 | gchar *msg_text, *username; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1079 | gboolean rc; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1080 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1081 | msg_text = msim_msg_get_string(msg, "msg"); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1082 | username = msim_msg_get_string(msg, "_username"); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1083 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1084 | purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", msg_text, username); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1085 | |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1086 | if (strcmp(msg_text, "%typing%") == 0) |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1087 | { |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1088 | /* TODO: find out if msim repeatedly sends typing messages, so we can give it a timeout. |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1089 | * Right now, there does seem to be an inordinately amount of time between typing/ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1090 | * stopped-typing notifications. */ |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1091 | serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1092 | rc = TRUE; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1093 | } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1094 | serv_got_typing_stopped(session->gc, username); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1095 | rc = TRUE; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1096 | } else { |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1097 | msim_unrecognized(session, msg, "got to msim_incoming_action but unrecognized value for 'msg'"); |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1098 | rc = FALSE; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1099 | } |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1100 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1101 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1102 | g_free(msg_text); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1103 | g_free(username); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1104 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
1105 | return rc; |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1106 | } |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1107 | |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1108 | /** |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1109 | * Handle when our user starts or stops typing to another user. |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1110 | * |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1111 | * @param gc |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1112 | * @param name The buddy name to which our user is typing to |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1113 | * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1114 | * |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1115 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1116 | unsigned int |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1117 | msim_send_typing(PurpleConnection *gc, const gchar *name, PurpleTypingState state) |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1118 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
1119 | const gchar *typing_str; |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
1120 | MsimSession *session; |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
1121 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
1122 | session = (MsimSession *)gc->proto_data; |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1123 | |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1124 | switch (state) |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1125 | { |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1126 | case PURPLE_TYPING: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1127 | typing_str = "%typing%"; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1128 | break; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1129 | |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1130 | case PURPLE_TYPED: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1131 | case PURPLE_NOT_TYPING: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1132 | default: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1133 | typing_str = "%stoptyping%"; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1134 | break; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1135 | } |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1136 | |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1137 | purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
1138 | msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1139 | return 0; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1140 | } |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1141 | |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1142 | /** Callback for msim_get_info(), for when user info is received. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1143 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1144 | msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, gpointer data) |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1145 | { |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1146 | GHashTable *body; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1147 | gchar *body_str; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1148 | MsimMessage *msg; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1149 | gchar *user; |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1150 | PurpleNotifyUserInfo *user_info; |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1151 | PurpleBuddy *buddy; |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1152 | const gchar *str, *str2; |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1153 | |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1154 | |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1155 | /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1156 | orthogonality. */ |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1157 | msg = (MsimMessage *)data; |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1158 | user = msim_msg_get_string(msg, "user"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1159 | if (!user) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1160 | { |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1161 | purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1162 | return; |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1163 | } |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1164 | |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1165 | purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", user); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1166 | msim_msg_free(msg); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1167 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1168 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1169 | body_str = msim_msg_get_string(user_info_msg, "body"); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1170 | body = msim_parse_body(body_str); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1171 | g_free(body_str); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1172 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1173 | buddy = purple_find_buddy(session->account, user); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1174 | /* Note: don't assume buddy is non-NULL; will be if lookup random user not on blist. */ |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1175 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1176 | user_info = purple_notify_user_info_new(); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1177 | |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1178 | /* Identification */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1179 | purple_notify_user_info_add_pair(user_info, _("User"), g_strdup(user)); |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1180 | |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1181 | /* note: g_hash_table_lookup does not create a new string! */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1182 | str = g_hash_table_lookup(body, "UserID"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1183 | if (str) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1184 | purple_notify_user_info_add_pair(user_info, _("User ID"), |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1185 | g_strdup(str)); |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1186 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1187 | /* a/s/l...the vitals */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1188 | str = g_hash_table_lookup(body, "Age"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1189 | if (str) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1190 | purple_notify_user_info_add_pair(user_info, _("Age"), g_strdup(str)); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1191 | |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1192 | str = g_hash_table_lookup(body, "Gender"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1193 | if (str) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1194 | purple_notify_user_info_add_pair(user_info, _("Gender"), g_strdup(str)); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1195 | |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1196 | str = g_hash_table_lookup(body, "Location"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1197 | if (str) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1198 | purple_notify_user_info_add_pair(user_info, _("Location"), |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1199 | g_strdup(str)); |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1200 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1201 | /* Other information */ |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1202 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1203 | /* Headline comes from buddy status messages */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1204 | if (buddy) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1205 | { |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1206 | str = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1207 | if (str) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1208 | purple_notify_user_info_add_pair(user_info, "Headline", str); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1209 | } |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1210 | |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1211 | |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1212 | str = g_hash_table_lookup(body, "BandName"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1213 | str2 = g_hash_table_lookup(body, "SongName"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1214 | if (str || str2) |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1215 | { |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1216 | purple_notify_user_info_add_pair(user_info, _("Song"), |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1217 | g_strdup_printf("%s - %s", |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1218 | str ? str : "Unknown Artist", |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1219 | str2 ? str2 : "Unknown Song")); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1220 | } |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1221 | |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1222 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1223 | /* Total friends only available if looked up by uid, not username. */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1224 | str = g_hash_table_lookup(body, "TotalFriends"); |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1225 | if (str) |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1226 | purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1227 | g_strdup(str)); |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1228 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1229 | purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1230 | purple_debug_info("msim", "msim_get_info_cb: username=%s\n", user); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1231 | //purple_notify_user_info_destroy(user_info); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1232 | /* Do not free username, since it will be used by user_info. */ |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1233 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1234 | //g_hash_table_destroy(body); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1235 | } |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1236 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1237 | /** Retrieve a user's profile. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1238 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1239 | msim_get_info(PurpleConnection *gc, const gchar *user) |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1240 | { |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1241 | PurpleBuddy *buddy; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1242 | MsimSession *session; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1243 | guint uid; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1244 | gchar *user_to_lookup; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1245 | MsimMessage *user_msg; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1246 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1247 | session = (MsimSession *)gc->proto_data; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1248 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1249 | /* Obtain uid of buddy. */ |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1250 | buddy = purple_find_buddy(session->account, user); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1251 | if (buddy) |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1252 | { |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1253 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1254 | if (!uid) |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1255 | { |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1256 | PurpleNotifyUserInfo *user_info; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1257 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1258 | user_info = purple_notify_user_info_new(); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1259 | purple_notify_user_info_add_pair(user_info, NULL, |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1260 | _("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?")); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1261 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1262 | purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1263 | purple_notify_user_info_destroy(user_info); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1264 | return; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1265 | } |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1266 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1267 | user_to_lookup = g_strdup_printf("%d", uid); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1268 | } else { |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1269 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1270 | /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1271 | user_to_lookup = g_strdup(user); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1272 | } |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1273 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1274 | /* Pass the username to msim_get_info_cb(), because since we lookup |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1275 | * by userid, the userinfo message will only contain the uid (not |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1276 | * the username). |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1277 | */ |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1278 | user_msg = msim_msg_new(TRUE, |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1279 | "user", MSIM_TYPE_STRING, g_strdup(user), |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1280 | NULL); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1281 | purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", user); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1282 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1283 | msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1284 | |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1285 | g_free(user_to_lookup); |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1286 | } |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
1287 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1288 | /** After a uid is resolved to username, tag it with the username and submit for processing. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1289 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1290 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1291 | * @param userinfo Response messsage to resolving request. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1292 | * @param data MsimMessage *, the message to attach information to. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1293 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1294 | static void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1295 | msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1296 | gpointer data) |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1297 | { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1298 | gchar *body_str; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1299 | GHashTable *body; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1300 | gchar *username; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1301 | MsimMessage *msg; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1302 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1303 | body_str = msim_msg_get_string(userinfo, "body"); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1304 | g_return_if_fail(body_str != NULL); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1305 | body = msim_parse_body(body_str); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1306 | g_return_if_fail(body != NULL); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1307 | g_free(body_str); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1308 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1309 | username = g_hash_table_lookup(body, "UserName"); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1310 | g_return_if_fail(username != NULL); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1311 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1312 | msg = (MsimMessage *)data; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1313 | /* Special elements name beginning with '_', we'll use internally within the |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1314 | * program (did not come from the wire). */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1315 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1316 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1317 | msim_process(session, msg); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1318 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
1319 | /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1320 | //XXX msim_msg_free(msg); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1321 | g_hash_table_destroy(body); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1322 | } |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1323 | |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1324 | #if 0 |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1325 | /* Lookup a username by userid, from buddy list. |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1326 | * |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1327 | * @param wanted_uid |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1328 | * |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1329 | * @return Username of wanted_uid, if on blist, or NULL. Static string. |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1330 | * |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1331 | * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1332 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1333 | static const gchar * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1334 | msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1335 | { |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1336 | GSList *buddies, *cur; |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1337 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1338 | buddies = purple_find_buddies(session->account, NULL); |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1339 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1340 | if (!buddies) |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1341 | { |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1342 | purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?"); |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1343 | return NULL; |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1344 | } |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1345 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1346 | for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1347 | { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1348 | PurpleBuddy *buddy; |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1349 | //PurpleBlistNode *node; |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1350 | guint uid; |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1351 | const gchar *name; |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1352 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1353 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1354 | /* See finch/gnthistory.c */ |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1355 | buddy = cur->data; |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1356 | //node = cur->data; |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1357 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1358 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1359 | //uid = purple_blist_node_get_int(node, "UserID"); |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1360 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1361 | /* name = buddy->name; */ /* crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1362 | /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1363 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1364 | /* XXX Is this right? Memory corruption here somehow. Happens only |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1365 | * when return one of these values. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1366 | name = purple_buddy_get_name(buddy); /* crash */ |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1367 | //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */ |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1368 | /* return name; */ /* crash (with above) */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1369 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1370 | /* name = NULL; */ /* no crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1371 | /* return NULL; */ /* no crash (with anything) */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1372 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1373 | /* crash = |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1374 | *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1375 | ======= Backtrace: ========= |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1376 | /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1377 | /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1378 | /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1379 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1380 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1381 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1382 | /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1383 | /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1384 | /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1385 | /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1386 | pidgin(main+0x8be)[0x46b45e] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1387 | /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1388 | pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1389 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1390 | or: |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1391 | *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1392 | (gdb) bt |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1393 | #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1394 | #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1395 | #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1396 | #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1397 | #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1398 | #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1399 | #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1400 | #7 0x00002b407810969f in msim_parse ( |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1401 | raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1402 | at message.c:648 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1403 | #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1404 | source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1405 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1406 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1407 | Why is it crashing in msim_parse()'s g_strdup()? |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1408 | */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1409 | purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1410 | name, uid, wanted_uid); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1411 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1412 | if (uid == wanted_uid) |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1413 | { |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1414 | gchar *ret; |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1415 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1416 | ret = g_strdup(name); |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1417 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1418 | g_slist_free(buddies); |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1419 | |
|
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1420 | return ret; |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1421 | } |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1422 | } |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1423 | |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1424 | g_slist_free(buddies); |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1425 | return NULL; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1426 | } |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1427 | #endif |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1428 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1429 | /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1430 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1431 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1432 | * @param msg MsimMessage *, freed by caller. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1433 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1434 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1435 | msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1436 | { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1437 | if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1438 | { |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1439 | guint uid; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1440 | const gchar *username; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1441 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1442 | /* 'f' = userid message is from, in buddy messages */ |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1443 | uid = msim_msg_get_integer(msg, "f"); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1444 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1445 | /* TODO: Make caching work. Currently it is commented out because |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1446 | * it crashes for unknown reasons, memory realloc error. */ |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1447 | #if 0 |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1448 | username = msim_uid2username_from_blist(session, uid); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1449 | #else |
|
18002
ba63892ad307
Change around msim_uid2username_from_blist() to try to get it to work
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18001
diff
changeset
|
1450 | username = NULL; |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1451 | #endif |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1452 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1453 | if (username) |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1454 | { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1455 | /* Know username already, use it. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1456 | purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1457 | username); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1458 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1459 | return msim_process(session, msg); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1460 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1461 | } else { |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1462 | gchar *from; |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1463 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1464 | /* Send lookup request. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1465 | /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1466 | purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1467 | from = msim_msg_get_string(msg, "f"); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1468 | msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
|
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
1469 | g_free(from); |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1470 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1471 | /* indeterminate */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1472 | return TRUE; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1473 | } |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1474 | } else { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1475 | /* Nothing to resolve - send directly to processing. */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1476 | return msim_process(session, msg); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1477 | } |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1478 | } |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1479 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1480 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1481 | * Process a message. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1482 | * |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1483 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1484 | * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1485 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1486 | * @return TRUE if successful. FALSE if processing failed. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1487 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1488 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1489 | msim_process(MsimSession *session, MsimMessage *msg) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1490 | { |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1491 | g_return_val_if_fail(session != NULL, -1); |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1492 | g_return_val_if_fail(msg != NULL, -1); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1493 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
1494 | #ifdef MSIM_DEBUG_MSG |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1495 | { |
|
17942
4d750e00cdae
Change msim_msg_debug_string() to msim_msg_dump(), which prints the string
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17941
diff
changeset
|
1496 | msim_msg_dump("ready to process: %s\n", msg); |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1497 | } |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1498 | #endif |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1499 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1500 | if (msim_msg_get(msg, "nc")) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1501 | { |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1502 | return msim_login_challenge(session, msg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1503 | } else if (msim_msg_get(msg, "sesskey")) { |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1504 | purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1505 | |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1506 | session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
|
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1507 | purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1508 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1509 | /* Comes with: proof,profileid,userid,uniquenick -- all same values |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1510 | * some of the time, but can vary. This is our own user ID. */ |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1511 | session->userid = msim_msg_get_integer(msg, "userid"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1512 | |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1513 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1514 | purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
|
18003
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1515 | |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1516 | |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1517 | /* We now know are our own username, only after we're logged in.. |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1518 | * which is weird, but happens because you login with your email |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1519 | * address and not username. Will be freed in msim_session_destroy(). */ |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1520 | session->username = msim_msg_get_string(msg, "uniquenick"); |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1521 | |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1522 | #ifdef MSIM_FAKE_SELF_ONLINE |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1523 | /* Fake our self coming online. */ |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1524 | purple_prpl_got_user_status(session->account, session->username, purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE), NULL); |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1525 | #endif |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1526 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1527 | return TRUE; |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1528 | } else if (msim_msg_get(msg, "bm")) { |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1529 | guint bm; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1530 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1531 | bm = msim_msg_get_integer(msg, "bm"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1532 | switch (bm) |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1533 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1534 | case MSIM_BM_STATUS: |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1535 | return msim_status(session, msg); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1536 | case MSIM_BM_INSTANT: |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1537 | return msim_incoming_im(session, msg); |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1538 | case MSIM_BM_ACTION: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1539 | return msim_incoming_action(session, msg); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1540 | default: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1541 | /* Not really an IM, but show it for informational |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1542 | * purposes during development. */ |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1543 | return msim_incoming_im(session, msg); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1544 | } |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1545 | } else if (msim_msg_get(msg, "rid")) { |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1546 | return msim_process_reply(session, msg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1547 | } else if (msim_msg_get(msg, "error")) { |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1548 | return msim_error(session, msg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1549 | } else if (msim_msg_get(msg, "ka")) { |
|
17983
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1550 | /* TODO: Setup a timer, if keep-alive is not received within ~3 minutes, then |
|
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1551 | * disconnect the user. As it stands, if Internet connection goes out (this |
|
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1552 | * just happened here), msimprpl will appear to be connected forever, while |
|
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1553 | * other plugins (oscar, etc.) will time out. Msimprpl should timeout too. */ |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1554 | purple_debug_info("msim", "msim_process: got keep alive\n"); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1555 | return TRUE; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1556 | } else { |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1557 | msim_unrecognized(session, msg, "in msim_process"); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1558 | return FALSE; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1559 | } |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1560 | } |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1561 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1562 | /** Store an field of information about a buddy. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1563 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1564 | msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1565 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1566 | PurpleBuddy *buddy; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1567 | gchar *key_str, *value_str; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1568 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1569 | buddy = (PurpleBuddy *)user_data; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1570 | key_str = (gchar *)key; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1571 | value_str = (gchar *)value; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1572 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1573 | if (strcmp(key_str, "UserID") == 0 || |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1574 | strcmp(key_str, "Age") == 0 || |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1575 | strcmp(key_str, "TotalFriends") == 0) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1576 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1577 | /* Certain fields get set as integers, instead of strings, for |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1578 | * convenience. May not be the best way to do it, but having at least |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1579 | * UserID as an integer is convenient...until it overflows! */ |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1580 | purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1581 | } else { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1582 | purple_blist_node_set_string(&buddy->node, key_str, value_str); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1583 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1584 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1585 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1586 | /** Save buddy information to the buddy list from a user info reply message. |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1587 | * |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1588 | * @param session |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1589 | * @param msg The user information reply, with any amount of information. |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1590 | * |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1591 | * The information is saved to the buddy's blist node, which ends up in blist.xml. |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1592 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1593 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1594 | msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1595 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1596 | GHashTable *body; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1597 | gchar *username, *body_str, *uid; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1598 | PurpleBuddy *buddy; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1599 | guint rid; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1600 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1601 | rid = msim_msg_get_integer(msg, "rid"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1602 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1603 | g_return_val_if_fail(rid != 0, FALSE); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1604 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1605 | body_str = msim_msg_get_string(msg, "body"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1606 | g_return_val_if_fail(body_str != NULL, FALSE); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1607 | body = msim_parse_body(body_str); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1608 | g_free(body_str); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1609 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1610 | /* TODO: implement a better hash-like interface, and use it. */ |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1611 | username = g_hash_table_lookup(body, "UserName"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1612 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1613 | if (!username) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1614 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1615 | purple_debug_info("msim", |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1616 | "msim_process_reply: not caching body, no UserName\n"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1617 | return FALSE; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1618 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1619 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1620 | uid = g_hash_table_lookup(body, "UserID"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1621 | g_return_val_if_fail(uid, FALSE); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1622 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1623 | purple_debug_info("msim", "associating uid %d with username %s\n", uid, username); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1624 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1625 | buddy = purple_find_buddy(session->account, username); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1626 | if (buddy) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1627 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1628 | g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1629 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1630 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1631 | return TRUE; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1632 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1633 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1634 | /** |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1635 | * Process a persistance message reply from the server. |
| 16322 | 1636 | * |
| 1637 | * @param session | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1638 | * @param msg Message reply from server. |
| 16322 | 1639 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1640 | * @return TRUE if successful. |
| 16322 | 1641 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1642 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1643 | msim_process_reply(MsimSession *session, MsimMessage *msg) |
| 16322 | 1644 | { |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1645 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1646 | g_return_val_if_fail(msg != NULL, FALSE); |
| 16322 | 1647 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1648 | if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
| 16322 | 1649 | { |
| 1650 | MSIM_USER_LOOKUP_CB cb; | |
| 1651 | gpointer data; | |
| 1652 | guint rid; | |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1653 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1654 | msim_store_buddy_info(session, msg); |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1655 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1656 | rid = msim_msg_get_integer(msg, "rid"); |
| 16322 | 1657 | |
| 1658 | /* If a callback is registered for this userid lookup, call it. */ | |
| 1659 | cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); | |
| 1660 | data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
| 1661 | ||
| 1662 | if (cb) | |
| 1663 | { | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1664 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1665 | "msim_process_body: calling callback now\n"); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1666 | /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1667 | cb(session, msim_msg_clone(msg), data); |
| 16322 | 1668 | g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
| 1669 | g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
| 1670 | } else { | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1671 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1672 | "msim_process_body: no callback for rid %d\n", rid); |
| 16322 | 1673 | } |
| 1674 | } | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1675 | |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1676 | return TRUE; |
| 16322 | 1677 | } |
| 1678 | ||
| 1679 | /** | |
| 1680 | * Handle an error from the server. | |
| 1681 | * | |
| 1682 | * @param session | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1683 | * @param msg The message. |
| 16322 | 1684 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1685 | * @return TRUE if successfully reported error. |
| 16322 | 1686 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1687 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1688 | msim_error(MsimSession *session, MsimMessage *msg) |
| 16322 | 1689 | { |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1690 | gchar *errmsg, *full_errmsg; |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1691 | guint err; |
| 16322 | 1692 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1693 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1694 | g_return_val_if_fail(msg != NULL, FALSE); |
| 16322 | 1695 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1696 | err = msim_msg_get_integer(msg, "err"); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1697 | errmsg = msim_msg_get_string(msg, "errmsg"); |
| 16322 | 1698 | |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1699 | full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
1700 | errmsg ? errmsg : "no 'errmsg' given"); |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1701 | |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1702 | g_free(errmsg); |
| 16322 | 1703 | |
| 16324 | 1704 | purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
| 16322 | 1705 | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1706 | purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
| 16322 | 1707 | full_errmsg, NULL); |
| 1708 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1709 | /* Destroy session if fatal. */ |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1710 | if (msim_msg_get(msg, "fatal")) |
| 16322 | 1711 | { |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1712 | purple_debug_info("msim", "fatal error, closing\n"); |
| 16324 | 1713 | purple_connection_error(session->gc, full_errmsg); |
| 16322 | 1714 | } |
| 1715 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1716 | return TRUE; |
| 16322 | 1717 | } |
| 1718 | ||
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1719 | /** |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1720 | * Process incoming status messages. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1721 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1722 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1723 | * @param msg Status update message. Caller frees. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1724 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1725 | * @return TRUE if successful. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1726 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1727 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1728 | msim_status(MsimSession *session, MsimMessage *msg) |
| 16322 | 1729 | { |
| 16324 | 1730 | PurpleBuddyList *blist; |
| 1731 | PurpleBuddy *buddy; | |
| 1732 | //PurpleStatus *status; | |
| 16322 | 1733 | gchar **status_array; |
| 1734 | GList *list; | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1735 | gchar *status_headline; |
| 16322 | 1736 | gchar *status_str; |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1737 | gint i, status_code, purple_status_code; |
| 16322 | 1738 | gchar *username; |
| 1739 | ||
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1740 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1741 | g_return_val_if_fail(msg != NULL, FALSE); |
|
17949
a74745e42b2b
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17948
diff
changeset
|
1742 | |
|
a74745e42b2b
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17948
diff
changeset
|
1743 | status_str = msim_msg_get_string(msg, "msg"); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1744 | g_return_val_if_fail(status_str != NULL, FALSE); |
| 16322 | 1745 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1746 | msim_msg_dump("msim_status msg=%s\n", msg); |
| 16322 | 1747 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1748 | /* Helpfully looked up by msim_incoming_resolve() for us. */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1749 | username = msim_msg_get_string(msg, "_username"); |
| 16322 | 1750 | /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
| 1751 | * the buddy list, if the UserID was stored along with it. */ | |
| 1752 | ||
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1753 | if (username == NULL) |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1754 | { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1755 | g_free(status_str); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1756 | g_return_val_if_fail(NULL, FALSE); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1757 | } |
| 16322 | 1758 | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1759 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1760 | "msim_status_cb: updating status for <%s> to <%s>\n", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1761 | username, status_str); |
| 16322 | 1762 | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1763 | /* TODO: generic functions to split into a GList, part of MsimMessage */ |
| 16322 | 1764 | status_array = g_strsplit(status_str, "|", 0); |
| 1765 | for (list = NULL, i = 0; | |
| 1766 | status_array[i]; | |
| 1767 | i++) | |
| 1768 | { | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1769 | /* Note: this adds the 0th ordinal too, which might not be a value |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1770 | * at all (the 0 in the 0|1|2|3... status fields, but 0 always appears blank). |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1771 | */ |
| 16322 | 1772 | list = g_list_append(list, status_array[i]); |
| 1773 | } | |
| 1774 | ||
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1775 | /* Example fields: |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1776 | * |s|0|ss|Offline |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1777 | * |s|1|ss|:-)|ls||ip|0|p|0 |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1778 | * |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1779 | * TODO: write list support in MsimMessage, and use it here. |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1780 | */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1781 | |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1782 | status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1783 | purple_debug_info("msim", "msim_status_cb: %s's status code = %d\n", username, status_code); |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1784 | status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
| 16322 | 1785 | |
| 16324 | 1786 | blist = purple_get_blist(); |
| 16322 | 1787 | |
| 1788 | /* Add buddy if not found */ | |
| 16324 | 1789 | buddy = purple_find_buddy(session->account, username); |
| 16322 | 1790 | if (!buddy) |
| 1791 | { | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1792 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1793 | "msim_status: making new buddy for %s\n", username); |
| 16324 | 1794 | buddy = purple_buddy_new(session->account, username, NULL); |
| 16322 | 1795 | |
| 16324 | 1796 | purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1797 | |
|
17943
d33c1657f68b
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17942
diff
changeset
|
1798 | /* All buddies on list should have 'uid' integer associated with them. */ |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1799 | purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1800 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1801 | msim_store_buddy_info(session, msg); |
| 16322 | 1802 | } else { |
| 16324 | 1803 | purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
| 16322 | 1804 | } |
| 1805 | ||
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1806 | purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1807 | |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1808 | /* Set user status */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1809 | switch (status_code) |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1810 | { |
|
18007
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1811 | case MSIM_STATUS_CODE_OFFLINE: |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1812 | purple_status_code = PURPLE_STATUS_OFFLINE; |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1813 | break; |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1814 | |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1815 | case MSIM_STATUS_CODE_ONLINE: |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1816 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1817 | break; |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1818 | |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1819 | case MSIM_STATUS_CODE_AWAY: |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1820 | purple_status_code = PURPLE_STATUS_AWAY; |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1821 | break; |
|
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1822 | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1823 | default: |
|
18007
d9fcb200fff6
Recognize online/away status of buddies on buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18006
diff
changeset
|
1824 | purple_debug_info("msim", "msim_status_cb for %s, unknown status code %d, treating as available\n", |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1825 | username, status_code); |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1826 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1827 | } |
|
18003
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1828 | |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1829 | #ifdef MSIM_FAKE_SELF_ONLINE |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1830 | if (!strcmp(username, session->username) && purple_status_code == PURPLE_STATUS_OFFLINE) |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1831 | { |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1832 | /* Hack to ignore offline status notices on self. */ |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1833 | } else { |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1834 | #endif |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1835 | purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1836 | #ifdef MSIM_FAKE_SELF_ONLINE |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1837 | } |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
1838 | #endif |
| 16322 | 1839 | |
| 1840 | g_strfreev(status_array); | |
|
17949
a74745e42b2b
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17948
diff
changeset
|
1841 | g_free(status_str); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1842 | g_free(username); |
| 16322 | 1843 | g_list_free(list); |
| 1844 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1845 | return TRUE; |
| 16322 | 1846 | } |
| 1847 | ||
|
17975
1404d3846cd4
Update several outdated TODO comments.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17974
diff
changeset
|
1848 | /** Add a buddy to user's buddy list. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1849 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1850 | msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1851 | { |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1852 | MsimSession *session; |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1853 | MsimMessage *msg; |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1854 | /* MsimMessage *msg_blocklist; */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1855 | |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1856 | session = (MsimSession *)gc->proto_data; |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1857 | purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1858 | group ? group->name : "(no group)"); |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1859 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1860 | msg = msim_msg_new(TRUE, |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1861 | "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1862 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1863 | /* "newprofileid" will be inserted here with uid. */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1864 | "reason", MSIM_TYPE_STRING, g_strdup(""), |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1865 | NULL); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1866 | |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1867 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1868 | { |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1869 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1870 | msim_msg_free(msg); |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1871 | return; |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1872 | } |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1873 | msim_msg_free(msg); |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1874 | |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1875 | /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1876 | * buddy list since Purple adds it locally. */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1877 | |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1878 | /* TODO: Update blocklist. */ |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1879 | #if 0 |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1880 | msg_blocklist = msim_msg_new(TRUE, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1881 | "persist", MSIM_TYPE_INTEGER, 1, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1882 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1883 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1884 | "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1885 | "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1886 | /* TODO: Use msim_new_reply_callback to get rid. */ |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1887 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1888 | "body", MSIM_TYPE_STRING, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1889 | g_strdup_printf("ContactID=<uid>\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1890 | "GroupName=%s\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1891 | "Position=1000\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1892 | "Visibility=1\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1893 | "NickName=\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1894 | "NameSelect=0", |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1895 | "Friends" /*group->name*/ )); |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1896 | |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1897 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1898 | { |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1899 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1900 | msim_msg_free(msg_blocklist); |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1901 | return; |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1902 | } |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1903 | msim_msg_free(msg_blocklist); |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1904 | #endif |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1905 | } |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1906 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1907 | /** Perform actual postprocessing on a message, adding userid as specified. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1908 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1909 | * @param msg The message to postprocess. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1910 | * @param uid_before Name of field where to insert new field before, or NULL for end. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1911 | * @param uid_field_name Name of field to add uid to. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1912 | * @param uid The userid to insert. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1913 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1914 | * If the field named by uid_field_name already exists, then its string contents will |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1915 | * be used for the field, except "<uid>" will be replaced by the userid. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1916 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1917 | * If the field named by uid_field_name does not exist, it will be added before the |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1918 | * field named by uid_before, as an integer, with the userid. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1919 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1920 | * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1921 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1922 | MsimMessage * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1923 | msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1924 | const gchar *uid_field_name, guint uid) |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1925 | { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1926 | purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n", |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1927 | uid_field_name, uid_before, uid); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1928 | msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1929 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1930 | /* First, check - if the field already exists, treat it as a format string. */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1931 | if (msim_msg_get(msg, uid_field_name)) |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1932 | { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1933 | MsimMessageElement *elem; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1934 | gchar *fmt_string; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1935 | gchar *uid_str; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1936 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1937 | /* Warning: this probably violates the encapsulation of MsimMessage */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1938 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1939 | elem = msim_msg_get(msg, uid_field_name); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1940 | g_return_val_if_fail(elem->type == MSIM_TYPE_STRING, NULL); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1941 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1942 | /* Get the raw string, not with msim_msg_get_string() since that copies it. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1943 | * Want the original string so can free it. */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1944 | fmt_string = (gchar *)(elem->data); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1945 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1946 | uid_str = g_strdup_printf("%d", uid); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1947 | elem->data = str_replace(fmt_string, "<uid>", uid_str); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1948 | g_free(uid_str); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1949 | g_free(fmt_string); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1950 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1951 | purple_debug_info("msim", "msim_postprocess_outgoing_cb: formatted new string, %s\n", |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1952 | elem->data); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1953 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1954 | } else { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1955 | /* Otherwise, insert new field into outgoing message. */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1956 | msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1957 | } |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1958 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1959 | return msg; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1960 | } |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1961 | |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1962 | /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1963 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1964 | * @param session |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1965 | * @param userinfo The user information reply message, containing the user ID |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1966 | * @param data The message to postprocess and send. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1967 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1968 | * The data message should contain these fields: |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1969 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1970 | * _uid_field_name: string, name of field to add with userid from userinfo message |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1971 | * _uid_before: string, name of field before field to insert, or NULL for end |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1972 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1973 | * |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1974 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1975 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
1976 | msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1977 | { |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1978 | gchar *body_str; |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1979 | GHashTable *body; |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1980 | gchar *uid, *uid_field_name, *uid_before; |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1981 | MsimMessage *msg; |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1982 | |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1983 | msg = (MsimMessage *)data; |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1984 | |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1985 | msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1986 | |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1987 | /* Obtain userid from userinfo message. */ |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1988 | body_str = msim_msg_get_string(userinfo, "body"); |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1989 | g_return_if_fail(body_str != NULL); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1990 | body = msim_parse_body(body_str); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1991 | g_free(body_str); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1992 | |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1993 | uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1994 | g_hash_table_destroy(body); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1995 | |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1996 | uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1997 | uid_before = msim_msg_get_string(msg, "_uid_before"); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1998 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1999 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2000 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2001 | /* Send */ |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2002 | if (!msim_msg_send(session, msg)) |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2003 | { |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2004 | purple_debug_info("msim", "msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2005 | } |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2006 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2007 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2008 | /* Free field names AFTER sending message, because MsimMessage does NOT copy |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2009 | * field names - instead, treats them as static strings (which they usually are). |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2010 | */ |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2011 | g_free(uid_field_name); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2012 | g_free(uid_before); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2013 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2014 | //msim_msg_free(msg); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2015 | } |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2016 | |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2017 | /** Postprocess and send a message. |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2018 | * |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2019 | * @param session |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2020 | * @param msg Message to postprocess. Will NOT be freed. |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2021 | * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2022 | * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2023 | * @param uid_before Name of existing field to insert username field before. Static string. |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2024 | * |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2025 | * @return Postprocessed message. |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2026 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2027 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2028 | msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2029 | const gchar *username, const gchar *uid_field_name, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2030 | const gchar *uid_before) |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2031 | { |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2032 | PurpleBuddy *buddy; |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2033 | guint uid; |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2034 | gboolean rc; |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2035 | |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2036 | /* Store information for msim_postprocess_outgoing_cb(). */ |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2037 | purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n", |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2038 | username, uid_field_name, uid_before); |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2039 | msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2040 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2041 | msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2042 | msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2043 | |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2044 | /* First, try the most obvious. If numeric userid is given, use that directly. */ |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2045 | if (msim_is_userid(username)) |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2046 | { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2047 | uid = atol(username); |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2048 | } else { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2049 | /* Next, see if on buddy list and know uid. */ |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2050 | buddy = purple_find_buddy(session->account, username); |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2051 | if (buddy) |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2052 | { |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2053 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2054 | } else { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2055 | uid = 0; |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2056 | } |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2057 | |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2058 | if (!buddy || !uid) |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2059 | { |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2060 | /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2061 | purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2062 | username); |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2063 | msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2064 | /* TODO: where is cloned message freed? Should be in _cb. */ |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
2065 | msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2066 | return TRUE; /* not sure of status yet - haven't sent! */ |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
2067 | } |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2068 | } |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2069 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2070 | /* Already have uid, postprocess and send msg immediately. */ |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2071 | purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2072 | username, uid); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2073 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2074 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2075 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2076 | msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2077 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2078 | rc = msim_msg_send(session, msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2079 | |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2080 | //msim_msg_free(msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2081 | |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2082 | return rc; |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2083 | } |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
2084 | |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2085 | /** Remove a buddy from the user's buddy list. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2086 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2087 | msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2088 | { |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2089 | MsimSession *session; |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2090 | MsimMessage *delbuddy_msg; |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2091 | MsimMessage *persist_msg; |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2092 | MsimMessage *blocklist_msg; |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2093 | |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2094 | session = (MsimSession *)gc->proto_data; |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2095 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2096 | delbuddy_msg = msim_msg_new(TRUE, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2097 | "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
2098 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2099 | /* 'delprofileid' with uid will be inserted here. */ |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2100 | NULL); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2101 | /* TODO: free msg */ |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2102 | if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2103 | { |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2104 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2105 | return; |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2106 | } |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2107 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2108 | persist_msg = msim_msg_new(TRUE, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2109 | "persist", MSIM_TYPE_INTEGER, 1, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
2110 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2111 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2112 | "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2113 | "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
|
17961
16c5545a0a95
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17960
diff
changeset
|
2114 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2115 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2116 | /* <uid> will be replaced by postprocessing */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2117 | "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2118 | NULL); |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2119 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2120 | /* TODO: free msg */ |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2121 | if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2122 | { |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2123 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2124 | return; |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2125 | } |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2126 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2127 | blocklist_msg = msim_msg_new(TRUE, |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2128 | "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2129 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2130 | /* TODO: MsimMessage lists */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2131 | "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2132 | NULL); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2133 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2134 | if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2135 | { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2136 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2137 | return; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
2138 | } |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2139 | } |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2140 | |
|
17968
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2141 | /** Return whether the buddy can be messaged while offline. |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2142 | * |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2143 | * The protocol supports offline messages in just the same way as online |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2144 | * messages. |
|
17968
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2145 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2146 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2147 | msim_offline_message(const PurpleBuddy *buddy) |
|
17968
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2148 | { |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2149 | return TRUE; |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2150 | } |
| 16322 | 2151 | |
| 2152 | /** | |
| 2153 | * Callback when input available. | |
| 2154 | * | |
| 16324 | 2155 | * @param gc_uncasted A PurpleConnection pointer. |
| 16322 | 2156 | * @param source File descriptor. |
| 16324 | 2157 | * @param cond PURPLE_INPUT_READ |
| 16322 | 2158 | * |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
2159 | * Reads the input, and calls msim_preprocess_incoming() to handle it. |
| 16322 | 2160 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2161 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2162 | msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
| 16322 | 2163 | { |
| 16324 | 2164 | PurpleConnection *gc; |
| 2165 | PurpleAccount *account; | |
| 16322 | 2166 | MsimSession *session; |
| 2167 | gchar *end; | |
| 2168 | int n; | |
| 2169 | ||
| 2170 | g_return_if_fail(gc_uncasted != NULL); | |
| 2171 | g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ | |
| 2172 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
2173 | gc = (PurpleConnection *)(gc_uncasted); |
| 16324 | 2174 | account = purple_connection_get_account(gc); |
| 16322 | 2175 | session = gc->proto_data; |
| 2176 | ||
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
2177 | g_return_if_fail(cond == PURPLE_INPUT_READ); |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
2178 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
| 16322 | 2179 | |
| 2180 | /* Only can handle so much data at once... | |
| 2181 | * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. | |
| 2182 | * Should be large enough to hold the largest protocol message. | |
| 2183 | */ | |
| 2184 | if (session->rxoff == MSIM_READ_BUF_SIZE) | |
| 2185 | { | |
| 16324 | 2186 | purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
| 16322 | 2187 | MSIM_READ_BUF_SIZE); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
2188 | purple_connection_error(gc, _("Read buffer full")); |
| 16322 | 2189 | return; |
| 2190 | } | |
| 2191 | ||
| 16324 | 2192 | purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2193 | session->rxoff, MSIM_READ_BUF_SIZE, |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2194 | MSIM_READ_BUF_SIZE - session->rxoff); |
| 16322 | 2195 | |
| 2196 | /* Read into buffer. On Win32, need recv() not read(). session->fd also holds | |
| 2197 | * the file descriptor, but it sometimes differs from the 'source' parameter. | |
| 2198 | */ | |
| 2199 | n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); | |
| 2200 | ||
| 2201 | if (n < 0 && errno == EAGAIN) | |
| 2202 | { | |
| 2203 | return; | |
| 2204 | } | |
| 2205 | else if (n < 0) | |
| 2206 | { | |
| 16324 | 2207 | purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
| 16322 | 2208 | "error=%s, source=%d, fd=%d (%X))\n", |
| 2209 | n, strerror(errno), source, session->fd, session->fd); | |
|
17996
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2210 | purple_connection_error(gc, _("Read error")); |
| 16322 | 2211 | return; |
| 2212 | } | |
| 2213 | else if (n == 0) | |
| 2214 | { | |
| 16324 | 2215 | purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
2216 | purple_connection_error(gc, _("Server has disconnected")); |
| 16322 | 2217 | return; |
| 2218 | } | |
| 2219 | ||
| 2220 | /* Null terminate */ | |
| 2221 | session->rxbuf[session->rxoff + n] = 0; | |
| 2222 | ||
|
18005
f8992f7ce49b
Remove check in msim_input_cb() for embedded nulls. May be causing #1990.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18003
diff
changeset
|
2223 | #ifdef MSIM_CHECK_EMBEDDED_NULLS |
| 16322 | 2224 | /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
| 2225 | if (strlen(session->rxbuf + session->rxoff) != n) | |
| 2226 | { | |
| 2227 | /* Occurs after login, but it is not a null byte. */ | |
| 16324 | 2228 | purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2229 | "--null byte encountered?\n", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2230 | strlen(session->rxbuf + session->rxoff), n); |
| 16324 | 2231 | //purple_connection_error(gc, "Invalid message - null byte on input"); |
| 16322 | 2232 | return; |
| 2233 | } | |
|
18005
f8992f7ce49b
Remove check in msim_input_cb() for embedded nulls. May be causing #1990.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18003
diff
changeset
|
2234 | #endif |
| 16322 | 2235 | |
| 2236 | session->rxoff += n; | |
| 16324 | 2237 | purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
| 16322 | 2238 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
2239 | #ifdef MSIM_DEBUG_RXBUF |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2240 | purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2241 | #endif |
| 16322 | 2242 | |
| 2243 | /* Look for \\final\\ end markers. If found, process message. */ | |
| 2244 | while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) | |
| 2245 | { | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
2246 | MsimMessage *msg; |
| 16322 | 2247 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
2248 | #ifdef MSIM_DEBUG_RXBUF |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2249 | purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2250 | #endif |
| 16322 | 2251 | *end = 0; |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
2252 | msg = msim_parse(g_strdup(session->rxbuf)); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
2253 | if (!msg) |
| 16322 | 2254 | { |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2255 | purple_debug_info("msim", "msim_input_cb: couldn't parse <%s>\n", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2256 | session->rxbuf); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
2257 | purple_connection_error(gc, _("Unparseable message")); |
| 16322 | 2258 | } |
| 2259 | else | |
| 2260 | { | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2261 | /* Process message and then free it (processing function should |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2262 | * clone message if it wants to keep it afterwards.) */ |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
2263 | if (!msim_preprocess_incoming(session, msg)) |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2264 | { |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
2265 | msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2266 | } |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2267 | msim_msg_free(msg); |
| 16322 | 2268 | } |
| 2269 | ||
| 2270 | /* Move remaining part of buffer to beginning. */ | |
| 2271 | session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); | |
| 2272 | memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), | |
| 2273 | MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); | |
| 2274 | ||
| 2275 | /* Clear end of buffer */ | |
| 2276 | //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); | |
| 2277 | } | |
| 2278 | } | |
| 2279 | ||
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2280 | /* Setup a callback, to be called when a reply is received with the returned rid. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2281 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2282 | * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2283 | * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2284 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2285 | * @return The request/reply ID, used to link replies with requests. Put the rid in your request. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2286 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2287 | * TODO: Make more generic and more specific: |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2288 | * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2289 | * 2) data - make it an MsimMessage? |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2290 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2291 | guint |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2292 | msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2293 | gpointer data) |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2294 | { |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2295 | guint rid; |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2296 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2297 | rid = session->next_rid++; |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2298 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2299 | g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2300 | g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2301 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2302 | return rid; |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2303 | } |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2304 | |
| 16322 | 2305 | /** |
| 2306 | * Callback when connected. Sets up input handlers. | |
| 2307 | * | |
| 16324 | 2308 | * @param data A PurpleConnection pointer. |
| 16322 | 2309 | * @param source File descriptor. |
| 2310 | * @param error_message | |
| 2311 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2312 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2313 | msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
| 16322 | 2314 | { |
| 16324 | 2315 | PurpleConnection *gc; |
| 16322 | 2316 | MsimSession *session; |
| 2317 | ||
| 2318 | g_return_if_fail(data != NULL); | |
| 2319 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
2320 | gc = (PurpleConnection *)data; |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2321 | session = (MsimSession *)gc->proto_data; |
| 16322 | 2322 | |
| 2323 | if (source < 0) | |
| 2324 | { | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
2325 | purple_connection_error(gc, _("Couldn't connect to host")); |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
2326 | purple_connection_error(gc, g_strdup_printf( |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
2327 | _("Couldn't connect to host: %s (%d)"), |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
2328 | error_message ? error_message : "no message given", |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
2329 | source)); |
| 16322 | 2330 | return; |
| 2331 | } | |
| 2332 | ||
| 2333 | session->fd = source; | |
| 2334 | ||
| 16324 | 2335 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
|
18003
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
2336 | |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
2337 | |
| 16322 | 2338 | } |
| 2339 | ||
| 2340 | /* Session methods */ | |
| 2341 | ||
| 2342 | /** | |
| 2343 | * Create a new MSIM session. | |
| 2344 | * | |
| 2345 | * @param acct The account to create the session from. | |
| 2346 | * | |
| 2347 | * @return Pointer to a new session. Free with msim_session_destroy. | |
| 2348 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2349 | MsimSession * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2350 | msim_session_new(PurpleAccount *acct) |
| 16322 | 2351 | { |
| 2352 | MsimSession *session; | |
| 2353 | ||
| 2354 | g_return_val_if_fail(acct != NULL, NULL); | |
| 2355 | ||
| 2356 | session = g_new0(MsimSession, 1); | |
| 2357 | ||
| 2358 | session->magic = MSIM_SESSION_STRUCT_MAGIC; | |
| 2359 | session->account = acct; | |
| 16324 | 2360 | session->gc = purple_account_get_connection(acct); |
|
18003
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
2361 | session->sesskey = 0; |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
2362 | session->userid = 0; |
|
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
2363 | session->username = NULL; |
| 16322 | 2364 | session->fd = -1; |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
2365 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
2366 | /* TODO: Remove. */ |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2367 | session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
2368 | g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2369 | session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
|
17947
a423b14fda56
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17944
diff
changeset
|
2370 | g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
2371 | they could be integers inside gpointers |
|
17947
a423b14fda56
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17944
diff
changeset
|
2372 | or strings, so I don't freed them. |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
2373 | Figure this out, once free cache. */ |
| 16322 | 2374 | session->rxoff = 0; |
| 2375 | session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); | |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
2376 | session->next_rid = 1; |
| 16322 | 2377 | |
| 2378 | return session; | |
| 2379 | } | |
| 2380 | ||
| 2381 | /** | |
| 2382 | * Free a session. | |
| 2383 | * | |
| 2384 | * @param session The session to destroy. | |
| 2385 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2386 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2387 | msim_session_destroy(MsimSession *session) |
| 16322 | 2388 | { |
| 2389 | g_return_if_fail(MSIM_SESSION_VALID(session)); | |
|
17996
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2390 | |
| 16322 | 2391 | session->magic = -1; |
| 2392 | ||
| 2393 | g_free(session->rxbuf); | |
|
18003
fb399e32e44c
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18002
diff
changeset
|
2394 | g_free(session->username); |
| 16322 | 2395 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
2396 | /* TODO: Remove. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
2397 | g_hash_table_destroy(session->user_lookup_cb); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
2398 | g_hash_table_destroy(session->user_lookup_cb_data); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
2399 | |
| 16322 | 2400 | g_free(session); |
| 2401 | } | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
2402 | |
| 16322 | 2403 | /** |
| 2404 | * Close the connection. | |
| 2405 | * | |
| 2406 | * @param gc The connection. | |
| 2407 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2408 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2409 | msim_close(PurpleConnection *gc) |
| 16322 | 2410 | { |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
2411 | MsimSession *session; |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
2412 | |
|
17996
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2413 | if (gc == NULL) |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2414 | return; |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2415 | |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
2416 | session = (MsimSession *)gc->proto_data; |
|
17996
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2417 | if (session == NULL) |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2418 | return; |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2419 | |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2420 | gc->proto_data = NULL; |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2421 | |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2422 | if (!MSIM_SESSION_VALID(session)) |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2423 | return; |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2424 | |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2425 | if (session->gc->inpa) |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2426 | purple_input_remove(session->gc->inpa); |
|
d419619280db
Add a bunch of debugging to help fix #193.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17995
diff
changeset
|
2427 | |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
2428 | msim_session_destroy(session); |
| 16322 | 2429 | } |
| 2430 | ||
| 2431 | ||
| 2432 | /** | |
| 2433 | * Check if a string is a userid (all numeric). | |
| 2434 | * | |
| 2435 | * @param user The user id, email, or name. | |
| 2436 | * | |
| 2437 | * @return TRUE if is userid, FALSE if not. | |
| 2438 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2439 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2440 | msim_is_userid(const gchar *user) |
| 16322 | 2441 | { |
| 2442 | g_return_val_if_fail(user != NULL, FALSE); | |
| 2443 | ||
| 2444 | return strspn(user, "0123456789") == strlen(user); | |
| 2445 | } | |
| 2446 | ||
| 2447 | /** | |
| 2448 | * Check if a string is an email address (contains an @). | |
| 2449 | * | |
| 2450 | * @param user The user id, email, or name. | |
| 2451 | * | |
| 2452 | * @return TRUE if is an email, FALSE if not. | |
| 2453 | * | |
| 2454 | * This function is not intended to be used as a generic | |
| 2455 | * means of validating email addresses, but to distinguish | |
| 2456 | * between a user represented by an email address from | |
| 2457 | * other forms of identification. | |
| 2458 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2459 | gboolean |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2460 | msim_is_email(const gchar *user) |
| 16322 | 2461 | { |
| 2462 | g_return_val_if_fail(user != NULL, FALSE); | |
| 2463 | ||
| 2464 | return strchr(user, '@') != NULL; | |
| 2465 | } | |
| 2466 | ||
| 2467 | ||
| 2468 | /** | |
| 2469 | * Asynchronously lookup user information, calling callback when receive result. | |
| 2470 | * | |
| 2471 | * @param session | |
|
17989
48499e10fac3
Retrieve information for profile ("Get Info") from server, instead of from
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17988
diff
changeset
|
2472 | * @param user The user id, email address, or username. Not freed. |
| 16322 | 2473 | * @param cb Callback, called with user information when available. |
| 2474 | * @param data An arbitray data pointer passed to the callback. | |
| 2475 | */ | |
|
17943
d33c1657f68b
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17942
diff
changeset
|
2476 | /* TODO: change to not use callbacks */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2477 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2478 | msim_lookup_user(MsimSession *session, const gchar *user, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2479 | MSIM_USER_LOOKUP_CB cb, gpointer data) |
| 16322 | 2480 | { |
| 2481 | gchar *field_name; | |
| 2482 | guint rid, cmd, dsn, lid; | |
| 2483 | ||
| 2484 | g_return_if_fail(MSIM_SESSION_VALID(session)); | |
| 2485 | g_return_if_fail(user != NULL); | |
| 2486 | g_return_if_fail(cb != NULL); | |
| 2487 | ||
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
2488 | purple_debug_info("msim", "msim_lookup_userid: " |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
2489 | "asynchronously looking up <%s>\n", user); |
| 16322 | 2490 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2491 | msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
2492 | |
| 16322 | 2493 | /* Setup callback. Response will be associated with request using 'rid'. */ |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
2494 | rid = msim_new_reply_callback(session, cb, data); |
| 16322 | 2495 | |
| 2496 | /* Send request */ | |
| 2497 | ||
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2498 | cmd = MSIM_CMD_GET; |
| 16322 | 2499 | |
| 2500 | if (msim_is_userid(user)) | |
| 2501 | { | |
| 2502 | field_name = "UserID"; | |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2503 | dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
|
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2504 | lid = MG_MYSPACE_INFO_BY_ID_LID; |
| 16322 | 2505 | } else if (msim_is_email(user)) { |
| 2506 | field_name = "Email"; | |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2507 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2508 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
| 16322 | 2509 | } else { |
| 2510 | field_name = "UserName"; | |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2511 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
2512 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
| 16322 | 2513 | } |
| 2514 | ||
| 2515 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2516 | g_return_if_fail(msim_send(session, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2517 | "persist", MSIM_TYPE_INTEGER, 1, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
2518 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2519 | "cmd", MSIM_TYPE_INTEGER, 1, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2520 | "dsn", MSIM_TYPE_INTEGER, dsn, |
|
17961
16c5545a0a95
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17960
diff
changeset
|
2521 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2522 | "lid", MSIM_TYPE_INTEGER, lid, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2523 | "rid", MSIM_TYPE_INTEGER, rid, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2524 | /* TODO: dictionary field type */ |
|
18009
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
2525 | "body", MSIM_TYPE_STRING, |
|
59eed9bd2dea
Be more defensive about null pointers, especially null strings in %s format
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18007
diff
changeset
|
2526 | g_strdup_printf("%s=%s", field_name, user), |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2527 | NULL)); |
| 16322 | 2528 | } |
| 2529 | ||
| 2530 | ||
| 2531 | /** | |
| 2532 | * Obtain the status text for a buddy. | |
| 2533 | * | |
| 2534 | * @param buddy The buddy to obtain status text for. | |
| 2535 | * | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
2536 | * @return Status text, or NULL if error. Caller g_free()'s. |
| 16322 | 2537 | * |
| 2538 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2539 | char * |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2540 | msim_status_text(PurpleBuddy *buddy) |
| 16322 | 2541 | { |
| 2542 | MsimSession *session; | |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2543 | const gchar *display_name, *headline; |
| 16322 | 2544 | |
| 2545 | g_return_val_if_fail(buddy != NULL, NULL); | |
| 2546 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
2547 | session = (MsimSession *)buddy->account->gc->proto_data; |
|
17894
e9d07c821d6f
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17893
diff
changeset
|
2548 | g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
| 16322 | 2549 | |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2550 | display_name = headline = NULL; |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2551 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2552 | /* Retrieve display name and/or headline, depending on user preference. */ |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2553 | if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2554 | { |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2555 | display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2556 | } |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2557 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2558 | if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2559 | { |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2560 | headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2561 | } |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2562 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2563 | /* Return appropriate combination of display name and/or headline, or neither. */ |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2564 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2565 | if (display_name && headline) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2566 | return g_strconcat(display_name, " ", headline, NULL); |
| 16322 | 2567 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2568 | if (display_name) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2569 | return g_strdup(display_name); |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2570 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2571 | if (headline) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2572 | return g_strdup(headline); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2573 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2574 | return NULL; |
| 16322 | 2575 | } |
| 2576 | ||
| 2577 | /** | |
| 2578 | * Obtain the tooltip text for a buddy. | |
| 2579 | * | |
| 2580 | * @param buddy Buddy to obtain tooltip text on. | |
| 2581 | * @param user_info Variable modified to have the tooltip text. | |
| 2582 | * @param full TRUE if should obtain full tooltip text. | |
| 2583 | * | |
| 2584 | */ | |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2585 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2586 | msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2587 | gboolean full) |
| 16322 | 2588 | { |
|
18006
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2589 | const gchar *str, *str2; |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2590 | gint n; |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2591 | |
| 16322 | 2592 | g_return_if_fail(buddy != NULL); |
| 2593 | g_return_if_fail(user_info != NULL); | |
| 2594 | ||
| 16324 | 2595 | if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
| 16322 | 2596 | { |
| 2597 | MsimSession *session; | |
| 2598 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
2599 | session = (MsimSession *)buddy->account->gc->proto_data; |
| 16322 | 2600 | |
|
17894
e9d07c821d6f
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17893
diff
changeset
|
2601 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
| 16322 | 2602 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2603 | /* TODO: if (full), do something different */ |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2604 | |
|
18006
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2605 | /* Useful to identify the account the tooltip refers to. |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2606 | * Other prpls show this. */ |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2607 | str = purple_blist_node_get_string(&buddy->node, "UserName"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2608 | if (str) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2609 | purple_notify_user_info_add_pair(user_info, _("User Name"), str); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2610 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2611 | /* a/s/l...the vitals */ |
|
18006
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2612 | n = purple_blist_node_get_int(&buddy->node, "Age"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2613 | if (n) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2614 | purple_notify_user_info_add_pair(user_info, _("Age"), |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2615 | g_strdup_printf("%d", n)); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2616 | |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2617 | str = purple_blist_node_get_string(&buddy->node, "Gender"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2618 | if (str) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2619 | purple_notify_user_info_add_pair(user_info, _("Gender"), str); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2620 | |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2621 | str = purple_blist_node_get_string(&buddy->node, "Location"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2622 | if (str) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2623 | purple_notify_user_info_add_pair(user_info, _("Location"), str); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2624 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2625 | /* Other information */ |
|
18006
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2626 | str = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2627 | if (str) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2628 | purple_notify_user_info_add_pair(user_info, _("Headline"), str); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2629 | |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2630 | str = purple_blist_node_get_string(&buddy->node, "BandName"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2631 | str2 = purple_blist_node_get_string(&buddy->node, "SongName"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2632 | if (str || str2) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2633 | purple_notify_user_info_add_pair(user_info, _("Song"), |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2634 | g_strdup_printf("%s - %s", |
|
18006
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2635 | str ? str : _("Unknown Artist"), |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2636 | str2 ? str2 : _("Unknown Song"))); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2637 | |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2638 | n = purple_blist_node_get_int(&buddy->node, "TotalFriends"); |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2639 | if (n) |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2640 | purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
|
a63c60e26d12
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18005
diff
changeset
|
2641 | g_strdup_printf("%d", n)); |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2642 | |
| 16322 | 2643 | } |
| 2644 | } | |
| 2645 | ||
| 16324 | 2646 | /** Callbacks called by Purple, to access this plugin. */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2647 | PurplePluginProtocolInfo prpl_info = |
| 16322 | 2648 | { |
|
18011
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
2649 | /* options */ |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
2650 | OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
2651 | /* | OPT_PROTO_MAIL_CHECK - TODO: myspace will notify of mail */ |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
2652 | /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
|
c60bea7aee94
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18010
diff
changeset
|
2653 | , |
| 16322 | 2654 | NULL, /* user_splits */ |
| 2655 | NULL, /* protocol_options */ | |
| 2656 | NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ | |
| 2657 | msim_list_icon, /* list_icon */ | |
| 2658 | NULL, /* list_emblems */ | |
| 2659 | msim_status_text, /* status_text */ | |
| 2660 | msim_tooltip_text, /* tooltip_text */ | |
| 2661 | msim_status_types, /* status_types */ | |
| 2662 | NULL, /* blist_node_menu */ | |
| 2663 | NULL, /* chat_info */ | |
| 2664 | NULL, /* chat_info_defaults */ | |
| 2665 | msim_login, /* login */ | |
| 2666 | msim_close, /* close */ | |
| 2667 | msim_send_im, /* send_im */ | |
| 2668 | NULL, /* set_info */ | |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
2669 | msim_send_typing, /* send_typing */ |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
2670 | msim_get_info, /* get_info */ |
| 16322 | 2671 | NULL, /* set_away */ |
| 2672 | NULL, /* set_idle */ | |
| 2673 | NULL, /* change_passwd */ | |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2674 | msim_add_buddy, /* add_buddy */ |
| 16322 | 2675 | NULL, /* add_buddies */ |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2676 | msim_remove_buddy, /* remove_buddy */ |
| 16322 | 2677 | NULL, /* remove_buddies */ |
| 2678 | NULL, /* add_permit */ | |
| 2679 | NULL, /* add_deny */ | |
| 2680 | NULL, /* rem_permit */ | |
| 2681 | NULL, /* rem_deny */ | |
| 2682 | NULL, /* set_permit_deny */ | |
| 2683 | NULL, /* join_chat */ | |
| 2684 | NULL, /* reject chat invite */ | |
| 2685 | NULL, /* get_chat_name */ | |
| 2686 | NULL, /* chat_invite */ | |
| 2687 | NULL, /* chat_leave */ | |
| 2688 | NULL, /* chat_whisper */ | |
| 2689 | NULL, /* chat_send */ | |
| 2690 | NULL, /* keepalive */ | |
| 2691 | NULL, /* register_user */ | |
| 2692 | NULL, /* get_cb_info */ | |
| 2693 | NULL, /* get_cb_away */ | |
| 2694 | NULL, /* alias_buddy */ | |
| 2695 | NULL, /* group_buddy */ | |
| 2696 | NULL, /* rename_group */ | |
| 2697 | NULL, /* buddy_free */ | |
| 2698 | NULL, /* convo_closed */ | |
| 2699 | NULL, /* normalize */ | |
| 2700 | NULL, /* set_buddy_icon */ | |
| 2701 | NULL, /* remove_group */ | |
| 2702 | NULL, /* get_cb_real_name */ | |
| 2703 | NULL, /* set_chat_topic */ | |
| 2704 | NULL, /* find_blist_chat */ | |
| 2705 | NULL, /* roomlist_get_list */ | |
| 2706 | NULL, /* roomlist_cancel */ | |
| 2707 | NULL, /* roomlist_expand_category */ | |
| 2708 | NULL, /* can_receive_file */ | |
| 2709 | NULL, /* send_file */ | |
| 2710 | NULL, /* new_xfer */ | |
|
17968
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2711 | msim_offline_message, /* offline_message */ |
| 16322 | 2712 | NULL, /* whiteboard_prpl_ops */ |
|
17993
d11321258152
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17992
diff
changeset
|
2713 | msim_send_really_raw, /* send_raw */ |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2714 | NULL, /* roomlist_room_serialize */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2715 | NULL, /* _purple_reserved1 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2716 | NULL, /* _purple_reserved2 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2717 | NULL, /* _purple_reserved3 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2718 | NULL /* _purple_reserved4 */ |
| 16322 | 2719 | }; |
| 2720 | ||
| 2721 | ||
| 2722 | ||
| 2723 | /** Based on MSN's plugin info comments. */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2724 | PurplePluginInfo info = |
| 16322 | 2725 | { |
| 16324 | 2726 | PURPLE_PLUGIN_MAGIC, |
| 2727 | PURPLE_MAJOR_VERSION, | |
| 2728 | PURPLE_MINOR_VERSION, | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2729 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2730 | NULL, /**< ui_requirement */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2731 | 0, /**< flags */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2732 | NULL, /**< dependencies */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2733 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 16322 | 2734 | |
| 2735 | "prpl-myspace", /**< id */ | |
| 2736 | "MySpaceIM", /**< name */ | |
|
17980
a455980c81a8
Add script to produce tarballs and zip archives for releases, for v0.8.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17976
diff
changeset
|
2737 | "0.8", /**< version */ |
| 16322 | 2738 | /** summary */ |
| 2739 | "MySpaceIM Protocol Plugin", | |
| 2740 | /** description */ | |
| 2741 | "MySpaceIM Protocol Plugin", | |
|
17988
54b762751673
Update author email address.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17987
diff
changeset
|
2742 | "Jeff Connelly <jeff2@homing.pidgin.im>", /**< author */ |
| 16322 | 2743 | "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
| 2744 | ||
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
2745 | msim_load, /**< load */ |
| 16322 | 2746 | NULL, /**< unload */ |
| 2747 | NULL, /**< destroy */ | |
| 2748 | NULL, /**< ui_info */ | |
| 2749 | &prpl_info, /**< extra_info */ | |
| 2750 | NULL, /**< prefs_info */ | |
| 2751 | ||
| 2752 | /* msim_actions */ | |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2753 | NULL, |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2754 | |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2755 | NULL, /**< reserved1 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2756 | NULL, /**< reserved2 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2757 | NULL, /**< reserved3 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2758 | NULL /**< reserved4 */ |
| 16322 | 2759 | }; |
| 2760 | ||
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2761 | |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
2762 | #ifdef MSIM_SELF_TEST |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2763 | /** Test functions. |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2764 | * Used to test or try out the internal workings of msimprpl. If you're reading |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2765 | * this code for the first time, these functions can be instructive in how |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2766 | * msimprpl is architected. |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2767 | */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2768 | void |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2769 | msim_test_all(void) |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2770 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2771 | guint failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2772 | |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2773 | |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2774 | failures = 0; |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2775 | failures += msim_test_xml(); |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2776 | failures += msim_test_msg(); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2777 | failures += msim_test_escaping(); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2778 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2779 | if (failures) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2780 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2781 | purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2782 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2783 | else |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2784 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2785 | purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2786 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2787 | exit(0); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2788 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2789 | |
|
17995
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2790 | int |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2791 | msim_test_xml(void) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2792 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2793 | gchar *msg_text; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2794 | xmlnode *root, *n; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2795 | guint failures; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2796 | char *s; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2797 | int len; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2798 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2799 | failures = 0; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2800 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2801 | msg_text = "<p><f n=\"Arial\" h=\"12\">woo!</f>xxx<c v='black'>yyy</c></p>"; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2802 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2803 | purple_debug_info("msim", "msim_test_xml: msg_text=%s\n", msg_text); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2804 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2805 | root = xmlnode_from_str(msg_text, -1); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2806 | if (!root) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2807 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2808 | purple_debug_info("msim", "there is no root\n"); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2809 | exit(0); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2810 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2811 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2812 | purple_debug_info("msim", "root name=%s, child name=%s\n", root->name, |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2813 | root->child->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2814 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2815 | purple_debug_info("msim", "last child name=%s\n", root->lastchild->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2816 | purple_debug_info("msim", "Root xml=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2817 | xmlnode_to_str(root, &len)); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2818 | purple_debug_info("msim", "Child xml=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2819 | xmlnode_to_str(root->child, &len)); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2820 | purple_debug_info("msim", "Lastchild xml=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2821 | xmlnode_to_str(root->lastchild, &len)); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2822 | purple_debug_info("msim", "Next xml=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2823 | xmlnode_to_str(root->next, &len)); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2824 | purple_debug_info("msim", "Next data=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2825 | xmlnode_get_data(root->next)); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2826 | purple_debug_info("msim", "Child->next xml=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2827 | xmlnode_to_str(root->child->next, &len)); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2828 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2829 | for (n = root->child; n; n = n->next) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2830 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2831 | if (n->name) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2832 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2833 | purple_debug_info("msim", " ** n=%s\n",n->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2834 | } else { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2835 | purple_debug_info("msim", " ** n data=%s\n", n->data); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2836 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2837 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2838 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2839 | purple_debug_info("msim", "root data=%s, child data=%s, child 'h'=%s\n", |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2840 | xmlnode_get_data(root), |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2841 | xmlnode_get_data(root->child), |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2842 | xmlnode_get_attrib(root->child, "h")); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2843 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2844 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2845 | for (n = root->child; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2846 | n != NULL; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2847 | n = n->next) |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2848 | { |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2849 | purple_debug_info("msim", "next name=%s\n", n->name); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2850 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2851 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2852 | s = xmlnode_to_str(root, &len); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2853 | s[len] = 0; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2854 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2855 | purple_debug_info("msim", "str: %s\n", s); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2856 | g_free(s); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2857 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2858 | xmlnode_free(root); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2859 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2860 | exit(0); |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2861 | |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2862 | return failures; |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2863 | } |
|
8ca08f4eface
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17994
diff
changeset
|
2864 | |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2865 | /** Test MsimMessage for basic functionality. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2866 | int |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2867 | msim_test_msg(void) |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2868 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2869 | MsimMessage *msg, *msg_cloned; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2870 | gchar *packed, *packed_expected, *packed_cloned; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2871 | guint failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2872 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2873 | failures = 0; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2874 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2875 | purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2876 | msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2877 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2878 | /* Append some new elements. */ |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2879 | msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2880 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2881 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2882 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2883 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2884 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2885 | msim_msg_dump("msg debug str=%s\n", msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2886 | packed = msim_msg_pack(msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2887 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2888 | purple_debug_info("msim", "msg packed=%s\n", packed); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2889 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2890 | packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2891 | "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2892 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2893 | if (0 != strcmp(packed, packed_expected)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2894 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2895 | purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2896 | ++failures, packed, packed_expected); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2897 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2898 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2899 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2900 | msg_cloned = msim_msg_clone(msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2901 | packed_cloned = msim_msg_pack(msg_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2902 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2903 | purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2904 | if (0 != strcmp(packed, packed_cloned)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2905 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2906 | purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2907 | ++failures, packed_cloned, packed); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2908 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2909 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2910 | g_free(packed); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2911 | g_free(packed_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2912 | msim_msg_free(msg_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2913 | msim_msg_free(msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2914 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2915 | return failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2916 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2917 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2918 | /** Test protocol-level escaping/unescaping. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2919 | int |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2920 | msim_test_escaping(void) |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2921 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2922 | guint failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2923 | gchar *raw, *escaped, *unescaped, *expected; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2924 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2925 | failures = 0; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2926 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2927 | purple_debug_info("msim", "\n\nTesting escaping\n"); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2928 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2929 | raw = "hello/world\\hello/world"; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2930 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2931 | escaped = msim_escape(raw); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2932 | purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2933 | expected = "hello/1world/2hello/1world"; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2934 | if (0 != strcmp(escaped, expected)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2935 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2936 | purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2937 | ++failures, escaped, expected); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2938 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2939 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2940 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2941 | unescaped = msim_unescape(escaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2942 | g_free(escaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2943 | purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2944 | if (0 != strcmp(raw, unescaped)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2945 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2946 | purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2947 | ++failures, raw, unescaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2948 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2949 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2950 | return failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2951 | } |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
2952 | #endif |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2953 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2954 | /** Initialize plugin. */ |
|
17994
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2955 | void |
|
b3b072dd8478
Split return type and function name + arguments on to separate lines, to
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17993
diff
changeset
|
2956 | init_plugin(PurplePlugin *plugin) |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2957 | { |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2958 | PurpleAccountOption *option; |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2959 | #ifdef MSIM_SELF_TEST |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2960 | msim_test_all(); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2961 | #endif /* MSIM_SELF_TEST */ |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2962 | |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2963 | /* TODO: default to automatically try different ports. Make the user be |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2964 | * able to set the first port to try (like LastConnectedPort in Windows client). */ |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2965 | option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2966 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2967 | |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2968 | option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2969 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2970 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2971 | option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2972 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2973 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2974 | option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2975 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2976 | } |
| 16322 | 2977 | |
| 16324 | 2978 | PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |