Mercurial > pidgin
annotate libpurple/protocols/myspace/myspace.c @ 18893:cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
name<=>symbol data structure, for (much better) clarity.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Sat, 11 Aug 2007 04:54:13 +0000 |
parents | 138e9be2f917 |
children | daedc9647341 |
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 |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
40 |
17960
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
41 /* Loosely based on Miranda plugin by Scott Ellis, formatting.cpp, |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
42 * https://server.scottellis.com.au/websvn/filedetails.php?repname=Miranda+Plugins&path=%2FMySpace%2Fformatting.cpp&rev=0&sc=0 */ |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
43 |
17960
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
44 /* The names in in emoticon_names (for <i n=whatever>) map to corresponding |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
45 * entries in emoticon_symbols (for the ASCII representation of the emoticon). |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
46 * |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
47 * Multiple emoticon symbols in Pidgin can map to one name. List the |
17960
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
48 * canonical form, as inserted by the "Smile!" dialog, first. For example, |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
49 * :) comes before :-), because although both are recognized as 'happy', |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
50 * the first is inserted by the smiley button. |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
51 * |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
52 * Note that symbols are case-sensitive in Pidgin -- :-X is not :-x. */ |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
53 |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
54 /* TODO: Use extra smileys not in default theme! Hylke is also working on |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
55 * some new smileys specific to MySpaceIM, use them too! */ |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
56 static struct MSIM_EMOTICON |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
57 { |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
58 gchar *name; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
59 gchar *symbol; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
60 } msim_emoticons[] = { |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
61 { "bigsmile", ":D" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
62 { "growl", ">:o" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
63 { "growl", ">:O" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
64 { "mad", ":-[" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
65 { "scared", "=-O" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
66 { "scared", "=-o" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
67 { "tongue", ":P" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
68 { "tongue", ":p" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
69 { "devil", "O:-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
70 { "devil", "o:-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
71 { "happy", ":)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
72 { "happy", ":-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
73 { "happi", ":-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
74 { "messed", "8-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
75 { "sidefrown", ":-$" } , |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
76 { "upset", ":-$" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
77 { "frazzled", ":-/" } , |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
78 { "heart", ";-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
79 { "heart", ";)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
80 { "nerd", "8-)"}, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
81 { "sinister", ":-,D" } , |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
82 { "wink", ";-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
83 { "winc", ";-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
84 { "geek", ":-X" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
85 { "laugh", ":-D" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
86 { "laugh", ":-d" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
87 { "oops", ":'(" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
88 { "smirk", "8-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
89 { "worried", ":-(" } , |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
90 { "worried", ":(" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
91 { "googles", "8-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
92 { "mohawk", ":-X" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
93 { "pirate", ":-)" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
94 { "straight", ":-!" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
95 { "kiss", ":-*" }, |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
96 { NULL, NULL } |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
97 }; |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
98 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
99 /* Internal functions */ |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
100 static void msim_send_zap(PurpleBlistNode *node, gpointer zap_num_ptr); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
101 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
102 #ifdef MSIM_DEBUG_MSG |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
103 static void print_hash_item(gpointer key, gpointer value, gpointer user_data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
104 #endif |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
105 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
106 static int msim_send_really_raw(PurpleConnection *gc, const char *buf, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
107 int total_bytes); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
108 static gboolean msim_login_challenge(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
109 static const gchar *msim_compute_login_response( |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
110 const gchar nonce[2 * NONCE_SIZE], const gchar *email, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
111 const gchar *password, guint *response_len); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
112 static gboolean msim_send_bm(MsimSession *session, const gchar *who, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
113 const gchar *text, int type); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
114 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
115 static guint msim_point_to_purple_size(MsimSession *session, guint point); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
116 static guint msim_purple_size_to_point(MsimSession *session, guint size); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
117 static guint msim_height_to_point(MsimSession *session, guint height); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
118 static guint msim_point_to_height(MsimSession *session, guint point); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
119 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
120 static void msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
121 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
122 static void msim_markup_tag_to_html(MsimSession *, xmlnode *root, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
123 gchar **begin, gchar **end); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
124 static void html_tag_to_msim_markup(MsimSession *, xmlnode *root, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
125 gchar **begin, gchar **end); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
126 static gchar *msim_convert_xml(MsimSession *, const gchar *raw, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
127 MSIM_XMLNODE_CONVERT f); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
128 static gchar *msim_convert_smileys_to_markup(gchar *before); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
129 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
130 /* High-level msim markup <=> html conversion functions. */ |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
131 static gchar *msim_markup_to_html(MsimSession *, const gchar *raw); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
132 static gchar *html_to_msim_markup(MsimSession *, const gchar *raw); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
133 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
134 static gboolean msim_incoming_bm_record_cv(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
135 MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
136 static gboolean msim_incoming_bm(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
137 static gboolean msim_incoming_status(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
138 static gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
139 static gboolean msim_incoming_zap(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
140 static gboolean msim_incoming_action(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
141 static gboolean msim_incoming_media(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
142 static gboolean msim_incoming_unofficial_client(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
143 MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
144 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
145 #ifdef MSIM_SEND_CLIENT_VERSION |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
146 static gboolean msim_send_unofficial_client(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
147 gchar *username); |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
148 #endif |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
149 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
150 static void msim_get_info_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
151 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
152 static void msim_set_status_code(MsimSession *session, guint code, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
153 gchar *statstring); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
154 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
155 static void msim_store_buddy_info_each(gpointer key, gpointer value, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
156 gpointer user_data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
157 static gboolean msim_store_buddy_info(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
158 static gboolean msim_process_server_info(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
159 MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
160 static gboolean msim_web_challenge(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
161 static gboolean msim_process_reply(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
162 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
163 static gboolean msim_preprocess_incoming(MsimSession *session,MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
164 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
165 #ifdef MSIM_USE_KEEPALIVE |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
166 static gboolean msim_check_alive(gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
167 #endif |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
168 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
169 static gboolean msim_we_are_logged_on(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
170 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
171 static gboolean msim_process(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
172 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
173 static MsimMessage *msim_do_postprocessing(MsimMessage *msg, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
174 const gchar *uid_field_name, const gchar *uid_before, guint uid); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
175 static void msim_postprocess_outgoing_cb(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
176 MsimMessage *userinfo, gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
177 static gboolean msim_postprocess_outgoing(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
178 MsimMessage *msg, const gchar *username, const gchar *uid_field_name, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
179 const gchar *uid_before); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
180 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
181 static gboolean msim_error(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
182 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
183 static void msim_check_inbox_cb(MsimSession *session, MsimMessage *userinfo, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
184 gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
185 static gboolean msim_check_inbox(gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
186 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
187 static void msim_input_cb(gpointer gc_uncasted, gint source, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
188 PurpleInputCondition cond); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
189 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
190 static guint msim_new_reply_callback(MsimSession *session, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
191 MSIM_USER_LOOKUP_CB cb, gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
192 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
193 static void msim_connect_cb(gpointer data, gint source, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
194 const gchar *error_message); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
195 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
196 static gboolean msim_is_userid(const gchar *user); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
197 static gboolean msim_is_email(const gchar *user); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
198 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
199 static void msim_lookup_user(MsimSession *session, const gchar *user, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
200 MSIM_USER_LOOKUP_CB cb, gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
201 |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
202 double msim_round(double round); |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
203 |
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
204 /* round is part of C99, but sometimes is unavailable before then. |
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
205 * Based on http://forums.belution.com/en/cpp/000/050/13.shtml |
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
206 */ |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
207 double msim_round(double value) |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
208 { |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
209 if (value < 0) { |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
210 return -(floor(-value + 0.5)); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
211 } else { |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
212 return floor( value + 0.5); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
213 } |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
214 } |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
215 |
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
|
216 /** |
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 * 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
|
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_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
|
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 /* If compiled to use RC4 from libpurple, check if it is really there. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
223 if (!purple_ciphers_find_cipher("rc4")) { |
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
|
224 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
|
225 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
|
226 _("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
|
227 _("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
|
228 "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
|
229 "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
|
230 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
|
231 } |
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 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
|
233 } |
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 |
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 /** |
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 * 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
|
237 * |
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 * @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
|
239 */ |
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 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
|
241 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
|
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 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
|
244 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
|
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 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
|
247 |
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 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
|
249 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
250 /* 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
|
251 #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
|
252 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
|
253 prim, /* PurpleStatusPrimitive */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
254 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
|
255 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
|
256 TRUE, /* savable */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
257 TRUE, /* user_settable */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
258 FALSE, /* not independent */ \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
259 \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
260 /* 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
|
261 "message", \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
262 _("Message"), \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
263 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
|
264 NULL); \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
265 \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
266 \ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
267 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
|
268 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
269 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
270 _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
|
271 _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
|
272 _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
|
273 _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
|
274 |
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
|
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 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
|
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 |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
279 /** Zap someone. Callback from msim_blist_node_menu zap menu. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
280 static void |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
281 msim_send_zap(PurpleBlistNode *node, gpointer zap_num_ptr) |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
282 { |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
283 PurpleBuddy *buddy; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
284 PurpleConnection *gc; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
285 MsimSession *session; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
286 gchar *username, *zap_string, *zap_text; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
287 guint zap; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
288 const gchar *zap_gerund[10]; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
289 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
290 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
291 /* Only know about buddies for now. */ |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
292 return; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
293 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
294 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
295 zap_gerund[0] = _("Zapping"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
296 zap_gerund[1] = _("Whacking"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
297 zap_gerund[2] = _("Torching"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
298 zap_gerund[3] = _("Smooching"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
299 zap_gerund[4] = _("Hugging"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
300 zap_gerund[5] = _("Bslapping"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
301 zap_gerund[6] = _("Goosing"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
302 zap_gerund[7] = _("Hi-fiving"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
303 zap_gerund[8] = _("Punking"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
304 zap_gerund[9] = _("Raspberry'ing"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
305 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
306 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
307 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
308 buddy = (PurpleBuddy *)node; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
309 gc = purple_account_get_connection(buddy->account); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
310 g_return_if_fail(gc != NULL); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
311 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
312 session = (MsimSession *)(gc->proto_data); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
313 g_return_if_fail(session != NULL); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
314 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
315 username = buddy->name; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
316 g_return_if_fail(username != NULL); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
317 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
318 zap = GPOINTER_TO_INT(zap_num_ptr); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
319 zap_string = g_strdup_printf("!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", zap); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
320 zap_text = g_strdup_printf("*** %s! ***", zap_gerund[zap]); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
321 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
322 serv_got_im(session->gc, username, zap_text, |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
323 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
324 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
325 if (!msim_send_bm(session, username, zap_string, MSIM_BM_ACTION)) { |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
326 purple_debug_info("msim_send_zap", "msim_send_bm failed: zapping %s with %s", |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
327 username, zap_string); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
328 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
329 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
330 g_free(zap_string); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
331 g_free(zap_text); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
332 return; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
333 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
334 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
335 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
336 /** Return menu, if any, for a buddy list node. */ |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
337 GList * |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
338 msim_blist_node_menu(PurpleBlistNode *node) |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
339 { |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
340 GList *menu, *zap_menu; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
341 PurpleMenuAction *act; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
342 const gchar *zap_names[10]; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
343 guint i; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
344 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
345 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
346 /* Only know about buddies for now. */ |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
347 return NULL; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
348 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
349 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
350 /* Names from official client. */ |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
351 zap_names[0] = _("zap"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
352 zap_names[1] = _("whack"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
353 zap_names[2] = _("torch"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
354 zap_names[3] = _("smooch"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
355 zap_names[4] = _("hug"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
356 zap_names[5] = _("bslap"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
357 zap_names[6] = _("goose"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
358 zap_names[7] = _("hi-five"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
359 zap_names[8] = _("punk'd"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
360 zap_names[9] = _("raspberry"); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
361 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
362 menu = zap_menu = NULL; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
363 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
364 for (i = 0; i < sizeof(zap_names) / sizeof(zap_names[0]); ++i) { |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
365 act = purple_menu_action_new(zap_names[i], PURPLE_CALLBACK(msim_send_zap), |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
366 GUINT_TO_POINTER(i), NULL); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
367 zap_menu = g_list_append(zap_menu, act); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
368 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
369 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
370 act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
371 menu = g_list_append(menu, act); |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
372 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
373 return menu; |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
374 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
375 |
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 /** |
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 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
|
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 * @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
|
380 * @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
|
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 * @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
|
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 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
|
385 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
|
386 { |
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 /* 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
|
388 * 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
|
389 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
|
390 } |
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 |
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 /** |
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 * 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
|
394 * |
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 * @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
|
396 * @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
|
397 * @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
|
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 * @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
|
400 * 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
|
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 * 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
|
403 * 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
|
404 * |
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 */ |
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 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
|
407 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
|
408 { |
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 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
|
410 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
|
411 |
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 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
|
413 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
|
414 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
|
415 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
|
416 } |
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 #ifdef MSIM_DEBUG_MSG |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
419 static void |
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
|
420 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
|
421 { |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
422 purple_debug_info("msim", "%s=%s\n", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
423 key ? (gchar *)key : "(NULL)", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
424 value ? (gchar *)value : "(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
|
425 } |
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 #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
|
427 |
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 /** |
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 * 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
|
430 * |
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 * @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
|
432 * @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
|
433 * |
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 * @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
|
435 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
436 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
437 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
|
438 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
|
439 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
440 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
|
441 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
|
442 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
443 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
|
444 |
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 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
|
446 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
|
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 |
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 /** 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
|
450 * |
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 * 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
|
452 * 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
|
453 * 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
|
454 * |
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 * @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
|
456 * @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
|
457 * @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
|
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 * @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
|
460 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
461 static int |
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
|
462 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
|
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 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
|
465 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
|
466 |
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 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
|
468 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
|
469 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
|
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 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
|
472 |
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 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
|
474 |
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 /* 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
|
476 total_bytes_sent = 0; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
477 do { |
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
|
478 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
|
479 |
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 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
|
481 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
|
482 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
483 if (bytes_sent < 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
|
484 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
|
485 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
|
486 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
|
487 } |
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 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
|
489 |
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 } 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
|
491 |
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 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
|
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 |
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 /** |
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 * 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
|
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 * @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
|
500 */ |
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 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
|
502 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
|
503 { |
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 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
|
505 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
|
506 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
|
507 |
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 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
|
509 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
|
510 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
511 purple_debug_info("msim", "logging in %s\n", acct->username); |
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
|
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 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
|
514 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
|
515 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
|
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 /* Passwords are limited in length. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
518 if (strlen(acct->password) > MSIM_MAX_PASSWORD_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
|
519 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
|
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 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
|
522 _("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
|
523 "%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
|
524 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
|
525 (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
|
526 |
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 /* 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
|
528 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
|
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 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
|
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 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
|
533 } |
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 |
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 /* 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
|
536 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
|
537 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
|
538 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
|
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 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
|
541 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
|
542 |
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 /* 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
|
544 * """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
|
545 * "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
|
546 * 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
|
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 /* Calls msim_connect_cb when connected. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
549 if (!purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc)) { |
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
|
550 /* 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
|
551 * 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
|
552 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
|
553 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
|
554 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
555 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
556 |
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 * 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
|
559 * |
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 * @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
|
561 * @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
|
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 * @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
|
564 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
565 static gboolean |
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
|
566 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
|
567 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
568 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
|
569 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
|
570 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
|
571 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
|
572 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
|
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 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
|
575 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
|
576 |
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 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
|
578 |
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 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
|
580 |
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 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
|
582 |
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 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
|
584 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
585 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
|
586 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
587 if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) { |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
588 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
|
589 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
|
590 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
|
591 } |
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 |
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 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
|
594 |
17972
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
595 response_len = 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
|
596 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
|
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 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
|
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 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
|
601 "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
|
602 /* 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
|
603 "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
|
604 /* 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
|
605 "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
|
606 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
607 "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
608 "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH), |
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
|
609 "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
|
610 "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
|
611 "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
|
612 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
|
613 } |
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 /** |
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 * 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
|
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 * @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
|
619 * @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
|
620 * @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
|
621 * @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
|
622 * |
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 * @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
|
624 * 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
|
625 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
626 static const gchar * |
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
|
627 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
|
628 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
|
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 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
|
631 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
|
632 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
|
633 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
634 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
|
635 guchar key[HASH_SIZE]; |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
636 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
|
637 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
|
638 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
|
639 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
|
640 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
|
641 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
|
642 #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
|
643 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
|
644 #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
|
645 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
646 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
|
647 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
|
648 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
|
649 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
|
650 |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
651 /* 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
|
652 * uppercase characters). MySpace passwords are lowercase, |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
653 * see ticket #2066. */ |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
654 password_ascii_lc = g_strdup(password); |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
655 g_strdown(password_ascii_lc); |
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
656 |
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
|
657 /* 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
|
658 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
|
659 conv_error = NULL; |
17941
dcbb535e8d55
Lowercase password before sending it. Closes #2066.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17696
diff
changeset
|
660 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
|
661 &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
|
662 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
|
663 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
664 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
|
665 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
666 if (conv_error != 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
|
667 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
|
668 "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
|
669 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
|
670 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
|
671 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
|
672 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
673 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
674 /* 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
|
675 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
|
676 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
|
677 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
|
678 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
679 #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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 #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
|
685 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
686 /* 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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
693 #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
|
694 purple_debug_info("msim", "key = "); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
695 for (i = 0; i < sizeof(key); i++) { |
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
|
696 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
|
697 } |
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 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
|
699 #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
|
700 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
701 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
|
702 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
703 /* 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
|
704 * 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
|
705 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
|
706 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
|
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 /* 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
|
709 |
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 /* 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
|
711 * 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
|
712 |
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 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 |
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 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
|
720 |
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 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
|
722 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
|
723 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
|
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 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
|
726 |
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 #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
|
728 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
|
729 #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
|
730 |
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 *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
|
732 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
733 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
|
734 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
735 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
736 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
737 * 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
|
738 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
739 * @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
|
740 * @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
|
741 * @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
|
742 * @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
|
743 * |
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 * @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
|
745 * |
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 * 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
|
747 * 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
|
748 * 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
|
749 */ |
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 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
|
751 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
|
752 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
|
753 { |
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 MsimSession *session; |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
755 gchar *message_msim; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
756 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
|
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 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
|
759 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
|
760 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
|
761 |
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 /* '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
|
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 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
|
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 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
|
767 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
768 message_msim = html_to_msim_markup(session, message); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
769 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
770 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
|
771 /* 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
|
772 * 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
|
773 * 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
|
774 * 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
|
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 /* 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
|
777 * 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
|
778 * sent? Would be complicated. */ |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
779 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
|
780 } else { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
781 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
|
782 } |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
783 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
784 g_free(message_msim); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
785 |
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
|
786 /* |
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 * 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
|
788 * 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
|
789 * 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
|
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 * 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
|
792 * 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
|
793 * 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
|
794 * |
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 * 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
|
796 * 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
|
797 */ |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
798 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
799 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
|
800 } |
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 |
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 /** 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
|
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 * @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
|
805 * @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
|
806 * @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
|
807 * @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
|
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 * @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
|
810 * |
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 * 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
|
812 * |
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 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
814 static gboolean |
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
|
815 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
|
816 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
|
817 { |
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 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
|
819 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
|
820 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
|
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 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
|
823 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
|
824 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
|
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 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
|
827 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
828 g_return_val_if_fail(from_username != NULL, FALSE); |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
829 |
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
|
830 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
|
831 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
|
832 |
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 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
|
834 "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
|
835 "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
|
836 /* '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
|
837 "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
|
838 "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
|
839 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
|
840 |
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 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
|
842 |
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 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
|
844 |
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 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
|
846 } |
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 |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
848 /* 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
|
849 * 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
|
850 * 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
|
851 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
|
852 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
853 #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
|
854 #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
|
855 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
856 /** 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
|
857 * Based on libpurple/gtkimhtml.c */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
858 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
859 msim_point_to_purple_size(MsimSession *session, 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
|
860 { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
861 guint size, this_point, base; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
862 gdouble scale; |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
863 |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
864 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
865 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
866 for (size = 0; |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
867 size < sizeof(_font_scale) / sizeof(_font_scale[0]); |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
868 ++size) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
869 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
870 this_point = (guint)msim_round(scale * base); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
871 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
872 if (this_point >= point) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
873 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
|
874 point, size); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
875 return size; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
876 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
877 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
878 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
879 /* 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
|
880 return this_point; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
881 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
882 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
883 /** Convert HTML font size to point size. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
884 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
885 msim_purple_size_to_point(MsimSession *session, guint size) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
886 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
887 gdouble scale; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
888 guint point; |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
889 guint base; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
890 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
891 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
|
892 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
893 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
894 |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
895 point = (guint)msim_round(scale * base); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
896 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
897 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
|
898 size, point); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
899 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
900 return point; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
901 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
902 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
903 /** Convert a msim markup font pixel height to the more usual point size, for incoming messages. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
904 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
905 msim_height_to_point(MsimSession *session, guint height) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
906 { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
907 guint dpi; |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
908 |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
909 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
910 |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
911 return (guint)msim_round((POINTS_PER_INCH * 1. / dpi) * height); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
912 |
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
|
913 /* 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
|
914 * _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
|
915 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
916 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
917 /** Convert point size to msim pixel height font size specification, for outgoing messages. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
918 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
919 msim_point_to_height(MsimSession *session, guint point) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
920 { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
921 guint dpi; |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
922 |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
923 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
924 |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
925 return (guint)msim_round((dpi * 1. / POINTS_PER_INCH) * point); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
926 } |
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
|
927 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
928 /** 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
|
929 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
930 msim_markup_f_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **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
|
931 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
932 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
|
933 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
|
934 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
|
935 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
940 if (height_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
|
941 height = atol(height_str); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
942 } else { |
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
|
943 height = 12; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
944 } |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
945 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
946 if (decor_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
|
947 decor = atol(decor_str); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
948 } else { |
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
|
949 decor = 0; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
950 } |
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
|
951 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
952 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
|
953 /* TODO: get font size working */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
954 if (height && !face) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
955 g_string_printf(gs_begin, "<font size='%d'>", |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
956 msim_point_to_purple_size(session, msim_height_to_point(session, height))); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
957 } else if (height && face) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
958 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
959 msim_point_to_purple_size(session, msim_height_to_point(session, height))); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
960 } else { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
961 g_string_printf(gs_begin, "<font>"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
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 |
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 /* 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
|
965 /* 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
|
966 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
|
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 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
|
969 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
970 if (decor & MSIM_TEXT_BOLD) { |
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 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
|
972 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
|
973 } |
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 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
975 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
|
976 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
|
977 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
|
978 } |
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 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
980 if (decor & MSIM_TEXT_UNDERLINE) { |
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
|
981 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
|
982 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
|
983 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
984 |
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 *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
|
987 *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
|
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 |
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 /** 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
|
991 * |
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 * @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
|
993 * |
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 * @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
|
995 */ |
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 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
|
997 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
|
998 { |
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 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
|
1000 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1001 if (!msim) { |
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
|
1002 return g_strdup("black"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1003 } |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1004 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1005 if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) { |
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
|
1006 /* 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
|
1007 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
|
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 /* 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
|
1010 |
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 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
|
1012 } |
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 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1014 /** 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
|
1015 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1016 msim_markup_p_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **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
|
1017 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1018 /* 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
|
1019 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1020 * 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
|
1021 *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
|
1022 *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
|
1023 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1024 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1025 /** 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
|
1026 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1027 msim_markup_c_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **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
|
1028 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1029 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
|
1030 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
|
1031 |
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 color = xmlnode_get_attrib(root, "v"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1033 if (!color) { |
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
|
1034 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
|
1035 *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
|
1036 *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
|
1037 /* 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
|
1038 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
|
1039 } |
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 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
|
1042 |
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 *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
|
1044 |
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 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
|
1046 |
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 /* *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
|
1048 *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
|
1049 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1050 |
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 /** 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
|
1052 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1053 msim_markup_b_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **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
|
1054 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1055 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
|
1056 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
|
1057 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1058 color = xmlnode_get_attrib(root, "v"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1059 if (!color) { |
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
|
1060 *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
|
1061 *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
|
1062 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
|
1063 /* 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
|
1064 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
|
1065 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1066 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1067 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
|
1068 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1069 /* 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
|
1070 *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
|
1071 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
|
1072 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
|
1073 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1074 *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
|
1075 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1076 |
17956
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1077 /** Convert the msim markup <i> tag (emoticon image) into HTML. */ |
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
|
1078 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1079 msim_markup_i_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **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
|
1080 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1081 const gchar *name; |
17956
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1082 guint i; |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1083 struct MSIM_EMOTICON *emote; |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1084 |
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
|
1085 name = xmlnode_get_attrib(root, "n"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1086 if (!name) { |
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
|
1087 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
|
1088 *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
|
1089 *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
|
1090 /* 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
|
1091 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
|
1092 } |
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 |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1094 for (i = 0; (emote = &msim_emoticons[i]) && emote->name != NULL; ++i) { |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1095 gchar *name; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1096 gchar *symbol; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1097 |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1098 name = emote->name; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1099 symbol = emote->symbol; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1100 |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1101 if (!strcmp(name, name)) { |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1102 *begin = g_strdup(symbol); |
17956
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1103 *end = g_strdup(""); |
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1104 return; |
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1105 } |
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1106 } |
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1107 |
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1108 *begin = g_strdup(name); |
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1109 *end = 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
|
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 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1112 /** Convert an individual msim markup tag to HTML. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1113 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1114 msim_markup_tag_to_html(MsimSession *session, xmlnode *root, gchar **begin, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1115 gchar **end) |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1116 { |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1117 if (!strcmp(root->name, "f")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1118 msim_markup_f_to_html(session, root, begin, end); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1119 } else if (!strcmp(root->name, "p")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1120 msim_markup_p_to_html(session, root, begin, end); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1121 } else if (!strcmp(root->name, "c")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1122 msim_markup_c_to_html(session, root, begin, end); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1123 } else if (!strcmp(root->name, "b")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1124 msim_markup_b_to_html(session, root, begin, end); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1125 } else if (!strcmp(root->name, "i")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1126 msim_markup_i_to_html(session, root, begin, end); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1127 } else { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1128 purple_debug_info("msim", "msim_markup_tag_to_html: " |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1129 "unknown tag name=%s, ignoring", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1130 (root && root->name) ? root->name : "(NULL)"); |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1131 *begin = g_strdup(""); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1132 *end = g_strdup(""); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1133 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1134 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1135 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1136 /** Convert an individual HTML tag to msim markup. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1137 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1138 html_tag_to_msim_markup(MsimSession *session, xmlnode *root, gchar **begin, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1139 gchar **end) |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1140 { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1141 /* 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
|
1142 * 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
|
1143 * 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
|
1144 * applied to the text. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1145 if (!strcmp(root->name, "root")) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1146 *begin = g_strdup(""); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1147 *end = g_strdup(""); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1148 } 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
|
1149 *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
|
1150 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1151 } else if (!strcmp(root->name, "i")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1152 *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
|
1153 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1154 } else if (!strcmp(root->name, "u")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1155 *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
|
1156 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1157 } else if (!strcmp(root->name, "font")) { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1158 const gchar *size; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1159 const gchar *face; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1160 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1161 size = xmlnode_get_attrib(root, "size"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1162 face = xmlnode_get_attrib(root, "face"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1163 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1164 if (face && size) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1165 { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1166 *begin = g_strdup_printf("<f f='%s' h='%d'>", face, |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1167 msim_point_to_height(session, |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1168 msim_purple_size_to_point(session, atoi(size)))); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1169 } else if (face) { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1170 *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
|
1171 } else if (size) { |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1172 *begin = g_strdup_printf("<f h='%d'>", |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1173 msim_point_to_height(session, |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1174 msim_purple_size_to_point(session, atoi(size)))); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1175 } else { |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1176 *begin = g_strdup("<f>"); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1177 } |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1178 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1179 *end = g_strdup("</f>"); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1180 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1181 /* TODO: color (bg uses <body>), emoticons */ |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1182 } else { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1183 *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
|
1184 *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
|
1185 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1186 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1187 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1188 /** 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
|
1189 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1190 * @param f Function to convert tags. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1191 * |
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
|
1192 * @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
|
1193 */ |
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 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1195 msim_convert_xmlnode(MsimSession *session, 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
|
1196 { |
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 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
|
1198 gchar *begin, *inner, *end; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1199 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
|
1200 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1201 if (!root || !root->name) { |
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
|
1202 return g_strdup(""); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1203 } |
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
|
1204 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1205 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
|
1206 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
|
1207 |
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 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
|
1209 |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1210 final = g_string_new(""); |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1211 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1212 f(session, root, &begin, &end); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1213 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1214 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
|
1215 |
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 /* Loop over all child nodes. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1217 for (node = root->child; node != NULL; node = node->next) { |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1218 switch (node->type) { |
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
|
1219 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
|
1220 /* 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
|
1221 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
|
1222 |
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 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
|
1224 /* A tag or tag with attributes. Recursively descend. */ |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1225 inner = msim_convert_xmlnode(session, 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
|
1226 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
|
1227 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1228 purple_debug_info("msim", " ** node name=%s\n", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1229 (node && node->name) ? node->name : "(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
|
1230 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
|
1231 |
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 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
|
1233 /* 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
|
1234 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
|
1235 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
|
1236 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
|
1237 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1238 purple_debug_info("msim", " ** node data=%s\n", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1239 inner ? inner : "(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
|
1240 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
|
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 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
|
1243 purple_debug_info("msim", |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1244 "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
|
1245 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
|
1246 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1247 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1248 if (inner) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1249 g_string_append(final, inner); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1250 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1251 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1252 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1253 /* 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
|
1254 * 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
|
1255 * 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
|
1256 * 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
|
1257 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
|
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 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1260 (final && final->str) ? final->str : "(NULL)"); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1261 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1262 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
|
1263 } |
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 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1265 /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1266 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1267 msim_convert_xml(MsimSession *session, 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
|
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 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
|
1270 gchar *str; |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1271 gchar *enclosed_raw; |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1272 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1273 g_return_val_if_fail(raw != NULL, NULL); |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1274 |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1275 /* Enclose text in one root tag, to try to make it valid XML for parsing. */ |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1276 enclosed_raw = g_strconcat("<root>", raw, "</root>", NULL); |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1277 |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1278 root = xmlnode_from_str(enclosed_raw, -1); |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1279 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1280 if (!root) { |
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
|
1281 purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1282 "%s as XML, returning raw: %s\n", enclosed_raw, raw); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1283 /* TODO: msim_unrecognized */ |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1284 g_free(enclosed_raw); |
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
|
1285 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
|
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 |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1288 g_free(enclosed_raw); |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1289 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1290 str = msim_convert_xmlnode(session, root, f); |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1291 g_return_val_if_fail(str != NULL, 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
|
1292 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
|
1293 |
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 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
|
1295 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1296 return str; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1297 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1298 |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1299 /** Convert plaintext smileys to <i> markup tags. |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1300 * |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1301 * @param before Original text with ASCII smileys. Will be freed. |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1302 * @return A new string with <i> tags, if applicable. Must be g_free()'d. |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1303 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1304 static gchar * |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1305 msim_convert_smileys_to_markup(gchar *before) |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1306 { |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1307 gchar *old, *new, *replacement; |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1308 guint i; |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1309 struct MSIM_EMOTICON *emote; |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1310 |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1311 old = before; |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1312 new = NULL; |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1313 |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1314 for (i = 0; (emote = &msim_emoticons[i]) && emote->name != NULL; ++i) { |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1315 gchar *name, *symbol; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1316 |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1317 name = emote->name; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1318 symbol = emote->symbol; |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1319 |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1320 replacement = g_strdup_printf("<i n=\"%s\"/>", name); |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1321 |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1322 purple_debug_info("msim", "msim_convert_smileys_to_markup: %s->%s\n", |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1323 symbol ? symbol : "(NULL)", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1324 replacement ? replacement : "(NULL)"); |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
1325 new = str_replace(old, symbol, replacement); |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1326 |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1327 g_free(replacement); |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1328 g_free(old); |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1329 |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1330 old = new; |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1331 } |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1332 |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1333 return new; |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1334 } |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1335 |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1336 |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1337 /** 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
|
1338 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1339 * @return Purple markup string, must be g_free()'d. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1340 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1341 msim_markup_to_html(MsimSession *session, const gchar *raw) |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1342 { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1343 return msim_convert_xml(session, raw, |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1344 (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
|
1345 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1346 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1347 /** 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
|
1348 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1349 * @return HTML markup string, must be g_free()'d. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1350 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1351 html_to_msim_markup(MsimSession *session, const gchar *raw) |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1352 { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1353 gchar *markup; |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1354 |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1355 markup = msim_convert_xml(session, raw, |
17695
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17693
diff
changeset
|
1356 (MSIM_XMLNODE_CONVERT)(html_tag_to_msim_markup)); |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1357 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1358 if (purple_account_get_bool(session->account, "emoticons", TRUE)) { |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1359 /* Frees markup and allocates a new one. */ |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1360 markup = msim_convert_smileys_to_markup(markup); |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1361 } |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1362 |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1363 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
|
1364 } |
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 |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1366 /** Record the client version in the buddy list, from an incoming message. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1367 static gboolean |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1368 msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg) |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1369 { |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1370 gchar *username, *cv; |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1371 gboolean ret; |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1372 PurpleBuddy *buddy; |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1373 |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1374 username = msim_msg_get_string(msg, "_username"); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1375 cv = msim_msg_get_string(msg, "cv"); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1376 |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1377 g_return_val_if_fail(username != NULL, FALSE); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1378 g_return_val_if_fail(cv != NULL, FALSE); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1379 |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1380 buddy = purple_find_buddy(session->account, username); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1381 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1382 if (buddy) { |
17972
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1383 purple_blist_node_set_int(&buddy->node, "client_cv", atol(cv)); |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1384 ret = TRUE; |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1385 } else { |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1386 ret = FALSE; |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1387 } |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1388 |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1389 g_free(username); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1390 g_free(cv); |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1391 |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1392 return ret; |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1393 } |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1394 |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1395 /** Handle an incoming buddy message. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1396 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1397 msim_incoming_bm(MsimSession *session, MsimMessage *msg) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1398 { |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1399 guint bm; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1400 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1401 bm = msim_msg_get_integer(msg, "bm"); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1402 |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1403 msim_incoming_bm_record_cv(session, msg); |
17954
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
1404 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1405 switch (bm) { |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1406 case MSIM_BM_STATUS: |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1407 return msim_incoming_status(session, msg); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1408 case MSIM_BM_INSTANT: |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1409 return msim_incoming_im(session, msg); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1410 case MSIM_BM_ACTION: |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1411 return msim_incoming_action(session, msg); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1412 case MSIM_BM_MEDIA: |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1413 return msim_incoming_media(session, msg); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1414 case MSIM_BM_UNOFFICIAL_CLIENT: |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1415 return msim_incoming_unofficial_client(session, msg); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1416 default: |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1417 /* Not really an IM, but show it for informational |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1418 * purposes during development. */ |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1419 return msim_incoming_im(session, msg); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1420 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1421 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1422 |
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
|
1423 /** |
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 * 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
|
1425 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1426 * @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
|
1427 * @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
|
1428 * 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
|
1429 * |
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 * @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
|
1431 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1432 static gboolean |
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
|
1433 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
|
1434 { |
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 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
|
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 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
|
1438 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
|
1439 |
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 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
|
1441 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
|
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 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
|
1444 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
|
1445 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1446 msg_purple_markup = msim_markup_to_html(session, msg_msim_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
|
1447 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
|
1448 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1449 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
|
1450 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
|
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 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
|
1453 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
|
1454 |
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 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
|
1456 } |
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 /** |
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 * 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
|
1460 * |
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 * @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
|
1462 * @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
|
1463 * @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
|
1464 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1465 static void |
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
|
1466 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
|
1467 { |
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 /* 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
|
1469 * 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
|
1470 * 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
|
1471 * 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
|
1472 */ |
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 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1474 /* 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
|
1475 * 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
|
1476 * 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
|
1477 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1478 purple_debug_info("msim", "Unrecognized data on account for %s\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1479 session->account->username ? session->account->username |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1480 : "(NULL)"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1481 if (note) { |
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 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
|
1483 } |
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 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1485 if (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
|
1486 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
|
1487 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1488 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1489 |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1490 /** Process an incoming zap. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1491 static gboolean |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1492 msim_incoming_zap(MsimSession *session, MsimMessage *msg) |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1493 { |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1494 gchar *msg_text, *username, *zap_text; |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1495 gint zap; |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
1496 const gchar *zap_past_tense[10]; |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1497 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1498 zap_past_tense[0] = _("zapped"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1499 zap_past_tense[1] = _("whacked"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1500 zap_past_tense[2] = _("torched"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1501 zap_past_tense[3] = _("smooched"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1502 zap_past_tense[4] = _("hugged"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1503 zap_past_tense[5] = _("bslapped"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1504 zap_past_tense[6] = _("goosed"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1505 zap_past_tense[7] = _("hi-fived"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1506 zap_past_tense[8] = _("punk'd"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1507 zap_past_tense[9] = _("raspberried"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1508 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1509 msg_text = msim_msg_get_string(msg, "msg"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1510 username = msim_msg_get_string(msg, "_username"); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1511 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1512 g_return_val_if_fail(msg_text != NULL, FALSE); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1513 g_return_val_if_fail(username != NULL, FALSE); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1514 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1515 g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1516 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1517 zap = CLAMP(zap, 0, sizeof(zap_past_tense) / sizeof(zap_past_tense[0])); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1518 |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
1519 zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]); |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1520 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1521 serv_got_im(session->gc, username, zap_text, |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1522 PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1523 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1524 g_free(zap_text); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1525 g_free(msg_text); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1526 g_free(username); |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1527 |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1528 return TRUE; |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1529 } |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1530 |
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
|
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 * 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
|
1533 * |
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 * @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
|
1535 * @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
|
1536 * |
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 * @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
|
1538 * |
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 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1540 static gboolean |
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
|
1541 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
|
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 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
|
1544 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
|
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 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
|
1547 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
|
1548 |
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 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
|
1550 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
|
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 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
|
1553 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
|
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 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
|
1556 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
|
1557 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1558 if (strcmp(msg_text, "%typing%") == 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
|
1559 /* 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
|
1560 * 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
|
1561 * 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
|
1562 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
|
1563 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
|
1564 } 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
|
1565 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
|
1566 rc = TRUE; |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1567 } else if (strstr(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_")) { |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1568 rc = msim_incoming_zap(session, 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
|
1569 } 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
|
1570 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
|
1571 "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
|
1572 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
|
1573 } |
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 |
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 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
|
1576 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
|
1577 |
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 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
|
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 |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1581 /* Process an incoming media (buddy icon) message. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1582 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1583 msim_incoming_media(MsimSession *session, MsimMessage *msg) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1584 { |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1585 gchar *username, *text; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1586 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1587 username = msim_msg_get_string(msg, "_username"); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1588 text = msim_msg_get_string(msg, "msg"); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1589 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1590 g_return_val_if_fail(username != NULL, FALSE); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1591 g_return_val_if_fail(text != NULL, FALSE); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1592 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1593 purple_debug_info("msim", "msim_incoming_media: from %s, got msg=%s\n", username, text); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1594 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1595 /* Media messages are sent when the user opens a window to someone. |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1596 * Tell libpurple they started typing and stopped typing, to inform the Psychic |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1597 * Mode plugin so it too can open a window to the user. */ |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1598 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1599 serv_got_typing_stopped(session->gc, username); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1600 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1601 g_free(username); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1602 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1603 return TRUE; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1604 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1605 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1606 /* Process an incoming "unofficial client" message. The plugin for |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1607 * Miranda IM sends this message with the plugin information. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1608 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1609 msim_incoming_unofficial_client(MsimSession *session, MsimMessage *msg) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1610 { |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1611 PurpleBuddy *buddy; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1612 gchar *username, *client_info; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1613 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1614 username = msim_msg_get_string(msg, "_username"); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1615 client_info = msim_msg_get_string(msg, "msg"); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1616 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1617 g_return_val_if_fail(username != NULL, FALSE); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1618 g_return_val_if_fail(client_info != NULL, FALSE); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1619 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1620 purple_debug_info("msim", "msim_incoming_unofficial_client: %s is using client %s\n", |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1621 username, client_info); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1622 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1623 buddy = purple_find_buddy(session->account, username); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1624 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1625 g_return_val_if_fail(buddy != NULL, FALSE); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1626 |
17972
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1627 purple_blist_node_remove_setting(&buddy->node, "client"); |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1628 purple_blist_node_set_string(&buddy->node, "client", client_info); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1629 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1630 g_free(username); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1631 /* Do not free client_info - the blist now owns it. */ |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1632 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1633 return TRUE; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1634 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1635 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1636 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1637 #ifdef MSIM_SEND_CLIENT_VERSION |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1638 /** Send our client version to another unofficial client that understands it. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1639 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1640 msim_send_unofficial_client(MsimSession *session, gchar *username) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1641 { |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1642 gchar *our_info; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1643 gboolean ret; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1644 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1645 our_info = g_strdup_printf("Libpurple %d.%d.%d - msimprpl %s", |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1646 PURPLE_MAJOR_VERSION, |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1647 PURPLE_MINOR_VERSION, |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1648 PURPLE_MICRO_VERSION, |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1649 MSIM_PRPL_VERSION_STRING); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1650 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1651 ret = msim_send_bm(session, username, our_info, MSIM_BM_UNOFFICIAL_CLIENT); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1652 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1653 return ret; |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1654 } |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1655 #endif |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1656 |
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
|
1657 /** |
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 * 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
|
1659 * |
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 * @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
|
1661 * @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
|
1662 * @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
|
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 * @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
|
1665 */ |
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 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
|
1667 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
|
1668 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
|
1669 { |
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 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
|
1671 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
|
1672 |
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 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
|
1674 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
|
1675 |
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 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
|
1677 |
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 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
|
1679 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1680 switch (state) { |
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
|
1681 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
|
1682 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
|
1683 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
|
1684 |
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 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
|
1686 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
|
1687 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
|
1688 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
|
1689 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
|
1690 } |
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 |
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 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
|
1693 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
|
1694 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
|
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 |
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 /** Callback for msim_get_info(), for when user info is received. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1698 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1699 msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1700 gpointer data) |
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
|
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 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
|
1703 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
|
1704 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
|
1705 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
|
1706 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
|
1707 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
|
1708 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
|
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 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
|
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 /* 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
|
1713 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
|
1714 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
|
1715 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
|
1716 |
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 user = msim_msg_get_string(msg, "user"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1718 if (!user) { |
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 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
|
1720 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
|
1721 } |
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 |
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 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
|
1724 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
|
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 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
|
1727 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
|
1728 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
|
1729 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
|
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 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
|
1732 /* 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
|
1733 * 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
|
1734 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1735 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
|
1736 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1737 /* 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
|
1738 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
|
1739 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1740 /* 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
|
1741 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
|
1742 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
|
1743 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
|
1744 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
|
1745 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1746 /* 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
|
1747 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
|
1748 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
|
1749 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
|
1750 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1751 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
|
1752 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
|
1753 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
|
1754 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1755 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
|
1756 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
|
1757 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
|
1758 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
|
1759 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1760 /* 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
|
1761 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1762 if (buddy) { |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1763 /* Headline comes from buddy status messages */ |
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
|
1764 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
|
1765 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
|
1766 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
|
1767 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1768 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1769 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1770 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
|
1771 str2 = g_hash_table_lookup(body, "SongName"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1772 if (str || str2) { |
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
|
1773 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
|
1774 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
|
1775 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
|
1776 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
|
1777 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1778 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1779 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1780 /* 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
|
1781 str = g_hash_table_lookup(body, "TotalFriends"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1782 if (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
|
1783 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
|
1784 g_strdup(str)); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1785 } |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1786 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1787 if (buddy) { |
17972
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1788 gint cv; |
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1789 |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1790 str = purple_blist_node_get_string(&buddy->node, "client"); |
17972
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1791 cv = purple_blist_node_get_int(&buddy->node, "client_cv"); |
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1792 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1793 if (str) { |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1794 purple_notify_user_info_add_pair(user_info, _("Client Version"), |
17972
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1795 g_strdup_printf("%s (build %d)", str, cv)); |
8f49acac9d1c
Store 3rd-party client name/version and official client build version (cv) separately.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17971
diff
changeset
|
1796 } |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1797 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1798 |
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
|
1799 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
|
1800 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
|
1801 //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
|
1802 /* 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
|
1803 |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
1804 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
|
1805 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1806 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1807 /** 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
|
1808 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
|
1809 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
|
1810 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1811 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
|
1812 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
|
1813 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
|
1814 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
|
1815 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
|
1816 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1817 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
|
1818 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
|
1819 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1820 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
|
1821 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1822 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
|
1823 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1824 /* 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
|
1825 buddy = purple_find_buddy(session->account, user); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1826 if (buddy) { |
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
|
1827 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1828 if (!uid) { |
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
|
1829 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
|
1830 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1831 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
|
1832 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
|
1833 _("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
|
1834 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1835 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
|
1836 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
|
1837 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
|
1838 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1839 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1840 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
|
1841 } 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
|
1842 /* 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
|
1843 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
|
1844 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1845 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1846 /* 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
|
1847 * 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
|
1848 * 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
|
1849 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1850 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
|
1851 "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
|
1852 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
|
1853 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
|
1854 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1855 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
|
1856 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1857 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
|
1858 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1859 |
17945
cf55077a3752
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17944
diff
changeset
|
1860 /** 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
|
1861 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
|
1862 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
|
1863 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1864 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
|
1865 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
|
1866 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
|
1867 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
|
1868 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1869 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
|
1870 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1871 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
|
1872 |
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 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
|
1874 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1875 switch (purple_status_type_get_primitive(type)) { |
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
|
1876 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
|
1877 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
|
1878 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
|
1879 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
|
1880 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
|
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 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
|
1883 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
|
1884 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
|
1885 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
|
1886 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
|
1887 |
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 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
|
1889 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
|
1890 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
|
1891 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
|
1892 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
|
1893 |
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 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
|
1895 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
|
1896 "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
|
1897 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
|
1898 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
|
1899 } |
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 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1901 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
|
1902 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1903 if (!statstring) { |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1904 statstring = g_strdup(""); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1905 } |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1906 |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1907 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
|
1908 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1909 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
1910 /** 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
|
1911 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
|
1912 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
|
1913 { |
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 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
|
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 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
|
1917 |
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 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
|
1919 |
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 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
|
1921 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1922 if (time == 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
|
1923 /* 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
|
1924 * 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
|
1925 * 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
|
1926 */ |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1927 /* 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
|
1928 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
|
1929 } 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
|
1930 /* 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
|
1931 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
|
1932 } |
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 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1935 /** 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
|
1936 * @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
|
1937 * @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
|
1938 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1939 static void |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1940 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
|
1941 { |
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 g_return_if_fail(MSIM_SESSION_VALID(session)); |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1943 g_return_if_fail(statstring != 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
|
1944 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1945 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
|
1946 status_code, statstring); |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
1947 |
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
|
1948 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
|
1949 "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
|
1950 "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
|
1951 "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
|
1952 "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
|
1953 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
|
1954 { |
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 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
|
1956 } |
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 } |
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 |
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 /** 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
|
1961 * |
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 * @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
|
1963 * @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
|
1964 * @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
|
1965 */ |
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 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
|
1967 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
|
1968 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
|
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 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
|
1971 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
|
1972 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
|
1973 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
|
1974 |
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 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
|
1976 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
|
1977 |
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 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
|
1979 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
|
1980 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
|
1981 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
|
1982 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
|
1983 |
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 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
|
1985 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
|
1986 |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
1987 |
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
|
1988 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
|
1989 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
|
1990 |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
1991 /* TODO: more elegant solution than below. attach whole message? */ |
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
|
1992 /* Special elements name beginning with '_', we'll use internally within the |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
1993 * program (did not come directly from the wire). */ |
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
|
1994 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
1995 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
1996 /* TODO: attach more useful information, like ImageURL */ |
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
|
1997 |
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 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
|
1999 |
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 /* 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
|
2001 //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
|
2002 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
|
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 |
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 #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
|
2006 /* 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
|
2007 * |
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 * @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
|
2009 * |
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 * @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
|
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 * 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
|
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 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
|
2015 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
|
2016 { |
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 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
|
2018 |
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 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
|
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 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
|
2022 { |
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 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
|
2024 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
|
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 |
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 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
|
2028 { |
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 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
|
2030 //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
|
2031 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
|
2032 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
|
2033 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2034 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2035 /* 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
|
2036 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
|
2037 //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
|
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 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
|
2040 //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
|
2041 |
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 /* 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
|
2043 /* 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
|
2044 |
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 /* 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
|
2046 * 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
|
2047 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
|
2048 //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
|
2049 /* 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
|
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 /* 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
|
2052 /* 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
|
2053 |
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 /* 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
|
2055 *** 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
|
2056 ======= 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
|
2057 /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
|
2058 /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
|
2059 /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
|
2060 /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
|
2061 /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
|
2062 /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
|
2063 /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
|
2064 /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
|
2065 /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
|
2066 /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
|
2067 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
|
2068 /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
|
2069 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
|
2070 |
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 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
|
2072 *** 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
|
2073 (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
|
2074 #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
|
2075 #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
|
2076 #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
|
2077 #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
|
2078 #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
|
2079 #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
|
2080 #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
|
2081 #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
|
2082 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
|
2083 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
|
2084 #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
|
2085 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
|
2086 |
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 |
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 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
|
2089 */ |
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 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
|
2091 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
|
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 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
|
2094 { |
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 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
|
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 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
|
2098 |
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 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
|
2100 |
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 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
|
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 } |
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 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
|
2106 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
|
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 #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
|
2109 |
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 /** 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
|
2111 * |
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 * @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
|
2113 * @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
|
2114 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2115 static gboolean |
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
|
2116 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
|
2117 { |
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 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
|
2119 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
|
2120 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2121 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "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
|
2122 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
|
2123 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
|
2124 |
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 /* '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
|
2126 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
|
2127 |
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 /* 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
|
2129 * 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
|
2130 #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
|
2131 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
|
2132 #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
|
2133 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
|
2134 #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
|
2135 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2136 if (username) { |
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
|
2137 /* 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
|
2138 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
|
2139 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
|
2140 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
|
2141 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
|
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 } 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
|
2144 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
|
2145 |
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 /* 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
|
2147 /* 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
|
2148 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
|
2149 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
|
2150 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
|
2151 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
|
2152 |
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 /* 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
|
2154 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
|
2155 } |
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 } 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
|
2157 /* 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
|
2158 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
|
2159 } |
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 |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2162 #ifdef MSIM_USE_KEEPALIVE |
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
|
2163 /** Check if the connection is still alive, based on last communication. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2164 static gboolean |
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
|
2165 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
|
2166 { |
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 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
|
2168 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
|
2169 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
|
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 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
|
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_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
|
2174 |
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 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
|
2176 //purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2177 if (delta >= MSIM_KEEPALIVE_INTERVAL) { |
17696
65cf1785e5bf
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17695
diff
changeset
|
2178 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
|
2179 |
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 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
|
2181 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
|
2182 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
|
2183 |
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 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
|
2185 |
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 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
|
2187 |
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 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
|
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 |
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 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
|
2192 } |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2193 #endif |
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
|
2194 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2195 /** Handle mail reply checks. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2196 static void |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2197 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
|
2198 { |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2199 GHashTable *body; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2200 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
|
2201 GString *notification; |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2202 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
|
2203 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
|
2204 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
|
2205 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2206 /* 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
|
2207 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
|
2208 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2209 "Mail", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2210 "BlogComment", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2211 "ProfileComment", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2212 "FriendRequest", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2213 "PictureComment" |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2214 }; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2215 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2216 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
|
2217 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2218 MSIM_INBOX_MAIL, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2219 MSIM_INBOX_BLOG_COMMENT, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2220 MSIM_INBOX_PROFILE_COMMENT, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2221 MSIM_INBOX_FRIEND_REQUEST, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2222 MSIM_INBOX_PICTURE_COMMENT |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2223 }; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2224 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2225 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
|
2226 { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2227 "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
|
2228 "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
|
2229 "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
|
2230 "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
|
2231 "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
|
2232 }; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2233 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2234 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
|
2235 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2236 /* 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
|
2237 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
|
2238 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
|
2239 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
|
2240 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
|
2241 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
|
2242 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2243 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
|
2244 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2245 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
|
2246 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2247 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
|
2248 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
|
2249 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2250 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
|
2251 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
|
2252 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2253 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
|
2254 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2255 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
|
2256 |
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
|
2257 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
|
2258 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2259 for (i = 0; i < sizeof(inbox_keys) / sizeof(inbox_keys[0]); ++i) { |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2260 const gchar *key; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2261 guint bit; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2262 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2263 key = inbox_keys[i]; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2264 bit = inbox_bits[i]; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2265 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2266 if (g_hash_table_lookup(body, key)) { |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2267 /* 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
|
2268 * (edge triggered) */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2269 if (!(session->inbox_status & bit)) { |
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
|
2270 purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2271 key ? key : "(NULL)", n); |
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
|
2272 |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
2273 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
|
2274 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
|
2275 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
|
2276 /* 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
|
2277 * 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
|
2278 */ |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
2279 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
|
2280 |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
2281 ++n; |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2282 } else { |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2283 purple_debug_info("msim", |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2284 "msim_check_inbox_cb: already notified of %s\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2285 key ? key : "(NULL)"); |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2286 } |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2287 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2288 session->inbox_status |= bit; |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2289 } |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2290 } |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2291 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2292 if (n) { |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2293 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
|
2294 "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
|
2295 |
2bf10f37fa37
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17948
diff
changeset
|
2296 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
2297 purple_notify_emails(session->gc, /* handle */ |
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
2298 n, /* count */ |
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
2299 TRUE, /* detailed */ |
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
2300 subjects, froms, tos, urls, |
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
2301 NULL, /* PurpleNotifyCloseCallback cb */ |
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
2302 NULL); /* gpointer user_data */ |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2303 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2304 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2305 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2306 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
|
2307 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2308 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2309 /* Send request to check if there is new mail. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2310 static gboolean |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2311 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
|
2312 { |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2313 MsimSession *session; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2314 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2315 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
|
2316 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2317 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
|
2318 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
|
2319 "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
|
2320 "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
|
2321 "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
|
2322 "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
|
2323 "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
|
2324 "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
|
2325 "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
|
2326 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
|
2327 "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
|
2328 NULL), TRUE); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2329 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2330 /* 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
|
2331 return TRUE; |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2332 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2333 |
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
|
2334 /** Called when the session key arrives. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2335 static gboolean |
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
|
2336 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
|
2337 { |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2338 MsimMessage *body; |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2339 |
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
|
2340 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
|
2341 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
|
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 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2344 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
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
|
2345 |
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 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
|
2347 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
|
2348 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2349 /* What is proof? Used to be uid, but now is 52 base64'd bytes... */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2350 |
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
|
2351 /* 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
|
2352 * 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
|
2353 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
|
2354 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2355 /* Not sure what profileid is used for. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2356 if (msim_msg_get_integer(msg, "profileid") != session->userid) { |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2357 msim_unrecognized(session, msg, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2358 "Profile ID didn't match user ID, don't know why"); |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2359 } |
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
|
2360 |
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 /* 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
|
2362 * 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
|
2363 * 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
|
2364 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
|
2365 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2366 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2367 purple_debug_info("msim_we_are_logged_on", "TODO: pick username"); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2368 } |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2369 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2370 body = msim_msg_new(TRUE, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2371 "UserID", MSIM_TYPE_INTEGER, session->userid, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2372 NULL); |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2373 |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2374 /* Request IM info about ourself. */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2375 msim_send(session, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2376 "persist", MSIM_TYPE_STRING, g_strdup("persist"), |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2377 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2378 "dsn", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_DSN, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2379 "uid", MSIM_TYPE_INTEGER, session->userid, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2380 "lid", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_LID, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2381 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2382 "body", MSIM_TYPE_DICTIONARY, body, |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2383 NULL); |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2384 |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2385 /* Request MySpace info about ourself. */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2386 msim_send(session, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2387 "persist", MSIM_TYPE_STRING, g_strdup("persist"), |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2388 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2389 "dsn", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_DSN, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2390 "uid", MSIM_TYPE_INTEGER, session->userid, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2391 "lid", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_LID, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2392 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2393 "body", MSIM_TYPE_STRING, g_strdup(""), |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2394 NULL); |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2395 |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2396 /* TODO: set options (persist cmd=514,dsn=1,lid=10) */ |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2397 /* TODO: set blocklist */ |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2398 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2399 /* Notify servers of our current status. */ |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2400 purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\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
|
2401 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
|
2402 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
|
2403 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2404 /* TODO: setinfo */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2405 /* |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2406 body = msim_msg_new(TRUE, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2407 "TotalFriends", MSIM_TYPE_INTEGER, 666, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2408 NULL); |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2409 msim_send(session, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2410 "setinfo", MSIM_TYPE_BOOLEAN, TRUE, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2411 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2412 "info", MSIM_TYPE_DICTIONARY, body, |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2413 NULL); |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2414 */ |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2415 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2416 /* 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
|
2417 #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
|
2418 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
|
2419 (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
|
2420 #endif |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2421 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2422 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
|
2423 (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
|
2424 |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2425 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
|
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 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
|
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 * 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
|
2432 * |
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 * @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
|
2434 * @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
|
2435 * |
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 * @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
|
2437 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2438 static gboolean |
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_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
|
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 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
|
2442 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
|
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 #ifdef MSIM_DEBUG_MSG |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2445 msim_msg_dump("ready to process: %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
|
2446 #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
|
2447 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2448 if (msim_msg_get_integer(msg, "lc") == 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
|
2449 return msim_login_challenge(session, msg); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2450 } else if (msim_msg_get_integer(msg, "lc") == 2) { |
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
|
2451 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
|
2452 } else if (msim_msg_get(msg, "bm")) { |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2453 return msim_incoming_bm(session, 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
|
2454 } 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
|
2455 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
|
2456 } 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
|
2457 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
|
2458 } 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
|
2459 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
|
2460 } 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
|
2461 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
|
2462 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
|
2463 } |
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 } |
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 |
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 /** Store an field of information about a buddy. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2467 static void |
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
|
2468 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
|
2469 { |
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 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
|
2471 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
|
2472 |
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 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
|
2474 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
|
2475 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
|
2476 |
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 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
|
2478 strcmp(key_str, "Age") == 0 || |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2479 strcmp(key_str, "TotalFriends") == 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
|
2480 /* 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
|
2481 * 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
|
2482 * 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
|
2483 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
|
2484 } 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
|
2485 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
|
2486 } |
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 } |
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 |
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 /** 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
|
2490 * |
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 * @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
|
2492 * @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
|
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 * 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
|
2495 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2496 static gboolean |
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
|
2497 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
|
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 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
|
2500 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
|
2501 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
|
2502 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
|
2503 |
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 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
|
2505 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
|
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 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
|
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 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
|
2510 |
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 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
|
2512 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
|
2513 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
|
2514 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
|
2515 |
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 /* 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
|
2517 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
|
2518 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2519 if (!username) { |
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
|
2520 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
|
2521 "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
|
2522 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
|
2523 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
|
2524 } |
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 |
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 uid = g_hash_table_lookup(body, "UserID"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2527 if (!uid) { |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2528 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
|
2529 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
|
2530 } |
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
|
2531 |
17954
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
2532 purple_debug_info("msim", "associating uid %s with username %s\n", uid, username); |
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
|
2533 |
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 buddy = purple_find_buddy(session->account, username); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2535 if (buddy) { |
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
|
2536 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
|
2537 } |
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 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2539 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN && |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2540 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID) { |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2541 /* TODO: do something with our own IM info, if we need it for some |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2542 * specific purpose. Otherwise it is available on the buddy list, |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2543 * if the user has themselves as their own buddy. */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2544 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN && |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2545 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) { |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2546 /* TODO: same as above, but for MySpace info. */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2547 } |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2548 |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2549 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
|
2550 |
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
|
2551 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
|
2552 } |
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 |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2554 /** Process the initial server information from the server. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2555 static gboolean |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2556 msim_process_server_info(MsimSession *session, MsimMessage *msg) |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2557 { |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2558 gchar *body_str; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2559 GHashTable *body; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2560 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2561 body_str = msim_msg_get_string(msg, "body"); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2562 g_return_val_if_fail(body_str != NULL, FALSE); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2563 body = msim_parse_body(body_str); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2564 g_free(body_str); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2565 g_return_val_if_fail(body != NULL, FALSE); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2566 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2567 /* Example body: |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2568 AdUnitRefreshInterval=10. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2569 AlertPollInterval=360. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2570 AllowChatRoomEmoticonSharing=False. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2571 ChatRoomUserIDs=78744676;163733130;1300326231;123521495;142663391. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2572 CurClientVersion=673. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2573 EnableIMBrowse=True. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2574 EnableIMStuffAvatars=False. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2575 EnableIMStuffZaps=False. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2576 MaxAddAllFriends=100. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2577 MaxContacts=1000. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2578 MinClientVersion=594. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2579 MySpaceIM_ENGLISH=78744676. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2580 MySpaceNowTimer=720. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2581 PersistenceDataTimeout=900. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2582 UseWebChallenge=1. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2583 WebTicketGoHome=False |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2584 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2585 Anything useful? TODO: use what is useful, and use it. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2586 */ |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2587 purple_debug_info("msim_process_server_info", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2588 "maximum contacts: %s\n", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2589 g_hash_table_lookup(body, "MaxContacts") ? |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2590 g_hash_table_lookup(body, "MaxContacts") : "(NULL)"); |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2591 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2592 session->server_info = body; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2593 /* session->server_info freed in msim_session_destroy */ |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2594 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2595 return TRUE; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2596 } |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2597 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2598 /** Process a web challenge, used to login to the web site. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2599 static gboolean |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2600 msim_web_challenge(MsimSession *session, MsimMessage *msg) |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2601 { |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2602 /* TODO: web challenge, store token */ |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2603 return FALSE; |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2604 } |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2605 |
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
|
2606 /** |
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 * 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
|
2608 * |
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 * @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
|
2610 * @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
|
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 * @return TRUE if successful. |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2613 * |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2614 * msim_lookup_user sets callback for here |
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
|
2615 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2616 static gboolean |
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
|
2617 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
|
2618 { |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2619 MSIM_USER_LOOKUP_CB cb; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2620 gpointer data; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2621 guint rid, cmd, dsn, lid; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2622 |
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
|
2623 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
|
2624 g_return_val_if_fail(msg != NULL, FALSE); |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2625 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2626 msim_store_buddy_info(session, msg); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2627 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2628 rid = msim_msg_get_integer(msg, "rid"); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2629 cmd = msim_msg_get_integer(msg, "cmd"); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2630 dsn = msim_msg_get_integer(msg, "dsn"); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2631 lid = msim_msg_get_integer(msg, "lid"); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2632 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2633 /* Unsolicited messages */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2634 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)) { |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2635 if (dsn == MG_SERVER_INFO_DSN && lid == MG_SERVER_INFO_LID) { |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2636 return msim_process_server_info(session, msg); |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2637 } else if (dsn == MG_WEB_CHALLENGE_DSN && lid == MG_WEB_CHALLENGE_LID) { |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2638 return msim_web_challenge(session, msg); |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2639 } |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2640 } |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2641 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2642 /* If a callback is registered for this userid lookup, call it. */ |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2643 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2644 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2645 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2646 if (cb) { |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2647 purple_debug_info("msim", |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2648 "msim_process_body: calling callback now\n"); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2649 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2650 cb(session, msim_msg_clone(msg), data); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2651 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2652 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2653 } else { |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2654 purple_debug_info("msim", |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2655 "msim_process_body: no callback for rid %d\n", rid); |
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
|
2656 } |
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 |
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 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
|
2659 } |
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 |
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 * 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
|
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 * @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
|
2665 * @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
|
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 * @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
|
2668 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2669 static gboolean |
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
|
2670 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
|
2671 { |
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 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
|
2673 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
|
2674 |
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 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
|
2676 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
|
2677 |
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 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
|
2679 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
|
2680 |
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 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
|
2682 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
|
2683 |
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 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
|
2685 |
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 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
|
2687 |
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 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
|
2689 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
|
2690 |
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 /* Destroy session if fatal. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2692 if (msim_msg_get(msg, "fatal")) { |
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
|
2693 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
|
2694 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
|
2695 } |
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 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
|
2698 } |
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 |
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 /** |
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 * 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
|
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 * @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
|
2704 * @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
|
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 * @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
|
2707 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2708 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2709 msim_incoming_status(MsimSession *session, MsimMessage *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
|
2710 { |
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 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
|
2712 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
|
2713 //PurpleStatus *status; |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2714 //gchar **status_array; |
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 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
|
2716 gchar *status_headline; |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2717 //gchar *status_str; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2718 //gint i; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2719 gint status_code, purple_status_code; |
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
|
2720 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
|
2721 |
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 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
|
2723 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
|
2724 |
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 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
|
2726 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
2727 /* 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
|
2728 username = msim_msg_get_string(msg, "_username"); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2729 g_return_val_if_fail(username != NULL, FALSE); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2730 |
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
|
2731 { |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2732 gchar *ss; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2733 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2734 ss = msim_msg_get_string(msg, "msg"); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2735 purple_debug_info("msim", |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2736 "msim_status: updating status for <%s> to <%s>\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2737 username, ss ? ss : "(NULL)"); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2738 g_free(ss); |
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
|
2739 } |
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 |
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 /* 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
|
2742 * |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
|
2743 * |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
|
2744 */ |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2745 list = msim_msg_get_list(msg, "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
|
2746 |
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 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
|
2748 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
|
2749 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
|
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 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
|
2752 |
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 /* 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
|
2754 buddy = purple_find_buddy(session->account, username); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2755 if (!buddy) { |
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
|
2756 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
|
2757 "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
|
2758 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
|
2759 |
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 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
|
2761 |
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 /* 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
|
2763 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
|
2764 |
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 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
|
2766 } 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
|
2767 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
|
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 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
|
2771 |
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 /* Set user status */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2773 switch (status_code) { |
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
|
2774 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
|
2775 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
|
2776 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
|
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 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
|
2779 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
|
2780 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
|
2781 |
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 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
|
2783 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
|
2784 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
|
2785 |
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 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
|
2787 /* 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
|
2788 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
|
2789 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
|
2790 |
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 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
|
2792 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
|
2793 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
|
2794 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
|
2795 } |
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 |
17945
cf55077a3752
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17944
diff
changeset
|
2797 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
|
2798 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2799 if (status_code == MSIM_STATUS_CODE_IDLE) { |
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
|
2800 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
|
2801 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
|
2802 } 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
|
2803 /* 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
|
2804 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
|
2805 } |
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 |
17974
3d400b022acc
Disable sending third-party client version to oncoming buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17973
diff
changeset
|
2807 #ifdef MSIM_SEND_CLIENT_VERSION |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2808 if (status_code == MSIM_STATUS_CODE_ONLINE) { |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2809 /* Secretly whisper to unofficial clients our own version as they come online */ |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2810 msim_send_unofficial_client(session, username); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2811 } |
17974
3d400b022acc
Disable sending third-party client version to oncoming buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17973
diff
changeset
|
2812 #endif |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2813 |
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
|
2814 g_free(username); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2815 msim_msg_list_free(list); |
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
|
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 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
|
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 |
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 /** 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
|
2821 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
|
2822 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
|
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 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
|
2825 MsimMessage *msg; |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2826 MsimMessage *msg_persist; |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2827 MsimMessage *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
|
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 session = (MsimSession *)gc->proto_data; |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2830 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", |
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2831 buddy->name, (group && group->name) ? group->name : "(no group)"); |
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
|
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 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
|
2834 "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
|
2835 "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
|
2836 /* "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
|
2837 "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
|
2838 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
|
2839 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2840 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) { |
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
|
2841 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
|
2842 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
|
2843 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
|
2844 } |
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 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
|
2846 |
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 /* 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
|
2848 * 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
|
2849 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2850 body = msim_msg_new(TRUE, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2851 "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"), |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2852 "GroupName", MSIM_TYPE_STRING, g_strdup(group->name), |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2853 "Position", MSIM_TYPE_INTEGER, 1000, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2854 "Visibility", MSIM_TYPE_INTEGER, 1, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2855 "NickName", MSIM_TYPE_STRING, g_strdup(""), |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2856 "NameSelect", MSIM_TYPE_INTEGER, 0, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2857 NULL); |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2858 |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2859 /* TODO: Update blocklist. */ |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2860 |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2861 #if 0 |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2862 msg_persist = msim_msg_new(TRUE, |
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
|
2863 "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
|
2864 "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
|
2865 "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
|
2866 "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
|
2867 "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
|
2868 /* 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
|
2869 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2870 "body", MSIM_TYPE_DICTIONARY, body, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2871 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
|
2872 |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2873 if (!msim_postprocess_outgoing(session, msg_persist, buddy->name, "body", 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
|
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 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2876 msim_msg_free(msg_persist); |
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
|
2877 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
|
2878 } |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2879 msim_msg_free(msg_persist); |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2880 #endif |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
2881 |
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
|
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 |
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 /** 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
|
2885 * |
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 * @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
|
2887 * @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
|
2888 * @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
|
2889 * @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
|
2890 * |
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 * 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
|
2892 * 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
|
2893 * |
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 * 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
|
2895 * 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
|
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 * 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
|
2898 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2899 static MsimMessage * |
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
|
2900 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
|
2901 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
|
2902 { |
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 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
|
2904 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2905 /* First, check - if the field already exists, replace <uid> within it */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2906 if (msim_msg_get(msg, uid_field_name)) { |
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
|
2907 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
|
2908 gchar *fmt_string; |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2909 gchar *uid_str, *new_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
|
2910 |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
2911 /* Warning: this is a delicate, but safe, operation */ |
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
|
2912 |
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 elem = msim_msg_get(msg, uid_field_name); |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
2914 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2915 /* Get the packed element, flattening it. This allows <uid> to be |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2916 * replaced within nested data structures, since the replacement is done |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2917 * on the linear, packed data, not on a complicated data structure. |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2918 * |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2919 * For example, if the field was originally a dictionary or a list, you |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2920 * would have to iterate over all the items in it to see what needs to |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2921 * be replaced. But by packing it first, the <uid> marker is easily replaced |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2922 * just by a string replacement. |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2923 */ |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2924 fmt_string = msim_msg_pack_element_data(elem); |
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
|
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 uid_str = g_strdup_printf("%d", uid); |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2927 new_str = str_replace(fmt_string, "<uid>", uid_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
|
2928 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
|
2929 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
|
2930 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2931 /* Free the old element data */ |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2932 msim_msg_free_element_data(elem->data); |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2933 |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2934 /* Replace it with our new data */ |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2935 elem->data = new_str; |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2936 elem->type = MSIM_TYPE_RAW; |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
2937 |
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
|
2938 } 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
|
2939 /* 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
|
2940 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
|
2941 } |
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 |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
2943 msim_msg_dump("msim_postprocess_outgoing_cb: postprocessed msg=%s\n", msg); |
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
2944 |
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
|
2945 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
|
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 /** 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
|
2949 * |
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 * @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
|
2951 * @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
|
2952 * @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
|
2953 * |
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 * 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
|
2955 * |
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 * _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
|
2957 * _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
|
2958 * |
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 * |
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 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2961 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2962 msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2963 gpointer data) |
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
|
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 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
|
2966 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
|
2967 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
|
2968 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
|
2969 |
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 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
|
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 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
|
2973 |
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 /* 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
|
2975 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
|
2976 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
|
2977 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
|
2978 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
|
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 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
|
2981 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
|
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 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
|
2984 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
|
2985 |
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 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
|
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 /* Send */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2989 if (!msim_msg_send(session, msg)) { |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
2990 msim_msg_dump("msim_postprocess_outgoing_cb: sending failed for message: %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
|
2991 } |
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 |
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 /* 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
|
2995 * 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
|
2996 */ |
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 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
|
2998 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
|
2999 |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
3000 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
|
3001 |
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
|
3002 //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
|
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 |
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 /** 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
|
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 * @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
|
3008 * @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
|
3009 * @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
|
3010 * @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
|
3011 * @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
|
3012 * |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3013 * @return TRUE if successful. |
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
|
3014 */ |
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 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
|
3016 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
|
3017 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
|
3018 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
|
3019 { |
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 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
|
3021 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
|
3022 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
|
3023 |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3024 g_return_val_if_fail(msg != NULL, FALSE); |
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3025 |
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
|
3026 /* 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
|
3027 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
|
3028 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
|
3029 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
|
3030 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
|
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 /* First, try the most obvious. If numeric userid is given, use that directly. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3033 if (msim_is_userid(username)) { |
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
|
3034 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
|
3035 } 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
|
3036 /* 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
|
3037 buddy = purple_find_buddy(session->account, username); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3038 if (buddy) { |
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
|
3039 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
|
3040 } 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
|
3041 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
|
3042 } |
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 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
|
3045 { |
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 /* 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
|
3047 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
3048 username ? username : "(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
|
3049 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
|
3050 /* 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
|
3051 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
|
3052 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
|
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 } |
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 |
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 /* 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
|
3057 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
3058 username ? username : "(NULL)", uid); |
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
|
3059 |
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 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
|
3061 |
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 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
|
3063 |
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 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
|
3065 |
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 //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
|
3067 |
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 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
|
3069 } |
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 /** 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
|
3072 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
|
3073 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
|
3074 { |
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 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
|
3076 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
|
3077 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
|
3078 MsimMessage *blocklist_msg; |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3079 GList *blocklist_updates; |
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
|
3080 |
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 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
|
3082 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3083 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
|
3084 "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
|
3085 "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
|
3086 /* '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
|
3087 NULL); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3088 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3089 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", 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
|
3090 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3091 msim_msg_free(delbuddy_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
|
3092 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
|
3093 } |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3094 msim_msg_free(delbuddy_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
|
3095 |
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 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
|
3097 "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
|
3098 "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
|
3099 "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
|
3100 "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
|
3101 "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
|
3102 "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
|
3103 "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
|
3104 /* <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
|
3105 "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
|
3106 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
|
3107 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3108 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", 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
|
3109 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3110 msim_msg_free(persist_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
|
3111 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
|
3112 } |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3113 msim_msg_free(persist_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
|
3114 |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3115 blocklist_updates = NULL; |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3116 blocklist_updates = g_list_prepend(blocklist_updates, "a-"); |
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3117 blocklist_updates = g_list_prepend(blocklist_updates, "<uid>"); |
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3118 blocklist_updates = g_list_prepend(blocklist_updates, "b-"); |
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3119 blocklist_updates = g_list_prepend(blocklist_updates, "<uid>"); |
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3120 blocklist_updates = g_list_reverse(blocklist_updates); |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3121 |
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
|
3122 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
|
3123 "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
|
3124 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3125 /* TODO: MsimMessage lists. Currently <uid> isn't replaced in lists. */ |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3126 //"idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3127 "idlist", MSIM_TYPE_LIST, blocklist_updates, |
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
|
3128 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
|
3129 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3130 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", 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
|
3131 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3132 msim_msg_free(blocklist_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
|
3133 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
|
3134 } |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3135 msim_msg_free(blocklist_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
|
3136 } |
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 |
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 /** 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
|
3139 * |
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 * 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
|
3141 * 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
|
3142 */ |
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 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
|
3144 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
|
3145 { |
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 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
|
3147 } |
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 |
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 /** |
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 * 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
|
3151 * |
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 * @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
|
3153 * @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
|
3154 * @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
|
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 * 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
|
3157 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3158 static void |
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
|
3159 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
|
3160 { |
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 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
|
3162 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
|
3163 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
|
3164 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
|
3165 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
|
3166 |
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 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
|
3168 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
|
3169 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3170 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
|
3171 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
|
3172 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
|
3173 |
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 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
|
3175 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
|
3176 |
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 /* 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
|
3178 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
|
3179 |
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 /* 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
|
3181 * 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
|
3182 * 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
|
3183 */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3184 if (session->rxoff >= MSIM_READ_BUF_SIZE) { |
17954
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3185 purple_debug_error("msim", |
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3186 "msim_input_cb: %d-byte read buffer full! rxoff=%d\n", |
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3187 MSIM_READ_BUF_SIZE, session->rxoff); |
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
|
3188 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
|
3189 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
|
3190 } |
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 |
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 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
|
3193 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
|
3194 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
|
3195 |
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 /* 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
|
3197 * 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
|
3198 */ |
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 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
|
3200 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3201 if (n < 0 && errno == EAGAIN) { |
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
|
3202 return; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3203 } else if (n < 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
|
3204 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
|
3205 "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
|
3206 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
|
3207 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
|
3208 return; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3209 } else if (n == 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
|
3210 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
|
3211 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
|
3212 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
|
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 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3215 if (n + session->rxoff >= MSIM_READ_BUF_SIZE) { |
17954
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3216 purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n", |
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3217 n, n + session->rxoff, MSIM_READ_BUF_SIZE); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3218 /* TODO: g_realloc like msn, yahoo, irc, jabber? */ |
17954
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3219 purple_connection_error(gc, _("Read buffer full")); |
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3220 } |
016f9b2d6ee0
Increase read buffer size and be more careful about overruns.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17953
diff
changeset
|
3221 |
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
|
3222 /* Null terminate */ |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
3223 purple_debug_info("msim", "msim_input_cb: going to null terminate " |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
3224 "at n=%d\n", 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
|
3225 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
|
3226 |
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 #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
|
3228 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3229 if (strlen(session->rxbuf + session->rxoff) != 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
|
3230 /* 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
|
3231 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
|
3232 "--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
|
3233 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
|
3234 //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
|
3235 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
|
3236 } |
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 #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
|
3238 |
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 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
|
3240 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
|
3241 |
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 #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
|
3243 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
|
3244 #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
|
3245 |
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 /* Look for \\final\\ end markers. If found, process message. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3247 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) { |
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
|
3248 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
|
3249 |
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 #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
|
3251 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
|
3252 #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
|
3253 *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
|
3254 msg = msim_parse(g_strdup(session->rxbuf)); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3255 if (!msg) { |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
3256 purple_debug_info("msim", "msim_input_cb: couldn't parse rxbuf\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
|
3257 purple_connection_error(gc, _("Unparseable message")); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3258 } else { |
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
|
3259 /* 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
|
3260 * clone message if it wants to keep it afterwards.) */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3261 if (!msim_preprocess_incoming(session, 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
|
3262 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
|
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 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
|
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 |
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 /* 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
|
3268 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
|
3269 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
|
3270 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
|
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 /* 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
|
3273 //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
|
3274 } |
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 } |
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 /* 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
|
3278 * |
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 * @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
|
3280 * @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
|
3281 * |
17951 | 3282 * @return The request/reply ID, used to link replies with requests, or -1. |
3283 * 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
|
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 * 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
|
3286 * 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
|
3287 * 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
|
3288 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3289 static guint |
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
|
3290 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
|
3291 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
|
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 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
|
3294 |
17951 | 3295 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
3296 | |
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
|
3297 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
|
3298 |
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 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
|
3300 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
|
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 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
|
3303 } |
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 |
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 * 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
|
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 * @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
|
3309 * @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
|
3310 * @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
|
3311 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3312 static void |
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
|
3313 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
|
3314 { |
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 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
|
3316 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
|
3317 |
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 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
|
3319 |
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 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
|
3321 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
|
3322 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3323 if (source < 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
|
3324 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
|
3325 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
|
3326 _("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
|
3327 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
|
3328 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
|
3329 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
|
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 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
|
3333 |
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 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
|
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 |
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 /* 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
|
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 /** |
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 * 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
|
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 * @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
|
3343 * |
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 * @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
|
3345 */ |
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 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
|
3347 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
|
3348 { |
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 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
|
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 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
|
3352 |
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 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
|
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 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
|
3356 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
|
3357 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
|
3358 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
|
3359 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
|
3360 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
|
3361 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
|
3362 |
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 /* 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
|
3364 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
|
3365 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
|
3366 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
|
3367 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
|
3368 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
|
3369 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
|
3370 Figure this out, once free cache. */ |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3371 |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3372 /* Created in msim_process_server_info() */ |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3373 session->server_info = NULL; |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3374 |
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
|
3375 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
|
3376 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
|
3377 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
|
3378 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
|
3379 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
|
3380 |
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 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
|
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 |
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 * 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
|
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 * @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
|
3388 */ |
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 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
|
3390 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
|
3391 { |
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 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
|
3393 |
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 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
|
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 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
|
3397 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
|
3398 |
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 /* 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
|
3400 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
|
3401 g_hash_table_destroy(session->user_lookup_cb_data); |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3402 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3403 if (session->server_info) { |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3404 g_hash_table_destroy(session->server_info); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3405 } |
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
|
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 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
|
3408 } |
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 * 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
|
3412 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3413 * @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
|
3414 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3415 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
|
3416 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
|
3417 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3418 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
|
3419 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3420 if (gc == 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
|
3421 return; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3422 } |
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
|
3423 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3424 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
|
3425 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
|
3426 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
|
3427 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3428 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
|
3429 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3430 if (!MSIM_SESSION_VALID(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
|
3431 return; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3432 } |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3433 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3434 if (session->gc->inpa) { |
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
|
3435 purple_input_remove(session->gc->inpa); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3436 } |
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
|
3437 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3438 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
|
3439 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3440 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3441 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3442 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3443 * 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
|
3444 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3445 * @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
|
3446 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3447 * @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
|
3448 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3449 static gboolean |
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
|
3450 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
|
3451 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3452 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
|
3453 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3454 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
|
3455 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3456 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3457 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3458 * 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
|
3459 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3460 * @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
|
3461 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3462 * @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
|
3463 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3464 * 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
|
3465 * 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
|
3466 * 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
|
3467 * 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
|
3468 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3469 static gboolean |
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
|
3470 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
|
3471 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3472 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
|
3473 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3474 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
|
3475 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3476 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3477 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3478 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3479 * 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
|
3480 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3481 * @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
|
3482 * @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
|
3483 * @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
|
3484 * @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
|
3485 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3486 /* TODO: change to not use callbacks */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3487 static void |
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
|
3488 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
|
3489 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
|
3490 { |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3491 MsimMessage *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
|
3492 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
|
3493 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
|
3494 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3495 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
|
3496 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
|
3497 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
|
3498 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3499 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
|
3500 "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
|
3501 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3502 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
|
3503 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3504 /* 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
|
3505 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
|
3506 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3507 /* 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
|
3508 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3509 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
|
3510 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3511 if (msim_is_userid(user)) { |
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
|
3512 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
|
3513 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
|
3514 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
|
3515 } 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
|
3516 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
|
3517 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
|
3518 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
|
3519 } 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
|
3520 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
|
3521 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
|
3522 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
|
3523 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3524 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3525 body = msim_msg_new(TRUE, |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3526 field_name, MSIM_TYPE_STRING, g_strdup(user), |
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3527 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
|
3528 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3529 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
|
3530 "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
|
3531 "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
|
3532 "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
|
3533 "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
|
3534 "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
|
3535 "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
|
3536 "rid", MSIM_TYPE_INTEGER, rid, |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3537 "body", MSIM_TYPE_DICTIONARY, 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
|
3538 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
|
3539 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3540 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3541 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3542 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3543 * 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
|
3544 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3545 * @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
|
3546 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3547 * @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
|
3548 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3549 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3550 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
|
3551 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
|
3552 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3553 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
|
3554 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
|
3555 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3556 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
|
3557 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3558 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
|
3559 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
|
3560 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3561 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
|
3562 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3563 /* Retrieve display name and/or headline, depending on user preference. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3564 if (purple_account_get_bool(session->account, "show_display_name", TRUE)) { |
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
|
3565 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
|
3566 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3567 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3568 if (purple_account_get_bool(session->account, "show_headline", FALSE)) { |
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
|
3569 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
|
3570 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3571 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3572 /* 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
|
3573 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3574 if (display_name && headline) { |
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
|
3575 return g_strconcat(display_name, " ", headline, NULL); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3576 } |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3577 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3578 if (display_name) { |
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
|
3579 return g_strdup(display_name); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3580 } |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3581 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3582 if (headline) { |
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
|
3583 return g_strdup(headline); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3584 } |
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
|
3585 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3586 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
|
3587 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3588 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3589 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3590 * 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
|
3591 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3592 * @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
|
3593 * @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
|
3594 * @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
|
3595 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3596 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3597 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
|
3598 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
|
3599 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
|
3600 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3601 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
|
3602 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
|
3603 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3604 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
|
3605 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
|
3606 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3607 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { |
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
|
3608 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
|
3609 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3610 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
|
3611 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3612 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
|
3613 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3614 /* 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
|
3615 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3616 /* 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
|
3617 * 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
|
3618 str = purple_blist_node_get_string(&buddy->node, "UserName"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3619 if (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
|
3620 purple_notify_user_info_add_pair(user_info, _("User Name"), str); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3621 } |
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
|
3622 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3623 /* 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
|
3624 n = purple_blist_node_get_int(&buddy->node, "Age"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3625 if (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
|
3626 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
|
3627 g_strdup_printf("%d", n)); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3628 } |
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
|
3629 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3630 str = purple_blist_node_get_string(&buddy->node, "Gender"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3631 if (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
|
3632 purple_notify_user_info_add_pair(user_info, _("Gender"), str); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3633 } |
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
|
3634 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3635 str = purple_blist_node_get_string(&buddy->node, "Location"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3636 if (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
|
3637 purple_notify_user_info_add_pair(user_info, _("Location"), str); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3638 } |
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
|
3639 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3640 /* 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
|
3641 str = purple_blist_node_get_string(&buddy->node, "Headline"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3642 if (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
|
3643 purple_notify_user_info_add_pair(user_info, _("Headline"), str); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3644 } |
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
|
3645 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3646 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
|
3647 str2 = purple_blist_node_get_string(&buddy->node, "SongName"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3648 if (str || str2) { |
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
|
3649 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
|
3650 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
|
3651 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
|
3652 str2 ? str2 : _("Unknown Song"))); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3653 } |
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
|
3654 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3655 n = purple_blist_node_get_int(&buddy->node, "TotalFriends"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3656 if (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
|
3657 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
|
3658 g_strdup_printf("%d", n)); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3659 } |
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
|
3660 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3661 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3662 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3663 |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3664 /** Actions menu for account. */ |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3665 GList * |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3666 msim_actions(PurplePlugin *plugin, gpointer context) |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3667 { |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3668 PurpleConnection *gc; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3669 GList *menu; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3670 //PurplePluginAction *act; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3671 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3672 gc = (PurpleConnection *)context; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3673 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3674 menu = NULL; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3675 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3676 #if 0 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3677 /* TODO: find out how */ |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3678 act = purple_plugin_action_new(_("Find people..."), msim_); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3679 menu = g_list_append(menu, act); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3680 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3681 act = purple_plugin_action_new(_("Import friends..."), NULL); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3682 menu = g_list_append(menu, act); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3683 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3684 act = purple_plugin_action_new(_("Change IM name..."), NULL); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3685 menu = g_list_append(menu, act); |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3686 #endif |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3687 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3688 return menu; |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3689 } |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3690 |
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
|
3691 /** Callbacks called by Purple, to access this plugin. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3692 PurplePluginProtocolInfo prpl_info = { |
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
|
3693 /* options */ |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3694 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
|
3695 | OPT_PROTO_MAIL_CHECK, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3696 |
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
|
3697 /* | 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
|
3698 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
|
3699 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
|
3700 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
|
3701 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
|
3702 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
|
3703 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
|
3704 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
|
3705 msim_status_types, /* status_types */ |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
3706 msim_blist_node_menu, /* blist_node_menu */ |
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
|
3707 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
|
3708 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
|
3709 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
|
3710 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
|
3711 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
|
3712 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
|
3713 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
|
3714 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
|
3715 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
|
3716 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
|
3717 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
|
3718 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
|
3719 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
|
3720 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
|
3721 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
|
3722 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
|
3723 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
|
3724 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
|
3725 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
|
3726 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
|
3727 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
|
3728 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
|
3729 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
|
3730 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
|
3731 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
|
3732 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
|
3733 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
|
3734 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
|
3735 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
|
3736 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
|
3737 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
|
3738 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
|
3739 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
|
3740 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
|
3741 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
|
3742 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
|
3743 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
|
3744 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
|
3745 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
|
3746 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
|
3747 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
|
3748 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
|
3749 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
|
3750 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
|
3751 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
|
3752 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
|
3753 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
|
3754 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
|
3755 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
|
3756 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
|
3757 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
|
3758 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
|
3759 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
|
3760 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
|
3761 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
|
3762 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
|
3763 }; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3764 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3765 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3766 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3767 /** Based on MSN's plugin info comments. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3768 PurplePluginInfo info = { |
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
|
3769 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
|
3770 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
|
3771 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
|
3772 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
|
3773 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
|
3774 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
|
3775 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
|
3776 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
|
3777 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3778 "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
|
3779 "MySpaceIM", /**< name */ |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
3780 MSIM_PRPL_VERSION_STRING, /**< 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
|
3781 /** 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
|
3782 "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
|
3783 /** 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
|
3784 "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
|
3785 "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
|
3786 "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
|
3787 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3788 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
|
3789 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
|
3790 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
|
3791 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
|
3792 &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
|
3793 NULL, /**< prefs_info */ |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3794 msim_actions, /**< msim_actions */ |
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
|
3795 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
|
3796 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
|
3797 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
|
3798 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
|
3799 }; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3800 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3801 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3802 #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
|
3803 /** 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
|
3804 * Used to test or try out the internal workings of msimprpl. If you're reading |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3805 * this code for the first time, these functions can be instructive in learning |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3806 * how msimprpl is architected. |
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
|
3807 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3808 void |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3809 msim_test_all(void) { |
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
|
3810 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
|
3811 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3812 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3813 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
|
3814 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
|
3815 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
|
3816 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3817 if (failures) { |
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
|
3818 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3819 } else { |
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
|
3820 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
|
3821 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3822 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
|
3823 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3824 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3825 /** 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
|
3826 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
|
3827 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
|
3828 { |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3829 MsimMessage *msg, *msg_cloned, *msg2; |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3830 GList *list; |
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
|
3831 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
|
3832 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
|
3833 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3834 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
|
3835 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3836 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
|
3837 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
|
3838 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3839 /* 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
|
3840 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
|
3841 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
|
3842 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
|
3843 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
|
3844 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
|
3845 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
|
3846 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
|
3847 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
|
3848 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3849 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
|
3850 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3851 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
|
3852 "\\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
|
3853 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3854 if (0 != strcmp(packed, packed_expected)) { |
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
|
3855 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
|
3856 ++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
|
3857 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3858 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3859 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3860 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
|
3861 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
|
3862 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3863 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3864 if (0 != strcmp(packed, packed_cloned)) { |
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
|
3865 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
|
3866 ++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
|
3867 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3868 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3869 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
|
3870 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
|
3871 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
|
3872 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
|
3873 |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3874 /* Try some of the more advanced functionality */ |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3875 list = NULL; |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3876 |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3877 list = g_list_prepend(list, "item3"); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3878 list = g_list_prepend(list, "item2"); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3879 list = g_list_prepend(list, "item1"); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3880 list = g_list_prepend(list, "item0"); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3881 |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3882 msg = msim_msg_new(FALSE); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3883 msg = msim_msg_append(msg, "string", MSIM_TYPE_STRING, g_strdup("string value")); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3884 msg = msim_msg_append(msg, "raw", MSIM_TYPE_RAW, g_strdup("raw value")); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3885 msg = msim_msg_append(msg, "integer", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(3140)); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3886 msg = msim_msg_append(msg, "boolean", MSIM_TYPE_BOOLEAN, GUINT_TO_POINTER(FALSE)); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3887 msg = msim_msg_append(msg, "list", MSIM_TYPE_LIST, list); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3888 |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3889 msim_msg_dump("msg with list=%s\n", msg); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3890 purple_debug_info("msim", "msg with list packed=%s\n", msim_msg_pack(msg)); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3891 |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3892 msg2 = msim_msg_new(FALSE); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3893 msg2 = msim_msg_append(msg2, "outer", MSIM_TYPE_STRING, g_strdup("outer value")); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3894 msg2 = msim_msg_append(msg2, "body", MSIM_TYPE_DICTIONARY, msg); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3895 msim_msg_dump("msg with dict=%s\n", msg2); /* msg2 now 'owns' msg */ |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3896 purple_debug_info("msim", "msg with dict packed=%s\n", msim_msg_pack(msg2)); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3897 |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3898 msim_msg_free(msg2); |
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3899 |
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
|
3900 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
|
3901 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3902 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3903 /** 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
|
3904 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
|
3905 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
|
3906 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3907 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
|
3908 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
|
3909 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3910 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
|
3911 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3912 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
|
3913 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3914 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
|
3915 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3916 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
|
3917 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
|
3918 expected = "hello/1world/2hello/1world"; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3919 if (0 != strcmp(escaped, expected)) { |
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
|
3920 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
|
3921 ++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
|
3922 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3923 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3924 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3925 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
|
3926 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
|
3927 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3928 if (0 != strcmp(raw, unescaped)) { |
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
|
3929 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
|
3930 ++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
|
3931 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3932 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3933 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
|
3934 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3935 #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
|
3936 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3937 /** 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
|
3938 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
|
3939 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
|
3940 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3941 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
|
3942 #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
|
3943 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
|
3944 #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
|
3945 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3946 /* 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
|
3947 * 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
|
3948 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
|
3949 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
|
3950 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3951 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
|
3952 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
|
3953 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3954 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
|
3955 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
|
3956 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3957 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
|
3958 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
3959 |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
3960 option = purple_account_option_bool_new(_("Send emoticons"), "emoticons", FALSE); |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
3961 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
3962 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
3963 #ifdef MSIM_USER_REALLY_CARES_ABOUT_PRECISE_FONT_SIZES |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
3964 option = purple_account_option_int_new(_("Screen resolution (dots per inch)"), "dpi", MSIM_DEFAULT_DPI); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
3965 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
3966 |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
3967 option = purple_account_option_int_new(_("Base font size (points)"), "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
3968 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
3969 #endif |
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
|
3970 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3971 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17692
diff
changeset
|
3972 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |