Mercurial > pidgin.yaz
annotate libpurple/protocols/myspace/markup.c @ 30107:08957bb38e30
jabber: Check at connection time that the user specified a JID with a node.
This was reported by Florian Quze as http://crash-stats.instantbird.com/report/index/6747f742-f02e-4ccf-8214-0ad152100325.
The only way I can see that happening is if jid->node is NULL (i.e. my
account username is something like "darkrain42.org").
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 10 Apr 2010 19:43:04 +0000 |
parents | eb9edb1c36ac |
children | b1a6535f99d9 |
rev | line source |
---|---|
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
1 /* MySpaceIM Protocol Plugin - markup |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
2 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
4 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
8 * (at your option) any later version. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
9 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
13 * GNU General Public License for more details. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
14 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
18 */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
19 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
20 #include "myspace.h" |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
21 |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
22 typedef int (*MSIM_XMLNODE_CONVERT)(MsimSession *, xmlnode *, gchar **, gchar **); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
23 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
24 /* Globals */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
25 |
24665 | 26 /* The names in in emoticon_names (for <i n=whatever>) map to corresponding |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
27 * entries in emoticon_symbols (for the ASCII representation of the emoticon). |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
28 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
29 * Multiple emoticon symbols in Pidgin can map to one name. List the |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
30 * canonical form, as inserted by the "Smile!" dialog, first. For example, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
31 * :) comes before :-), because although both are recognized as 'happy', |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
32 * the first is inserted by the smiley button (first symbol in theme). |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
33 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
34 * Note that symbols are case-sensitive in Pidgin -- :-X is not :-x. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
35 static struct MSIM_EMOTICON |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
36 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
37 gchar *name; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
38 gchar *symbol; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
39 } msim_emoticons[] = { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
40 /* Unfortunately, this list duplicates much of the file |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
41 * pidgin/pidgin/pixmaps/emotes/default/22/default.theme.in, because |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
42 * that file is part of Pidgin, but we're part of libpurple. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
43 */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
44 { "bigsmile", ":D" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
45 { "bigsmile", ":-D" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
46 { "devil", "}:)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
47 { "frazzled", ":Z" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
48 { "geek", "B)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
49 { "googles", "%)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
50 { "growl", ":E" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
51 { "laugh", ":))" }, /* Must be before ':)' */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
52 { "happy", ":)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
53 { "happy", ":-)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
54 { "happi", ":)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
55 { "heart", ":X" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
56 { "mohawk", "-:" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
57 { "mad", "X(" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
58 { "messed", "X)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
59 { "nerd", "Q)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
60 { "oops", ":G" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
61 { "pirate", "P)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
62 { "scared", ":O" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
63 { "sidefrown", ":{" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
64 { "sinister", ":B" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
65 { "smirk", ":," }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
66 { "straight", ":|" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
67 { "tongue", ":P" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
68 { "tongue", ":p" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
69 { "tongy", ":P" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
70 { "upset", "B|" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
71 { "wink", ";-)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
72 { "wink", ";)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
73 { "winc", ";)" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
74 { "worried", ":[" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
75 { "kiss", ":x" }, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
76 { NULL, NULL } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
77 }; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
78 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
79 /* Indexes of this array + 1 map HTML font size to scale of normal font size. * |
24665 | 80 * Based on _point_sizes from libpurple/gtkimhtml.c |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
81 * 1 2 3 4 5 6 7 */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
82 static gdouble _font_scale[] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736 }; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
83 |
24676 | 84 /* Purple maximum font size. Equivalent to sizeof(_font_scale) / sizeof(_font_scale[0]) */ |
85 #define MAX_FONT_SIZE 7 | |
86 | |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
87 #define POINTS_PER_INCH 72 /* How many pt's in an inch */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
88 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
89 /* Text formatting bits for <f s=#> */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
90 #define MSIM_TEXT_BOLD 1 |
24665 | 91 #define MSIM_TEXT_ITALIC 2 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
92 #define MSIM_TEXT_UNDERLINE 4 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
93 |
24665 | 94 /* Default baseline size of purple's fonts, in points. What is size 3 in points. |
95 * _font_scale specifies scaling factor relative to this point size. Note this | |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
96 * is only the default; it is configurable in account options. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
97 #define MSIM_BASE_FONT_POINT_SIZE 8 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
98 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
99 /* Default display's DPI. 96 is common but it can differ. Also configurable |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
100 * in account options. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
101 #define MSIM_DEFAULT_DPI 96 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
102 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
103 /* round is part of C99, but sometimes is unavailable before then. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
104 * Based on http://forums.belution.com/en/cpp/000/050/13.shtml |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
105 */ |
24664
85efcade4caa
Remove unneeded forward declarations. I guess my philosophy is to only
Mark Doliner <mark@kingant.net>
parents:
22499
diff
changeset
|
106 static double msim_round(double value) |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
107 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
108 if (value < 0) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
109 return -(floor(-value + 0.5)); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
110 } else { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
111 return floor( value + 0.5); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
112 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
113 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
114 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
115 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
116 * Convert typographical font point size to HTML font size. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
117 * Based on libpurple/gtkimhtml.c |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
118 */ |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
119 static guint |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
120 msim_point_to_purple_size(MsimSession *session, guint point) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
121 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
122 guint size, this_point, base; |
24665 | 123 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
124 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
24665 | 125 |
24676 | 126 for (size = 0; size < MAX_FONT_SIZE; ++size) { |
127 this_point = (guint)msim_round(base * _font_scale[size]); | |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
128 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
129 if (this_point >= point) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
130 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
131 point, size); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
132 return size; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
133 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
134 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
135 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
136 /* No HTML font size was this big; return largest possible. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
137 return this_point; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
138 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
139 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
140 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
141 * Convert HTML font size to point size. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
142 */ |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
143 static guint |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
144 msim_purple_size_to_point(MsimSession *session, guint size) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
145 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
146 gdouble scale; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
147 guint point; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
148 guint base; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
149 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
150 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
151 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
152 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
153 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
154 point = (guint)msim_round(scale * base); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
155 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
156 purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n", |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
157 size, point); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
158 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
159 return point; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
160 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
161 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
162 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
163 * Convert a msim markup font pixel height to the more usual point size, for incoming messages. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
164 */ |
24665 | 165 static guint |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
166 msim_height_to_point(MsimSession *session, guint height) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
167 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
168 guint dpi; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
169 |
22499
01dcbd5333ca
In msimprpl, when converting point size and MySpaceIM-markup font size,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22390
diff
changeset
|
170 dpi = purple_account_get_int(session->account, "dpi", MSIM_DEFAULT_DPI); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
171 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
172 return (guint)msim_round((POINTS_PER_INCH * 1. / dpi) * height); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
173 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
174 /* See also: libpurple/protocols/bonjour/jabber.c |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
175 * _font_size_ichat_to_purple */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
176 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
177 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
178 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
179 * Convert point size to msim pixel height font size specification, for outgoing messages. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
180 */ |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
181 static guint |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
182 msim_point_to_height(MsimSession *session, guint point) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
183 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
184 guint dpi; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
185 |
22499
01dcbd5333ca
In msimprpl, when converting point size and MySpaceIM-markup font size,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
22390
diff
changeset
|
186 dpi = purple_account_get_int(session->account, "dpi", MSIM_DEFAULT_DPI); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
187 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
188 return (guint)msim_round((dpi * 1. / POINTS_PER_INCH) * point); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
189 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
190 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
191 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
192 * Convert the msim markup <f> (font) tag into HTML. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
193 */ |
24665 | 194 static void |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
195 msim_markup_f_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
196 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
197 const gchar *face, *height_str, *decor_str; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
198 GString *gs_end, *gs_begin; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
199 guint decor, height; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
200 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
201 face = xmlnode_get_attrib(root, "f"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
202 height_str = xmlnode_get_attrib(root, "h"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
203 decor_str = xmlnode_get_attrib(root, "s"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
204 |
24689
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
205 /* Validate the font face, to avoid constructing invalid HTML later */ |
24733
b0b3952aae27
Only validate the font face if it's non-null
Mark Doliner <mark@kingant.net>
parents:
24689
diff
changeset
|
206 if (face != NULL && strchr(face, '\'') != NULL) |
24689
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
207 face = NULL; |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
208 |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
209 height = height_str != NULL ? atol(height_str) : 12; |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
210 decor = decor_str != NULL ? atol(decor_str) : 0; |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
211 |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
212 /* |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
213 * The HTML we're constructing here is a bit redudant. Ideally we |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
214 * would use only the font-family and font-size CSS span, but Pidgin |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
215 * doesn't support it (it's included for other UIs). For Pidgin we |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
216 * wrap the whole thing in an ugly font tag, and Pidgin will happily |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
217 * ignore the <span>. |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
218 */ |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
219 gs_begin = g_string_new(""); |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
220 if (height && !face) { |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
221 guint point_size = msim_height_to_point(session, height); |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
222 g_string_printf(gs_begin, |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
223 "<font size='%d'><span style='font-size: %dpt'>", |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
224 msim_point_to_purple_size(session, point_size), |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
225 point_size); |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
226 } else if (height && face) { |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
227 guint point_size = msim_height_to_point(session, height); |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
228 g_string_printf(gs_begin, |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
229 "<font face='%s' size='%d'><span style='font-family: %s; font-size: %dpt'>", |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
230 face, msim_point_to_purple_size(session, point_size), |
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
231 face, point_size); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
232 } else { |
24689
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
233 g_string_printf(gs_begin, "<font><span>"); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
234 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
235 |
24689
e268ad14e693
Change MySpace to wrap incoming messages in <span style="font-size: Npt;">
Mark Doliner <mark@kingant.net>
parents:
24676
diff
changeset
|
236 gs_end = g_string_new("</span></font>"); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
237 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
238 if (decor & MSIM_TEXT_BOLD) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
239 g_string_append(gs_begin, "<b>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
240 g_string_prepend(gs_end, "</b>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
241 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
242 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
243 if (decor & MSIM_TEXT_ITALIC) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
244 g_string_append(gs_begin, "<i>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
245 g_string_append(gs_end, "</i>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
246 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
247 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
248 if (decor & MSIM_TEXT_UNDERLINE) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
249 g_string_append(gs_begin, "<u>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
250 g_string_append(gs_end, "</u>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
251 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
252 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
253 *begin = g_string_free(gs_begin, FALSE); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
254 *end = g_string_free(gs_end, FALSE); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
255 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
256 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
257 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
258 * Convert a msim markup color to a color suitable for libpurple. |
24665 | 259 * |
260 * @param msim Either a color name, or an rgb(x,y,z) code. | |
261 * | |
262 * @return A new string, either a color name or #rrggbb code. Must g_free(). | |
263 */ | |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
264 static char * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
265 msim_color_to_purple(const char *msim) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
266 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
267 guint red, green, blue; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
268 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
269 if (!msim) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
270 return g_strdup("black"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
271 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
272 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
273 if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
274 /* Color name. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
275 return g_strdup(msim); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
276 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
277 /* TODO: rgba (alpha). */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
278 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
279 return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
280 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
281 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
282 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
283 * Convert the msim markup <a> (anchor) tag into HTML. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
284 */ |
24665 | 285 static void |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
286 msim_markup_a_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
287 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
288 const gchar *href; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
289 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
290 href = xmlnode_get_attrib(root, "h"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
291 if (!href) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
292 href = ""; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
293 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
294 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
295 *begin = g_strdup_printf("<a href=\"%s\">%s", href, href); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
296 *end = g_strdup("</a>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
297 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
298 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
299 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
300 * Convert the msim markup <p> (paragraph) tag into HTML. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
301 */ |
24665 | 302 static void |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
303 msim_markup_p_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
304 { |
24665 | 305 /* Just pass through unchanged. |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
306 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
307 * Note: attributes currently aren't passed, if there are any. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
308 *begin = g_strdup("<p>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
309 *end = g_strdup("</p>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
310 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
311 |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
312 /** |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
313 * Convert the msim markup <c> tag (text color) into HTML. |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
314 */ |
24665 | 315 static void |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
316 msim_markup_c_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
317 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
318 const gchar *color; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
319 gchar *purple_color; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
320 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
321 color = xmlnode_get_attrib(root, "v"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
322 if (!color) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
323 purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr\n"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
324 *begin = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
325 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
326 /* TODO: log as unrecognized */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
327 return; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
328 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
329 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
330 purple_color = msim_color_to_purple(color); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
331 |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
332 #ifdef USE_CSS_FORMATTING |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
333 *begin = g_strdup_printf("<span style='color: %s'>", purple_color); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
334 *end = g_strdup("</span>"); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
335 #else |
24665 | 336 *begin = g_strdup_printf("<font color='%s'>", purple_color); |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
337 *end = g_strdup("</font>"); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
338 #endif |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
339 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
340 g_free(purple_color); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
341 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
342 |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
343 /** |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
344 * Convert the msim markup <b> tag (background color) into HTML. |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
345 */ |
24665 | 346 static void |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
347 msim_markup_b_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
348 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
349 const gchar *color; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
350 gchar *purple_color; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
351 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
352 color = xmlnode_get_attrib(root, "v"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
353 if (!color) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
354 *begin = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
355 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
356 purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr\n"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
357 /* TODO: log as unrecognized. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
358 return; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
359 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
360 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
361 purple_color = msim_color_to_purple(color); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
362 |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
363 #ifdef USE_CSS_FORMATTING |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
364 *begin = g_strdup_printf("<span style='background-color: %s'>", purple_color); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
365 *end = g_strdup("</span>"); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
366 #else |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
367 *begin = g_strdup_printf("<body bgcolor='%s'>", purple_color); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
368 *end = g_strdup("</body>"); |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
369 #endif |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
370 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
371 g_free(purple_color); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
372 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
373 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
374 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
375 * Convert the msim markup <i> tag (emoticon image) into HTML. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
376 */ |
24665 | 377 static void |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
378 msim_markup_i_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
379 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
380 const gchar *name; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
381 guint i; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
382 struct MSIM_EMOTICON *emote; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
383 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
384 name = xmlnode_get_attrib(root, "n"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
385 if (!name) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
386 purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n\n"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
387 *begin = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
388 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
389 /* TODO: log as unrecognized */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
390 return; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
391 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
392 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
393 /* Find and use canonical form of smiley symbol. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
394 for (i = 0; (emote = &msim_emoticons[i]) && emote->name != NULL; ++i) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
395 if (g_str_equal(name, emote->name)) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
396 *begin = g_strdup(emote->symbol); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
397 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
398 return; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
399 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
400 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
401 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
402 /* Couldn't find it, sorry. Try to degrade gracefully. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
403 *begin = g_strdup_printf("**%s**", name); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
404 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
405 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
406 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
407 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
408 * Convert an individual msim markup tag to HTML. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
409 */ |
24665 | 410 static int |
411 msim_markup_tag_to_html(MsimSession *session, xmlnode *root, gchar **begin, | |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
412 gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
413 { |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
414 g_return_val_if_fail(root != NULL, 0); |
20860
2447efa8c93b
Move NULL check earlier to prevent confusion when it is checked after being derefed. Fixes CID 350
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20753
diff
changeset
|
415 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
416 if (g_str_equal(root->name, "f")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
417 msim_markup_f_to_html(session, root, begin, end); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
418 } else if (g_str_equal(root->name, "a")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
419 msim_markup_a_to_html(session, root, begin, end); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
420 } else if (g_str_equal(root->name, "p")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
421 msim_markup_p_to_html(session, root, begin, end); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
422 } else if (g_str_equal(root->name, "c")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
423 msim_markup_c_to_html(session, root, begin, end); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
424 } else if (g_str_equal(root->name, "b")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
425 msim_markup_b_to_html(session, root, begin, end); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
426 } else if (g_str_equal(root->name, "i")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
427 msim_markup_i_to_html(session, root, begin, end); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
428 } else { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
429 purple_debug_info("msim", "msim_markup_tag_to_html: " |
24757
cd0071208174
Add a newline to the end of a debug messages
Mark Doliner <mark@kingant.net>
parents:
24756
diff
changeset
|
430 "unknown tag name=%s, ignoring\n", |
20860
2447efa8c93b
Move NULL check earlier to prevent confusion when it is checked after being derefed. Fixes CID 350
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20753
diff
changeset
|
431 root->name ? root->name : "(NULL)"); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
432 *begin = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
433 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
434 } |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
435 return 0; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
436 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
437 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
438 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
439 * Convert an individual HTML tag to msim markup. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
440 */ |
24665 | 441 static int |
442 html_tag_to_msim_markup(MsimSession *session, xmlnode *root, gchar **begin, | |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
443 gchar **end) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
444 { |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
445 int ret = 0; |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
446 |
20273
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
447 if (!purple_utf8_strcasecmp(root->name, "root") || |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
448 !purple_utf8_strcasecmp(root->name, "html")) { |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
449 *begin = g_strdup(""); |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
450 *end = g_strdup(""); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
451 /* TODO: Coalesce nested tags into one <f> tag! |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
452 * Currently, the 's' value will be overwritten when b/i/u is nested |
24665 | 453 * within another one, and only the inner-most formatting will be |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
454 * applied to the text. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
455 } else if (!purple_utf8_strcasecmp(root->name, "b")) { |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
456 if (root->child->type == XMLNODE_TYPE_DATA) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
457 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
458 *end = g_strdup("</f>"); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
459 } else { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
460 if (!purple_utf8_strcasecmp(root->child->name,"i")) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
461 ret++; |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
462 if (root->child->child->type == XMLNODE_TYPE_DATA) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
463 *begin = g_strdup_printf("<f s='%d'>", (MSIM_TEXT_BOLD + MSIM_TEXT_ITALIC)); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
464 *end = g_strdup("</f>"); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
465 } else { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
466 if (!purple_utf8_strcasecmp(root->child->child->name,"u")) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
467 ret++; |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
468 *begin = g_strdup_printf("<f s='%d'>", (MSIM_TEXT_BOLD + MSIM_TEXT_ITALIC + MSIM_TEXT_UNDERLINE)); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
469 *end = g_strdup("</f>"); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
470 } |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
471 } |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
472 } else if (!purple_utf8_strcasecmp(root->child->name,"u")) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
473 ret++; |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
474 *begin = g_strdup_printf("<f s='%d'>", (MSIM_TEXT_BOLD + MSIM_TEXT_UNDERLINE)); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
475 *end = g_strdup("</f>"); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
476 } |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
477 } |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
478 } else if (!purple_utf8_strcasecmp(root->name, "i")) { |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
479 if (root->child->type == XMLNODE_TYPE_DATA) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
480 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
481 *end = g_strdup("</f>"); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
482 } else { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
483 if (!purple_utf8_strcasecmp(root->child->name,"u")) { |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
484 ret++; |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
485 *begin = g_strdup_printf("<f s='%d'>", (MSIM_TEXT_ITALIC + MSIM_TEXT_UNDERLINE)); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
486 *end = g_strdup("</f>"); |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
487 } |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
488 } |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
489 } else if (!purple_utf8_strcasecmp(root->name, "u")) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
490 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
491 *end = g_strdup("</f>"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
492 } else if (!purple_utf8_strcasecmp(root->name, "a")) { |
20752
e92c9987ba0d
A small memory leak fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
493 const gchar *href; |
e92c9987ba0d
A small memory leak fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
494 gchar *link_text; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
495 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
496 href = xmlnode_get_attrib(root, "href"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
497 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
498 if (!href) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
499 href = xmlnode_get_attrib(root, "HREF"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
500 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
501 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
502 link_text = xmlnode_get_data(root); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
503 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
504 if (href) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
505 if (g_str_equal(link_text, href)) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
506 /* Purple gives us: <a href="URL">URL</a> |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
507 * Translate to <a h='URL' /> |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
508 * Displayed as text of URL with link to URL |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
509 */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
510 *begin = g_strdup_printf("<a h='%s' />", href); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
511 } else { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
512 /* But if we get: <a href="URL">text</a> |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
513 * Translate to: text: <a h='URL' /> |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
514 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
515 * Because official client only supports self-closed <a> |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
516 * tags; you can't change the link text. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
517 */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
518 *begin = g_strdup_printf("%s: <a h='%s' />", link_text, href); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
519 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
520 } else { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
521 *begin = g_strdup("<a />"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
522 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
523 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
524 /* Sorry, kid. MySpace doesn't support you within <a> tags. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
525 xmlnode_free(root->child); |
20752
e92c9987ba0d
A small memory leak fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
526 g_free(link_text); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
527 root->child = NULL; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
528 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
529 *end = g_strdup(""); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
530 } else if (!purple_utf8_strcasecmp(root->name, "font")) { |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
531 GString *tmpbegin, *tmpend; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
532 const gchar *size; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
533 const gchar *face; |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
534 const gchar *color; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
535 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
536 size = xmlnode_get_attrib(root, "size"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
537 face = xmlnode_get_attrib(root, "face"); |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
538 color = xmlnode_get_attrib(root, "color"); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
539 |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
540 tmpbegin = g_string_new("<f"); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
541 tmpend = g_string_new("</f>"); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
542 |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
543 if (face != NULL) |
27323
eb9edb1c36ac
Fix font size and font face in outgoing myspace messages. I think I
Mark Doliner <mark@kingant.net>
parents:
27224
diff
changeset
|
544 g_string_append_printf(tmpbegin, " f='%s'", face); |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
545 |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
546 if (size != NULL) |
27323
eb9edb1c36ac
Fix font size and font face in outgoing myspace messages. I think I
Mark Doliner <mark@kingant.net>
parents:
27224
diff
changeset
|
547 g_string_append_printf(tmpbegin, " h='%d'", |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
548 msim_point_to_height(session, |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
549 msim_purple_size_to_point(session, atoi(size)))); |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
550 |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
551 /* Close the <f> tag */ |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
552 g_string_append(tmpbegin, ">"); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
553 |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
554 if (color != NULL) { |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
555 g_string_append_printf(tmpbegin, "<c v='%s'>", color); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
556 g_string_prepend(tmpend, "</c>"); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
557 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
558 |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
559 *begin = g_string_free(tmpbegin, FALSE); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
560 *end = g_string_free(tmpend, FALSE); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
561 |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
562 } else if (!purple_utf8_strcasecmp(root->name, "body")) { |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
563 const gchar *bgcolor; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
564 |
24758
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
565 bgcolor = xmlnode_get_attrib(root, "bgcolor"); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
566 |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
567 if (bgcolor != NULL) { |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
568 *begin = g_strdup_printf("<b v='%s'>", bgcolor); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
569 *end = g_strdup("</b>"); |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
570 } |
9a5a201e69a3
Add support for foreground and background font colors in MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24757
diff
changeset
|
571 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
572 } else { |
20273
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
573 gchar *err; |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
574 |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
575 #ifdef MSIM_MARKUP_SHOW_UNKNOWN_TAGS |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
576 *begin = g_strdup_printf("[%s]", root->name); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
577 *end = g_strdup_printf("[/%s]", root->name); |
20273
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
578 #else |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
579 *begin = g_strdup(""); |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
580 *end = g_strdup(""); |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
581 #endif |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
582 |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
583 err = g_strdup_printf("html_tag_to_msim_markup: unrecognized " |
24665 | 584 "HTML tag %s was sent by the IM client; ignoring", |
20150
52dce2882c03
Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
20148
diff
changeset
|
585 root->name ? root->name : "(NULL)"); |
20273
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
586 msim_unrecognized(NULL, NULL, err); |
187fa336c1b0
Plucked mysapce tag parsing fixes
Evan Schoenberg <evan.s@dreskin.net>
parents:
20243
diff
changeset
|
587 g_free(err); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
588 } |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
589 return ret; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
590 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
591 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
592 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
593 * Convert an xmlnode of msim markup or HTML to an HTML string or msim markup. |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
594 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
595 * @param f Function to convert tags. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
596 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
597 * @return An HTML string. Caller frees. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
598 */ |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
599 static void |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
600 msim_convert_xmlnode(MsimSession *session, GString *out, xmlnode *root, MSIM_XMLNODE_CONVERT f, int nodes_processed) |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
601 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
602 xmlnode *node; |
24756
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
603 gchar *begin, *inner, *end, *tmp; |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
604 int descended = nodes_processed; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
605 |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
606 if (!root || !root->name) |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
607 return; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
608 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
609 purple_debug_info("msim", "msim_convert_xmlnode: got root=%s\n", |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
610 root->name); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
611 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
612 begin = inner = end = NULL; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
613 |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
614 if (descended == 0) /* We've not formatted this yet.. :) */ |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
615 descended = f(session, root, &begin, &end); /* Get the value that our format function has already descended for us */ |
24665 | 616 |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
617 g_string_append(out, begin); |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
618 g_free(begin); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
619 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
620 /* Loop over all child nodes. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
621 for (node = root->child; node != NULL; node = node->next) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
622 switch (node->type) { |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
623 case XMLNODE_TYPE_ATTRIB: |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
624 /* Attributes handled above. */ |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
625 break; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
626 |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
627 case XMLNODE_TYPE_TAG: |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
628 /* A tag or tag with attributes. Recursively descend. */ |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
629 msim_convert_xmlnode(session, out, node, f, descended); |
24665 | 630 |
631 purple_debug_info("msim", " ** node name=%s\n", | |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
632 node->name ? node->name : "(NULL)"); |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
633 break; |
24665 | 634 |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
635 case XMLNODE_TYPE_DATA: |
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
636 /* Literal text. */ |
24756
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
637 /* |
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
638 * TODO: Why is it necessary to escape here? I thought |
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
639 * node->data was already escaped? |
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
640 */ |
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
641 tmp = g_markup_escape_text(node->data, node->data_sz); |
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
642 g_string_append(out, tmp); |
ced7ff727a97
Fix bugs sending and receiving myspace IMs related to not escaping
Mark Doliner <mark@kingant.net>
parents:
24733
diff
changeset
|
643 g_free(tmp); |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
644 break; |
24665 | 645 |
22390
89e0d994f010
In msimprpl, allow some levels of nested bold/italic/underline formatting.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
21284
diff
changeset
|
646 default: |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
647 purple_debug_warning("msim", |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
648 "msim_convert_xmlnode: unknown node type\n"); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
649 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
650 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
651 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
652 /* TODO: Note that msim counts each piece of text enclosed by <f> as |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
653 * a paragraph and will display each on its own line. You actually have |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
654 * to _nest_ <f> tags to intersperse different text in one paragraph! |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
655 * Comment out this line below to see. */ |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
656 g_string_append(out, end); |
20753
61045691aa72
Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20752
diff
changeset
|
657 g_free(end); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
658 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
659 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
660 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
661 * Convert XML to something based on MSIM_XMLNODE_CONVERT. |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
662 */ |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
663 static gchar * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
664 msim_convert_xml(MsimSession *session, const gchar *raw, MSIM_XMLNODE_CONVERT f) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
665 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
666 xmlnode *root; |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
667 GString *str; |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
668 gchar *enclosed_raw; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
669 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
670 g_return_val_if_fail(raw != NULL, NULL); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
671 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
672 /* Enclose text in one root tag, to try to make it valid XML for parsing. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
673 enclosed_raw = g_strconcat("<root>", raw, "</root>", NULL); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
674 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
675 root = xmlnode_from_str(enclosed_raw, -1); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
676 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
677 if (!root) { |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
678 purple_debug_warning("msim", "msim_markup_to_html: couldn't parse " |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
679 "%s as XML, returning raw: %s\n", enclosed_raw, raw); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
680 /* TODO: msim_unrecognized */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
681 g_free(enclosed_raw); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
682 return g_strdup(raw); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
683 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
684 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
685 g_free(enclosed_raw); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
686 |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
687 str = g_string_new(NULL); |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
688 msim_convert_xmlnode(session, str, root, f, 0); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
689 xmlnode_free(root); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
690 |
24667
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
691 purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str->str); |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
692 |
19f18fc9caed
Use one GString and pass it around instead of allocating and freeing a
Mark Doliner <mark@kingant.net>
parents:
24666
diff
changeset
|
693 return g_string_free(str, FALSE); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
694 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
695 |
27224
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
696 /** |
c51fc4daf81b
Consistent comment formatting
Mark Doliner <mark@kingant.net>
parents:
24760
diff
changeset
|
697 * Convert plaintext smileys to <i> markup tags. |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
698 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
699 * @param before Original text with ASCII smileys. Will be freed. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
700 * @return A new string with <i> tags, if applicable. Must be g_free()'d. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
701 */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
702 static gchar * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
703 msim_convert_smileys_to_markup(gchar *before) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
704 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
705 gchar *old, *new, *replacement; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
706 guint i; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
707 struct MSIM_EMOTICON *emote; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
708 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
709 old = before; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
710 new = NULL; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
711 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
712 for (i = 0; (emote = &msim_emoticons[i]) && emote->name != NULL; ++i) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
713 gchar *name, *symbol; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
714 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
715 name = emote->name; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
716 symbol = emote->symbol; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
717 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
718 replacement = g_strdup_printf("<i n=\"%s\"/>", name); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
719 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
720 purple_debug_info("msim", "msim_convert_smileys_to_markup: %s->%s\n", |
24665 | 721 symbol ? symbol : "(NULL)", |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
722 replacement ? replacement : "(NULL)"); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
723 new = purple_strreplace(old, symbol, replacement); |
24665 | 724 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
725 g_free(replacement); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
726 g_free(old); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
727 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
728 old = new; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
729 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
730 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
731 return new; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
732 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
733 |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
734 /** |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
735 * High-level function to convert MySpaceIM markup to Purple (HTML) markup. |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
736 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
737 * @return Purple markup string, must be g_free()'d. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
738 gchar * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
739 msim_markup_to_html(MsimSession *session, const gchar *raw) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
740 { |
24666
b25abc303e5a
Remove unnecessary casting
Mark Doliner <mark@kingant.net>
parents:
24665
diff
changeset
|
741 return msim_convert_xml(session, raw, msim_markup_tag_to_html); |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
742 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
743 |
24760
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
744 /** |
e12788365764
Support for background font colors in incoming MySpace IMs
Mark Doliner <mark@kingant.net>
parents:
24759
diff
changeset
|
745 * High-level function to convert Purple (HTML) to MySpaceIM markup. |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
746 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
747 * TODO: consider using purple_markup_html_to_xhtml() to make valid XML. |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
748 * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
749 * @return HTML markup string, must be g_free()'d. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
750 gchar * |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
751 html_to_msim_markup(MsimSession *session, const gchar *raw) |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
752 { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
753 gchar *markup; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
754 |
24666
b25abc303e5a
Remove unnecessary casting
Mark Doliner <mark@kingant.net>
parents:
24665
diff
changeset
|
755 markup = msim_convert_xml(session, raw, html_tag_to_msim_markup); |
24665 | 756 |
20243
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
757 if (purple_account_get_bool(session->account, "emoticons", TRUE)) { |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
758 /* Frees markup and allocates a new one. */ |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
759 markup = msim_convert_smileys_to_markup(markup); |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
760 } |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
761 |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
762 return markup; |
5440eed4ec7e
applied changes from efedefa70ee1d6f7f4dd39afe5db10c7e5bfe64c
Richard Laager <rlaager@wiktel.com>
parents:
19680
diff
changeset
|
763 } |