Mercurial > pidgin
annotate src/protocols/msn/utils.c @ 8573:7dcd6f26e4a7
[gaim-migrate @ 9321]
" This patch reimplements the system log. It writes
system log to
~/.gaim/logs/<protocol>/<username>/.system/<timestamp>.(txt|html),
where <timestamp> is the time that the account
<username> with <protocol> signs on. Nathan (faceprint)
and LSchiere suggested this logging scheme. No code is
currently written to read the old system logs.
Note that if you change the logging format, you need to
re-login the accounts for the change to take effect."
--Ka-Hing (javabsp) Cheung
who continues:
"Now this one applies, also contains a rider patch that, if
you enable sound for "Someone says your name in chat", it
will not play a sound if the message is a system message,
like if jabber chat tells you that "*** becomes available"
and *** is you, it won't play a sound."
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sat, 03 Apr 2004 18:34:29 +0000 |
| parents | 45e8c6cbd4a5 |
| children | 1d5e31e518fc |
| rev | line source |
|---|---|
| 5309 | 1 /** |
|
5312
89948fedf782
[gaim-migrate @ 5684]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
2 * @file utils.c Utility functions |
| 5309 | 3 * |
| 4 * gaim | |
| 5 * | |
|
8475
06f57183e29f
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
6 * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
|
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6359
diff
changeset
|
7 * |
| 5309 | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 #include "msn.h" | |
| 23 | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
24 void |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
25 msn_parse_format(const char *mime, char **pre_ret, char **post_ret) |
| 5309 | 26 { |
| 27 char *cur; | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
28 GString *pre = g_string_new(NULL); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
29 GString *post = g_string_new(NULL); |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
30 unsigned int colors[3]; |
| 5309 | 31 |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
32 if (pre_ret != NULL) *pre_ret = NULL; |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
33 if (post_ret != NULL) *post_ret = NULL; |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
34 |
| 5309 | 35 cur = strstr(mime, "FN="); |
| 36 | |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
37 if (cur && (*(cur = cur + 3) != ';')) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
38 { |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
39 pre = g_string_append(pre, "<FONT FACE=\""); |
| 5309 | 40 |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
41 while (*cur && *cur != ';') |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
42 { |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
43 pre = g_string_append_c(pre, *cur); |
| 5309 | 44 cur++; |
| 45 } | |
| 46 | |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
47 pre = g_string_append(pre, "\">"); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
48 post = g_string_prepend(post, "</FONT>"); |
| 5309 | 49 } |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
50 |
| 5309 | 51 cur = strstr(mime, "EF="); |
| 52 | |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
53 if (cur && (*(cur = cur + 3) != ';')) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
54 { |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
55 while (*cur && *cur != ';') |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
56 { |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
57 pre = g_string_append_c(pre, '<'); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
58 pre = g_string_append_c(pre, *cur); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
59 pre = g_string_append_c(pre, '>'); |
| 5309 | 60 cur++; |
| 61 } | |
| 62 } | |
| 63 | |
| 64 cur = strstr(mime, "CO="); | |
| 65 | |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
66 if (cur && (*(cur = cur + 3) != ';')) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
67 { |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
68 int i; |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
69 |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
70 i = sscanf(cur, "%02x%02x%02x;", &colors[0], &colors[1], &colors[2]); |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
71 |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
72 if (i > 0) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
73 { |
| 5309 | 74 char tag[64]; |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
75 |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
76 if (i == 1) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
77 { |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
78 colors[1] = 0; |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
79 colors[2] = 0; |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
80 } |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
81 else if (i == 2) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
82 { |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
83 unsigned int temp = colors[0]; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
84 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
85 colors[0] = colors[1]; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
86 colors[1] = temp; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
87 colors[2] = 0; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
88 } |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
89 else if (i == 3) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
90 { |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
91 unsigned int temp = colors[2]; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
92 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
93 colors[2] = colors[0]; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
94 colors[0] = temp; |
|
6093
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
95 } |
|
13a37cacd10b
[gaim-migrate @ 6552]
Christian Hammond <chipx86@chipx86.com>
parents:
5964
diff
changeset
|
96 |
| 5309 | 97 g_snprintf(tag, sizeof(tag), |
| 98 "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">", | |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
99 colors[0], colors[1], colors[2]); |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
100 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
101 gaim_debug_misc("msn", "Got: %s\n", tag); |
| 5309 | 102 |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
103 pre = g_string_append(pre, tag); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
104 post = g_string_prepend(post, "</FONT>"); |
| 5309 | 105 } |
| 106 } | |
| 107 | |
| 7134 | 108 cur = g_strdup(gaim_url_decode(pre->str)); |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
109 g_string_free(pre, TRUE); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
110 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
111 if (pre_ret != NULL) |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
112 *pre_ret = cur; |
|
6359
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
113 else |
|
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
114 g_free(cur); |
| 5309 | 115 |
| 7134 | 116 cur = g_strdup(gaim_url_decode(post->str)); |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
117 g_string_free(post, TRUE); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
118 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
119 if (post_ret != NULL) |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6093
diff
changeset
|
120 *post_ret = cur; |
|
6359
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
121 else |
|
dfde69e105ae
[gaim-migrate @ 6863]
Christian Hammond <chipx86@chipx86.com>
parents:
6358
diff
changeset
|
122 g_free(cur); |
| 5309 | 123 } |
|
8518
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
124 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
125 /* |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
126 * We need this because we're only supposed to encode spaces in the font |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
127 * names. gaim_url_encode() isn't acceptable. |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
128 */ |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
129 const char * |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
130 encode_spaces(const char *str) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
131 { |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
132 static char buf[BUF_LEN]; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
133 const char *c; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
134 char *d; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
135 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
136 g_return_val_if_fail(str != NULL, NULL); |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
137 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
138 for (c = str, d = buf; *c != '\0'; c++) |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
139 { |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
140 if (*c == ' ') |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
141 { |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
142 *d++ = '%'; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
143 *d++ = '2'; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
144 *d++ = '0'; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
145 } |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
146 else |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
147 *d++ = *c; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
148 } |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
149 |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
150 return buf; |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
151 } |
|
833dd756dcc3
[gaim-migrate @ 9257]
Christian Hammond <chipx86@chipx86.com>
parents:
8475
diff
changeset
|
152 |
