Mercurial > pidgin
annotate libpurple/protocols/myspace/myspace.c @ 17951:c0758f8dff33
Update for 0.12.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Mon, 16 Jul 2007 00:05:48 +0000 |
parents | 2bf10f37fa37 |
children | 4001661344e4 |
rev | line source |
---|---|
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1 /* MySpaceIM Protocol Plugin |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3 * \author Jeff Connelly |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
4 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
6 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
7 * Based on Purple's "C Plugin HOWTO" hello world example. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
8 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
9 * Code also drawn from mockprpl: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
10 * http://snarfed.org/space/purple+mock+protocol+plugin |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
11 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
12 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
13 * and some constructs also based on existing Purple plugins, which are: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
14 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
15 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
16 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
17 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
18 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
19 * This program is free software; you can redistribute it and/or modify |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
20 * it under the terms of the GNU General Public License as published by |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
21 * the Free Software Foundation; either version 2 of the License, or |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
22 * (at your option) any later version. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
23 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
27 * GNU General Public License for more details. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
28 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
30 * along with this program; if not, write to the Free Software |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
32 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
33 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
34 #define PURPLE_PLUGIN |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
35 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
36 #include "message.h" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
37 #include "persist.h" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
38 #include "myspace.h" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
39 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
40 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
41 * Load the plugin. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
42 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
43 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
44 msim_load(PurplePlugin *plugin) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
45 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
46 /* If compiled to use RC4 from libpurple, check if it is really there. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
47 if (!purple_ciphers_find_cipher("rc4")) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
48 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
49 purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
50 purple_notify_error(plugin, _("Missing Cipher"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
51 _("The RC4 cipher could not be found"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
52 _("Upgrade " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
53 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
54 "plugin will not be loaded.")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
55 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
56 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
57 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
58 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
59 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
60 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
61 * Get possible user status types. Based on mockprpl. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
62 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
63 * @return GList of status types. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
64 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
65 GList * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
66 msim_status_types(PurpleAccount *acct) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
67 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
68 GList *types; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
69 PurpleStatusType *status; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
70 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
71 purple_debug_info("myspace", "returning status types\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
72 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
73 types = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
74 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
75 /* Statuses are almost all the same. Define a macro to reduce code repetition. */ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
76 #define _MSIM_ADD_NEW_STATUS(prim) status = \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
77 purple_status_type_new_with_attrs( \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
78 prim, /* PurpleStatusPrimitive */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
79 NULL, /* id - use default */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
80 NULL, /* name - use default */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
81 TRUE, /* savable */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
82 TRUE, /* user_settable */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
83 FALSE, /* not independent */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
84 \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
85 /* Attributes - each status can have a message. */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
86 "message", \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
87 _("Message"), \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
88 purple_value_new(PURPLE_TYPE_STRING), \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
89 NULL); \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
90 \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
91 \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
92 types = g_list_append(types, status) |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
93 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
94 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
95 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AVAILABLE); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
96 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AWAY); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
97 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_OFFLINE); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
98 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_INVISIBLE); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
99 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
100 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
101 return types; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
102 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
103 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
104 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
105 * Return the icon name for a buddy and account. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
106 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
107 * @param acct The account to find the icon for, or NULL for protocol icon. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
108 * @param buddy The buddy to find the icon for, or NULL for the account icon. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
109 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
110 * @return The base icon name string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
111 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
112 const gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
113 msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
114 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
115 /* Use a MySpace icon submitted by hbons at |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
116 * http://developer.pidgin.im/wiki/MySpaceIM. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
117 return "myspace"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
118 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
119 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
120 /* Replacement codes to be replaced with associated replacement text, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
121 * used for protocol message escaping / unescaping. */ |
17942
949fddc9d82f
Add /3 -> | escape code (found by sje397, documented in [wiki:MsimProtocolSpec]).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17941
diff
changeset
|
122 static gchar* msim_replacement_code[] = { "/1", "/2", "/3", NULL }; |
949fddc9d82f
Add /3 -> | escape code (found by sje397, documented in [wiki:MsimProtocolSpec]).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17941
diff
changeset
|
123 static gchar* msim_replacement_text[] = { "/", "\\", "|", NULL }; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
124 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
125 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
126 * Unescape or escape a protocol message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
127 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
128 * @param msg The message to be unescaped or escaped. WILL BE FREED. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
129 * @param escape TRUE to escape, FALSE to unescape. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
130 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
131 * @return The unescaped or escaped message. Caller must g_free(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
132 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
133 gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
134 msim_unescape_or_escape(gchar *msg, gboolean escape) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
135 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
136 gchar *tmp, *code, *text; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
137 guint i; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
138 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
139 /* Replace each code in msim_replacement_code with |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
140 * corresponding entry in msim_replacement_text. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
141 for (i = 0; (code = msim_replacement_code[i]) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
142 && (text = msim_replacement_text[i]); ++i) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
143 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
144 if (escape) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
145 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
146 tmp = str_replace(msg, text, code); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
147 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
148 else |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
149 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
150 tmp = str_replace(msg, code, text); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
151 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
152 g_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
153 msg = tmp; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
154 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
155 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
156 return msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
157 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
158 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
159 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
160 * Escape a protocol message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
161 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
162 * @return The escaped message. Caller must g_free(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
163 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
164 gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
165 msim_escape(const gchar *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
166 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
167 return msim_unescape_or_escape(g_strdup(msg), TRUE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
168 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
169 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
170 gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
171 msim_unescape(const gchar *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
172 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
173 return msim_unescape_or_escape(g_strdup(msg), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
174 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
175 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
176 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
177 * Replace 'old' with 'new' in 'str'. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
178 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
179 * @param str The original string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
180 * @param old The substring of 'str' to replace. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
181 * @param new The replacement for 'old' within 'str'. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
182 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
183 * @return A _new_ string, based on 'str', with 'old' replaced |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
184 * by 'new'. Must be g_free()'d by caller. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
185 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
186 * This string replace method is based on |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
187 * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
188 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
189 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
190 gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
191 str_replace(const gchar *str, const gchar *old, const gchar *new) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
192 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
193 gchar **items; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
194 gchar *ret; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
195 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
196 items = g_strsplit(str, old, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
197 ret = g_strjoinv(new, items); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
198 g_free(items); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
199 return ret; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
200 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
201 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
202 #ifdef MSIM_DEBUG_MSG |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
203 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
204 print_hash_item(gpointer key, gpointer value, gpointer user_data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
205 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
206 purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
207 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
208 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
209 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
210 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
211 * Send raw data (given as a NUL-terminated string) to the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
212 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
213 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
214 * @param msg The raw data to send, in a NUL-terminated string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
215 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
216 * @return TRUE if succeeded, FALSE if not. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
217 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
218 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
219 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
220 msim_send_raw(MsimSession *session, const gchar *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
221 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
222 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
223 g_return_val_if_fail(msg != NULL, FALSE); |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
224 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
225 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
226 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
227 return msim_send_really_raw(session->gc, msg, strlen(msg)) == |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
228 strlen(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
229 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
230 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
231 /** Send raw data to the server, possibly with embedded NULs. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
232 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
233 * Used in prpl_info struct, so that plugins can have the most possible |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
234 * control of what is sent over the connection. Inside this prpl, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
235 * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
236 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
237 * @param gc PurpleConnection |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
238 * @param buf Buffer to send |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
239 * @param total_bytes Size of buffer to send |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
240 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
241 * @return Bytes successfully sent, or -1 on error. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
242 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
243 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
244 msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
245 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
246 int total_bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
247 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
248 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
249 g_return_val_if_fail(gc != NULL, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
250 g_return_val_if_fail(buf != NULL, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
251 g_return_val_if_fail(total_bytes >= 0, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
252 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
253 session = (MsimSession *)(gc->proto_data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
254 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
255 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
256 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
257 /* Loop until all data is sent, or a failure occurs. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
258 total_bytes_sent = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
259 do |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
260 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
261 int bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
262 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
263 bytes_sent = send(session->fd, buf + total_bytes_sent, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
264 total_bytes - total_bytes_sent, 0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
265 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
266 if (bytes_sent < 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
267 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
268 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
269 buf, g_strerror(errno)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
270 return total_bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
271 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
272 total_bytes_sent += bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
273 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
274 } while(total_bytes_sent < total_bytes); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
275 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
276 return total_bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
277 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
278 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
279 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
280 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
281 * Start logging in to the MSIM servers. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
282 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
283 * @param acct Account information to use to login. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
284 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
285 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
286 msim_login(PurpleAccount *acct) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
287 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
288 PurpleConnection *gc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
289 const gchar *host; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
290 int port; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
291 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
292 g_return_if_fail(acct != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
293 g_return_if_fail(acct->username != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
294 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
295 purple_debug_info("myspace", "logging in %s\n", acct->username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
296 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
297 gc = purple_account_get_connection(acct); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
298 gc->proto_data = msim_session_new(acct); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
299 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
300 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
301 /* Passwords are limited in length. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
302 if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
303 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
304 gchar *str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
305 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
306 str = g_strdup_printf( |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
307 _("Sorry, passwords over %d characters in length (yours is " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
308 "%d) are not supported by the MySpaceIM plugin."), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
309 MSIM_MAX_PASSWORD_LENGTH, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
310 (int)strlen(acct->password)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
311 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
312 /* Notify an error message also, because this is important! */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
313 purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
314 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
315 purple_connection_error(gc, str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
316 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
317 g_free(str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
318 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
319 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
320 /* 1. connect to server */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
321 purple_connection_update_progress(gc, _("Connecting"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
322 0, /* which connection step this is */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
323 4); /* total number of steps */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
324 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
325 host = purple_account_get_string(acct, "server", MSIM_SERVER); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
326 port = purple_account_get_int(acct, "port", MSIM_PORT); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
327 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
328 /* From purple.sf.net/api: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
329 * """Note that this function name can be misleading--although it is called |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
330 * "proxy connect," it is used for establishing any outgoing TCP connection, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
331 * whether through a proxy or not.""" */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
332 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
333 /* Calls msim_connect_cb when connected. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
334 if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
335 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
336 /* TODO: try other ports if in auto mode, then save |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
337 * working port and try that first next time. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
338 purple_connection_error(gc, _("Couldn't create socket")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
339 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
340 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
341 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
342 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
343 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
344 * Process a login challenge, sending a response. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
345 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
346 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
347 * @param msg Login challenge message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
348 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
349 * @return TRUE if successful, FALSE if not |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
350 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
351 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
352 msim_login_challenge(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
353 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
354 PurpleAccount *account; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
355 const gchar *response; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
356 guint response_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
357 gchar *nc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
358 gsize nc_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
359 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
360 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
361 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
362 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
363 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
364 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
365 account = session->account; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
366 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
367 g_return_val_if_fail(account != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
368 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
369 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
370 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
371 purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
372 |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
373 if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
374 { |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
375 purple_debug_info("msim", "bad nc length: %x != 0x%x\n", nc_len, MSIM_AUTH_CHALLENGE_LENGTH); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
376 purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
377 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
378 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
379 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
380 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
381 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
382 response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
383 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
384 g_free(nc); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
385 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
386 return msim_send(session, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
387 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
388 /* This is actually user's email address. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
389 "username", MSIM_TYPE_STRING, g_strdup(account->username), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
390 /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
391 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
392 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
393 "reconn", MSIM_TYPE_INTEGER, 0, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
394 "status", MSIM_TYPE_INTEGER, 100, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
395 "id", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
396 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
397 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
398 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
399 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
400 * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
401 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
402 * @param nonce The base64 encoded nonce ('nc') field from the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
403 * @param email User's email address (used as login name). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
404 * @param password User's cleartext password. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
405 * @param response_len Will be written with response length. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
406 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
407 * @return Binary login challenge response, ready to send to the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
408 * Must be g_free()'d when finished. NULL if error. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
409 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
410 const gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
411 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
412 const gchar *email, const gchar *password, guint *response_len) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
413 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
414 PurpleCipherContext *key_context; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
415 PurpleCipher *sha1; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
416 PurpleCipherContext *rc4; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
417 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
418 guchar hash_pw[HASH_SIZE]; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
419 guchar key[HASH_SIZE]; |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
420 gchar *password_utf16le, *password_ascii_lc; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
421 guchar *data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
422 guchar *data_out; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
423 size_t data_len, data_out_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
424 gsize conv_bytes_read, conv_bytes_written; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
425 GError *conv_error; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
426 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
427 int i; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
428 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
429 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
430 g_return_val_if_fail(nonce != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
431 g_return_val_if_fail(email != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
432 g_return_val_if_fail(password != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
433 g_return_val_if_fail(response_len != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
434 |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
435 /* Convert password to lowercase (required for passwords containing |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
436 * uppercase characters). MySpace passwords are lowercase, |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
437 * see ticket #2066. */ |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
438 password_ascii_lc = g_strdup(password); |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
439 g_strdown(password_ascii_lc); |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
440 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
441 /* Convert ASCII password to UTF16 little endian */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
442 purple_debug_info("msim", "converting password to UTF-16LE\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
443 conv_error = NULL; |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
444 password_utf16le = g_convert(password_ascii_lc, -1, "UTF-16LE", "UTF-8", |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
445 &conv_bytes_read, &conv_bytes_written, &conv_error); |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
446 g_free(password_ascii_lc); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
447 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
448 g_return_val_if_fail(conv_bytes_read == strlen(password), NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
449 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
450 if (conv_error != NULL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
451 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
452 purple_debug_error("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
453 "g_convert password UTF8->UTF16LE failed: %s", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
454 conv_error->message); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
455 g_error_free(conv_error); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
456 return NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
457 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
458 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
459 /* Compute password hash */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
460 purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
461 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
462 g_free(password_utf16le); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
463 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
464 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
465 purple_debug_info("msim", "pwhash = "); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
466 for (i = 0; i < sizeof(hash_pw); i++) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
467 purple_debug_info("msim", "%.2x ", hash_pw[i]); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
468 purple_debug_info("msim", "\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
469 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
470 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
471 /* key = sha1(sha1(pw) + nonce2) */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
472 sha1 = purple_ciphers_find_cipher("sha1"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
473 key_context = purple_cipher_context_new(sha1, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
474 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
475 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
476 purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
477 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
478 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
479 purple_debug_info("msim", "key = "); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
480 for (i = 0; i < sizeof(key); i++) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
481 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
482 purple_debug_info("msim", "%.2x ", key[i]); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
483 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
484 purple_debug_info("msim", "\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
485 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
486 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
487 rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
488 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
489 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
490 * but only first 0x10 used for the RC4 key. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
491 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
492 purple_cipher_context_set_key(rc4, key); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
493 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
494 /* TODO: obtain IPs of network interfaces */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
495 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
496 /* rc4 encrypt: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
497 * nonce1+email+IP list */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
498 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
499 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
500 data = g_new0(guchar, data_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
501 memcpy(data, nonce, NONCE_SIZE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
502 memcpy(data + NONCE_SIZE, email, strlen(email)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
503 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
504 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
505 data_out = g_new0(guchar, data_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
506 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
507 purple_cipher_context_encrypt(rc4, (const guchar *)data, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
508 data_len, data_out, &data_out_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
509 purple_cipher_context_destroy(rc4); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
510 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
511 g_assert(data_out_len == data_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
512 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
513 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
514 purple_debug_info("msim", "response=<%s>\n", data_out); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
515 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
516 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
517 *response_len = data_out_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
518 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
519 return (const gchar *)data_out; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
520 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
521 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
522 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
523 * Schedule an IM to be sent once the user ID is looked up. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
524 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
525 * @param gc Connection. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
526 * @param who A user id, email, or username to send the message to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
527 * @param message Instant message text to send. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
528 * @param flags Flags. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
529 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
530 * @return 1 if successful or postponed, -1 if failed |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
531 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
532 * Allows sending to a user by username, email address, or userid. If |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
533 * a username or email address is given, the userid must be looked up. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
534 * This function does that by calling msim_postprocess_outgoing(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
535 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
536 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
537 msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
538 PurpleMessageFlags flags) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
539 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
540 MsimSession *session; |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
541 gchar *message_msim; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
542 int rc; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
543 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
544 g_return_val_if_fail(gc != NULL, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
545 g_return_val_if_fail(who != NULL, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
546 g_return_val_if_fail(message != NULL, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
547 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
548 /* 'flags' has many options, not used here. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
549 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
550 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
551 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
552 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
553 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
554 message_msim = html_to_msim_markup(message); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
555 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
556 if (msim_send_bm(session, who, message_msim, MSIM_BM_INSTANT)) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
557 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
558 /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
559 * return 1 even if the message could not be sent, since I don't know if |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
560 * it has failed yet--because the IM is only sent after the userid is |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
561 * retrieved from the server (which happens after this function returns). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
562 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
563 /* TODO: maybe if message is delayed, don't echo to conv window, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
564 * but do echo it to conv window manually once it is actually |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
565 * sent? Would be complicated. */ |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
566 rc = 1; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
567 } else { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
568 rc = -1; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
569 } |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
570 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
571 g_free(message_msim); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
572 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
573 /* |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
574 * In MySpace, you login with your email address, but don't talk to other |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
575 * users using their email address. So there is currently an asymmetry in the |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
576 * IM windows when using this plugin: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
577 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
578 * you@example.com: hello |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
579 * some_other_user: what's going on? |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
580 * you@example.com: just coding a prpl |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
581 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
582 * TODO: Make the sent IM's appear as from the user's username, instead of |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
583 * their email address. Purple uses the login (in MSIM, the email)--change this. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
584 */ |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
585 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
586 return rc; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
587 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
588 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
589 /** Send a buddy message of a given type. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
590 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
591 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
592 * @param who Username to send message to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
593 * @param text Message text to send. Not freed; will be copied. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
594 * @param type A MSIM_BM_* constant. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
595 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
596 * @return TRUE if success, FALSE if fail. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
597 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
598 * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
599 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
600 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
601 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
602 msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
603 int type) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
604 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
605 gboolean rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
606 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
607 const gchar *from_username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
608 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
609 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
610 g_return_val_if_fail(who != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
611 g_return_val_if_fail(text != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
612 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
613 from_username = session->account->username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
614 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
615 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
616 type, from_username, who, text); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
617 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
618 msg = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
619 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
620 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
621 /* 't' will be inserted here */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
622 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
623 "msg", MSIM_TYPE_STRING, g_strdup(text), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
624 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
625 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
626 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
627 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
628 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
629 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
630 return rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
631 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
632 |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
633 /* Indexes of this array + 1 map HTML font size to scale of normal font size. * |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
634 * Based on _point_sizes from libpurple/gtkimhtml.c |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
635 * 1 2 3 4 5 6 7 */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
636 static gdouble _font_scale[] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736 }; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
637 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
638 #define MAX_FONT_SIZE 7 /* Purple maximum font size */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
639 #define POINTS_PER_INCH 72 /* How many pt's in an inch */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
640 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
641 /* Baseline size of purple's fonts, in points. What is size 3 in points. |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
642 * _font_scale specifies scaling factor relative to this point size. |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
643 * TODO: configurable */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
644 #define BASE_FONT_POINT_SIZE 8 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
645 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
646 /* Display's DPI. 96 is common but it can differ. TODO: configurable */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
647 #define DOTS_PER_INCH 96 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
648 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
649 /** Convert typographical font point size to HTML font size. |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
650 * Based on libpurple/gtkimhtml.c */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
651 guint |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
652 msim_point_to_purple_size(guint point) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
653 { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
654 guint size, this_point; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
655 gdouble scale; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
656 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
657 for (size = 0; size < sizeof(_font_scale) / sizeof(_font_scale[0]); ++size) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
658 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
659 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
660 this_point = (guint)round(scale * BASE_FONT_POINT_SIZE); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
661 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
662 if (this_point >= point) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
663 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
664 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
665 point, size); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
666 return size; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
667 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
668 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
669 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
670 /* No HTML font size was this big; return largest possible. */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
671 return this_point; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
672 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
673 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
674 /** Convert HTML font size to point size. */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
675 guint |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
676 msim_purple_size_to_point(guint size) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
677 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
678 gdouble scale; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
679 guint point; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
680 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
681 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
682 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
683 point = (guint)round(scale * BASE_FONT_POINT_SIZE); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
684 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
685 purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n", |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
686 size, point); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
687 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
688 return point; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
689 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
690 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
691 /** Convert a msim markup font pixel height to the more usual point size, for incoming messages. */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
692 guint |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
693 msim_height_to_point(guint height) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
694 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
695 return (guint)round((POINTS_PER_INCH * 1. / DOTS_PER_INCH) * height); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
696 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
697 /* See also: libpurple/protocols/bonjour/jabber.c |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
698 * _font_size_ichat_to_purple */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
699 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
700 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
701 /** Convert point size to msim pixel height font size specification, for outgoing messages. */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
702 guint |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
703 msim_point_to_height(guint point) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
704 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
705 return (guint)round((DOTS_PER_INCH * 1. / POINTS_PER_INCH) * point); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
706 } |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
707 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
708 /** Convert the msim markup <f> (font) tag into HTML. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
709 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
710 msim_markup_f_to_html(xmlnode *root, gchar **begin, gchar **end) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
711 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
712 const gchar *face, *height_str, *decor_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
713 GString *gs_end, *gs_begin; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
714 guint decor, height; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
715 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
716 face = xmlnode_get_attrib(root, "f"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
717 height_str = xmlnode_get_attrib(root, "h"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
718 decor_str = xmlnode_get_attrib(root, "s"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
719 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
720 if (height_str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
721 height = atol(height_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
722 else |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
723 height = 12; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
724 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
725 if (decor_str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
726 decor = atol(decor_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
727 else |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
728 decor = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
729 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
730 gs_begin = g_string_new(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
731 /* TODO: get font size working */ |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
732 if (height && !face) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
733 g_string_printf(gs_begin, "<font size='%d'>", |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
734 msim_point_to_purple_size(msim_height_to_point(height))); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
735 else if (height && face) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
736 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
737 msim_point_to_purple_size(msim_height_to_point(height))); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
738 else |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
739 g_string_printf(gs_begin, "<font>"); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
740 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
741 /* No support for font-size CSS? */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
742 /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
743 msim_height_to_point(height)); */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
744 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
745 gs_end = g_string_new("</font>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
746 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
747 if (decor & MSIM_TEXT_BOLD) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
748 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
749 g_string_append(gs_begin, "<b>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
750 g_string_prepend(gs_end, "</b>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
751 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
752 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
753 if (decor & MSIM_TEXT_ITALIC) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
754 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
755 g_string_append(gs_begin, "<i>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
756 g_string_append(gs_end, "</i>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
757 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
758 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
759 if (decor & MSIM_TEXT_UNDERLINE) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
760 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
761 g_string_append(gs_begin, "<u>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
762 g_string_append(gs_end, "</u>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
763 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
764 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
765 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
766 *begin = gs_begin->str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
767 *end = gs_end->str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
768 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
769 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
770 /** Convert a msim markup color to a color suitable for libpurple. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
771 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
772 * @param msim Either a color name, or an rgb(x,y,z) code. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
773 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
774 * @return A new string, either a color name or #rrggbb code. Must g_free(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
775 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
776 static char * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
777 msim_color_to_purple(const char *msim) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
778 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
779 guint red, green, blue; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
780 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
781 if (!msim) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
782 return g_strdup("black"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
783 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
784 if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
785 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
786 /* Color name. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
787 return g_strdup(msim); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
788 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
789 /* TODO: rgba (alpha). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
790 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
791 return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
792 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
793 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
794 /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
795 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
796 msim_markup_p_to_html(xmlnode *root, gchar **begin, gchar **end) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
797 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
798 /* Just pass through unchanged. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
799 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
800 * Note: attributes currently aren't passed, if there are any. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
801 *begin = g_strdup("<p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
802 *end = g_strdup("</p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
803 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
804 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
805 /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
806 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
807 msim_markup_c_to_html(xmlnode *root, gchar **begin, gchar **end) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
808 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
809 const gchar *color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
810 gchar *purple_color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
811 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
812 color = xmlnode_get_attrib(root, "v"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
813 if (!color) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
814 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
815 purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
816 *begin = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
817 *end = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
818 /* TODO: log as unrecognized */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
819 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
820 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
821 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
822 purple_color = msim_color_to_purple(color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
823 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
824 *begin = g_strdup_printf("<font color='%s'>", purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
825 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
826 g_free(purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
827 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
828 /* *begin = g_strdup_printf("<span style='color: %s'>", color); */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
829 *end = g_strdup("</font>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
830 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
831 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
832 /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
833 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
834 msim_markup_b_to_html(xmlnode *root, gchar **begin, gchar **end) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
835 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
836 const gchar *color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
837 gchar *purple_color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
838 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
839 color = xmlnode_get_attrib(root, "v"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
840 if (!color) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
841 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
842 *begin = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
843 *end = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
844 purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
845 /* TODO: log as unrecognized. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
846 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
847 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
848 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
849 purple_color = msim_color_to_purple(color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
850 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
851 /* TODO: find out how to set background color. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
852 *begin = g_strdup_printf("<span style='background-color: %s'>", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
853 purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
854 g_free(purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
855 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
856 *end = g_strdup("</p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
857 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
858 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
859 /** Convert the msim markup <i> tag (emoticon image) into HTML. TODO: Test */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
860 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
861 msim_markup_i_to_html(xmlnode *root, gchar **begin, gchar **end) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
862 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
863 const gchar *name; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
864 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
865 name = xmlnode_get_attrib(root, "n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
866 if (!name) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
867 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
868 purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
869 *begin = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
870 *end = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
871 /* TODO: log as unrecognized */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
872 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
873 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
874 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
875 /* TODO: Support these emoticons: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
876 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
877 * bigsmile growl mad scared tongue devil happy messed sidefrown upset |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
878 * frazzled heart nerd sinister wink geek laugh oops smirk worried |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
879 * googles mohawk pirate straight kiss |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
880 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
881 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
882 *begin = g_strdup_printf("<img id='%s'>", name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
883 *end = g_strdup("</p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
884 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
885 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
886 /** Convert an individual msim markup tag to HTML. */ |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
887 void msim_markup_tag_to_html(xmlnode *root, gchar **begin, gchar **end) |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
888 { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
889 if (!strcmp(root->name, "f")) |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
890 { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
891 msim_markup_f_to_html(root, begin, end); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
892 } else if (!strcmp(root->name, "p")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
893 msim_markup_p_to_html(root, begin, end); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
894 } else if (!strcmp(root->name, "c")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
895 msim_markup_c_to_html(root, begin, end); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
896 } else if (!strcmp(root->name, "b")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
897 msim_markup_b_to_html(root, begin, end); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
898 } else if (!strcmp(root->name, "i")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
899 msim_markup_i_to_html(root, begin, end); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
900 } else { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
901 purple_debug_info("msim", "msim_markup_tag_to_html: " |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
902 "unknown tag name=%s, ignoring", root->name); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
903 *begin = g_strdup(""); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
904 *end = g_strdup(""); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
905 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
906 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
907 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
908 /** Convert an individual HTML tag to msim markup. */ |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
909 void html_tag_to_msim_markup(xmlnode *root, gchar **begin, gchar **end) |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
910 { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
911 /* TODO: Coalesce nested tags into one <f> tag! |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
912 * Currently, the 's' value will be overwritten when b/i/u is nested |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
913 * within another one, and only the inner-most formatting will be |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
914 * applied to the text. */ |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
915 if (!strcmp(root->name, "root")) |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
916 { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
917 *begin = g_strdup(""); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
918 *end = g_strdup(""); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
919 } else if (!strcmp(root->name, "b")) { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
920 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
921 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
922 } else if (!strcmp(root->name, "i")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
923 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
924 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
925 } else if (!strcmp(root->name, "u")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
926 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
927 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
928 } else if (!strcmp(root->name, "font")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
929 const gchar *size; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
930 const gchar *face; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
931 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
932 size = xmlnode_get_attrib(root, "size"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
933 face = xmlnode_get_attrib(root, "face"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
934 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
935 if (face && size) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
936 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
937 *begin = g_strdup_printf("<f f='%s' h='%d'>", face, |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
938 msim_point_to_height(msim_purple_size_to_point( |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
939 atoi(size)))); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
940 } else if (face) { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
941 *begin = g_strdup_printf("<f f='%s'>", face); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
942 } else if (size) { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
943 *begin = g_strdup_printf("<f h='%d'>", |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
944 msim_point_to_height(msim_purple_size_to_point( |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
945 atoi(size)))); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
946 } else { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
947 *begin = g_strdup("<f>"); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
948 } |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
949 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
950 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
951 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
952 /* TODO: color (bg uses <body>), emoticons */ |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
953 } else { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
954 *begin = g_strdup_printf("[%s]", root->name); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
955 *end = g_strdup_printf("[/%s]", root->name); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
956 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
957 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
958 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
959 /** Convert an xmlnode of msim markup or HTML to an HTML string or msim markup. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
960 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
961 * @param f Function to convert tags. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
962 * |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
963 * @return An HTML string. Caller frees. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
964 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
965 static gchar * |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
966 msim_convert_xmlnode(xmlnode *root, MSIM_XMLNODE_CONVERT f) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
967 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
968 xmlnode *node; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
969 gchar *begin, *inner, *end; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
970 GString *final; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
971 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
972 if (!root || !root->name) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
973 return g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
974 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
975 purple_debug_info("msim", "msim_convert_xmlnode: got root=%s\n", |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
976 root->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
977 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
978 begin = inner = end = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
979 |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
980 final = g_string_new(""); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
981 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
982 f(root, &begin, &end); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
983 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
984 g_string_append(final, begin); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
985 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
986 /* Loop over all child nodes. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
987 for (node = root->child; node != NULL; node = node->next) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
988 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
989 switch (node->type) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
990 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
991 case XMLNODE_TYPE_ATTRIB: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
992 /* Attributes handled above. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
993 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
994 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
995 case XMLNODE_TYPE_TAG: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
996 /* A tag or tag with attributes. Recursively descend. */ |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
997 inner = msim_convert_xmlnode(node, f); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
998 g_return_val_if_fail(inner != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
999 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1000 purple_debug_info("msim", " ** node name=%s\n", node->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1001 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1002 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1003 case XMLNODE_TYPE_DATA: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1004 /* Literal text. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1005 inner = g_new0(char, node->data_sz + 1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1006 strncpy(inner, node->data, node->data_sz); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1007 inner[node->data_sz] = 0; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1008 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1009 purple_debug_info("msim", " ** node data=%s\n", inner); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1010 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1011 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1012 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1013 purple_debug_info("msim", |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1014 "msim_convert_xmlnode: strange node\n"); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1015 inner = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1016 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1017 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1018 if (inner) |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1019 g_string_append(final, inner); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1020 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1021 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1022 /* TODO: Note that msim counts each piece of text enclosed by <f> as |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1023 * a paragraph and will display each on its own line. You actually have |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1024 * to _nest_ <f> tags to intersperse different text in one paragraph! |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1025 * Comment out this line below to see. */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1026 g_string_append(final, end); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1027 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1028 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1029 final->str); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1030 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1031 return final->str; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1032 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1033 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1034 /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1035 gchar * |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1036 msim_convert_xml(const gchar *raw, MSIM_XMLNODE_CONVERT f) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1037 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1038 xmlnode *root; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1039 gchar *str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1040 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1041 root = xmlnode_from_str(raw, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1042 if (!root) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1043 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1044 purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1045 "%s as XML, returning raw\n", raw); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1046 /* TODO: msim_unrecognized */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1047 return g_strdup(raw); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1048 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1049 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1050 str = msim_convert_xmlnode(root, f); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1051 purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1052 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1053 xmlnode_free(root); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1054 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1055 return str; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1056 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1057 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1058 /** High-level function to convert MySpaceIM markup to Purple (HTML) markup. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1059 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1060 * @return Purple markup string, must be g_free()'d. */ |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1061 gchar * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1062 msim_markup_to_html(const gchar *raw) |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1063 { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1064 return msim_convert_xml(raw, |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1065 (MSIM_XMLNODE_CONVERT)(msim_markup_tag_to_html)); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1066 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1067 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1068 /** High-level function to convert Purple (HTML) to MySpaceIM markup. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1069 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1070 * @return HTML markup string, must be g_free()'d. */ |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1071 gchar * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1072 html_to_msim_markup(const gchar *raw) |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1073 { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1074 gchar *markup; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1075 gchar *enclosed_raw; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1076 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1077 /* Enclose text in one root tag, to try to make it valid XML for parsing. */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1078 enclosed_raw = g_strconcat("<root>", raw, "</root>", NULL); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1079 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1080 markup = msim_convert_xml(enclosed_raw, |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1081 (MSIM_XMLNODE_CONVERT)(html_tag_to_msim_markup)); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1082 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1083 g_free(enclosed_raw); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1084 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1085 return markup; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1086 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1087 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1088 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1089 * Handle an incoming instant message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1090 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1091 * @param session The session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1092 * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1093 * Should also contain username in _username from preprocessing. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1094 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1095 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1096 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1097 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1098 msim_incoming_im(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1099 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1100 gchar *username, *msg_msim_markup, *msg_purple_markup; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1101 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1102 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1103 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1104 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1105 username = msim_msg_get_string(msg, "_username"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1106 g_return_val_if_fail(username != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1107 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1108 msg_msim_markup = msim_msg_get_string(msg, "msg"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1109 g_return_val_if_fail(msg_msim_markup != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1110 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1111 msg_purple_markup = msim_markup_to_html(msg_msim_markup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1112 g_free(msg_msim_markup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1113 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1114 serv_got_im(session->gc, username, msg_purple_markup, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1115 PURPLE_MESSAGE_RECV, time(NULL)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1116 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1117 g_free(username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1118 g_free(msg_purple_markup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1119 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1120 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1121 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1122 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1123 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1124 * Process unrecognized information. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1125 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1126 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1127 * @param msg An MsimMessage that was unrecognized, or NULL. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1128 * @param note Information on what was unrecognized, or NULL. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1129 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1130 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1131 msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1132 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1133 /* TODO: Some more context, outwardly equivalent to a backtrace, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1134 * for helping figure out what this msg is for. What was going on? |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1135 * But not too much information so that a user |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1136 * posting this dump reveals confidential information. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1137 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1138 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1139 /* TODO: dump unknown msgs to file, so user can send them to me |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1140 * if they wish, to help add support for new messages (inspired |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1141 * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1142 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1143 purple_debug_info("msim", "Unrecognized data on account for %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1144 session->account->username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1145 if (note) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1146 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1147 purple_debug_info("msim", "(Note: %s)\n", note); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1148 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1149 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1150 if (msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1151 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1152 msim_msg_dump("Unrecognized message dump: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1153 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1154 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1155 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1156 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1157 * Handle an incoming action message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1158 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1159 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1160 * @param msg |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1161 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1162 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1163 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1164 * UNTESTED |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1165 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1166 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1167 msim_incoming_action(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1168 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1169 gchar *msg_text, *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1170 gboolean rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1171 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1172 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1173 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1174 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1175 msg_text = msim_msg_get_string(msg, "msg"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1176 g_return_val_if_fail(msg_text != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1177 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1178 username = msim_msg_get_string(msg, "_username"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1179 g_return_val_if_fail(username != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1180 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1181 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1182 msg_text, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1183 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1184 if (strcmp(msg_text, "%typing%") == 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1185 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1186 /* TODO: find out if msim repeatedly sends typing messages, so we can |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1187 * give it a timeout. Right now, there does seem to be an inordinately |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1188 * amount of time between typing stopped-typing notifications. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1189 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1190 rc = TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1191 } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1192 serv_got_typing_stopped(session->gc, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1193 rc = TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1194 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1195 msim_unrecognized(session, msg, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1196 "got to msim_incoming_action but unrecognized value for 'msg'"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1197 rc = FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1198 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1199 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1200 g_free(msg_text); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1201 g_free(username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1202 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1203 return rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1204 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1205 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1206 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1207 * Handle when our user starts or stops typing to another user. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1208 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1209 * @param gc |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1210 * @param name The buddy name to which our user is typing to |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1211 * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1212 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1213 * @return 0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1214 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1215 unsigned int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1216 msim_send_typing(PurpleConnection *gc, const gchar *name, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1217 PurpleTypingState state) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1218 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1219 const gchar *typing_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1220 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1221 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1222 g_return_val_if_fail(gc != NULL, 0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1223 g_return_val_if_fail(name != NULL, 0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1224 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1225 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1226 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1227 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1228 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1229 switch (state) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1230 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1231 case PURPLE_TYPING: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1232 typing_str = "%typing%"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1233 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1234 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1235 case PURPLE_TYPED: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1236 case PURPLE_NOT_TYPING: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1237 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1238 typing_str = "%stoptyping%"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1239 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1240 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1241 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1242 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1243 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1244 return 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1245 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1246 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1247 /** Callback for msim_get_info(), for when user info is received. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1248 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1249 msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1250 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1251 GHashTable *body; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1252 gchar *body_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1253 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1254 gchar *user; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1255 PurpleNotifyUserInfo *user_info; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1256 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1257 const gchar *str, *str2; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1258 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1259 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1260 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1261 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1262 orthogonality. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1263 msg = (MsimMessage *)data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1264 g_return_if_fail(msg != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1265 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1266 user = msim_msg_get_string(msg, "user"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1267 if (!user) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1268 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1269 purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1270 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1271 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1272 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1273 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1274 purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1275 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1276 body_str = msim_msg_get_string(user_info_msg, "body"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1277 g_return_if_fail(body_str != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1278 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1279 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1280 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1281 buddy = purple_find_buddy(session->account, user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1282 /* Note: don't assume buddy is non-NULL; will be if lookup random user |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1283 * not on blist. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1284 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1285 user_info = purple_notify_user_info_new(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1286 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1287 /* Identification */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1288 purple_notify_user_info_add_pair(user_info, _("User"), user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1289 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1290 /* note: g_hash_table_lookup does not create a new string! */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1291 str = g_hash_table_lookup(body, "UserID"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1292 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1293 purple_notify_user_info_add_pair(user_info, _("User ID"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1294 g_strdup(str)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1295 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1296 /* a/s/l...the vitals */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1297 str = g_hash_table_lookup(body, "Age"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1298 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1299 purple_notify_user_info_add_pair(user_info, _("Age"), g_strdup(str)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1300 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1301 str = g_hash_table_lookup(body, "Gender"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1302 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1303 purple_notify_user_info_add_pair(user_info, _("Gender"), g_strdup(str)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1304 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1305 str = g_hash_table_lookup(body, "Location"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1306 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1307 purple_notify_user_info_add_pair(user_info, _("Location"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1308 g_strdup(str)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1309 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1310 /* Other information */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1311 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1312 /* Headline comes from buddy status messages */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1313 if (buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1314 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1315 str = purple_blist_node_get_string(&buddy->node, "Headline"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1316 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1317 purple_notify_user_info_add_pair(user_info, "Headline", str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1318 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1319 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1320 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1321 str = g_hash_table_lookup(body, "BandName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1322 str2 = g_hash_table_lookup(body, "SongName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1323 if (str || str2) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1324 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1325 purple_notify_user_info_add_pair(user_info, _("Song"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1326 g_strdup_printf("%s - %s", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1327 str ? str : "Unknown Artist", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1328 str2 ? str2 : "Unknown Song")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1329 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1330 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1331 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1332 /* Total friends only available if looked up by uid, not username. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1333 str = g_hash_table_lookup(body, "TotalFriends"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1334 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1335 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1336 g_strdup(str)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1337 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1338 purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1339 purple_debug_info("msim", "msim_get_info_cb: username=%s\n", user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1340 //purple_notify_user_info_destroy(user_info); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1341 /* Do not free username, since it will be used by user_info. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1342 |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1343 g_hash_table_destroy(body); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1344 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1345 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1346 /** Retrieve a user's profile. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1347 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1348 msim_get_info(PurpleConnection *gc, const gchar *user) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1349 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1350 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1351 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1352 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1353 gchar *user_to_lookup; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1354 MsimMessage *user_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1355 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1356 g_return_if_fail(gc != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1357 g_return_if_fail(user != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1358 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1359 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1360 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1361 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1362 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1363 /* Obtain uid of buddy. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1364 buddy = purple_find_buddy(session->account, user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1365 if (buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1366 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1367 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1368 if (!uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1369 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1370 PurpleNotifyUserInfo *user_info; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1371 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1372 user_info = purple_notify_user_info_new(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1373 purple_notify_user_info_add_pair(user_info, NULL, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1374 _("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?")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1375 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1376 purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1377 purple_notify_user_info_destroy(user_info); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1378 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1379 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1380 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1381 user_to_lookup = g_strdup_printf("%d", uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1382 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1383 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1384 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1385 user_to_lookup = g_strdup(user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1386 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1387 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1388 /* Pass the username to msim_get_info_cb(), because since we lookup |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1389 * by userid, the userinfo message will only contain the uid (not |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1390 * the username). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1391 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1392 user_msg = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1393 "user", MSIM_TYPE_STRING, g_strdup(user), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1394 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1395 purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1396 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1397 msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1398 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1399 g_free(user_to_lookup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1400 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1401 |
17945
cf55077a3752
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17944
diff
changeset
|
1402 /** Set your status - callback for when user manually sets it. */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1403 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1404 msim_set_status(PurpleAccount *account, PurpleStatus *status) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1405 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1406 PurpleStatusType *type; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1407 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1408 guint status_code; |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1409 const gchar *statstring; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1410 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1411 session = (MsimSession *)account->gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1412 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1413 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1414 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1415 type = purple_status_get_type(status); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1416 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1417 switch (purple_status_type_get_primitive(type)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1418 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1419 case PURPLE_STATUS_AVAILABLE: |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1420 purple_debug_info("msim", "msim_set_status: available (%d->%d)\n", PURPLE_STATUS_AVAILABLE, |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1421 MSIM_STATUS_CODE_ONLINE); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1422 status_code = MSIM_STATUS_CODE_ONLINE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1423 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1424 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1425 case PURPLE_STATUS_INVISIBLE: |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1426 purple_debug_info("msim", "msim_set_status: invisible (%d->%d)\n", PURPLE_STATUS_INVISIBLE, |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1427 MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1428 status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1429 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1430 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1431 case PURPLE_STATUS_AWAY: |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1432 purple_debug_info("msim", "msim_set_status: away (%d->%d)\n", PURPLE_STATUS_AWAY, |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1433 MSIM_STATUS_CODE_AWAY); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1434 status_code = MSIM_STATUS_CODE_AWAY; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1435 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1436 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1437 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1438 purple_debug_info("msim", "msim_set_status: unknown " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1439 "status interpreting as online"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1440 status_code = MSIM_STATUS_CODE_ONLINE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1441 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1442 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1443 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1444 statstring = purple_status_get_attr_string(status, "message"); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1445 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1446 if (!statstring) |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1447 statstring = g_strdup(""); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1448 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1449 msim_set_status_code(session, status_code, g_strdup(statstring)); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1450 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1451 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1452 /** Go idle. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1453 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1454 msim_set_idle(PurpleConnection *gc, int time) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1455 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1456 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1457 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1458 g_return_if_fail(gc != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1459 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1460 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1461 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1462 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1463 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1464 if (time == 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1465 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1466 /* Going back from idle. In msim, idle is mutually exclusive |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1467 * from the other states (you can only be away or idle, but not |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1468 * both, for example), so by going non-idle I go online. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1469 */ |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1470 /* TODO: find out how to keep old status string? */ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1471 msim_set_status_code(session, MSIM_STATUS_CODE_ONLINE, g_strdup("")); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1472 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1473 /* msim doesn't support idle time, so just go idle */ |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1474 msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, g_strdup("")); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1475 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1476 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1477 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1478 /** Set status using an MSIM_STATUS_CODE_* value. |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1479 * @param status_code An MSIM_STATUS_CODE_* value. |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1480 * @param statstring Status string, must be a dynamic string (will be freed by msim_send). |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1481 */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1482 void |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1483 msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1484 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1485 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1486 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1487 purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n", |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1488 status_code, statstring); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1489 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1490 if (!msim_send(session, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1491 "status", MSIM_TYPE_INTEGER, status_code, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1492 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1493 "statstring", MSIM_TYPE_STRING, statstring, |
17696
65cf1785e5bf
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17695
diff
changeset
|
1494 "locstring", MSIM_TYPE_STRING, g_strdup(""), |
65cf1785e5bf
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17695
diff
changeset
|
1495 NULL)) |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1496 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1497 purple_debug_info("msim", "msim_set_status: failed to set status"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1498 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1499 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1500 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1501 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1502 /** After a uid is resolved to username, tag it with the username and submit for processing. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1503 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1504 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1505 * @param userinfo Response messsage to resolving request. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1506 * @param data MsimMessage *, the message to attach information to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1507 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1508 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1509 msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1510 gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1511 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1512 gchar *body_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1513 GHashTable *body; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1514 gchar *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1515 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1516 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1517 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1518 g_return_if_fail(userinfo != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1519 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1520 body_str = msim_msg_get_string(userinfo, "body"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1521 g_return_if_fail(body_str != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1522 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1523 g_return_if_fail(body != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1524 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1525 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1526 username = g_hash_table_lookup(body, "UserName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1527 g_return_if_fail(username != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1528 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1529 msg = (MsimMessage *)data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1530 g_return_if_fail(msg != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1531 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1532 /* Special elements name beginning with '_', we'll use internally within the |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1533 * program (did not come from the wire). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1534 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1535 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1536 msim_process(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1537 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1538 /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1539 //XXX msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1540 g_hash_table_destroy(body); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1541 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1542 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1543 #if 0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1544 /* Lookup a username by userid, from buddy list. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1545 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1546 * @param wanted_uid |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1547 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1548 * @return Username of wanted_uid, if on blist, or NULL. Static string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1549 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1550 * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1551 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1552 static const gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1553 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1554 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1555 GSList *buddies, *cur; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1556 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1557 buddies = purple_find_buddies(session->account, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1558 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1559 if (!buddies) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1560 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1561 purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1562 return NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1563 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1564 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1565 for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1566 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1567 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1568 //PurpleBlistNode *node; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1569 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1570 const gchar *name; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1571 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1572 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1573 /* See finch/gnthistory.c */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1574 buddy = cur->data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1575 //node = cur->data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1576 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1577 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1578 //uid = purple_blist_node_get_int(node, "UserID"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1579 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1580 /* name = buddy->name; */ /* crash */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1581 /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1582 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1583 /* XXX Is this right? Memory corruption here somehow. Happens only |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1584 * when return one of these values. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1585 name = purple_buddy_get_name(buddy); /* crash */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1586 //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1587 /* return name; */ /* crash (with above) */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1588 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1589 /* name = NULL; */ /* no crash */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1590 /* return NULL; */ /* no crash (with anything) */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1591 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1592 /* crash = |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1593 *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1594 ======= Backtrace: ========= |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1595 /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1596 /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1597 /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1598 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1599 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1600 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1601 /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1602 /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1603 /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1604 /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1605 pidgin(main+0x8be)[0x46b45e] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1606 /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1607 pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1608 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1609 or: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1610 *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1611 (gdb) bt |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1612 #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1613 #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1614 #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1615 #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1616 #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1617 #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1618 #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1619 #7 0x00002b407810969f in msim_parse ( |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1620 raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1621 at message.c:648 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1622 #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1623 source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1624 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1625 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1626 Why is it crashing in msim_parse()'s g_strdup()? |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1627 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1628 purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1629 name, uid, wanted_uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1630 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1631 if (uid == wanted_uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1632 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1633 gchar *ret; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1634 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1635 ret = g_strdup(name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1636 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1637 g_slist_free(buddies); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1638 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1639 return ret; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1640 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1641 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1642 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1643 g_slist_free(buddies); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1644 return NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1645 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1646 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1647 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1648 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1649 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1650 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1651 * @param msg MsimMessage *, freed by caller. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1652 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1653 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1654 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1655 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1656 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1657 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1658 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1659 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1660 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1661 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1662 const gchar *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1663 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1664 /* 'f' = userid message is from, in buddy messages */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1665 uid = msim_msg_get_integer(msg, "f"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1666 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1667 /* TODO: Make caching work. Currently it is commented out because |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1668 * it crashes for unknown reasons, memory realloc error. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1669 #if 0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1670 username = msim_uid2username_from_blist(session, uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1671 #else |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1672 username = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1673 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1674 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1675 if (username) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1676 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1677 /* Know username already, use it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1678 purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1679 username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1680 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1681 return msim_process(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1682 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1683 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1684 gchar *from; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1685 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1686 /* Send lookup request. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1687 /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1688 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1689 from = msim_msg_get_string(msg, "f"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1690 msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1691 g_free(from); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1692 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1693 /* indeterminate */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1694 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1695 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1696 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1697 /* Nothing to resolve - send directly to processing. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1698 return msim_process(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1699 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1700 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1701 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1702 /** Check if the connection is still alive, based on last communication. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1703 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1704 msim_check_alive(gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1705 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1706 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1707 time_t delta; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1708 gchar *errmsg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1709 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1710 session = (MsimSession *)data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1711 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1712 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1713 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1714 delta = time(NULL) - session->last_comm; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1715 //purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1716 if (delta >= MSIM_KEEPALIVE_INTERVAL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1717 { |
17696
65cf1785e5bf
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17695
diff
changeset
|
1718 errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), (int)delta); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1719 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1720 purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1721 errmsg, MSIM_KEEPALIVE_INTERVAL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1722 purple_connection_error(session->gc, errmsg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1723 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1724 purple_notify_error(session->gc, NULL, errmsg, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1725 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1726 g_free(errmsg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1727 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1728 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1729 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1730 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1731 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1732 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1733 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1734 /** Handle mail reply checks. */ |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1735 void |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1736 msim_check_inbox_cb(MsimSession *session, MsimMessage *reply, gpointer data) |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1737 { |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1738 GHashTable *body; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1739 gchar *body_str; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1740 GString *notification; |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1741 guint old_inbox_status; |
17950
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1742 guint i, n; |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1743 const gchar *froms[5], *tos[5], *urls[5], *subjects[5]; |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1744 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1745 /* Three parallel arrays for each new inbox message type. */ |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1746 static const gchar *inbox_keys[] = |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1747 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1748 "Mail", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1749 "BlogComment", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1750 "ProfileComment", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1751 "FriendRequest", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1752 "PictureComment" |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1753 }; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1754 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1755 static const guint inbox_bits[] = |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1756 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1757 MSIM_INBOX_MAIL, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1758 MSIM_INBOX_BLOG_COMMENT, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1759 MSIM_INBOX_PROFILE_COMMENT, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1760 MSIM_INBOX_FRIEND_REQUEST, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1761 MSIM_INBOX_PICTURE_COMMENT |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1762 }; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1763 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1764 static const gchar *inbox_urls[] = |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1765 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1766 "http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1767 "http://blog.myspace.com/index.cfm?fuseaction=blog", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1768 "http://home.myspace.com/index.cfm?fuseaction=user", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1769 "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1770 "http://home.myspace.com/index.cfm?fuseaction=user" |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1771 }; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1772 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1773 static const gchar *inbox_text[5]; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1774 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1775 /* Can't write _()'d strings in array initializers. Workaround. */ |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1776 inbox_text[0] = _("New mail messages"); |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1777 inbox_text[1] = _("New blog comments"); |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1778 inbox_text[2] = _("New profile comments"); |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1779 inbox_text[3] = _("New friend requests!"); |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1780 inbox_text[4] = _("New picture comments"); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1781 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1782 g_return_if_fail(reply != NULL); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1783 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1784 msim_msg_dump("msim_check_inbox_cb: reply=%s\n", reply); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1785 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1786 body_str = msim_msg_get_string(reply, "body"); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1787 g_return_if_fail(body_str != NULL); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1788 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1789 body = msim_parse_body(body_str); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1790 g_free(body_str); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1791 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1792 notification = g_string_new(""); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1793 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1794 old_inbox_status = session->inbox_status; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1795 |
17950
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1796 n = 0; |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1797 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1798 for (i = 0; i < sizeof(inbox_keys) / sizeof(inbox_keys[0]); ++i) |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1799 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1800 const gchar *key; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1801 guint bit; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1802 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1803 key = inbox_keys[i]; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1804 bit = inbox_bits[i]; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1805 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1806 if (g_hash_table_lookup(body, key)) |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1807 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1808 /* Notify only on when _changes_ from no mail -> has mail |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1809 * (edge triggered) */ |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1810 if (!(session->inbox_status & bit)) |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1811 { |
17950
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1812 purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n", |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1813 key, n); |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1814 |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1815 subjects[n] = inbox_text[i]; |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1816 froms[n] = _("MySpace"); |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1817 tos[n] = session->username; |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1818 /* TODO: append token, web challenge, so automatically logs in. |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1819 * Would also need to free strings because they won't be static |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1820 */ |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1821 urls[n] = inbox_urls[i]; |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1822 |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1823 ++n; |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1824 } else { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1825 purple_debug_info("msim", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1826 "msim_check_inbox_cb: already notified of %s\n", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1827 key); |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1828 } |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1829 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1830 session->inbox_status |= bit; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1831 } |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1832 } |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1833 |
17950
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1834 if (n) |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1835 { |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1836 purple_debug_info("msim", |
17950
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1837 "msim_check_inbox_cb: notifying of %d\n", n); |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1838 |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1839 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1840 purple_notify_emails(session->account, |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
1841 n, TRUE, subjects, froms, tos, urls, NULL, NULL); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1842 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1843 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1844 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1845 g_hash_table_destroy(body); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1846 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1847 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1848 /* Send request to check if there is new mail. */ |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1849 gboolean |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1850 msim_check_inbox(gpointer data) |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1851 { |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1852 MsimSession *session; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1853 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1854 session = (MsimSession *)data; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1855 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1856 purple_debug_info("msim", "msim_check_inbox: checking mail\n"); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1857 g_return_val_if_fail(msim_send(session, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1858 "persist", MSIM_TYPE_INTEGER, 1, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1859 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1860 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1861 "dsn", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_DSN, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1862 "lid", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_LID, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1863 "uid", MSIM_TYPE_INTEGER, session->userid, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1864 "rid", MSIM_TYPE_INTEGER, |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1865 msim_new_reply_callback(session, msim_check_inbox_cb, NULL), |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1866 "body", MSIM_TYPE_STRING, g_strdup(""), |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1867 NULL), TRUE); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1868 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1869 /* Always return true, so that we keep checking for mail. */ |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1870 return TRUE; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1871 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1872 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1873 /** Called when the session key arrives. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1874 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1875 msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1876 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1877 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1878 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1879 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1880 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1881 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1882 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1883 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1884 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1885 /* Comes with: proof,profileid,userid,uniquenick -- all same values |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1886 * some of the time, but can vary. This is our own user ID. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1887 session->userid = msim_msg_get_integer(msg, "userid"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1888 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1889 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1890 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1891 /* We now know are our own username, only after we're logged in.. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1892 * which is weird, but happens because you login with your email |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1893 * address and not username. Will be freed in msim_session_destroy(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1894 session->username = msim_msg_get_string(msg, "uniquenick"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1895 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1896 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1897 purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\n"); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1898 /* Notify servers of our current status. */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1899 msim_set_status(session->account, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1900 purple_account_get_active_status(session->account)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1901 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1902 /* Disable due to problems with timeouts. TODO: fix. */ |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1903 #ifdef MSIM_USE_KEEPALIVE |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1904 purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1905 (GSourceFunc)msim_check_alive, session); |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1906 #endif |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1907 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1908 purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1909 (GSourceFunc)msim_check_inbox, session); |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1910 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
1911 msim_check_inbox(session); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1912 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1913 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1914 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1915 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1916 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1917 * Process a message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1918 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1919 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1920 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1921 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1922 * @return TRUE if successful. FALSE if processing failed. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1923 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1924 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1925 msim_process(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1926 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1927 g_return_val_if_fail(session != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1928 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1929 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1930 #ifdef MSIM_DEBUG_MSG |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1931 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1932 msim_msg_dump("ready to process: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1933 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1934 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1935 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1936 if (msim_msg_get(msg, "nc")) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1937 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1938 return msim_login_challenge(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1939 } else if (msim_msg_get(msg, "sesskey")) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1940 return msim_we_are_logged_on(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1941 } else if (msim_msg_get(msg, "bm")) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1942 guint bm; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1943 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1944 bm = msim_msg_get_integer(msg, "bm"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1945 switch (bm) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1946 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1947 case MSIM_BM_STATUS: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1948 return msim_status(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1949 case MSIM_BM_INSTANT: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1950 return msim_incoming_im(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1951 case MSIM_BM_ACTION: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1952 return msim_incoming_action(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1953 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1954 /* Not really an IM, but show it for informational |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1955 * purposes during development. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1956 return msim_incoming_im(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1957 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1958 } else if (msim_msg_get(msg, "rid")) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1959 return msim_process_reply(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1960 } else if (msim_msg_get(msg, "error")) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1961 return msim_error(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1962 } else if (msim_msg_get(msg, "ka")) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1963 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1964 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1965 msim_unrecognized(session, msg, "in msim_process"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1966 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1967 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1968 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1969 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1970 /** Store an field of information about a buddy. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1971 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1972 msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1973 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1974 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1975 gchar *key_str, *value_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1976 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1977 buddy = (PurpleBuddy *)user_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1978 key_str = (gchar *)key; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1979 value_str = (gchar *)value; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1980 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1981 if (strcmp(key_str, "UserID") == 0 || |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1982 strcmp(key_str, "Age") == 0 || |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1983 strcmp(key_str, "TotalFriends") == 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1984 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1985 /* Certain fields get set as integers, instead of strings, for |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1986 * convenience. May not be the best way to do it, but having at least |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1987 * UserID as an integer is convenient...until it overflows! */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1988 purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1989 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1990 purple_blist_node_set_string(&buddy->node, key_str, value_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1991 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1992 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1993 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1994 /** Save buddy information to the buddy list from a user info reply message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1995 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1996 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1997 * @param msg The user information reply, with any amount of information. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1998 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1999 * The information is saved to the buddy's blist node, which ends up in blist.xml. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2000 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2001 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2002 msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2003 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2004 GHashTable *body; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2005 gchar *username, *body_str, *uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2006 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2007 guint rid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2008 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2009 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2010 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2011 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2012 rid = msim_msg_get_integer(msg, "rid"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2013 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2014 g_return_val_if_fail(rid != 0, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2015 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2016 body_str = msim_msg_get_string(msg, "body"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2017 g_return_val_if_fail(body_str != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2018 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2019 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2020 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2021 /* TODO: implement a better hash-like interface, and use it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2022 username = g_hash_table_lookup(body, "UserName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2023 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2024 if (!username) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2025 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2026 purple_debug_info("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2027 "msim_process_reply: not caching body, no UserName\n"); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2028 g_hash_table_destroy(body); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2029 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2030 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2031 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2032 uid = g_hash_table_lookup(body, "UserID"); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2033 if (!uid) |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2034 { |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2035 g_hash_table_destroy(body); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2036 g_return_val_if_fail(uid, FALSE); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2037 } |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2038 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2039 purple_debug_info("msim", "associating uid %d with username %s\n", uid, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2040 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2041 buddy = purple_find_buddy(session->account, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2042 if (buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2043 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2044 g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2045 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2046 |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2047 g_hash_table_destroy(body); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2048 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2049 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2050 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2051 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2052 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2053 * Process a persistance message reply from the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2054 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2055 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2056 * @param msg Message reply from server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2057 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2058 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2059 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2060 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2061 msim_process_reply(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2062 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2063 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2064 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2065 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2066 if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2067 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2068 MSIM_USER_LOOKUP_CB cb; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2069 gpointer data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2070 guint rid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2071 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2072 msim_store_buddy_info(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2073 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2074 rid = msim_msg_get_integer(msg, "rid"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2075 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2076 /* If a callback is registered for this userid lookup, call it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2077 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2078 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2079 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2080 if (cb) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2081 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2082 purple_debug_info("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2083 "msim_process_body: calling callback now\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2084 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2085 cb(session, msim_msg_clone(msg), data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2086 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2087 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2088 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2089 purple_debug_info("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2090 "msim_process_body: no callback for rid %d\n", rid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2091 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2092 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2093 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2094 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2095 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2096 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2097 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2098 * Handle an error from the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2099 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2100 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2101 * @param msg The message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2102 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2103 * @return TRUE if successfully reported error. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2104 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2105 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2106 msim_error(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2107 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2108 gchar *errmsg, *full_errmsg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2109 guint err; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2110 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2111 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2112 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2113 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2114 err = msim_msg_get_integer(msg, "err"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2115 errmsg = msim_msg_get_string(msg, "errmsg"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2116 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2117 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2118 errmsg ? errmsg : "no 'errmsg' given"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2119 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2120 g_free(errmsg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2121 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2122 purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2123 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2124 purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2125 full_errmsg, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2126 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2127 /* Destroy session if fatal. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2128 if (msim_msg_get(msg, "fatal")) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2129 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2130 purple_debug_info("msim", "fatal error, closing\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2131 purple_connection_error(session->gc, full_errmsg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2132 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2133 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2134 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2135 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2136 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2137 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2138 * Process incoming status messages. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2139 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2140 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2141 * @param msg Status update message. Caller frees. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2142 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2143 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2144 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2145 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2146 msim_status(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2147 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2148 PurpleBuddyList *blist; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2149 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2150 //PurpleStatus *status; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2151 gchar **status_array; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2152 GList *list; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2153 gchar *status_headline; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2154 gchar *status_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2155 gint i, status_code, purple_status_code; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2156 gchar *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2157 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2158 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2159 g_return_val_if_fail(msg != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2160 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2161 status_str = msim_msg_get_string(msg, "msg"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2162 g_return_val_if_fail(status_str != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2163 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2164 msim_msg_dump("msim_status msg=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2165 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2166 /* Helpfully looked up by msim_incoming_resolve() for us. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2167 username = msim_msg_get_string(msg, "_username"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2168 /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2169 * the buddy list, if the UserID was stored along with it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2170 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2171 if (username == NULL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2172 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2173 g_free(status_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2174 g_return_val_if_fail(NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2175 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2176 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2177 purple_debug_info("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2178 "msim_status: updating status for <%s> to <%s>\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2179 username, status_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2180 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2181 /* TODO: generic functions to split into a GList, part of MsimMessage */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2182 status_array = g_strsplit(status_str, "|", 0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2183 for (list = NULL, i = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2184 status_array[i]; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2185 i++) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2186 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2187 /* Note: this adds the 0th ordinal too, which might not be a value |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2188 * at all (the 0 in the 0|1|2|3... status fields, but 0 always appears blank). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2189 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2190 list = g_list_append(list, status_array[i]); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2191 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2192 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2193 /* Example fields: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2194 * |s|0|ss|Offline |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2195 * |s|1|ss|:-)|ls||ip|0|p|0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2196 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2197 * TODO: write list support in MsimMessage, and use it here. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2198 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2199 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2200 status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2201 purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2202 status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2203 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2204 blist = purple_get_blist(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2205 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2206 /* Add buddy if not found */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2207 buddy = purple_find_buddy(session->account, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2208 if (!buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2209 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2210 purple_debug_info("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2211 "msim_status: making new buddy for %s\n", username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2212 buddy = purple_buddy_new(session->account, username, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2213 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2214 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2215 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2216 /* All buddies on list should have 'uid' integer associated with them. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2217 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2218 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2219 msim_store_buddy_info(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2220 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2221 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2222 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2223 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2224 purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2225 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2226 /* Set user status */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2227 switch (status_code) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2228 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2229 case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2230 purple_status_code = PURPLE_STATUS_OFFLINE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2231 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2232 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2233 case MSIM_STATUS_CODE_ONLINE: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2234 purple_status_code = PURPLE_STATUS_AVAILABLE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2235 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2236 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2237 case MSIM_STATUS_CODE_AWAY: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2238 purple_status_code = PURPLE_STATUS_AWAY; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2239 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2240 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2241 case MSIM_STATUS_CODE_IDLE: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2242 /* will be handled below */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2243 purple_status_code = -1; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2244 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2245 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2246 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2247 purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2248 username, status_code); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2249 purple_status_code = PURPLE_STATUS_AVAILABLE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2250 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2251 |
17945
cf55077a3752
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17944
diff
changeset
|
2252 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2253 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2254 if (status_code == MSIM_STATUS_CODE_IDLE) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2255 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2256 purple_debug_info("msim", "msim_status: got idle: %s\n", username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2257 purple_prpl_got_user_idle(session->account, username, TRUE, time(NULL)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2258 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2259 /* All other statuses indicate going back to non-idle. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2260 purple_prpl_got_user_idle(session->account, username, FALSE, time(NULL)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2261 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2262 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2263 g_strfreev(status_array); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2264 g_free(status_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2265 g_free(username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2266 g_list_free(list); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2267 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2268 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2269 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2270 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2271 /** Add a buddy to user's buddy list. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2272 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2273 msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2274 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2275 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2276 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2277 /* MsimMessage *msg_blocklist; */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2278 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2279 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2280 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2281 group ? group->name : "(no group)"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2282 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2283 msg = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2284 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2285 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2286 /* "newprofileid" will be inserted here with uid. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2287 "reason", MSIM_TYPE_STRING, g_strdup(""), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2288 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2289 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2290 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2291 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2292 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2293 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2294 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2295 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2296 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2297 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2298 /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2299 * buddy list since Purple adds it locally. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2300 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2301 /* TODO: Update blocklist. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2302 #if 0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2303 msg_blocklist = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2304 "persist", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2305 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2306 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2307 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2308 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2309 /* TODO: Use msim_new_reply_callback to get rid. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2310 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2311 "body", MSIM_TYPE_STRING, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2312 g_strdup_printf("ContactID=<uid>\034" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2313 "GroupName=%s\034" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2314 "Position=1000\034" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2315 "Visibility=1\034" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2316 "NickName=\034" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2317 "NameSelect=0", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2318 "Friends" /*group->name*/ )); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2319 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2320 if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2321 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2322 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2323 msim_msg_free(msg_blocklist); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2324 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2325 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2326 msim_msg_free(msg_blocklist); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2327 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2328 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2329 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2330 /** Perform actual postprocessing on a message, adding userid as specified. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2331 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2332 * @param msg The message to postprocess. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2333 * @param uid_before Name of field where to insert new field before, or NULL for end. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2334 * @param uid_field_name Name of field to add uid to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2335 * @param uid The userid to insert. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2336 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2337 * If the field named by uid_field_name already exists, then its string contents will |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2338 * be used for the field, except "<uid>" will be replaced by the userid. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2339 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2340 * If the field named by uid_field_name does not exist, it will be added before the |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2341 * field named by uid_before, as an integer, with the userid. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2342 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2343 * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2344 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2345 MsimMessage * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2346 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2347 const gchar *uid_field_name, guint uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2348 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2349 purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2350 uid_field_name, uid_before, uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2351 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2352 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2353 /* First, check - if the field already exists, treat it as a format string. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2354 if (msim_msg_get(msg, uid_field_name)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2355 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2356 MsimMessageElement *elem; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2357 gchar *fmt_string; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2358 gchar *uid_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2359 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2360 /* Warning: this probably violates the encapsulation of MsimMessage */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2361 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2362 elem = msim_msg_get(msg, uid_field_name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2363 g_return_val_if_fail(elem->type == MSIM_TYPE_STRING, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2364 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2365 /* Get the raw string, not with msim_msg_get_string() since that copies it. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2366 * Want the original string so can free it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2367 fmt_string = (gchar *)(elem->data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2368 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2369 uid_str = g_strdup_printf("%d", uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2370 elem->data = str_replace(fmt_string, "<uid>", uid_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2371 g_free(uid_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2372 g_free(fmt_string); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2373 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2374 purple_debug_info("msim", "msim_postprocess_outgoing_cb: formatted new string, %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2375 elem->data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2376 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2377 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2378 /* Otherwise, insert new field into outgoing message. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2379 msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2380 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2381 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2382 return msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2383 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2384 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2385 /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2386 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2387 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2388 * @param userinfo The user information reply message, containing the user ID |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2389 * @param data The message to postprocess and send. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2390 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2391 * The data message should contain these fields: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2392 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2393 * _uid_field_name: string, name of field to add with userid from userinfo message |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2394 * _uid_before: string, name of field before field to insert, or NULL for end |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2395 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2396 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2397 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2398 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2399 msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2400 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2401 gchar *body_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2402 GHashTable *body; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2403 gchar *uid, *uid_field_name, *uid_before; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2404 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2405 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2406 msg = (MsimMessage *)data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2407 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2408 msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2409 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2410 /* Obtain userid from userinfo message. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2411 body_str = msim_msg_get_string(userinfo, "body"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2412 g_return_if_fail(body_str != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2413 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2414 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2415 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2416 uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2417 g_hash_table_destroy(body); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2418 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2419 uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2420 uid_before = msim_msg_get_string(msg, "_uid_before"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2421 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2422 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2423 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2424 /* Send */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2425 if (!msim_msg_send(session, msg)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2426 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2427 purple_debug_info("msim", "msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2428 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2429 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2430 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2431 /* Free field names AFTER sending message, because MsimMessage does NOT copy |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2432 * field names - instead, treats them as static strings (which they usually are). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2433 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2434 g_free(uid_field_name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2435 g_free(uid_before); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2436 |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2437 g_hash_table_destroy(body); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2438 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2439 //msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2440 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2441 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2442 /** Postprocess and send a message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2443 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2444 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2445 * @param msg Message to postprocess. Will NOT be freed. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2446 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2447 * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2448 * @param uid_before Name of existing field to insert username field before. Static string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2449 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2450 * @return Postprocessed message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2451 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2452 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2453 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2454 const gchar *username, const gchar *uid_field_name, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2455 const gchar *uid_before) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2456 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2457 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2458 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2459 gboolean rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2460 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2461 /* Store information for msim_postprocess_outgoing_cb(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2462 purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2463 username, uid_field_name, uid_before); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2464 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2465 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2466 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2467 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2468 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2469 /* First, try the most obvious. If numeric userid is given, use that directly. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2470 if (msim_is_userid(username)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2471 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2472 uid = atol(username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2473 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2474 /* Next, see if on buddy list and know uid. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2475 buddy = purple_find_buddy(session->account, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2476 if (buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2477 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2478 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2479 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2480 uid = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2481 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2482 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2483 if (!buddy || !uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2484 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2485 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2486 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2487 username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2488 msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2489 /* TODO: where is cloned message freed? Should be in _cb. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2490 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2491 return TRUE; /* not sure of status yet - haven't sent! */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2492 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2493 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2494 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2495 /* Already have uid, postprocess and send msg immediately. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2496 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2497 username, uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2498 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2499 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2500 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2501 msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2502 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2503 rc = msim_msg_send(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2504 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2505 //msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2506 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2507 return rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2508 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2509 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2510 /** Remove a buddy from the user's buddy list. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2511 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2512 msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2513 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2514 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2515 MsimMessage *delbuddy_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2516 MsimMessage *persist_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2517 MsimMessage *blocklist_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2518 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2519 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2520 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2521 delbuddy_msg = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2522 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2523 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2524 /* 'delprofileid' with uid will be inserted here. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2525 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2526 /* TODO: free msg */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2527 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2528 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2529 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2530 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2531 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2532 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2533 persist_msg = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2534 "persist", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2535 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2536 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2537 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2538 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2539 "uid", MSIM_TYPE_INTEGER, session->userid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2540 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2541 /* <uid> will be replaced by postprocessing */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2542 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2543 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2544 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2545 /* TODO: free msg */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2546 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2547 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2548 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2549 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2550 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2551 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2552 blocklist_msg = msim_msg_new(TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2553 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2554 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2555 /* TODO: MsimMessage lists */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2556 "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2557 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2558 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2559 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2560 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2561 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2562 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2563 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2564 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2565 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2566 /** Return whether the buddy can be messaged while offline. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2567 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2568 * The protocol supports offline messages in just the same way as online |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2569 * messages. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2570 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2571 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2572 msim_offline_message(const PurpleBuddy *buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2573 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2574 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2575 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2576 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2577 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2578 * Callback when input available. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2579 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2580 * @param gc_uncasted A PurpleConnection pointer. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2581 * @param source File descriptor. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2582 * @param cond PURPLE_INPUT_READ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2583 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2584 * Reads the input, and calls msim_preprocess_incoming() to handle it. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2585 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2586 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2587 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2588 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2589 PurpleConnection *gc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2590 PurpleAccount *account; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2591 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2592 gchar *end; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2593 int n; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2594 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2595 g_return_if_fail(gc_uncasted != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2596 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2597 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2598 gc = (PurpleConnection *)(gc_uncasted); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2599 account = purple_connection_get_account(gc); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2600 session = gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2601 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2602 g_return_if_fail(cond == PURPLE_INPUT_READ); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2603 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2604 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2605 /* Mark down that we got data, so don't timeout. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2606 session->last_comm = time(NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2607 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2608 /* Only can handle so much data at once... |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2609 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2610 * Should be large enough to hold the largest protocol message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2611 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2612 if (session->rxoff == MSIM_READ_BUF_SIZE) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2613 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2614 purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2615 MSIM_READ_BUF_SIZE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2616 purple_connection_error(gc, _("Read buffer full")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2617 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2618 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2619 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2620 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2621 session->rxoff, MSIM_READ_BUF_SIZE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2622 MSIM_READ_BUF_SIZE - session->rxoff); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2623 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2624 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2625 * the file descriptor, but it sometimes differs from the 'source' parameter. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2626 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2627 n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2628 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2629 if (n < 0 && errno == EAGAIN) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2630 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2631 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2632 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2633 else if (n < 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2634 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2635 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2636 "error=%s, source=%d, fd=%d (%X))\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2637 n, strerror(errno), source, session->fd, session->fd); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2638 purple_connection_error(gc, _("Read error")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2639 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2640 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2641 else if (n == 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2642 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2643 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2644 purple_connection_error(gc, _("Server has disconnected")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2645 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2646 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2647 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2648 /* Null terminate */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2649 session->rxbuf[session->rxoff + n] = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2650 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2651 #ifdef MSIM_CHECK_EMBEDDED_NULLS |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2652 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2653 if (strlen(session->rxbuf + session->rxoff) != n) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2654 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2655 /* Occurs after login, but it is not a null byte. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2656 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2657 "--null byte encountered?\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2658 strlen(session->rxbuf + session->rxoff), n); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2659 //purple_connection_error(gc, "Invalid message - null byte on input"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2660 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2661 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2662 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2663 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2664 session->rxoff += n; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2665 purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2666 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2667 #ifdef MSIM_DEBUG_RXBUF |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2668 purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2669 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2670 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2671 /* Look for \\final\\ end markers. If found, process message. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2672 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2673 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2674 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2675 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2676 #ifdef MSIM_DEBUG_RXBUF |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2677 purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2678 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2679 *end = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2680 msg = msim_parse(g_strdup(session->rxbuf)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2681 if (!msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2682 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2683 purple_debug_info("msim", "msim_input_cb: couldn't parse <%s>\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2684 session->rxbuf); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2685 purple_connection_error(gc, _("Unparseable message")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2686 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2687 else |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2688 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2689 /* Process message and then free it (processing function should |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2690 * clone message if it wants to keep it afterwards.) */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2691 if (!msim_preprocess_incoming(session, msg)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2692 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2693 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2694 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2695 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2696 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2697 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2698 /* Move remaining part of buffer to beginning. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2699 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2700 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2701 MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2702 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2703 /* Clear end of buffer */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2704 //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2705 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2706 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2707 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2708 /* Setup a callback, to be called when a reply is received with the returned rid. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2709 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2710 * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2711 * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2712 * |
17951 | 2713 * @return The request/reply ID, used to link replies with requests, or -1. |
2714 * Put the rid in your request, 'rid' field. | |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2715 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2716 * TODO: Make more generic and more specific: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2717 * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2718 * 2) data - make it an MsimMessage? |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2719 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2720 guint |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2721 msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2722 gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2723 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2724 guint rid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2725 |
17951 | 2726 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
2727 | |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2728 rid = session->next_rid++; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2729 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2730 g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2731 g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2732 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2733 return rid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2734 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2735 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2736 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2737 * Callback when connected. Sets up input handlers. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2738 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2739 * @param data A PurpleConnection pointer. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2740 * @param source File descriptor. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2741 * @param error_message |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2742 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2743 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2744 msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2745 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2746 PurpleConnection *gc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2747 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2748 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2749 g_return_if_fail(data != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2750 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2751 gc = (PurpleConnection *)data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2752 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2753 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2754 if (source < 0) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2755 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2756 purple_connection_error(gc, _("Couldn't connect to host")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2757 purple_connection_error(gc, g_strdup_printf( |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2758 _("Couldn't connect to host: %s (%d)"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2759 error_message ? error_message : "no message given", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2760 source)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2761 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2762 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2763 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2764 session->fd = source; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2765 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2766 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2767 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2768 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2769 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2770 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2771 /* Session methods */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2772 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2773 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2774 * Create a new MSIM session. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2775 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2776 * @param acct The account to create the session from. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2777 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2778 * @return Pointer to a new session. Free with msim_session_destroy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2779 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2780 MsimSession * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2781 msim_session_new(PurpleAccount *acct) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2782 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2783 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2784 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2785 g_return_val_if_fail(acct != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2786 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2787 session = g_new0(MsimSession, 1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2788 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2789 session->magic = MSIM_SESSION_STRUCT_MAGIC; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2790 session->account = acct; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2791 session->gc = purple_account_get_connection(acct); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2792 session->sesskey = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2793 session->userid = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2794 session->username = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2795 session->fd = -1; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2796 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2797 /* TODO: Remove. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2798 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2799 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2800 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2801 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2802 they could be integers inside gpointers |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2803 or strings, so I don't freed them. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2804 Figure this out, once free cache. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2805 session->rxoff = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2806 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2807 session->next_rid = 1; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2808 session->last_comm = time(NULL); |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2809 session->inbox_status = 0; |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2810 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2811 return session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2812 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2813 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2814 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2815 * Free a session. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2816 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2817 * @param session The session to destroy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2818 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2819 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2820 msim_session_destroy(MsimSession *session) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2821 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2822 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2823 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2824 session->magic = -1; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2825 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2826 g_free(session->rxbuf); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2827 g_free(session->username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2828 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2829 /* TODO: Remove. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2830 g_hash_table_destroy(session->user_lookup_cb); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2831 g_hash_table_destroy(session->user_lookup_cb_data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2832 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2833 g_free(session); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2834 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2835 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2836 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2837 * Close the connection. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2838 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2839 * @param gc The connection. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2840 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2841 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2842 msim_close(PurpleConnection *gc) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2843 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2844 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2845 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2846 if (gc == NULL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2847 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2848 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2849 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2850 if (session == NULL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2851 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2852 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2853 gc->proto_data = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2854 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2855 if (!MSIM_SESSION_VALID(session)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2856 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2857 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2858 if (session->gc->inpa) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2859 purple_input_remove(session->gc->inpa); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2860 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2861 msim_session_destroy(session); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2862 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2863 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2864 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2865 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2866 * Check if a string is a userid (all numeric). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2867 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2868 * @param user The user id, email, or name. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2869 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2870 * @return TRUE if is userid, FALSE if not. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2871 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2872 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2873 msim_is_userid(const gchar *user) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2874 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2875 g_return_val_if_fail(user != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2876 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2877 return strspn(user, "0123456789") == strlen(user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2878 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2879 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2880 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2881 * Check if a string is an email address (contains an @). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2882 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2883 * @param user The user id, email, or name. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2884 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2885 * @return TRUE if is an email, FALSE if not. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2886 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2887 * This function is not intended to be used as a generic |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2888 * means of validating email addresses, but to distinguish |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2889 * between a user represented by an email address from |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2890 * other forms of identification. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2891 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2892 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2893 msim_is_email(const gchar *user) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2894 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2895 g_return_val_if_fail(user != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2896 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2897 return strchr(user, '@') != NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2898 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2899 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2900 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2901 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2902 * Asynchronously lookup user information, calling callback when receive result. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2903 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2904 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2905 * @param user The user id, email address, or username. Not freed. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2906 * @param cb Callback, called with user information when available. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2907 * @param data An arbitray data pointer passed to the callback. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2908 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2909 /* TODO: change to not use callbacks */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2910 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2911 msim_lookup_user(MsimSession *session, const gchar *user, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2912 MSIM_USER_LOOKUP_CB cb, gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2913 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2914 gchar *field_name; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2915 guint rid, cmd, dsn, lid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2916 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2917 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2918 g_return_if_fail(user != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2919 g_return_if_fail(cb != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2920 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2921 purple_debug_info("msim", "msim_lookup_userid: " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2922 "asynchronously looking up <%s>\n", user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2923 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2924 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2925 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2926 /* Setup callback. Response will be associated with request using 'rid'. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2927 rid = msim_new_reply_callback(session, cb, data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2928 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2929 /* Send request */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2930 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2931 cmd = MSIM_CMD_GET; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2932 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2933 if (msim_is_userid(user)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2934 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2935 field_name = "UserID"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2936 dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2937 lid = MG_MYSPACE_INFO_BY_ID_LID; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2938 } else if (msim_is_email(user)) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2939 field_name = "Email"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2940 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2941 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2942 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2943 field_name = "UserName"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2944 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2945 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2946 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2947 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2948 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2949 g_return_if_fail(msim_send(session, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2950 "persist", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2951 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2952 "cmd", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2953 "dsn", MSIM_TYPE_INTEGER, dsn, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2954 "uid", MSIM_TYPE_INTEGER, session->userid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2955 "lid", MSIM_TYPE_INTEGER, lid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2956 "rid", MSIM_TYPE_INTEGER, rid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2957 /* TODO: dictionary field type */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2958 "body", MSIM_TYPE_STRING, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2959 g_strdup_printf("%s=%s", field_name, user), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2960 NULL)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2961 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2962 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2963 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2964 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2965 * Obtain the status text for a buddy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2966 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2967 * @param buddy The buddy to obtain status text for. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2968 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2969 * @return Status text, or NULL if error. Caller g_free()'s. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2970 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2971 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2972 char * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2973 msim_status_text(PurpleBuddy *buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2974 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2975 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2976 const gchar *display_name, *headline; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2977 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2978 g_return_val_if_fail(buddy != NULL, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2979 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2980 session = (MsimSession *)buddy->account->gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2981 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2982 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2983 display_name = headline = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2984 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2985 /* Retrieve display name and/or headline, depending on user preference. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2986 if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2987 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2988 display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2989 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2990 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2991 if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2992 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2993 headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2994 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2995 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2996 /* Return appropriate combination of display name and/or headline, or neither. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2997 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2998 if (display_name && headline) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2999 return g_strconcat(display_name, " ", headline, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3000 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3001 if (display_name) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3002 return g_strdup(display_name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3003 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3004 if (headline) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3005 return g_strdup(headline); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3006 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3007 return NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3008 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3009 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3010 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3011 * Obtain the tooltip text for a buddy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3012 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3013 * @param buddy Buddy to obtain tooltip text on. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3014 * @param user_info Variable modified to have the tooltip text. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3015 * @param full TRUE if should obtain full tooltip text. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3016 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3017 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3018 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3019 msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3020 gboolean full) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3021 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3022 const gchar *str, *str2; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3023 gint n; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3024 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3025 g_return_if_fail(buddy != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3026 g_return_if_fail(user_info != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3027 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3028 if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3029 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3030 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3031 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3032 session = (MsimSession *)buddy->account->gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3033 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3034 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3035 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3036 /* TODO: if (full), do something different */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3037 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3038 /* Useful to identify the account the tooltip refers to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3039 * Other prpls show this. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3040 str = purple_blist_node_get_string(&buddy->node, "UserName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3041 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3042 purple_notify_user_info_add_pair(user_info, _("User Name"), str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3043 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3044 /* a/s/l...the vitals */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3045 n = purple_blist_node_get_int(&buddy->node, "Age"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3046 if (n) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3047 purple_notify_user_info_add_pair(user_info, _("Age"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3048 g_strdup_printf("%d", n)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3049 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3050 str = purple_blist_node_get_string(&buddy->node, "Gender"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3051 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3052 purple_notify_user_info_add_pair(user_info, _("Gender"), str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3053 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3054 str = purple_blist_node_get_string(&buddy->node, "Location"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3055 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3056 purple_notify_user_info_add_pair(user_info, _("Location"), str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3057 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3058 /* Other information */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3059 str = purple_blist_node_get_string(&buddy->node, "Headline"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3060 if (str) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3061 purple_notify_user_info_add_pair(user_info, _("Headline"), str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3062 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3063 str = purple_blist_node_get_string(&buddy->node, "BandName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3064 str2 = purple_blist_node_get_string(&buddy->node, "SongName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3065 if (str || str2) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3066 purple_notify_user_info_add_pair(user_info, _("Song"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3067 g_strdup_printf("%s - %s", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3068 str ? str : _("Unknown Artist"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3069 str2 ? str2 : _("Unknown Song"))); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3070 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3071 n = purple_blist_node_get_int(&buddy->node, "TotalFriends"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3072 if (n) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3073 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3074 g_strdup_printf("%d", n)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3075 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3076 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3077 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3078 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3079 /** Callbacks called by Purple, to access this plugin. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3080 PurplePluginProtocolInfo prpl_info = |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3081 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3082 /* options */ |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3083 OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3084 | OPT_PROTO_MAIL_CHECK, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3085 |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3086 /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3087 NULL, /* user_splits */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3088 NULL, /* protocol_options */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3089 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3090 msim_list_icon, /* list_icon */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3091 NULL, /* list_emblems */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3092 msim_status_text, /* status_text */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3093 msim_tooltip_text, /* tooltip_text */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3094 msim_status_types, /* status_types */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3095 NULL, /* blist_node_menu */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3096 NULL, /* chat_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3097 NULL, /* chat_info_defaults */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3098 msim_login, /* login */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3099 msim_close, /* close */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3100 msim_send_im, /* send_im */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3101 NULL, /* set_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3102 msim_send_typing, /* send_typing */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3103 msim_get_info, /* get_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3104 msim_set_status, /* set_status */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3105 msim_set_idle, /* set_idle */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3106 NULL, /* change_passwd */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3107 msim_add_buddy, /* add_buddy */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3108 NULL, /* add_buddies */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3109 msim_remove_buddy, /* remove_buddy */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3110 NULL, /* remove_buddies */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3111 NULL, /* add_permit */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3112 NULL, /* add_deny */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3113 NULL, /* rem_permit */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3114 NULL, /* rem_deny */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3115 NULL, /* set_permit_deny */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3116 NULL, /* join_chat */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3117 NULL, /* reject chat invite */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3118 NULL, /* get_chat_name */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3119 NULL, /* chat_invite */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3120 NULL, /* chat_leave */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3121 NULL, /* chat_whisper */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3122 NULL, /* chat_send */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3123 NULL, /* keepalive */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3124 NULL, /* register_user */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3125 NULL, /* get_cb_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3126 NULL, /* get_cb_away */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3127 NULL, /* alias_buddy */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3128 NULL, /* group_buddy */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3129 NULL, /* rename_group */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3130 NULL, /* buddy_free */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3131 NULL, /* convo_closed */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3132 NULL, /* normalize */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3133 NULL, /* set_buddy_icon */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3134 NULL, /* remove_group */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3135 NULL, /* get_cb_real_name */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3136 NULL, /* set_chat_topic */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3137 NULL, /* find_blist_chat */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3138 NULL, /* roomlist_get_list */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3139 NULL, /* roomlist_cancel */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3140 NULL, /* roomlist_expand_category */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3141 NULL, /* can_receive_file */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3142 NULL, /* send_file */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3143 NULL, /* new_xfer */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3144 msim_offline_message, /* offline_message */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3145 NULL, /* whiteboard_prpl_ops */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3146 msim_send_really_raw, /* send_raw */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3147 NULL, /* roomlist_room_serialize */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3148 NULL, /* _purple_reserved1 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3149 NULL, /* _purple_reserved2 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3150 NULL, /* _purple_reserved3 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3151 NULL /* _purple_reserved4 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3152 }; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3153 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3154 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3155 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3156 /** Based on MSN's plugin info comments. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3157 PurplePluginInfo info = |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3158 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3159 PURPLE_PLUGIN_MAGIC, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3160 PURPLE_MAJOR_VERSION, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3161 PURPLE_MINOR_VERSION, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3162 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3163 NULL, /**< ui_requirement */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3164 0, /**< flags */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3165 NULL, /**< dependencies */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3166 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3167 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3168 "prpl-myspace", /**< id */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3169 "MySpaceIM", /**< name */ |
17951 | 3170 "0.12", /**< version */ |
17693
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3171 /** summary */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3172 "MySpaceIM Protocol Plugin", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3173 /** description */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3174 "MySpaceIM Protocol Plugin", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3175 "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3176 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3177 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3178 msim_load, /**< load */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3179 NULL, /**< unload */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3180 NULL, /**< destroy */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3181 NULL, /**< ui_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3182 &prpl_info, /**< extra_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3183 NULL, /**< prefs_info */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3184 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3185 /* msim_actions */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3186 NULL, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3187 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3188 NULL, /**< reserved1 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3189 NULL, /**< reserved2 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3190 NULL, /**< reserved3 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3191 NULL /**< reserved4 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3192 }; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3193 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3194 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3195 #ifdef MSIM_SELF_TEST |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3196 /** Test functions. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3197 * Used to test or try out the internal workings of msimprpl. If you're reading |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3198 * this code for the first time, these functions can be instructive in how |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3199 * msimprpl is architected. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3200 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3201 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3202 msim_test_all(void) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3203 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3204 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3205 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3206 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3207 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3208 failures += msim_test_xml(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3209 failures += msim_test_msg(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3210 failures += msim_test_escaping(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3211 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3212 if (failures) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3213 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3214 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3215 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3216 else |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3217 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3218 purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3219 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3220 exit(0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3221 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3222 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3223 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3224 msim_test_xml(void) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3225 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3226 gchar *msg_text; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3227 xmlnode *root, *n; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3228 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3229 char *s; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3230 int len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3231 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3232 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3233 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3234 msg_text = "<p><f n=\"Arial\" h=\"12\">woo!</f>xxx<c v='black'>yyy</c></p>"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3235 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3236 purple_debug_info("msim", "msim_test_xml: msg_text=%s\n", msg_text); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3237 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3238 root = xmlnode_from_str(msg_text, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3239 if (!root) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3240 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3241 purple_debug_info("msim", "there is no root\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3242 exit(0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3243 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3244 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3245 purple_debug_info("msim", "root name=%s, child name=%s\n", root->name, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3246 root->child->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3247 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3248 purple_debug_info("msim", "last child name=%s\n", root->lastchild->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3249 purple_debug_info("msim", "Root xml=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3250 xmlnode_to_str(root, &len)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3251 purple_debug_info("msim", "Child xml=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3252 xmlnode_to_str(root->child, &len)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3253 purple_debug_info("msim", "Lastchild xml=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3254 xmlnode_to_str(root->lastchild, &len)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3255 purple_debug_info("msim", "Next xml=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3256 xmlnode_to_str(root->next, &len)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3257 purple_debug_info("msim", "Next data=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3258 xmlnode_get_data(root->next)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3259 purple_debug_info("msim", "Child->next xml=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3260 xmlnode_to_str(root->child->next, &len)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3261 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3262 for (n = root->child; n; n = n->next) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3263 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3264 if (n->name) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3265 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3266 purple_debug_info("msim", " ** n=%s\n",n->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3267 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3268 purple_debug_info("msim", " ** n data=%s\n", n->data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3269 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3270 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3271 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3272 purple_debug_info("msim", "root data=%s, child data=%s, child 'h'=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3273 xmlnode_get_data(root), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3274 xmlnode_get_data(root->child), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3275 xmlnode_get_attrib(root->child, "h")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3276 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3277 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3278 for (n = root->child; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3279 n != NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3280 n = n->next) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3281 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3282 purple_debug_info("msim", "next name=%s\n", n->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3283 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3284 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3285 s = xmlnode_to_str(root, &len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3286 s[len] = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3287 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3288 purple_debug_info("msim", "str: %s\n", s); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3289 g_free(s); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3290 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3291 xmlnode_free(root); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3292 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3293 exit(0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3294 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3295 return failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3296 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3297 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3298 /** Test MsimMessage for basic functionality. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3299 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3300 msim_test_msg(void) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3301 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3302 MsimMessage *msg, *msg_cloned; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3303 gchar *packed, *packed_expected, *packed_cloned; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3304 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3305 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3306 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3307 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3308 purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3309 msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3310 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3311 /* Append some new elements. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3312 msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3313 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3314 msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3315 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3316 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3317 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3318 msim_msg_dump("msg debug str=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3319 packed = msim_msg_pack(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3320 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3321 purple_debug_info("msim", "msg packed=%s\n", packed); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3322 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3323 packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3324 "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3325 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3326 if (0 != strcmp(packed, packed_expected)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3327 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3328 purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3329 ++failures, packed, packed_expected); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3330 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3331 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3332 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3333 msg_cloned = msim_msg_clone(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3334 packed_cloned = msim_msg_pack(msg_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3335 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3336 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3337 if (0 != strcmp(packed, packed_cloned)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3338 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3339 purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3340 ++failures, packed_cloned, packed); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3341 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3342 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3343 g_free(packed); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3344 g_free(packed_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3345 msim_msg_free(msg_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3346 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3347 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3348 return failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3349 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3350 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3351 /** Test protocol-level escaping/unescaping. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3352 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3353 msim_test_escaping(void) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3354 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3355 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3356 gchar *raw, *escaped, *unescaped, *expected; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3357 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3358 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3359 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3360 purple_debug_info("msim", "\n\nTesting escaping\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3361 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3362 raw = "hello/world\\hello/world"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3363 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3364 escaped = msim_escape(raw); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3365 purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3366 expected = "hello/1world/2hello/1world"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3367 if (0 != strcmp(escaped, expected)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3368 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3369 purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3370 ++failures, escaped, expected); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3371 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3372 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3373 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3374 unescaped = msim_unescape(escaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3375 g_free(escaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3376 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3377 if (0 != strcmp(raw, unescaped)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3378 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3379 purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3380 ++failures, raw, unescaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3381 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3382 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3383 return failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3384 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3385 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3386 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3387 /** Initialize plugin. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3388 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3389 init_plugin(PurplePlugin *plugin) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3390 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3391 PurpleAccountOption *option; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3392 #ifdef MSIM_SELF_TEST |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3393 msim_test_all(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3394 #endif /* MSIM_SELF_TEST */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3395 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3396 /* TODO: default to automatically try different ports. Make the user be |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3397 * able to set the first port to try (like LastConnectedPort in Windows client). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3398 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3399 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3400 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3401 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3402 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3403 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3404 option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3405 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3406 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3407 option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3408 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3409 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3410 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3411 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |