Thu, 12 Jul 2007 04:15:45 +0000
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
(it wasn't apparent before msim_set_status was implemented, since without it,
we would always appear as invisible (hidden) / offline).
Clean up some old comments. The bug mentioned in the last commit message
seems to be a Pidgin bug, but I can't reproduce it.
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1 | /* MySpaceIM Protocol Plugin |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3 | * \author Jeff Connelly |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
5 | * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
6 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
7 | * Based on Purple's "C Plugin HOWTO" hello world example. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
8 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
9 | * Code also drawn from mockprpl: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
10 | * http://snarfed.org/space/purple+mock+protocol+plugin |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
11 | * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
12 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
13 | * and some constructs also based on existing Purple plugins, which are: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
14 | * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
15 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
16 | * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
17 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
18 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
19 | * This program is free software; you can redistribute it and/or modify |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
20 | * it under the terms of the GNU General Public License as published by |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
21 | * the Free Software Foundation; either version 2 of the License, or |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
22 | * (at your option) any later version. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
23 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
24 | * This program is distributed in the hope that it will be useful, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
27 | * GNU General Public License for more details. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
28 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
29 | * You should have received a copy of the GNU General Public License |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
30 | * along with this program; if not, write to the Free Software |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
32 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
33 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
34 | #define PURPLE_PLUGIN |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
35 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
36 | #include "message.h" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
37 | #include "persist.h" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
38 | #include "myspace.h" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
39 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
40 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
41 | * Load the plugin. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
42 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
43 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
44 | msim_load(PurplePlugin *plugin) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
45 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
46 | /* If compiled to use RC4 from libpurple, check if it is really there. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
47 | if (!purple_ciphers_find_cipher("rc4")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
48 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
49 | purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
50 | purple_notify_error(plugin, _("Missing Cipher"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
51 | _("The RC4 cipher could not be found"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
52 | _("Upgrade " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
53 | "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
54 | "plugin will not be loaded.")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
55 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
56 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
57 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
58 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
59 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
60 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
61 | * Get possible user status types. Based on mockprpl. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
62 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
63 | * @return GList of status types. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
64 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
65 | GList * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
66 | msim_status_types(PurpleAccount *acct) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
67 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
68 | GList *types; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
69 | PurpleStatusType *status; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
70 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
71 | purple_debug_info("myspace", "returning status types\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
72 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
73 | types = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
74 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
75 | /* Statuses are almost all the same. Define a macro to reduce code repetition. */ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
76 | #define _MSIM_ADD_NEW_STATUS(prim) status = \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
77 | purple_status_type_new_with_attrs( \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
78 | prim, /* PurpleStatusPrimitive */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
79 | NULL, /* id - use default */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
80 | NULL, /* name - use default */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
81 | TRUE, /* savable */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
82 | TRUE, /* user_settable */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
83 | FALSE, /* not independent */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
84 | \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
85 | /* Attributes - each status can have a message. */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
86 | "message", \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
87 | _("Message"), \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
88 | purple_value_new(PURPLE_TYPE_STRING), \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
89 | NULL); \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
90 | \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
91 | \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
92 | types = g_list_append(types, status) |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
93 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
94 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
95 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AVAILABLE); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
96 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AWAY); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
97 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_OFFLINE); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
98 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_INVISIBLE); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
99 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
100 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
101 | return types; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
102 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
103 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
104 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
105 | * Return the icon name for a buddy and account. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
106 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
107 | * @param acct The account to find the icon for, or NULL for protocol icon. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
108 | * @param buddy The buddy to find the icon for, or NULL for the account icon. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
109 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
110 | * @return The base icon name string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
111 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
112 | const gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
113 | msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
114 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
115 | /* Use a MySpace icon submitted by hbons at |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
116 | * http://developer.pidgin.im/wiki/MySpaceIM. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
117 | return "myspace"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
118 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
119 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
120 | /* Replacement codes to be replaced with associated replacement text, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
121 | * used for protocol message escaping / unescaping. */ |
|
18032
c8351d294015
Add /3 -> | escape code (found by sje397, documented in [wiki:MsimProtocolSpec]).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18031
diff
changeset
|
122 | static gchar* msim_replacement_code[] = { "/1", "/2", "/3", NULL }; |
|
c8351d294015
Add /3 -> | escape code (found by sje397, documented in [wiki:MsimProtocolSpec]).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18031
diff
changeset
|
123 | static gchar* msim_replacement_text[] = { "/", "\\", "|", NULL }; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
124 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
125 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
126 | * Unescape or escape a protocol message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
127 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
128 | * @param msg The message to be unescaped or escaped. WILL BE FREED. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
129 | * @param escape TRUE to escape, FALSE to unescape. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
130 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
131 | * @return The unescaped or escaped message. Caller must g_free(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
132 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
133 | gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
134 | msim_unescape_or_escape(gchar *msg, gboolean escape) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
135 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
136 | gchar *tmp, *code, *text; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
137 | guint i; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
138 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
139 | /* Replace each code in msim_replacement_code with |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
140 | * corresponding entry in msim_replacement_text. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
141 | for (i = 0; (code = msim_replacement_code[i]) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
142 | && (text = msim_replacement_text[i]); ++i) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
143 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
144 | if (escape) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
145 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
146 | tmp = str_replace(msg, text, code); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
147 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
148 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
149 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
150 | tmp = str_replace(msg, code, text); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
151 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
152 | g_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
153 | msg = tmp; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
154 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
155 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
156 | return msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
157 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
158 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
159 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
160 | * Escape a protocol message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
161 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
162 | * @return The escaped message. Caller must g_free(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
163 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
164 | gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
165 | msim_escape(const gchar *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
166 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
167 | return msim_unescape_or_escape(g_strdup(msg), TRUE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
168 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
169 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
170 | gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
171 | msim_unescape(const gchar *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
172 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
173 | return msim_unescape_or_escape(g_strdup(msg), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
174 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
175 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
176 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
177 | * Replace 'old' with 'new' in 'str'. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
178 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
179 | * @param str The original string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
180 | * @param old The substring of 'str' to replace. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
181 | * @param new The replacement for 'old' within 'str'. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
182 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
183 | * @return A _new_ string, based on 'str', with 'old' replaced |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
184 | * by 'new'. Must be g_free()'d by caller. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
185 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
186 | * This string replace method is based on |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
187 | * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
188 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
189 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
190 | gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
191 | str_replace(const gchar *str, const gchar *old, const gchar *new) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
192 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
193 | gchar **items; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
194 | gchar *ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
195 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
196 | items = g_strsplit(str, old, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
197 | ret = g_strjoinv(new, items); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
198 | g_free(items); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
199 | return ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
200 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
201 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
202 | #ifdef MSIM_DEBUG_MSG |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
203 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
204 | print_hash_item(gpointer key, gpointer value, gpointer user_data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
205 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
206 | purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
207 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
208 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
209 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
210 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
211 | * Send raw data (given as a NUL-terminated string) to the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
212 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
213 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
214 | * @param msg The raw data to send, in a NUL-terminated string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
215 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
216 | * @return TRUE if succeeded, FALSE if not. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
217 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
218 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
219 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
220 | msim_send_raw(MsimSession *session, const gchar *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
221 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
222 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
223 | g_return_val_if_fail(msg != NULL, FALSE); |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
224 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
225 | purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
226 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
227 | return msim_send_really_raw(session->gc, msg, strlen(msg)) == |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
228 | strlen(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
229 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
230 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
231 | /** Send raw data to the server, possibly with embedded NULs. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
232 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
233 | * Used in prpl_info struct, so that plugins can have the most possible |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
234 | * control of what is sent over the connection. Inside this prpl, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
235 | * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
236 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
237 | * @param gc PurpleConnection |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
238 | * @param buf Buffer to send |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
239 | * @param total_bytes Size of buffer to send |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
240 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
241 | * @return Bytes successfully sent, or -1 on error. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
242 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
243 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
244 | msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
245 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
246 | int total_bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
247 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
248 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
249 | g_return_val_if_fail(gc != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
250 | g_return_val_if_fail(buf != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
251 | g_return_val_if_fail(total_bytes >= 0, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
252 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
253 | session = (MsimSession *)(gc->proto_data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
254 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
255 | g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
256 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
257 | /* Loop until all data is sent, or a failure occurs. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
258 | total_bytes_sent = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
259 | do |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
260 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
261 | int bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
262 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
263 | bytes_sent = send(session->fd, buf + total_bytes_sent, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
264 | total_bytes - total_bytes_sent, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
265 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
266 | if (bytes_sent < 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
267 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
268 | purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
269 | buf, g_strerror(errno)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
270 | return total_bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
271 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
272 | total_bytes_sent += bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
273 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
274 | } while(total_bytes_sent < total_bytes); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
275 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
276 | return total_bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
277 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
278 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
279 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
280 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
281 | * Start logging in to the MSIM servers. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
282 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
283 | * @param acct Account information to use to login. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
284 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
285 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
286 | msim_login(PurpleAccount *acct) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
287 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
288 | PurpleConnection *gc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
289 | const gchar *host; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
290 | int port; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
291 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
292 | g_return_if_fail(acct != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
293 | g_return_if_fail(acct->username != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
294 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
295 | purple_debug_info("myspace", "logging in %s\n", acct->username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
296 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
297 | gc = purple_account_get_connection(acct); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
298 | gc->proto_data = msim_session_new(acct); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
299 | gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
300 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
301 | /* Passwords are limited in length. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
302 | if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
303 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
304 | gchar *str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
305 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
306 | str = g_strdup_printf( |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
307 | _("Sorry, passwords over %d characters in length (yours is " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
308 | "%d) are not supported by the MySpaceIM plugin."), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
309 | MSIM_MAX_PASSWORD_LENGTH, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
310 | (int)strlen(acct->password)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
311 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
312 | /* Notify an error message also, because this is important! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
313 | purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
314 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
315 | purple_connection_error(gc, str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
316 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
317 | g_free(str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
318 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
319 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
320 | /* 1. connect to server */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
321 | purple_connection_update_progress(gc, _("Connecting"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
322 | 0, /* which connection step this is */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
323 | 4); /* total number of steps */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
324 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
325 | host = purple_account_get_string(acct, "server", MSIM_SERVER); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
326 | port = purple_account_get_int(acct, "port", MSIM_PORT); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
327 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
328 | /* From purple.sf.net/api: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
329 | * """Note that this function name can be misleading--although it is called |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
330 | * "proxy connect," it is used for establishing any outgoing TCP connection, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
331 | * whether through a proxy or not.""" */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
332 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
333 | /* Calls msim_connect_cb when connected. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
334 | if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
335 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
336 | /* TODO: try other ports if in auto mode, then save |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
337 | * working port and try that first next time. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
338 | purple_connection_error(gc, _("Couldn't create socket")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
339 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
340 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
341 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
342 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
343 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
344 | * Process a login challenge, sending a response. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
345 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
346 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
347 | * @param msg Login challenge message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
348 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
349 | * @return TRUE if successful, FALSE if not |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
350 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
351 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
352 | msim_login_challenge(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
353 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
354 | PurpleAccount *account; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
355 | const gchar *response; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
356 | guint response_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
357 | gchar *nc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
358 | gsize nc_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
359 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
360 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
361 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
362 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
363 | g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
364 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
365 | account = session->account; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
366 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
367 | g_return_val_if_fail(account != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
368 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
369 | purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
370 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
371 | purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
372 | |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
373 | if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
374 | { |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
375 | purple_debug_info("msim", "bad nc length: %x != 0x%x\n", nc_len, MSIM_AUTH_CHALLENGE_LENGTH); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
376 | purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
377 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
378 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
379 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
380 | purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
381 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
382 | response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
383 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
384 | g_free(nc); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
385 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
386 | return msim_send(session, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
387 | "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
388 | /* This is actually user's email address. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
389 | "username", MSIM_TYPE_STRING, g_strdup(account->username), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
390 | /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
391 | "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
392 | "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
393 | "reconn", MSIM_TYPE_INTEGER, 0, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
394 | "status", MSIM_TYPE_INTEGER, 100, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
395 | "id", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
396 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
397 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
398 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
399 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
400 | * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
401 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
402 | * @param nonce The base64 encoded nonce ('nc') field from the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
403 | * @param email User's email address (used as login name). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
404 | * @param password User's cleartext password. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
405 | * @param response_len Will be written with response length. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
406 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
407 | * @return Binary login challenge response, ready to send to the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
408 | * Must be g_free()'d when finished. NULL if error. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
409 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
410 | const gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
411 | msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
412 | const gchar *email, const gchar *password, guint *response_len) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
413 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
414 | PurpleCipherContext *key_context; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
415 | PurpleCipher *sha1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
416 | PurpleCipherContext *rc4; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
417 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
418 | guchar hash_pw[HASH_SIZE]; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
419 | guchar key[HASH_SIZE]; |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
420 | gchar *password_utf16le, *password_ascii_lc; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
421 | guchar *data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
422 | guchar *data_out; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
423 | size_t data_len, data_out_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
424 | gsize conv_bytes_read, conv_bytes_written; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
425 | GError *conv_error; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
426 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
427 | int i; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
428 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
429 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
430 | g_return_val_if_fail(nonce != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
431 | g_return_val_if_fail(email != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
432 | g_return_val_if_fail(password != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
433 | g_return_val_if_fail(response_len != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
434 | |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
435 | /* Convert password to lowercase (required for passwords containing |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
436 | * uppercase characters). MySpace passwords are lowercase, |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
437 | * see ticket #2066. */ |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
438 | password_ascii_lc = g_strdup(password); |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
439 | g_strdown(password_ascii_lc); |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
440 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
441 | /* Convert ASCII password to UTF16 little endian */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
442 | purple_debug_info("msim", "converting password to UTF-16LE\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
443 | conv_error = NULL; |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
444 | password_utf16le = g_convert(password_ascii_lc, -1, "UTF-16LE", "UTF-8", |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
445 | &conv_bytes_read, &conv_bytes_written, &conv_error); |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
446 | g_free(password_ascii_lc); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
447 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
448 | g_return_val_if_fail(conv_bytes_read == strlen(password), NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
449 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
450 | if (conv_error != NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
451 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
452 | purple_debug_error("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
453 | "g_convert password UTF8->UTF16LE failed: %s", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
454 | conv_error->message); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
455 | g_error_free(conv_error); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
456 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
457 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
458 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
459 | /* Compute password hash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
460 | purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
461 | conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
462 | g_free(password_utf16le); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
463 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
464 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
465 | purple_debug_info("msim", "pwhash = "); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
466 | for (i = 0; i < sizeof(hash_pw); i++) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
467 | purple_debug_info("msim", "%.2x ", hash_pw[i]); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
468 | purple_debug_info("msim", "\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
469 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
470 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
471 | /* key = sha1(sha1(pw) + nonce2) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
472 | sha1 = purple_ciphers_find_cipher("sha1"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
473 | key_context = purple_cipher_context_new(sha1, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
474 | purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
475 | purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
476 | purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
477 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
478 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
479 | purple_debug_info("msim", "key = "); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
480 | for (i = 0; i < sizeof(key); i++) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
481 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
482 | purple_debug_info("msim", "%.2x ", key[i]); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
483 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
484 | purple_debug_info("msim", "\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
485 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
486 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
487 | rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
488 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
489 | /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
490 | * but only first 0x10 used for the RC4 key. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
491 | purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
492 | purple_cipher_context_set_key(rc4, key); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
493 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
494 | /* TODO: obtain IPs of network interfaces */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
495 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
496 | /* rc4 encrypt: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
497 | * nonce1+email+IP list */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
498 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
499 | data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
500 | data = g_new0(guchar, data_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
501 | memcpy(data, nonce, NONCE_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
502 | memcpy(data + NONCE_SIZE, email, strlen(email)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
503 | memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
504 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
505 | data_out = g_new0(guchar, data_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
506 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
507 | purple_cipher_context_encrypt(rc4, (const guchar *)data, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
508 | data_len, data_out, &data_out_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
509 | purple_cipher_context_destroy(rc4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
510 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
511 | g_assert(data_out_len == data_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
512 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
513 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
514 | purple_debug_info("msim", "response=<%s>\n", data_out); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
515 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
516 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
517 | *response_len = data_out_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
518 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
519 | return (const gchar *)data_out; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
520 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
521 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
522 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
523 | * Schedule an IM to be sent once the user ID is looked up. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
524 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
525 | * @param gc Connection. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
526 | * @param who A user id, email, or username to send the message to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
527 | * @param message Instant message text to send. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
528 | * @param flags Flags. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
529 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
530 | * @return 1 if successful or postponed, -1 if failed |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
531 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
532 | * Allows sending to a user by username, email address, or userid. If |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
533 | * a username or email address is given, the userid must be looked up. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
534 | * This function does that by calling msim_postprocess_outgoing(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
535 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
536 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
537 | msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
538 | PurpleMessageFlags flags) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
539 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
540 | MsimSession *session; |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
541 | gchar *message_msim; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
542 | int rc; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
543 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
544 | g_return_val_if_fail(gc != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
545 | g_return_val_if_fail(who != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
546 | g_return_val_if_fail(message != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
547 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
548 | /* 'flags' has many options, not used here. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
549 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
550 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
551 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
552 | g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
553 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
554 | message_msim = html_to_msim_markup(message); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
555 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
556 | if (msim_send_bm(session, who, message_msim, MSIM_BM_INSTANT)) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
557 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
558 | /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
559 | * return 1 even if the message could not be sent, since I don't know if |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
560 | * it has failed yet--because the IM is only sent after the userid is |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
561 | * retrieved from the server (which happens after this function returns). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
562 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
563 | /* TODO: maybe if message is delayed, don't echo to conv window, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
564 | * but do echo it to conv window manually once it is actually |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
565 | * sent? Would be complicated. */ |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
566 | rc = 1; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
567 | } else { |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
568 | rc = -1; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
569 | } |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
570 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
571 | g_free(message_msim); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
572 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
573 | /* |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
574 | * In MySpace, you login with your email address, but don't talk to other |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
575 | * users using their email address. So there is currently an asymmetry in the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
576 | * IM windows when using this plugin: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
577 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
578 | * you@example.com: hello |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
579 | * some_other_user: what's going on? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
580 | * you@example.com: just coding a prpl |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
581 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
582 | * TODO: Make the sent IM's appear as from the user's username, instead of |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
583 | * their email address. Purple uses the login (in MSIM, the email)--change this. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
584 | */ |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
585 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
586 | return rc; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
587 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
588 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
589 | /** Send a buddy message of a given type. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
590 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
591 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
592 | * @param who Username to send message to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
593 | * @param text Message text to send. Not freed; will be copied. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
594 | * @param type A MSIM_BM_* constant. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
595 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
596 | * @return TRUE if success, FALSE if fail. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
597 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
598 | * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
599 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
600 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
601 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
602 | msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
603 | int type) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
604 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
605 | gboolean rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
606 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
607 | const gchar *from_username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
608 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
609 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
610 | g_return_val_if_fail(who != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
611 | g_return_val_if_fail(text != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
612 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
613 | from_username = session->account->username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
614 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
615 | purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
616 | type, from_username, who, text); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
617 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
618 | msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
619 | "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
620 | "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
621 | /* 't' will be inserted here */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
622 | "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
623 | "msg", MSIM_TYPE_STRING, g_strdup(text), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
624 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
625 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
626 | rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
627 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
628 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
629 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
630 | return rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
631 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
632 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
633 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
634 | #ifdef MSIM_FONT_SIZE_WORKS |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
635 | /** Convert a msim markup font height to points. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
636 | static guint |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
637 | msim_font_height_to_point(guint height) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
638 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
639 | /* See also: libpurple/protocols/bonjour/jabber.c |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
640 | * _font_size_ichat_to_purple */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
641 | switch (height) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
642 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
643 | case 11: return 8; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
644 | case 12: return 9; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
645 | case 13: return 10; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
646 | case 14: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
647 | case 15: return 11; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
648 | case 16: return 12; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
649 | case 17: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
650 | case 18: return 13; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
651 | case 19: return 14; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
652 | case 20: return 15; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
653 | case 21: return 16; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
654 | default: return 12; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
655 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
656 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
657 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
658 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
659 | /** Convert the msim markup <f> (font) tag into HTML. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
660 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
661 | msim_markup_f_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
662 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
663 | const gchar *face, *height_str, *decor_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
664 | GString *gs_end, *gs_begin; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
665 | guint decor, height; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
666 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
667 | face = xmlnode_get_attrib(root, "f"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
668 | height_str = xmlnode_get_attrib(root, "h"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
669 | decor_str = xmlnode_get_attrib(root, "s"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
670 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
671 | if (height_str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
672 | height = atol(height_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
673 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
674 | height = 12; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
675 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
676 | if (decor_str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
677 | decor = atol(decor_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
678 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
679 | decor = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
680 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
681 | gs_begin = g_string_new(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
682 | #ifdef MSIM_FONT_SIZE_WORKS |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
683 | /* TODO: get font size working */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
684 | if (!face) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
685 | g_string_printf(gs_begin, "<font size='%d'>", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
686 | msim_font_height_to_point(height)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
687 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
688 | g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
689 | msim_font_height_to_point(height)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
690 | #else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
691 | if (face) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
692 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
693 | g_string_printf(gs_begin, "<font face='%s'>", face); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
694 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
695 | g_string_printf(gs_begin, "<font>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
696 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
697 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
698 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
699 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
700 | /* No support for font-size CSS? */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
701 | /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
702 | msim_font_height_to_point(height)); */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
703 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
704 | gs_end = g_string_new("</font>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
705 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
706 | if (decor & MSIM_TEXT_BOLD) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
707 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
708 | g_string_append(gs_begin, "<b>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
709 | g_string_prepend(gs_end, "</b>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
710 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
711 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
712 | if (decor & MSIM_TEXT_ITALIC) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
713 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
714 | g_string_append(gs_begin, "<i>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
715 | g_string_append(gs_end, "</i>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
716 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
717 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
718 | if (decor & MSIM_TEXT_UNDERLINE) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
719 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
720 | g_string_append(gs_begin, "<u>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
721 | g_string_append(gs_end, "</u>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
722 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
723 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
724 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
725 | *begin = gs_begin->str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
726 | *end = gs_end->str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
727 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
728 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
729 | /** Convert a msim markup color to a color suitable for libpurple. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
730 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
731 | * @param msim Either a color name, or an rgb(x,y,z) code. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
732 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
733 | * @return A new string, either a color name or #rrggbb code. Must g_free(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
734 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
735 | static char * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
736 | msim_color_to_purple(const char *msim) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
737 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
738 | guint red, green, blue; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
739 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
740 | if (!msim) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
741 | return g_strdup("black"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
742 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
743 | if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
744 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
745 | /* Color name. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
746 | return g_strdup(msim); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
747 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
748 | /* TODO: rgba (alpha). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
749 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
750 | return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
751 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
752 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
753 | /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
754 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
755 | msim_markup_p_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
756 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
757 | /* Just pass through unchanged. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
758 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
759 | * Note: attributes currently aren't passed, if there are any. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
760 | *begin = g_strdup("<p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
761 | *end = g_strdup("</p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
762 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
763 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
764 | /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
765 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
766 | msim_markup_c_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
767 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
768 | const gchar *color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
769 | gchar *purple_color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
770 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
771 | color = xmlnode_get_attrib(root, "v"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
772 | if (!color) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
773 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
774 | purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
775 | *begin = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
776 | *end = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
777 | /* TODO: log as unrecognized */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
778 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
779 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
780 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
781 | purple_color = msim_color_to_purple(color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
782 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
783 | *begin = g_strdup_printf("<font color='%s'>", purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
784 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
785 | g_free(purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
786 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
787 | /* *begin = g_strdup_printf("<span style='color: %s'>", color); */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
788 | *end = g_strdup("</font>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
789 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
790 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
791 | /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
792 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
793 | msim_markup_b_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
794 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
795 | const gchar *color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
796 | gchar *purple_color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
797 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
798 | color = xmlnode_get_attrib(root, "v"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
799 | if (!color) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
800 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
801 | *begin = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
802 | *end = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
803 | purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
804 | /* TODO: log as unrecognized. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
805 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
806 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
807 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
808 | purple_color = msim_color_to_purple(color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
809 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
810 | /* TODO: find out how to set background color. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
811 | *begin = g_strdup_printf("<span style='background-color: %s'>", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
812 | purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
813 | g_free(purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
814 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
815 | *end = g_strdup("</p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
816 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
817 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
818 | /** Convert the msim markup <i> tag (emoticon image) into HTML. TODO: Test */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
819 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
820 | msim_markup_i_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
821 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
822 | const gchar *name; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
823 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
824 | name = xmlnode_get_attrib(root, "n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
825 | if (!name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
826 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
827 | purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
828 | *begin = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
829 | *end = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
830 | /* TODO: log as unrecognized */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
831 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
832 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
833 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
834 | /* TODO: Support these emoticons: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
835 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
836 | * bigsmile growl mad scared tongue devil happy messed sidefrown upset |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
837 | * frazzled heart nerd sinister wink geek laugh oops smirk worried |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
838 | * googles mohawk pirate straight kiss |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
839 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
840 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
841 | *begin = g_strdup_printf("<img id='%s'>", name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
842 | *end = g_strdup("</p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
843 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
844 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
845 | /** Convert an individual msim markup tag to HTML. */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
846 | void msim_markup_tag_to_html(xmlnode *root, gchar **begin, gchar **end) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
847 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
848 | if (!strcmp(root->name, "f")) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
849 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
850 | msim_markup_f_to_html(root, begin, end); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
851 | } else if (!strcmp(root->name, "p")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
852 | msim_markup_p_to_html(root, begin, end); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
853 | } else if (!strcmp(root->name, "c")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
854 | msim_markup_c_to_html(root, begin, end); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
855 | } else if (!strcmp(root->name, "b")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
856 | msim_markup_b_to_html(root, begin, end); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
857 | } else if (!strcmp(root->name, "i")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
858 | msim_markup_i_to_html(root, begin, end); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
859 | } else { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
860 | purple_debug_info("msim", "msim_markup_tag_to_html: " |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
861 | "unknown tag name=%s, ignoring", root->name); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
862 | *begin = g_strdup(""); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
863 | *end = g_strdup(""); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
864 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
865 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
866 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
867 | /** Convert an individual HTML tag to msim markup. */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
868 | void html_tag_to_msim_markup(xmlnode *root, gchar **begin, gchar **end) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
869 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
870 | /* TODO: Coalesce nested tags into one <f> tag! |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
871 | * Currently, the 's' value will be overwritten when b/i/u is nested |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
872 | * within another one, and only the inner-most formatting will be |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
873 | * applied to the text. */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
874 | if (!strcmp(root->name, "b")) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
875 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
876 | *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
877 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
878 | } else if (!strcmp(root->name, "i")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
879 | *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
880 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
881 | } else if (!strcmp(root->name, "u")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
882 | *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
883 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
884 | } else if (!strcmp(root->name, "font")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
885 | const gchar *size; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
886 | const gchar *face; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
887 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
888 | size = xmlnode_get_attrib(root, "size"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
889 | face = xmlnode_get_attrib(root, "face"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
890 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
891 | if (face && size) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
892 | *begin = g_strdup_printf("<f f='%s' h='%s'>", face, size); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
893 | else if (face) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
894 | *begin = g_strdup_printf("<f f='%s'>", face); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
895 | else if (size) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
896 | *begin = g_strdup_printf("<f h='%s'>", face); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
897 | else |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
898 | *begin = g_strdup("<f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
899 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
900 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
901 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
902 | /* TODO: color (bg uses <body>), emoticons */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
903 | } else { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
904 | *begin = g_strdup_printf("[%s]", root->name); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
905 | *end = g_strdup_printf("[/%s]", root->name); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
906 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
907 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
908 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
909 | /** Convert an xmlnode of msim markup or HTML to an HTML string or msim markup. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
910 | * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
911 | * @param f Function to convert tags. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
912 | * |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
913 | * @return An HTML string. Caller frees. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
914 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
915 | static gchar * |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
916 | msim_convert_xmlnode(xmlnode *root, MSIM_XMLNODE_CONVERT f) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
917 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
918 | xmlnode *node; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
919 | gchar *begin, *inner, *end; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
920 | gchar *final; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
921 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
922 | if (!root || !root->name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
923 | return g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
924 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
925 | purple_debug_info("msim", "msim_convert_xmlnode: got root=%s\n", |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
926 | root->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
927 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
928 | begin = inner = end = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
929 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
930 | f(root, &begin, &end); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
931 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
932 | /* Loop over all child nodes. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
933 | for (node = root->child; node != NULL; node = node->next) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
934 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
935 | switch (node->type) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
936 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
937 | case XMLNODE_TYPE_ATTRIB: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
938 | /* Attributes handled above. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
939 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
940 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
941 | case XMLNODE_TYPE_TAG: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
942 | /* A tag or tag with attributes. Recursively descend. */ |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
943 | inner = msim_convert_xmlnode(node, f); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
944 | g_return_val_if_fail(inner != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
945 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
946 | purple_debug_info("msim", " ** node name=%s\n", node->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
947 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
948 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
949 | case XMLNODE_TYPE_DATA: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
950 | /* Literal text. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
951 | inner = g_new0(char, node->data_sz + 1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
952 | strncpy(inner, node->data, node->data_sz); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
953 | inner[node->data_sz + 1] = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
954 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
955 | purple_debug_info("msim", " ** node data=%s\n", inner); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
956 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
957 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
958 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
959 | purple_debug_info("msim", |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
960 | "msim_convert_xmlnode: strange node\n"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
961 | inner = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
962 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
963 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
964 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
965 | final = g_strconcat(begin, inner, end, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
966 | g_free(begin); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
967 | g_free(inner); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
968 | g_free(end); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
969 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
970 | purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
971 | final); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
972 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
973 | return final; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
974 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
975 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
976 | /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
977 | gchar * |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
978 | msim_convert_xml(const gchar *raw, MSIM_XMLNODE_CONVERT f) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
979 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
980 | xmlnode *root; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
981 | gchar *str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
982 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
983 | root = xmlnode_from_str(raw, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
984 | if (!root) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
985 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
986 | purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
987 | "%s as XML, returning raw\n", raw); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
988 | return g_strdup(raw); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
989 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
990 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
991 | str = msim_convert_xmlnode(root, f); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
992 | purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
993 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
994 | xmlnode_free(root); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
995 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
996 | return str; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
997 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
998 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
999 | /** High-level function to convert MySpaceIM markup to Purple (HTML) markup. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1000 | * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1001 | * @return Purple markup string, must be g_free()'d. */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1002 | gchar * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1003 | msim_markup_to_html(const gchar *raw) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1004 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1005 | return msim_convert_xml(raw, |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1006 | (MSIM_XMLNODE_CONVERT)(msim_markup_tag_to_html)); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1007 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1008 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1009 | /** High-level function to convert Purple (HTML) to MySpaceIM markup. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1010 | * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1011 | * @return HTML markup string, must be g_free()'d. */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1012 | gchar * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1013 | html_to_msim_markup(const gchar *raw) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1014 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1015 | return msim_convert_xml(raw, |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1016 | (MSIM_XMLNODE_CONVERT)(html_tag_to_msim_markup)); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1017 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1018 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1019 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1020 | * Handle an incoming instant message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1021 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1022 | * @param session The session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1023 | * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1024 | * Should also contain username in _username from preprocessing. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1025 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1026 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1027 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1028 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1029 | msim_incoming_im(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1030 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1031 | gchar *username, *msg_msim_markup, *msg_purple_markup; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1032 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1033 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1034 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1035 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1036 | username = msim_msg_get_string(msg, "_username"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1037 | g_return_val_if_fail(username != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1038 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1039 | msg_msim_markup = msim_msg_get_string(msg, "msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1040 | g_return_val_if_fail(msg_msim_markup != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1041 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1042 | msg_purple_markup = msim_markup_to_html(msg_msim_markup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1043 | g_free(msg_msim_markup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1044 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1045 | serv_got_im(session->gc, username, msg_purple_markup, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1046 | PURPLE_MESSAGE_RECV, time(NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1047 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1048 | g_free(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1049 | g_free(msg_purple_markup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1050 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1051 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1052 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1053 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1054 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1055 | * Process unrecognized information. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1056 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1057 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1058 | * @param msg An MsimMessage that was unrecognized, or NULL. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1059 | * @param note Information on what was unrecognized, or NULL. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1060 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1061 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1062 | msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1063 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1064 | /* TODO: Some more context, outwardly equivalent to a backtrace, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1065 | * for helping figure out what this msg is for. What was going on? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1066 | * But not too much information so that a user |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1067 | * posting this dump reveals confidential information. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1068 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1069 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1070 | /* TODO: dump unknown msgs to file, so user can send them to me |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1071 | * if they wish, to help add support for new messages (inspired |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1072 | * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1073 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1074 | purple_debug_info("msim", "Unrecognized data on account for %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1075 | session->account->username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1076 | if (note) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1077 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1078 | purple_debug_info("msim", "(Note: %s)\n", note); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1079 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1080 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1081 | if (msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1082 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1083 | msim_msg_dump("Unrecognized message dump: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1084 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1085 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1086 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1087 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1088 | * Handle an incoming action message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1089 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1090 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1091 | * @param msg |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1092 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1093 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1094 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1095 | * UNTESTED |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1096 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1097 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1098 | msim_incoming_action(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1099 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1100 | gchar *msg_text, *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1101 | gboolean rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1102 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1103 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1104 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1105 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1106 | msg_text = msim_msg_get_string(msg, "msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1107 | g_return_val_if_fail(msg_text != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1108 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1109 | username = msim_msg_get_string(msg, "_username"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1110 | g_return_val_if_fail(username != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1111 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1112 | purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1113 | msg_text, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1114 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1115 | if (strcmp(msg_text, "%typing%") == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1116 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1117 | /* TODO: find out if msim repeatedly sends typing messages, so we can |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1118 | * give it a timeout. Right now, there does seem to be an inordinately |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1119 | * amount of time between typing stopped-typing notifications. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1120 | serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1121 | rc = TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1122 | } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1123 | serv_got_typing_stopped(session->gc, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1124 | rc = TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1125 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1126 | msim_unrecognized(session, msg, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1127 | "got to msim_incoming_action but unrecognized value for 'msg'"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1128 | rc = FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1129 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1130 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1131 | g_free(msg_text); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1132 | g_free(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1133 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1134 | return rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1135 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1136 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1137 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1138 | * Handle when our user starts or stops typing to another user. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1139 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1140 | * @param gc |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1141 | * @param name The buddy name to which our user is typing to |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1142 | * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1143 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1144 | * @return 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1145 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1146 | unsigned int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1147 | msim_send_typing(PurpleConnection *gc, const gchar *name, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1148 | PurpleTypingState state) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1149 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1150 | const gchar *typing_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1151 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1152 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1153 | g_return_val_if_fail(gc != NULL, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1154 | g_return_val_if_fail(name != NULL, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1155 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1156 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1157 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1158 | g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1159 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1160 | switch (state) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1161 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1162 | case PURPLE_TYPING: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1163 | typing_str = "%typing%"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1164 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1165 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1166 | case PURPLE_TYPED: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1167 | case PURPLE_NOT_TYPING: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1168 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1169 | typing_str = "%stoptyping%"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1170 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1171 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1172 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1173 | purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1174 | msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1175 | return 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1176 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1177 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1178 | /** Callback for msim_get_info(), for when user info is received. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1179 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1180 | msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1181 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1182 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1183 | gchar *body_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1184 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1185 | gchar *user; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1186 | PurpleNotifyUserInfo *user_info; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1187 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1188 | const gchar *str, *str2; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1189 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1190 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1191 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1192 | /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1193 | orthogonality. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1194 | msg = (MsimMessage *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1195 | g_return_if_fail(msg != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1196 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1197 | user = msim_msg_get_string(msg, "user"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1198 | if (!user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1199 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1200 | purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1201 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1202 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1203 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1204 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1205 | purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1206 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1207 | body_str = msim_msg_get_string(user_info_msg, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1208 | g_return_if_fail(body_str != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1209 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1210 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1211 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1212 | buddy = purple_find_buddy(session->account, user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1213 | /* Note: don't assume buddy is non-NULL; will be if lookup random user |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1214 | * not on blist. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1215 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1216 | user_info = purple_notify_user_info_new(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1217 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1218 | /* Identification */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1219 | purple_notify_user_info_add_pair(user_info, _("User"), user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1220 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1221 | /* note: g_hash_table_lookup does not create a new string! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1222 | str = g_hash_table_lookup(body, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1223 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1224 | purple_notify_user_info_add_pair(user_info, _("User ID"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1225 | g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1226 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1227 | /* a/s/l...the vitals */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1228 | str = g_hash_table_lookup(body, "Age"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1229 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1230 | purple_notify_user_info_add_pair(user_info, _("Age"), g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1231 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1232 | str = g_hash_table_lookup(body, "Gender"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1233 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1234 | purple_notify_user_info_add_pair(user_info, _("Gender"), g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1235 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1236 | str = g_hash_table_lookup(body, "Location"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1237 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1238 | purple_notify_user_info_add_pair(user_info, _("Location"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1239 | g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1240 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1241 | /* Other information */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1242 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1243 | /* Headline comes from buddy status messages */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1244 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1245 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1246 | str = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1247 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1248 | purple_notify_user_info_add_pair(user_info, "Headline", str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1249 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1250 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1251 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1252 | str = g_hash_table_lookup(body, "BandName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1253 | str2 = g_hash_table_lookup(body, "SongName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1254 | if (str || str2) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1255 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1256 | purple_notify_user_info_add_pair(user_info, _("Song"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1257 | g_strdup_printf("%s - %s", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1258 | str ? str : "Unknown Artist", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1259 | str2 ? str2 : "Unknown Song")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1260 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1261 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1262 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1263 | /* Total friends only available if looked up by uid, not username. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1264 | str = g_hash_table_lookup(body, "TotalFriends"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1265 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1266 | purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1267 | g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1268 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1269 | purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1270 | purple_debug_info("msim", "msim_get_info_cb: username=%s\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1271 | //purple_notify_user_info_destroy(user_info); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1272 | /* Do not free username, since it will be used by user_info. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1273 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1274 | //g_hash_table_destroy(body); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1275 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1276 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1277 | /** Retrieve a user's profile. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1278 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1279 | msim_get_info(PurpleConnection *gc, const gchar *user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1280 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1281 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1282 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1283 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1284 | gchar *user_to_lookup; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1285 | MsimMessage *user_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1286 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1287 | g_return_if_fail(gc != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1288 | g_return_if_fail(user != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1289 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1290 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1291 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1292 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1293 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1294 | /* Obtain uid of buddy. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1295 | buddy = purple_find_buddy(session->account, user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1296 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1297 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1298 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1299 | if (!uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1300 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1301 | PurpleNotifyUserInfo *user_info; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1302 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1303 | user_info = purple_notify_user_info_new(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1304 | purple_notify_user_info_add_pair(user_info, NULL, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1305 | _("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?")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1306 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1307 | purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1308 | purple_notify_user_info_destroy(user_info); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1309 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1310 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1311 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1312 | user_to_lookup = g_strdup_printf("%d", uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1313 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1314 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1315 | /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1316 | user_to_lookup = g_strdup(user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1317 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1318 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1319 | /* Pass the username to msim_get_info_cb(), because since we lookup |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1320 | * by userid, the userinfo message will only contain the uid (not |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1321 | * the username). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1322 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1323 | user_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1324 | "user", MSIM_TYPE_STRING, g_strdup(user), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1325 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1326 | purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1327 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1328 | msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1329 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1330 | g_free(user_to_lookup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1331 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1332 | |
|
18035
2c401f444456
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18034
diff
changeset
|
1333 | /** Set your status - callback for when user manually sets it. */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1334 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1335 | msim_set_status(PurpleAccount *account, PurpleStatus *status) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1336 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1337 | PurpleStatusType *type; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1338 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1339 | guint status_code; |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1340 | const gchar *statstring; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1341 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1342 | session = (MsimSession *)account->gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1343 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1344 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1345 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1346 | type = purple_status_get_type(status); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1347 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1348 | switch (purple_status_type_get_primitive(type)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1349 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1350 | case PURPLE_STATUS_AVAILABLE: |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1351 | purple_debug_info("msim", "msim_set_status: available (%d->%d)\n", PURPLE_STATUS_AVAILABLE, |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1352 | MSIM_STATUS_CODE_ONLINE); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1353 | status_code = MSIM_STATUS_CODE_ONLINE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1354 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1355 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1356 | case PURPLE_STATUS_INVISIBLE: |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1357 | purple_debug_info("msim", "msim_set_status: invisible (%d->%d)\n", PURPLE_STATUS_INVISIBLE, |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1358 | MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1359 | status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1360 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1361 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1362 | case PURPLE_STATUS_AWAY: |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1363 | purple_debug_info("msim", "msim_set_status: away (%d->%d)\n", PURPLE_STATUS_AWAY, |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1364 | MSIM_STATUS_CODE_AWAY); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1365 | status_code = MSIM_STATUS_CODE_AWAY; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1366 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1367 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1368 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1369 | purple_debug_info("msim", "msim_set_status: unknown " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1370 | "status interpreting as online"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1371 | status_code = MSIM_STATUS_CODE_ONLINE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1372 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1373 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1374 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1375 | statstring = purple_status_get_attr_string(status, "message"); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1376 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1377 | if (!statstring) |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1378 | statstring = g_strdup(""); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1379 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1380 | msim_set_status_code(session, status_code, g_strdup(statstring)); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1381 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1382 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1383 | /** Go idle. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1384 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1385 | msim_set_idle(PurpleConnection *gc, int time) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1386 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1387 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1388 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1389 | g_return_if_fail(gc != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1390 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1391 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1392 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1393 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1394 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1395 | if (time == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1396 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1397 | /* Going back from idle. In msim, idle is mutually exclusive |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1398 | * from the other states (you can only be away or idle, but not |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1399 | * both, for example), so by going non-idle I go online. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1400 | */ |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1401 | /* TODO: find out how to keep old status string? */ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1402 | msim_set_status_code(session, MSIM_STATUS_CODE_ONLINE, g_strdup("")); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1403 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1404 | /* msim doesn't support idle time, so just go idle */ |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1405 | msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, g_strdup("")); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1406 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1407 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1408 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1409 | /** Set status using an MSIM_STATUS_CODE_* value. |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1410 | * @param status_code An MSIM_STATUS_CODE_* value. |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1411 | * @param statstring Status string, must be a dynamic string (will be freed by msim_send). |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1412 | */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1413 | void |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1414 | msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1415 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1416 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1417 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1418 | purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n", |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1419 | status_code, statstring); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1420 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1421 | if (!msim_send(session, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1422 | "status", MSIM_TYPE_INTEGER, status_code, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1423 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1424 | "statstring", MSIM_TYPE_STRING, statstring, |
|
18029
48e7b6d97f1f
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18028
diff
changeset
|
1425 | "locstring", MSIM_TYPE_STRING, g_strdup(""), |
|
48e7b6d97f1f
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18028
diff
changeset
|
1426 | NULL)) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1427 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1428 | purple_debug_info("msim", "msim_set_status: failed to set status"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1429 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1430 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1431 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1432 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1433 | /** After a uid is resolved to username, tag it with the username and submit for processing. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1434 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1435 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1436 | * @param userinfo Response messsage to resolving request. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1437 | * @param data MsimMessage *, the message to attach information to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1438 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1439 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1440 | msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1441 | gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1442 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1443 | gchar *body_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1444 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1445 | gchar *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1446 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1447 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1448 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1449 | g_return_if_fail(userinfo != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1450 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1451 | body_str = msim_msg_get_string(userinfo, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1452 | g_return_if_fail(body_str != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1453 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1454 | g_return_if_fail(body != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1455 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1456 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1457 | username = g_hash_table_lookup(body, "UserName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1458 | g_return_if_fail(username != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1459 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1460 | msg = (MsimMessage *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1461 | g_return_if_fail(msg != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1462 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1463 | /* Special elements name beginning with '_', we'll use internally within the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1464 | * program (did not come from the wire). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1465 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1466 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1467 | msim_process(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1468 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1469 | /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1470 | //XXX msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1471 | g_hash_table_destroy(body); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1472 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1473 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1474 | #if 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1475 | /* Lookup a username by userid, from buddy list. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1476 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1477 | * @param wanted_uid |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1478 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1479 | * @return Username of wanted_uid, if on blist, or NULL. Static string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1480 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1481 | * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1482 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1483 | static const gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1484 | msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1485 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1486 | GSList *buddies, *cur; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1487 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1488 | buddies = purple_find_buddies(session->account, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1489 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1490 | if (!buddies) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1491 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1492 | purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1493 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1494 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1495 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1496 | for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1497 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1498 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1499 | //PurpleBlistNode *node; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1500 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1501 | const gchar *name; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1502 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1503 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1504 | /* See finch/gnthistory.c */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1505 | buddy = cur->data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1506 | //node = cur->data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1507 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1508 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1509 | //uid = purple_blist_node_get_int(node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1510 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1511 | /* name = buddy->name; */ /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1512 | /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1513 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1514 | /* XXX Is this right? Memory corruption here somehow. Happens only |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1515 | * when return one of these values. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1516 | name = purple_buddy_get_name(buddy); /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1517 | //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1518 | /* return name; */ /* crash (with above) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1519 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1520 | /* name = NULL; */ /* no crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1521 | /* return NULL; */ /* no crash (with anything) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1522 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1523 | /* crash = |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1524 | *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1525 | ======= Backtrace: ========= |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1526 | /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1527 | /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1528 | /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1529 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1530 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1531 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1532 | /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1533 | /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1534 | /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1535 | /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1536 | pidgin(main+0x8be)[0x46b45e] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1537 | /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1538 | pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1539 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1540 | or: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1541 | *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1542 | (gdb) bt |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1543 | #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1544 | #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1545 | #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1546 | #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1547 | #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1548 | #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1549 | #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1550 | #7 0x00002b407810969f in msim_parse ( |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1551 | raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1552 | at message.c:648 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1553 | #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1554 | source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1555 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1556 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1557 | Why is it crashing in msim_parse()'s g_strdup()? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1558 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1559 | purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1560 | name, uid, wanted_uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1561 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1562 | if (uid == wanted_uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1563 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1564 | gchar *ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1565 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1566 | ret = g_strdup(name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1567 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1568 | g_slist_free(buddies); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1569 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1570 | return ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1571 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1572 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1573 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1574 | g_slist_free(buddies); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1575 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1576 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1577 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1578 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1579 | /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1580 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1581 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1582 | * @param msg MsimMessage *, freed by caller. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1583 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1584 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1585 | msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1586 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1587 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1588 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1589 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1590 | if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1591 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1592 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1593 | const gchar *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1594 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1595 | /* 'f' = userid message is from, in buddy messages */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1596 | uid = msim_msg_get_integer(msg, "f"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1597 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1598 | /* TODO: Make caching work. Currently it is commented out because |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1599 | * it crashes for unknown reasons, memory realloc error. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1600 | #if 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1601 | username = msim_uid2username_from_blist(session, uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1602 | #else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1603 | username = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1604 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1605 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1606 | if (username) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1607 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1608 | /* Know username already, use it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1609 | purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1610 | username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1611 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1612 | return msim_process(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1613 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1614 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1615 | gchar *from; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1616 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1617 | /* Send lookup request. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1618 | /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1619 | purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1620 | from = msim_msg_get_string(msg, "f"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1621 | msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1622 | g_free(from); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1623 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1624 | /* indeterminate */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1625 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1626 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1627 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1628 | /* Nothing to resolve - send directly to processing. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1629 | return msim_process(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1630 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1631 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1632 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1633 | /** Check if the connection is still alive, based on last communication. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1634 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1635 | msim_check_alive(gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1636 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1637 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1638 | time_t delta; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1639 | gchar *errmsg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1640 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1641 | session = (MsimSession *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1642 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1643 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1644 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1645 | delta = time(NULL) - session->last_comm; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1646 | purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1647 | if (delta >= MSIM_KEEPALIVE_INTERVAL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1648 | { |
|
18029
48e7b6d97f1f
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18028
diff
changeset
|
1649 | errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), (int)delta); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1650 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1651 | purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1652 | errmsg, MSIM_KEEPALIVE_INTERVAL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1653 | purple_connection_error(session->gc, errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1654 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1655 | purple_notify_error(session->gc, NULL, errmsg, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1656 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1657 | g_free(errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1658 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1659 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1660 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1661 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1662 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1663 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1664 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1665 | /** Called when the session key arrives. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1666 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1667 | msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1668 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1669 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1670 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1671 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1672 | purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1673 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1674 | session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1675 | purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1676 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1677 | /* Comes with: proof,profileid,userid,uniquenick -- all same values |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1678 | * some of the time, but can vary. This is our own user ID. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1679 | session->userid = msim_msg_get_integer(msg, "userid"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1680 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1681 | purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1682 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1683 | /* We now know are our own username, only after we're logged in.. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1684 | * which is weird, but happens because you login with your email |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1685 | * address and not username. Will be freed in msim_session_destroy(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1686 | session->username = msim_msg_get_string(msg, "uniquenick"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1687 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1688 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1689 | purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\n"); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1690 | /* Notify servers of our current status. */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1691 | msim_set_status(session->account, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1692 | purple_account_get_active_status(session->account)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1693 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1694 | purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, msim_check_alive, session); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1695 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1696 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1697 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1698 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1699 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1700 | * Process a message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1701 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1702 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1703 | * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1704 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1705 | * @return TRUE if successful. FALSE if processing failed. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1706 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1707 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1708 | msim_process(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1709 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1710 | g_return_val_if_fail(session != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1711 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1712 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1713 | #ifdef MSIM_DEBUG_MSG |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1714 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1715 | msim_msg_dump("ready to process: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1716 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1717 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1718 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1719 | if (msim_msg_get(msg, "nc")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1720 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1721 | return msim_login_challenge(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1722 | } else if (msim_msg_get(msg, "sesskey")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1723 | return msim_we_are_logged_on(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1724 | } else if (msim_msg_get(msg, "bm")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1725 | guint bm; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1726 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1727 | bm = msim_msg_get_integer(msg, "bm"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1728 | switch (bm) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1729 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1730 | case MSIM_BM_STATUS: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1731 | return msim_status(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1732 | case MSIM_BM_INSTANT: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1733 | return msim_incoming_im(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1734 | case MSIM_BM_ACTION: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1735 | return msim_incoming_action(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1736 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1737 | /* Not really an IM, but show it for informational |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1738 | * purposes during development. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1739 | return msim_incoming_im(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1740 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1741 | } else if (msim_msg_get(msg, "rid")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1742 | return msim_process_reply(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1743 | } else if (msim_msg_get(msg, "error")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1744 | return msim_error(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1745 | } else if (msim_msg_get(msg, "ka")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1746 | /* TODO: Setup a timer, if keep-alive is not received within ~3 minutes, then |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1747 | * disconnect the user. As it stands, if Internet connection goes out (this |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1748 | * just happened here), msimprpl will appear to be connected forever, while |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1749 | * other plugins (oscar, etc.) will time out. Msimprpl should timeout too. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1750 | purple_debug_info("msim", "msim_process: got keep alive\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1751 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1752 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1753 | msim_unrecognized(session, msg, "in msim_process"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1754 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1755 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1756 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1757 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1758 | /** Store an field of information about a buddy. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1759 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1760 | msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1761 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1762 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1763 | gchar *key_str, *value_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1764 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1765 | buddy = (PurpleBuddy *)user_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1766 | key_str = (gchar *)key; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1767 | value_str = (gchar *)value; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1768 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1769 | if (strcmp(key_str, "UserID") == 0 || |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1770 | strcmp(key_str, "Age") == 0 || |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1771 | strcmp(key_str, "TotalFriends") == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1772 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1773 | /* Certain fields get set as integers, instead of strings, for |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1774 | * convenience. May not be the best way to do it, but having at least |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1775 | * UserID as an integer is convenient...until it overflows! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1776 | purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1777 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1778 | purple_blist_node_set_string(&buddy->node, key_str, value_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1779 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1780 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1781 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1782 | /** Save buddy information to the buddy list from a user info reply message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1783 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1784 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1785 | * @param msg The user information reply, with any amount of information. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1786 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1787 | * The information is saved to the buddy's blist node, which ends up in blist.xml. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1788 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1789 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1790 | msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1791 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1792 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1793 | gchar *username, *body_str, *uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1794 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1795 | guint rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1796 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1797 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1798 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1799 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1800 | rid = msim_msg_get_integer(msg, "rid"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1801 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1802 | g_return_val_if_fail(rid != 0, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1803 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1804 | body_str = msim_msg_get_string(msg, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1805 | g_return_val_if_fail(body_str != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1806 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1807 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1808 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1809 | /* TODO: implement a better hash-like interface, and use it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1810 | username = g_hash_table_lookup(body, "UserName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1811 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1812 | if (!username) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1813 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1814 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1815 | "msim_process_reply: not caching body, no UserName\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1816 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1817 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1818 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1819 | uid = g_hash_table_lookup(body, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1820 | g_return_val_if_fail(uid, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1821 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1822 | purple_debug_info("msim", "associating uid %d with username %s\n", uid, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1823 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1824 | buddy = purple_find_buddy(session->account, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1825 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1826 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1827 | g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1828 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1829 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1830 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1831 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1832 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1833 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1834 | * Process a persistance message reply from the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1835 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1836 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1837 | * @param msg Message reply from server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1838 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1839 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1840 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1841 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1842 | msim_process_reply(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1843 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1844 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1845 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1846 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1847 | if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1848 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1849 | MSIM_USER_LOOKUP_CB cb; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1850 | gpointer data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1851 | guint rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1852 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1853 | msim_store_buddy_info(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1854 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1855 | rid = msim_msg_get_integer(msg, "rid"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1856 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1857 | /* If a callback is registered for this userid lookup, call it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1858 | cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1859 | data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1860 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1861 | if (cb) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1862 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1863 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1864 | "msim_process_body: calling callback now\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1865 | /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1866 | cb(session, msim_msg_clone(msg), data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1867 | g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1868 | g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1869 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1870 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1871 | "msim_process_body: no callback for rid %d\n", rid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1872 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1873 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1874 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1875 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1876 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1877 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1878 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1879 | * Handle an error from the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1880 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1881 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1882 | * @param msg The message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1883 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1884 | * @return TRUE if successfully reported error. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1885 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1886 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1887 | msim_error(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1888 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1889 | gchar *errmsg, *full_errmsg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1890 | guint err; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1891 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1892 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1893 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1894 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1895 | err = msim_msg_get_integer(msg, "err"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1896 | errmsg = msim_msg_get_string(msg, "errmsg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1897 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1898 | full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1899 | errmsg ? errmsg : "no 'errmsg' given"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1900 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1901 | g_free(errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1902 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1903 | purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1904 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1905 | purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1906 | full_errmsg, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1907 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1908 | /* Destroy session if fatal. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1909 | if (msim_msg_get(msg, "fatal")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1910 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1911 | purple_debug_info("msim", "fatal error, closing\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1912 | purple_connection_error(session->gc, full_errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1913 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1914 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1915 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1916 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1917 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1918 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1919 | * Process incoming status messages. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1920 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1921 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1922 | * @param msg Status update message. Caller frees. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1923 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1924 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1925 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1926 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1927 | msim_status(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1928 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1929 | PurpleBuddyList *blist; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1930 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1931 | //PurpleStatus *status; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1932 | gchar **status_array; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1933 | GList *list; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1934 | gchar *status_headline; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1935 | gchar *status_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1936 | gint i, status_code, purple_status_code; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1937 | gchar *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1938 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1939 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1940 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1941 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1942 | status_str = msim_msg_get_string(msg, "msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1943 | g_return_val_if_fail(status_str != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1944 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1945 | msim_msg_dump("msim_status msg=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1946 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1947 | /* Helpfully looked up by msim_incoming_resolve() for us. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1948 | username = msim_msg_get_string(msg, "_username"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1949 | /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1950 | * the buddy list, if the UserID was stored along with it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1951 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1952 | if (username == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1953 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1954 | g_free(status_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1955 | g_return_val_if_fail(NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1956 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1957 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1958 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1959 | "msim_status: updating status for <%s> to <%s>\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1960 | username, status_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1961 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1962 | /* TODO: generic functions to split into a GList, part of MsimMessage */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1963 | status_array = g_strsplit(status_str, "|", 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1964 | for (list = NULL, i = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1965 | status_array[i]; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1966 | i++) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1967 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1968 | /* Note: this adds the 0th ordinal too, which might not be a value |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1969 | * at all (the 0 in the 0|1|2|3... status fields, but 0 always appears blank). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1970 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1971 | list = g_list_append(list, status_array[i]); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1972 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1973 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1974 | /* Example fields: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1975 | * |s|0|ss|Offline |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1976 | * |s|1|ss|:-)|ls||ip|0|p|0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1977 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1978 | * TODO: write list support in MsimMessage, and use it here. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1979 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1980 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1981 | status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1982 | purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1983 | status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1984 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1985 | blist = purple_get_blist(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1986 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1987 | /* Add buddy if not found */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1988 | buddy = purple_find_buddy(session->account, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1989 | if (!buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1990 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1991 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1992 | "msim_status: making new buddy for %s\n", username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1993 | buddy = purple_buddy_new(session->account, username, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1994 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1995 | purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1996 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1997 | /* All buddies on list should have 'uid' integer associated with them. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1998 | purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1999 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2000 | msim_store_buddy_info(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2001 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2002 | purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2003 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2004 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2005 | purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2006 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2007 | /* Set user status */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2008 | switch (status_code) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2009 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2010 | case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2011 | purple_status_code = PURPLE_STATUS_OFFLINE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2012 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2013 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2014 | case MSIM_STATUS_CODE_ONLINE: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2015 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2016 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2017 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2018 | case MSIM_STATUS_CODE_AWAY: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2019 | purple_status_code = PURPLE_STATUS_AWAY; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2020 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2021 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2022 | case MSIM_STATUS_CODE_IDLE: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2023 | /* will be handled below */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2024 | purple_status_code = -1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2025 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2026 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2027 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2028 | purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2029 | username, status_code); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2030 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2031 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2032 | |
|
18035
2c401f444456
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18034
diff
changeset
|
2033 | purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2034 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2035 | if (status_code == MSIM_STATUS_CODE_IDLE) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2036 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2037 | purple_debug_info("msim", "msim_status: got idle: %s\n", username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2038 | purple_prpl_got_user_idle(session->account, username, TRUE, time(NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2039 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2040 | /* All other statuses indicate going back to non-idle. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2041 | purple_prpl_got_user_idle(session->account, username, FALSE, time(NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2042 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2043 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2044 | g_strfreev(status_array); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2045 | g_free(status_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2046 | g_free(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2047 | g_list_free(list); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2048 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2049 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2050 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2051 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2052 | /** Add a buddy to user's buddy list. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2053 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2054 | msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2055 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2056 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2057 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2058 | /* MsimMessage *msg_blocklist; */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2059 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2060 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2061 | purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2062 | group ? group->name : "(no group)"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2063 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2064 | msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2065 | "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2066 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2067 | /* "newprofileid" will be inserted here with uid. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2068 | "reason", MSIM_TYPE_STRING, g_strdup(""), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2069 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2070 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2071 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2072 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2073 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2074 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2075 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2076 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2077 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2078 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2079 | /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2080 | * buddy list since Purple adds it locally. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2081 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2082 | /* TODO: Update blocklist. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2083 | #if 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2084 | msg_blocklist = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2085 | "persist", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2086 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2087 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2088 | "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2089 | "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2090 | /* TODO: Use msim_new_reply_callback to get rid. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2091 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2092 | "body", MSIM_TYPE_STRING, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2093 | g_strdup_printf("ContactID=<uid>\034" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2094 | "GroupName=%s\034" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2095 | "Position=1000\034" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2096 | "Visibility=1\034" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2097 | "NickName=\034" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2098 | "NameSelect=0", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2099 | "Friends" /*group->name*/ )); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2100 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2101 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2102 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2103 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2104 | msim_msg_free(msg_blocklist); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2105 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2106 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2107 | msim_msg_free(msg_blocklist); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2108 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2109 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2110 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2111 | /** Perform actual postprocessing on a message, adding userid as specified. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2112 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2113 | * @param msg The message to postprocess. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2114 | * @param uid_before Name of field where to insert new field before, or NULL for end. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2115 | * @param uid_field_name Name of field to add uid to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2116 | * @param uid The userid to insert. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2117 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2118 | * If the field named by uid_field_name already exists, then its string contents will |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2119 | * be used for the field, except "<uid>" will be replaced by the userid. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2120 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2121 | * If the field named by uid_field_name does not exist, it will be added before the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2122 | * field named by uid_before, as an integer, with the userid. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2123 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2124 | * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2125 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2126 | MsimMessage * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2127 | msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2128 | const gchar *uid_field_name, guint uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2129 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2130 | purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2131 | uid_field_name, uid_before, uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2132 | msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2133 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2134 | /* First, check - if the field already exists, treat it as a format string. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2135 | if (msim_msg_get(msg, uid_field_name)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2136 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2137 | MsimMessageElement *elem; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2138 | gchar *fmt_string; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2139 | gchar *uid_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2140 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2141 | /* Warning: this probably violates the encapsulation of MsimMessage */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2142 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2143 | elem = msim_msg_get(msg, uid_field_name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2144 | g_return_val_if_fail(elem->type == MSIM_TYPE_STRING, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2145 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2146 | /* Get the raw string, not with msim_msg_get_string() since that copies it. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2147 | * Want the original string so can free it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2148 | fmt_string = (gchar *)(elem->data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2149 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2150 | uid_str = g_strdup_printf("%d", uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2151 | elem->data = str_replace(fmt_string, "<uid>", uid_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2152 | g_free(uid_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2153 | g_free(fmt_string); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2154 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2155 | purple_debug_info("msim", "msim_postprocess_outgoing_cb: formatted new string, %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2156 | elem->data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2157 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2158 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2159 | /* Otherwise, insert new field into outgoing message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2160 | msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2161 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2162 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2163 | return msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2164 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2165 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2166 | /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2167 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2168 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2169 | * @param userinfo The user information reply message, containing the user ID |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2170 | * @param data The message to postprocess and send. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2171 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2172 | * The data message should contain these fields: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2173 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2174 | * _uid_field_name: string, name of field to add with userid from userinfo message |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2175 | * _uid_before: string, name of field before field to insert, or NULL for end |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2176 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2177 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2178 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2179 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2180 | msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2181 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2182 | gchar *body_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2183 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2184 | gchar *uid, *uid_field_name, *uid_before; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2185 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2186 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2187 | msg = (MsimMessage *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2188 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2189 | msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2190 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2191 | /* Obtain userid from userinfo message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2192 | body_str = msim_msg_get_string(userinfo, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2193 | g_return_if_fail(body_str != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2194 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2195 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2196 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2197 | uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2198 | g_hash_table_destroy(body); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2199 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2200 | uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2201 | uid_before = msim_msg_get_string(msg, "_uid_before"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2202 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2203 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2204 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2205 | /* Send */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2206 | if (!msim_msg_send(session, msg)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2207 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2208 | purple_debug_info("msim", "msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2209 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2210 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2211 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2212 | /* Free field names AFTER sending message, because MsimMessage does NOT copy |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2213 | * field names - instead, treats them as static strings (which they usually are). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2214 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2215 | g_free(uid_field_name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2216 | g_free(uid_before); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2217 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2218 | //msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2219 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2220 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2221 | /** Postprocess and send a message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2222 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2223 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2224 | * @param msg Message to postprocess. Will NOT be freed. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2225 | * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2226 | * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2227 | * @param uid_before Name of existing field to insert username field before. Static string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2228 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2229 | * @return Postprocessed message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2230 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2231 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2232 | msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2233 | const gchar *username, const gchar *uid_field_name, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2234 | const gchar *uid_before) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2235 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2236 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2237 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2238 | gboolean rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2239 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2240 | /* Store information for msim_postprocess_outgoing_cb(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2241 | purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2242 | username, uid_field_name, uid_before); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2243 | msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2244 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2245 | msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2246 | msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2247 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2248 | /* First, try the most obvious. If numeric userid is given, use that directly. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2249 | if (msim_is_userid(username)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2250 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2251 | uid = atol(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2252 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2253 | /* Next, see if on buddy list and know uid. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2254 | buddy = purple_find_buddy(session->account, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2255 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2256 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2257 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2258 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2259 | uid = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2260 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2261 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2262 | if (!buddy || !uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2263 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2264 | /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2265 | purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2266 | username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2267 | msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2268 | /* TODO: where is cloned message freed? Should be in _cb. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2269 | msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2270 | return TRUE; /* not sure of status yet - haven't sent! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2271 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2272 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2273 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2274 | /* Already have uid, postprocess and send msg immediately. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2275 | purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2276 | username, uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2277 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2278 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2279 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2280 | msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2281 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2282 | rc = msim_msg_send(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2283 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2284 | //msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2285 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2286 | return rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2287 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2288 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2289 | /** Remove a buddy from the user's buddy list. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2290 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2291 | msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2292 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2293 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2294 | MsimMessage *delbuddy_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2295 | MsimMessage *persist_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2296 | MsimMessage *blocklist_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2297 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2298 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2299 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2300 | delbuddy_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2301 | "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2302 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2303 | /* 'delprofileid' with uid will be inserted here. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2304 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2305 | /* TODO: free msg */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2306 | if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2307 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2308 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2309 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2310 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2311 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2312 | persist_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2313 | "persist", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2314 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2315 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2316 | "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2317 | "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2318 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2319 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2320 | /* <uid> will be replaced by postprocessing */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2321 | "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2322 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2323 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2324 | /* TODO: free msg */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2325 | if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2326 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2327 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2328 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2329 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2330 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2331 | blocklist_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2332 | "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2333 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2334 | /* TODO: MsimMessage lists */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2335 | "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2336 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2337 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2338 | if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2339 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2340 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2341 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2342 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2343 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2344 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2345 | /** Return whether the buddy can be messaged while offline. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2346 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2347 | * The protocol supports offline messages in just the same way as online |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2348 | * messages. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2349 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2350 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2351 | msim_offline_message(const PurpleBuddy *buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2352 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2353 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2354 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2355 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2356 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2357 | * Callback when input available. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2358 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2359 | * @param gc_uncasted A PurpleConnection pointer. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2360 | * @param source File descriptor. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2361 | * @param cond PURPLE_INPUT_READ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2362 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2363 | * Reads the input, and calls msim_preprocess_incoming() to handle it. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2364 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2365 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2366 | msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2367 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2368 | PurpleConnection *gc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2369 | PurpleAccount *account; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2370 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2371 | gchar *end; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2372 | int n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2373 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2374 | g_return_if_fail(gc_uncasted != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2375 | g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2376 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2377 | gc = (PurpleConnection *)(gc_uncasted); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2378 | account = purple_connection_get_account(gc); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2379 | session = gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2380 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2381 | g_return_if_fail(cond == PURPLE_INPUT_READ); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2382 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2383 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2384 | /* Mark down that we got data, so don't timeout. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2385 | session->last_comm = time(NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2386 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2387 | /* Only can handle so much data at once... |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2388 | * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2389 | * Should be large enough to hold the largest protocol message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2390 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2391 | if (session->rxoff == MSIM_READ_BUF_SIZE) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2392 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2393 | purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2394 | MSIM_READ_BUF_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2395 | purple_connection_error(gc, _("Read buffer full")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2396 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2397 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2398 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2399 | purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2400 | session->rxoff, MSIM_READ_BUF_SIZE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2401 | MSIM_READ_BUF_SIZE - session->rxoff); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2402 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2403 | /* Read into buffer. On Win32, need recv() not read(). session->fd also holds |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2404 | * the file descriptor, but it sometimes differs from the 'source' parameter. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2405 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2406 | n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2407 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2408 | if (n < 0 && errno == EAGAIN) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2409 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2410 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2411 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2412 | else if (n < 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2413 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2414 | purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2415 | "error=%s, source=%d, fd=%d (%X))\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2416 | n, strerror(errno), source, session->fd, session->fd); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2417 | purple_connection_error(gc, _("Read error")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2418 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2419 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2420 | else if (n == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2421 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2422 | purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2423 | purple_connection_error(gc, _("Server has disconnected")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2424 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2425 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2426 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2427 | /* Null terminate */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2428 | session->rxbuf[session->rxoff + n] = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2429 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2430 | #ifdef MSIM_CHECK_EMBEDDED_NULLS |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2431 | /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2432 | if (strlen(session->rxbuf + session->rxoff) != n) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2433 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2434 | /* Occurs after login, but it is not a null byte. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2435 | purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2436 | "--null byte encountered?\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2437 | strlen(session->rxbuf + session->rxoff), n); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2438 | //purple_connection_error(gc, "Invalid message - null byte on input"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2439 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2440 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2441 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2442 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2443 | session->rxoff += n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2444 | purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2445 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2446 | #ifdef MSIM_DEBUG_RXBUF |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2447 | purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2448 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2449 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2450 | /* Look for \\final\\ end markers. If found, process message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2451 | while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2452 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2453 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2454 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2455 | #ifdef MSIM_DEBUG_RXBUF |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2456 | purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2457 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2458 | *end = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2459 | msg = msim_parse(g_strdup(session->rxbuf)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2460 | if (!msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2461 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2462 | purple_debug_info("msim", "msim_input_cb: couldn't parse <%s>\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2463 | session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2464 | purple_connection_error(gc, _("Unparseable message")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2465 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2466 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2467 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2468 | /* Process message and then free it (processing function should |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2469 | * clone message if it wants to keep it afterwards.) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2470 | if (!msim_preprocess_incoming(session, msg)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2471 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2472 | msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2473 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2474 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2475 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2476 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2477 | /* Move remaining part of buffer to beginning. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2478 | session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2479 | memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2480 | MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2481 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2482 | /* Clear end of buffer */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2483 | //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2484 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2485 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2486 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2487 | /* Setup a callback, to be called when a reply is received with the returned rid. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2488 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2489 | * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2490 | * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2491 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2492 | * @return The request/reply ID, used to link replies with requests. Put the rid in your request. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2493 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2494 | * TODO: Make more generic and more specific: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2495 | * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2496 | * 2) data - make it an MsimMessage? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2497 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2498 | guint |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2499 | msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2500 | gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2501 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2502 | guint rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2503 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2504 | rid = session->next_rid++; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2505 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2506 | g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2507 | g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2508 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2509 | return rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2510 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2511 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2512 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2513 | * Callback when connected. Sets up input handlers. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2514 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2515 | * @param data A PurpleConnection pointer. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2516 | * @param source File descriptor. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2517 | * @param error_message |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2518 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2519 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2520 | msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2521 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2522 | PurpleConnection *gc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2523 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2524 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2525 | g_return_if_fail(data != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2526 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2527 | gc = (PurpleConnection *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2528 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2529 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2530 | if (source < 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2531 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2532 | purple_connection_error(gc, _("Couldn't connect to host")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2533 | purple_connection_error(gc, g_strdup_printf( |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2534 | _("Couldn't connect to host: %s (%d)"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2535 | error_message ? error_message : "no message given", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2536 | source)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2537 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2538 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2539 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2540 | session->fd = source; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2541 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2542 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2543 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2544 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2545 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2546 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2547 | /* Session methods */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2548 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2549 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2550 | * Create a new MSIM session. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2551 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2552 | * @param acct The account to create the session from. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2553 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2554 | * @return Pointer to a new session. Free with msim_session_destroy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2555 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2556 | MsimSession * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2557 | msim_session_new(PurpleAccount *acct) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2558 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2559 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2560 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2561 | g_return_val_if_fail(acct != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2562 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2563 | session = g_new0(MsimSession, 1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2564 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2565 | session->magic = MSIM_SESSION_STRUCT_MAGIC; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2566 | session->account = acct; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2567 | session->gc = purple_account_get_connection(acct); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2568 | session->sesskey = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2569 | session->userid = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2570 | session->username = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2571 | session->fd = -1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2572 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2573 | /* TODO: Remove. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2574 | session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2575 | g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2576 | session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2577 | g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2578 | they could be integers inside gpointers |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2579 | or strings, so I don't freed them. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2580 | Figure this out, once free cache. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2581 | session->rxoff = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2582 | session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2583 | session->next_rid = 1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2584 | session->last_comm = time(NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2585 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2586 | return session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2587 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2588 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2589 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2590 | * Free a session. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2591 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2592 | * @param session The session to destroy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2593 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2594 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2595 | msim_session_destroy(MsimSession *session) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2596 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2597 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2598 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2599 | session->magic = -1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2600 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2601 | g_free(session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2602 | g_free(session->username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2603 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2604 | /* TODO: Remove. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2605 | g_hash_table_destroy(session->user_lookup_cb); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2606 | g_hash_table_destroy(session->user_lookup_cb_data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2607 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2608 | g_free(session); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2609 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2610 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2611 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2612 | * Close the connection. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2613 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2614 | * @param gc The connection. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2615 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2616 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2617 | msim_close(PurpleConnection *gc) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2618 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2619 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2620 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2621 | if (gc == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2622 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2623 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2624 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2625 | if (session == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2626 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2627 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2628 | gc->proto_data = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2629 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2630 | if (!MSIM_SESSION_VALID(session)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2631 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2632 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2633 | if (session->gc->inpa) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2634 | purple_input_remove(session->gc->inpa); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2635 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2636 | msim_session_destroy(session); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2637 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2638 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2639 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2640 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2641 | * Check if a string is a userid (all numeric). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2642 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2643 | * @param user The user id, email, or name. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2644 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2645 | * @return TRUE if is userid, FALSE if not. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2646 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2647 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2648 | msim_is_userid(const gchar *user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2649 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2650 | g_return_val_if_fail(user != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2651 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2652 | return strspn(user, "0123456789") == strlen(user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2653 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2654 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2655 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2656 | * Check if a string is an email address (contains an @). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2657 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2658 | * @param user The user id, email, or name. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2659 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2660 | * @return TRUE if is an email, FALSE if not. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2661 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2662 | * This function is not intended to be used as a generic |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2663 | * means of validating email addresses, but to distinguish |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2664 | * between a user represented by an email address from |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2665 | * other forms of identification. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2666 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2667 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2668 | msim_is_email(const gchar *user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2669 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2670 | g_return_val_if_fail(user != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2671 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2672 | return strchr(user, '@') != NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2673 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2674 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2675 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2676 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2677 | * Asynchronously lookup user information, calling callback when receive result. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2678 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2679 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2680 | * @param user The user id, email address, or username. Not freed. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2681 | * @param cb Callback, called with user information when available. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2682 | * @param data An arbitray data pointer passed to the callback. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2683 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2684 | /* TODO: change to not use callbacks */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2685 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2686 | msim_lookup_user(MsimSession *session, const gchar *user, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2687 | MSIM_USER_LOOKUP_CB cb, gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2688 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2689 | gchar *field_name; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2690 | guint rid, cmd, dsn, lid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2691 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2692 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2693 | g_return_if_fail(user != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2694 | g_return_if_fail(cb != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2695 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2696 | purple_debug_info("msim", "msim_lookup_userid: " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2697 | "asynchronously looking up <%s>\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2698 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2699 | msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2700 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2701 | /* Setup callback. Response will be associated with request using 'rid'. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2702 | rid = msim_new_reply_callback(session, cb, data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2703 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2704 | /* Send request */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2705 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2706 | cmd = MSIM_CMD_GET; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2707 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2708 | if (msim_is_userid(user)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2709 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2710 | field_name = "UserID"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2711 | dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2712 | lid = MG_MYSPACE_INFO_BY_ID_LID; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2713 | } else if (msim_is_email(user)) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2714 | field_name = "Email"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2715 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2716 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2717 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2718 | field_name = "UserName"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2719 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2720 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2721 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2722 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2723 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2724 | g_return_if_fail(msim_send(session, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2725 | "persist", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2726 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2727 | "cmd", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2728 | "dsn", MSIM_TYPE_INTEGER, dsn, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2729 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2730 | "lid", MSIM_TYPE_INTEGER, lid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2731 | "rid", MSIM_TYPE_INTEGER, rid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2732 | /* TODO: dictionary field type */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2733 | "body", MSIM_TYPE_STRING, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2734 | g_strdup_printf("%s=%s", field_name, user), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2735 | NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2736 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2737 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2738 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2739 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2740 | * Obtain the status text for a buddy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2741 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2742 | * @param buddy The buddy to obtain status text for. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2743 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2744 | * @return Status text, or NULL if error. Caller g_free()'s. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2745 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2746 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2747 | char * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2748 | msim_status_text(PurpleBuddy *buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2749 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2750 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2751 | const gchar *display_name, *headline; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2752 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2753 | g_return_val_if_fail(buddy != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2754 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2755 | session = (MsimSession *)buddy->account->gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2756 | g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2757 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2758 | display_name = headline = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2759 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2760 | /* Retrieve display name and/or headline, depending on user preference. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2761 | if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2762 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2763 | display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2764 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2765 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2766 | if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2767 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2768 | headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2769 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2770 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2771 | /* Return appropriate combination of display name and/or headline, or neither. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2772 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2773 | if (display_name && headline) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2774 | return g_strconcat(display_name, " ", headline, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2775 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2776 | if (display_name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2777 | return g_strdup(display_name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2778 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2779 | if (headline) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2780 | return g_strdup(headline); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2781 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2782 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2783 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2784 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2785 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2786 | * Obtain the tooltip text for a buddy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2787 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2788 | * @param buddy Buddy to obtain tooltip text on. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2789 | * @param user_info Variable modified to have the tooltip text. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2790 | * @param full TRUE if should obtain full tooltip text. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2791 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2792 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2793 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2794 | msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2795 | gboolean full) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2796 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2797 | const gchar *str, *str2; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2798 | gint n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2799 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2800 | g_return_if_fail(buddy != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2801 | g_return_if_fail(user_info != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2802 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2803 | if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2804 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2805 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2806 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2807 | session = (MsimSession *)buddy->account->gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2808 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2809 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2810 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2811 | /* TODO: if (full), do something different */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2812 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2813 | /* Useful to identify the account the tooltip refers to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2814 | * Other prpls show this. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2815 | str = purple_blist_node_get_string(&buddy->node, "UserName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2816 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2817 | purple_notify_user_info_add_pair(user_info, _("User Name"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2818 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2819 | /* a/s/l...the vitals */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2820 | n = purple_blist_node_get_int(&buddy->node, "Age"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2821 | if (n) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2822 | purple_notify_user_info_add_pair(user_info, _("Age"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2823 | g_strdup_printf("%d", n)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2824 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2825 | str = purple_blist_node_get_string(&buddy->node, "Gender"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2826 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2827 | purple_notify_user_info_add_pair(user_info, _("Gender"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2828 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2829 | str = purple_blist_node_get_string(&buddy->node, "Location"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2830 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2831 | purple_notify_user_info_add_pair(user_info, _("Location"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2832 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2833 | /* Other information */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2834 | str = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2835 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2836 | purple_notify_user_info_add_pair(user_info, _("Headline"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2837 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2838 | str = purple_blist_node_get_string(&buddy->node, "BandName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2839 | str2 = purple_blist_node_get_string(&buddy->node, "SongName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2840 | if (str || str2) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2841 | purple_notify_user_info_add_pair(user_info, _("Song"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2842 | g_strdup_printf("%s - %s", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2843 | str ? str : _("Unknown Artist"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2844 | str2 ? str2 : _("Unknown Song"))); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2845 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2846 | n = purple_blist_node_get_int(&buddy->node, "TotalFriends"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2847 | if (n) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2848 | purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2849 | g_strdup_printf("%d", n)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2850 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2851 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2852 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2853 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2854 | /** Callbacks called by Purple, to access this plugin. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2855 | PurplePluginProtocolInfo prpl_info = |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2856 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2857 | /* options */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2858 | OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2859 | /* | OPT_PROTO_MAIL_CHECK - TODO: myspace will notify of mail */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2860 | /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2861 | , |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2862 | NULL, /* user_splits */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2863 | NULL, /* protocol_options */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2864 | NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2865 | msim_list_icon, /* list_icon */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2866 | NULL, /* list_emblems */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2867 | msim_status_text, /* status_text */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2868 | msim_tooltip_text, /* tooltip_text */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2869 | msim_status_types, /* status_types */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2870 | NULL, /* blist_node_menu */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2871 | NULL, /* chat_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2872 | NULL, /* chat_info_defaults */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2873 | msim_login, /* login */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2874 | msim_close, /* close */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2875 | msim_send_im, /* send_im */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2876 | NULL, /* set_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2877 | msim_send_typing, /* send_typing */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2878 | msim_get_info, /* get_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2879 | msim_set_status, /* set_status */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2880 | msim_set_idle, /* set_idle */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2881 | NULL, /* change_passwd */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2882 | msim_add_buddy, /* add_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2883 | NULL, /* add_buddies */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2884 | msim_remove_buddy, /* remove_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2885 | NULL, /* remove_buddies */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2886 | NULL, /* add_permit */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2887 | NULL, /* add_deny */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2888 | NULL, /* rem_permit */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2889 | NULL, /* rem_deny */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2890 | NULL, /* set_permit_deny */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2891 | NULL, /* join_chat */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2892 | NULL, /* reject chat invite */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2893 | NULL, /* get_chat_name */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2894 | NULL, /* chat_invite */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2895 | NULL, /* chat_leave */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2896 | NULL, /* chat_whisper */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2897 | NULL, /* chat_send */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2898 | NULL, /* keepalive */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2899 | NULL, /* register_user */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2900 | NULL, /* get_cb_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2901 | NULL, /* get_cb_away */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2902 | NULL, /* alias_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2903 | NULL, /* group_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2904 | NULL, /* rename_group */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2905 | NULL, /* buddy_free */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2906 | NULL, /* convo_closed */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2907 | NULL, /* normalize */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2908 | NULL, /* set_buddy_icon */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2909 | NULL, /* remove_group */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2910 | NULL, /* get_cb_real_name */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2911 | NULL, /* set_chat_topic */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2912 | NULL, /* find_blist_chat */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2913 | NULL, /* roomlist_get_list */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2914 | NULL, /* roomlist_cancel */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2915 | NULL, /* roomlist_expand_category */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2916 | NULL, /* can_receive_file */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2917 | NULL, /* send_file */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2918 | NULL, /* new_xfer */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2919 | msim_offline_message, /* offline_message */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2920 | NULL, /* whiteboard_prpl_ops */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2921 | msim_send_really_raw, /* send_raw */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2922 | NULL, /* roomlist_room_serialize */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2923 | NULL, /* _purple_reserved1 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2924 | NULL, /* _purple_reserved2 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2925 | NULL, /* _purple_reserved3 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2926 | NULL /* _purple_reserved4 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2927 | }; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2928 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2929 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2930 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2931 | /** Based on MSN's plugin info comments. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2932 | PurplePluginInfo info = |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2933 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2934 | PURPLE_PLUGIN_MAGIC, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2935 | PURPLE_MAJOR_VERSION, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2936 | PURPLE_MINOR_VERSION, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2937 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2938 | NULL, /**< ui_requirement */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2939 | 0, /**< flags */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2940 | NULL, /**< dependencies */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2941 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2942 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2943 | "prpl-myspace", /**< id */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2944 | "MySpaceIM", /**< name */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2945 | "0.10", /**< version */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2946 | /** summary */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2947 | "MySpaceIM Protocol Plugin", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2948 | /** description */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2949 | "MySpaceIM Protocol Plugin", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2950 | "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2951 | "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2952 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2953 | msim_load, /**< load */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2954 | NULL, /**< unload */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2955 | NULL, /**< destroy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2956 | NULL, /**< ui_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2957 | &prpl_info, /**< extra_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2958 | NULL, /**< prefs_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2959 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2960 | /* msim_actions */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2961 | NULL, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2962 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2963 | NULL, /**< reserved1 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2964 | NULL, /**< reserved2 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2965 | NULL, /**< reserved3 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2966 | NULL /**< reserved4 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2967 | }; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2968 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2969 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2970 | #ifdef MSIM_SELF_TEST |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2971 | /** Test functions. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2972 | * Used to test or try out the internal workings of msimprpl. If you're reading |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2973 | * this code for the first time, these functions can be instructive in how |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2974 | * msimprpl is architected. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2975 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2976 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2977 | msim_test_all(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2978 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2979 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2980 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2981 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2982 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2983 | failures += msim_test_xml(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2984 | failures += msim_test_msg(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2985 | failures += msim_test_escaping(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2986 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2987 | if (failures) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2988 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2989 | purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2990 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2991 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2992 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2993 | purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2994 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2995 | exit(0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2996 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2997 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2998 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2999 | msim_test_xml(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3000 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3001 | gchar *msg_text; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3002 | xmlnode *root, *n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3003 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3004 | char *s; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3005 | int len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3006 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3007 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3008 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3009 | msg_text = "<p><f n=\"Arial\" h=\"12\">woo!</f>xxx<c v='black'>yyy</c></p>"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3010 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3011 | purple_debug_info("msim", "msim_test_xml: msg_text=%s\n", msg_text); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3012 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3013 | root = xmlnode_from_str(msg_text, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3014 | if (!root) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3015 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3016 | purple_debug_info("msim", "there is no root\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3017 | exit(0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3018 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3019 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3020 | purple_debug_info("msim", "root name=%s, child name=%s\n", root->name, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3021 | root->child->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3022 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3023 | purple_debug_info("msim", "last child name=%s\n", root->lastchild->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3024 | purple_debug_info("msim", "Root xml=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3025 | xmlnode_to_str(root, &len)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3026 | purple_debug_info("msim", "Child xml=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3027 | xmlnode_to_str(root->child, &len)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3028 | purple_debug_info("msim", "Lastchild xml=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3029 | xmlnode_to_str(root->lastchild, &len)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3030 | purple_debug_info("msim", "Next xml=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3031 | xmlnode_to_str(root->next, &len)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3032 | purple_debug_info("msim", "Next data=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3033 | xmlnode_get_data(root->next)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3034 | purple_debug_info("msim", "Child->next xml=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3035 | xmlnode_to_str(root->child->next, &len)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3036 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3037 | for (n = root->child; n; n = n->next) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3038 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3039 | if (n->name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3040 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3041 | purple_debug_info("msim", " ** n=%s\n",n->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3042 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3043 | purple_debug_info("msim", " ** n data=%s\n", n->data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3044 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3045 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3046 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3047 | purple_debug_info("msim", "root data=%s, child data=%s, child 'h'=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3048 | xmlnode_get_data(root), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3049 | xmlnode_get_data(root->child), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3050 | xmlnode_get_attrib(root->child, "h")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3051 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3052 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3053 | for (n = root->child; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3054 | n != NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3055 | n = n->next) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3056 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3057 | purple_debug_info("msim", "next name=%s\n", n->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3058 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3059 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3060 | s = xmlnode_to_str(root, &len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3061 | s[len] = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3062 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3063 | purple_debug_info("msim", "str: %s\n", s); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3064 | g_free(s); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3065 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3066 | xmlnode_free(root); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3067 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3068 | exit(0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3069 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3070 | return failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3071 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3072 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3073 | /** Test MsimMessage for basic functionality. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3074 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3075 | msim_test_msg(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3076 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3077 | MsimMessage *msg, *msg_cloned; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3078 | gchar *packed, *packed_expected, *packed_cloned; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3079 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3080 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3081 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3082 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3083 | purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3084 | msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3085 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3086 | /* Append some new elements. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3087 | msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3088 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3089 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3090 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3091 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3092 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3093 | msim_msg_dump("msg debug str=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3094 | packed = msim_msg_pack(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3095 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3096 | purple_debug_info("msim", "msg packed=%s\n", packed); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3097 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3098 | packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3099 | "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3100 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3101 | if (0 != strcmp(packed, packed_expected)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3102 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3103 | purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3104 | ++failures, packed, packed_expected); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3105 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3106 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3107 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3108 | msg_cloned = msim_msg_clone(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3109 | packed_cloned = msim_msg_pack(msg_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3110 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3111 | purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3112 | if (0 != strcmp(packed, packed_cloned)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3113 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3114 | purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3115 | ++failures, packed_cloned, packed); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3116 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3117 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3118 | g_free(packed); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3119 | g_free(packed_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3120 | msim_msg_free(msg_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3121 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3122 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3123 | return failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3124 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3125 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3126 | /** Test protocol-level escaping/unescaping. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3127 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3128 | msim_test_escaping(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3129 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3130 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3131 | gchar *raw, *escaped, *unescaped, *expected; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3132 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3133 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3134 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3135 | purple_debug_info("msim", "\n\nTesting escaping\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3136 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3137 | raw = "hello/world\\hello/world"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3138 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3139 | escaped = msim_escape(raw); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3140 | purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3141 | expected = "hello/1world/2hello/1world"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3142 | if (0 != strcmp(escaped, expected)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3143 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3144 | purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3145 | ++failures, escaped, expected); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3146 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3147 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3148 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3149 | unescaped = msim_unescape(escaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3150 | g_free(escaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3151 | purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3152 | if (0 != strcmp(raw, unescaped)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3153 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3154 | purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3155 | ++failures, raw, unescaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3156 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3157 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3158 | return failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3159 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3160 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3161 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3162 | /** Initialize plugin. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3163 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3164 | init_plugin(PurplePlugin *plugin) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3165 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3166 | PurpleAccountOption *option; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3167 | #ifdef MSIM_SELF_TEST |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3168 | msim_test_all(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3169 | #endif /* MSIM_SELF_TEST */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3170 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3171 | /* TODO: default to automatically try different ports. Make the user be |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3172 | * able to set the first port to try (like LastConnectedPort in Windows client). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3173 | option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3174 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3175 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3176 | option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3177 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3178 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3179 | option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3180 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3181 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3182 | option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3183 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3184 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3185 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3186 | PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |