Mercurial > pidgin.yaz
annotate src/protocols/msn/msg.c @ 6826:2adf21e70601
[gaim-migrate @ 7371]
Fixed message length problems for binary and text.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 13 Sep 2003 23:28:08 +0000 |
parents | 8f228a7d5076 |
children | 1cfbb731aa1f |
rev | line source |
---|---|
4542 | 1 /** |
2 * @file msg.c Message functions | |
3 * | |
4 * gaim | |
5 * | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
7 * |
4542 | 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" | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
23 #include "msg.h" |
4542 | 24 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
25 #define GET_NEXT(tmp) \ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
26 while (*(tmp) && *(tmp) != ' ' && *(tmp) != '\r') \ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
27 (tmp)++; \ |
5315
b1c430fbf9d5
[gaim-migrate @ 5687]
Christian Hammond <chipx86@chipx86.com>
parents:
5310
diff
changeset
|
28 if (*(tmp) != '\0') *(tmp)++ = '\0'; \ |
6075
f7ddc1f6227e
[gaim-migrate @ 6534]
Christian Hammond <chipx86@chipx86.com>
parents:
6011
diff
changeset
|
29 if (*(tmp) == '\n') (tmp)++; \ |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
30 while (*(tmp) && *(tmp) == ' ') \ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
31 (tmp)++ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
32 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
33 #define GET_NEXT_LINE(tmp) \ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
34 while (*(tmp) && *(tmp) != '\r') \ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
35 (tmp)++; \ |
5315
b1c430fbf9d5
[gaim-migrate @ 5687]
Christian Hammond <chipx86@chipx86.com>
parents:
5310
diff
changeset
|
36 if (*(tmp) != '\0') *(tmp)++ = '\0'; \ |
6075
f7ddc1f6227e
[gaim-migrate @ 6534]
Christian Hammond <chipx86@chipx86.com>
parents:
6011
diff
changeset
|
37 if (*(tmp) == '\n') (tmp)++ |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
38 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
39 /* |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
40 * "MIME-Version: 1.0\r\n" == 19 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
41 * "Content-Type: " == 14 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
42 * "\r\n" == 2 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
43 * "\r\n" before body == 2 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
44 * ---- |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
45 * 37 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
46 * MATH PAYS OFF!! |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
47 */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
48 #define MSN_MESSAGE_BASE_SIZE 37 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
49 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
50 MsnMessage * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
51 msn_message_new(void) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
52 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
53 MsnMessage *msg; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
54 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
55 msg = g_new0(MsnMessage, 1); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
56 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
57 msg->attr_table = g_hash_table_new_full(g_str_hash, g_str_equal, |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
58 g_free, g_free); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
59 msg->size = MSN_MESSAGE_BASE_SIZE; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
60 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
61 msn_message_set_attr(msg, "User-Agent", "Gaim/" VERSION); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
62 msn_message_set_content_type(msg, "text/plain"); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
63 msn_message_set_charset(msg, "UTF-8"); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
64 msn_message_set_flag(msg, 'N'); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
65 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
66 msn_message_ref(msg); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
67 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
68 return msg; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
69 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
70 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
71 MsnMessage * |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
72 msn_message_new_msnslp(void) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
73 { |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
74 MsnMessage *msg; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
75 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
76 msg = msn_message_new(); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
77 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
78 msn_message_set_attr(msg, "User-Agent", NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
79 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
80 msg->msnslp_message = TRUE; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
81 msg->size += 52; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
82 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
83 return msg; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
84 } |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
85 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
86 MsnMessage * |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
87 msn_message_new_from_str(MsnSession *session, const char *str) |
4542 | 88 { |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
89 MsnMessage *msg; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
90 char *tmp_base, *msg_base, *tmp, *field1, *field2, *c; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
91 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
92 g_return_val_if_fail(str != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
93 g_return_val_if_fail(!g_ascii_strncasecmp(str, "MSG", 3), NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
94 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
95 msg = msn_message_new(); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
96 |
5454
c6efac0e28ff
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5315
diff
changeset
|
97 /* Clear out the old stuff. */ |
c6efac0e28ff
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5315
diff
changeset
|
98 msn_message_set_attr(msg, "User-Agent", NULL); |
5455
f9658a84d1ed
[gaim-migrate @ 5843]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
99 msn_message_set_content_type(msg, NULL); |
f9658a84d1ed
[gaim-migrate @ 5843]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
100 msn_message_set_charset(msg, NULL); |
5454
c6efac0e28ff
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5315
diff
changeset
|
101 |
6011
b8abf266dd3b
[gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
102 tmp_base = tmp = g_strdup(str); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
103 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
104 GET_NEXT(tmp); /* Skip MSG */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
105 field1 = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
106 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
107 GET_NEXT(tmp); /* Skip the passport or TID */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
108 field2 = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
109 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
110 GET_NEXT(tmp); /* Skip the username or flag */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
111 msg->size = atoi(tmp); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
112 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
113 if (msg->size != strlen(strchr(str, '\n') + 1)) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
114 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
115 "Incoming message size (%d) and string length (%d) " |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
116 "do not match!\n", msg->size, strlen(str)); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
117 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
118 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
119 /* |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
120 * We're going to make sure this is incoming by checking field1. |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
121 * If it has any non-numbers in it, it's incoming. Otherwise, outgoing. |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
122 */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
123 msg->incoming = FALSE; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
124 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
125 for (c = field1; *c != '\0'; c++) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
126 if (*c < '0' || *c > '9') { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
127 msg->incoming = TRUE; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
128 break; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
129 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
130 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
131 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
132 if (msg->incoming) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
133 msg->sender = msn_users_find_with_passport(session->users, field1); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
134 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
135 if (msg->sender == NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
136 msg->sender = msn_user_new(session, field1, field2); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
137 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
138 msn_user_ref(msg->sender); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
139 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
140 else { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
141 msg->tid = atoi(field1); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
142 msg->flag = *field2; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
143 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
144 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
145 msg_base = tmp; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
146 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
147 /* Back to the parsination. */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
148 while (*tmp != '\r') { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
149 char *key, *value; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
150 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
151 key = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
152 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
153 GET_NEXT(tmp); /* Key */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
154 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
155 value = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
156 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
157 GET_NEXT_LINE(tmp); /* Value */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
158 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
159 if ((c = strchr(key, ':')) != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
160 *c = '\0'; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
161 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
162 if (!g_ascii_strcasecmp(key, "Content-Type")) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
163 char *charset; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
164 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
165 if ((c = strchr(value, ';')) != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
166 if ((charset = strchr(c, '=')) != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
167 charset++; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
168 msn_message_set_charset(msg, charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
169 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
170 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
171 *c = '\0'; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
172 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
173 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
174 msn_message_set_content_type(msg, value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
175 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
176 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
177 msn_message_set_attr(msg, key, value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
178 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
179 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
180 /* "\r\n" */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
181 tmp += 2; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
182 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
183 /* Now we *should* be at the body. */ |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
184 if (!strcmp(msn_message_get_content_type(msg), "application/x-msnmsgrp2p")) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
185 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
186 char header[48]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
187 char footer[4]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
188 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
189 msg->msnslp_message = TRUE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
190 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
191 memcpy(header, tmp, 48); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
192 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
193 tmp += 48; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
194 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
195 msg->body = g_memdup(tmp, msg->size - (tmp - msg_base) + 1); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
196 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
197 tmp++; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
198 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
199 memcpy(footer, tmp, 4); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
200 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
201 /* Import the header. */ |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
202 memcpy(&msg->msnslp_header.session_id, tmp, 4); tmp += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
203 memcpy(&msg->msnslp_header.id, tmp, 4); tmp += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
204 memcpy(&msg->msnslp_header.offset, tmp, 4); tmp += 8; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
205 memcpy(&msg->msnslp_header.total_size, tmp, 4); tmp += 8; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
206 memcpy(&msg->msnslp_header.length, tmp, 4); tmp += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
207 memcpy(&msg->msnslp_header.flags, tmp, 4); tmp += 4; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
208 memcpy(&msg->msnslp_header.ack_session_id, tmp, 4); tmp += 4; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
209 memcpy(&msg->msnslp_header.ack_unique_id, tmp, 4); tmp += 4; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
210 memcpy(&msg->msnslp_header.ack_length, tmp, 4); tmp += 8; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
211 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
212 /* Convert to the right endianness */ |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
213 msg->msnslp_header.session_id = ntohl(msg->msnslp_header.session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
214 msg->msnslp_header.id = ntohl(msg->msnslp_header.id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
215 msg->msnslp_header.length = ntohl(msg->msnslp_header.length); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
216 msg->msnslp_header.flags = ntohl(msg->msnslp_header.flags); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
217 msg->msnslp_header.ack_length = ntohl(msg->msnslp_header.ack_length); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
218 msg->msnslp_header.ack_session_id = |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
219 ntohl(msg->msnslp_header.ack_session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
220 msg->msnslp_header.ack_unique_id = |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
221 ntohl(msg->msnslp_header.ack_unique_id); |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
222 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
223 /* Import the footer. */ |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
224 msg->msnslp_footer.app_id = (long)footer; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
225 } |
6705
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
226 else |
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
227 { |
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
228 msn_message_set_body(msg, tmp); |
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
229 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
230 |
6011
b8abf266dd3b
[gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
231 g_free(tmp_base); |
b8abf266dd3b
[gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
232 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
233 /* Done! */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
234 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
235 return msg; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
236 } |
4542 | 237 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
238 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
239 msn_message_destroy(MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
240 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
241 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
242 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
243 if (msg->ref_count > 0) { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
244 msn_message_unref(msg); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
245 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
246 return; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
247 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
248 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
249 if (msg->sender != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
250 msn_user_unref(msg->sender); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
251 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
252 if (msg->receiver != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
253 msn_user_unref(msg->receiver); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
254 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
255 if (msg->body != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
256 g_free(msg->body); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
257 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
258 if (msg->content_type != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
259 g_free(msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
260 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
261 if (msg->charset != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
262 g_free(msg->charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
263 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
264 g_hash_table_destroy(msg->attr_table); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
265 g_list_free(msg->attr_list); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
266 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
267 gaim_debug(GAIM_DEBUG_INFO, "msn", "Destroying message\n"); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
268 g_free(msg); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
269 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
270 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
271 MsnMessage * |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
272 msn_message_ref(MsnMessage *msg) |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
273 { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
274 g_return_val_if_fail(msg != NULL, NULL); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
275 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
276 msg->ref_count++; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
277 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
278 return msg; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
279 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
280 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
281 MsnMessage * |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
282 msn_message_unref(MsnMessage *msg) |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
283 { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
284 g_return_val_if_fail(msg != NULL, NULL); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
285 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
286 if (msg->ref_count <= 0) |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
287 return NULL; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
288 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
289 msg->ref_count--; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
290 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
291 if (msg->ref_count == 0) { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
292 msn_message_destroy(msg); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
293 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
294 return NULL; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
295 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
296 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
297 return msg; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
298 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
299 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
300 char * |
6826
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
301 msn_message_to_string(const MsnMessage *msg, size_t *ret_size) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
302 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
303 GList *l; |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
304 char *msg_start; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
305 char *str; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
306 char buf[MSN_BUF_LEN]; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
307 int len; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
308 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
309 /* |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
310 * Okay, how we do things here is just bad. I don't like writing to |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
311 * a static buffer and then copying to the string. Unfortunately, |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
312 * just trying to append to the string is causing issues.. Such as |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
313 * the string you're appending to being erased. Ugh. So, this is |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
314 * good enough for now. |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
315 * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
316 * -- ChipX86 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
317 */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
318 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
319 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
320 if (msn_message_is_incoming(msg)) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
321 MsnUser *sender = msn_message_get_sender(msg); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
322 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
323 g_snprintf(buf, sizeof(buf), "MSG %s %s %d\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
324 msn_user_get_passport(sender), msn_user_get_name(sender), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
325 msg->size); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
326 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
327 else { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
328 g_snprintf(buf, sizeof(buf), "MSG %d %c %d\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
329 msn_message_get_transaction_id(msg), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
330 msn_message_get_flag(msg), msg->size); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
331 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
332 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
333 len = strlen(buf) + msg->size + 1; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
334 |
6826
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
335 str = g_new0(char, len + 1); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
336 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
337 g_strlcpy(str, buf, len); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
338 |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
339 msg_start = str + strlen(str); |
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
340 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
341 /* Standard header. */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
342 if (msg->charset == NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
343 g_snprintf(buf, sizeof(buf), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
344 "MIME-Version: 1.0\r\n" |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
345 "Content-Type: %s\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
346 msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
347 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
348 else { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
349 g_snprintf(buf, sizeof(buf), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
350 "MIME-Version: 1.0\r\n" |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
351 "Content-Type: %s; charset=%s\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
352 msg->content_type, msg->charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
353 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
354 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
355 g_strlcat(str, buf, len); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
356 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
357 for (l = msg->attr_list; l != NULL; l = l->next) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
358 const char *key = (char *)l->data; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
359 const char *value; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
360 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
361 value = msn_message_get_attr(msg, key); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
362 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
363 g_snprintf(buf, sizeof(buf), "%s: %s\r\n", key, value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
364 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
365 g_strlcat(str, buf, len); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
366 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
367 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
368 if (msg->msnslp_message) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
369 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
370 char *c; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
371 char blank[4]; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
372 long session_id, id, offset, total_size, length, flags; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
373 long ack_session_id, ack_unique_id, ack_length; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
374 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
375 blank[0] = blank[1] = blank[2] = blank[3] = 0; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
376 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
377 g_strlcat(str, "\r\n", 3); |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
378 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
379 c = str + strlen(str); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
380 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
381 session_id = htonl(msg->msnslp_header.session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
382 id = htonl(msg->msnslp_header.id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
383 offset = htonl(msg->msnslp_header.offset); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
384 total_size = htonl(msg->msnslp_header.total_size); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
385 length = htonl(msg->msnslp_header.length); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
386 flags = htonl(msg->msnslp_header.flags); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
387 ack_session_id = htonl(msg->msnslp_header.ack_session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
388 ack_unique_id = htonl(msg->msnslp_header.ack_unique_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
389 ack_length = htonl(msg->msnslp_header.ack_length); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
390 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
391 memcpy(c, &session_id, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
392 memcpy(c, &id, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
393 memcpy(c, &offset, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
394 memcpy(c, blank, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
395 memcpy(c, &total_size, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
396 memcpy(c, blank, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
397 memcpy(c, &length, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
398 memcpy(c, &flags, 4); c += 4; |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
399 memcpy(c, &ack_session_id, 4); c += 4; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
400 memcpy(c, &ack_unique_id, 4); c += 4; |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
401 memcpy(c, &ack_length, 4); c += 4; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
402 memcpy(c, blank, 4); c += 4; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
403 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
404 strncpy(c, msn_message_get_body(msg), len); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
405 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
406 c += strlen(msn_message_get_body(msg)); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
407 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
408 if (strlen(msn_message_get_body(msg)) > 0) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
409 *c++ = '\0'; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
410 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
411 memcpy(c, &msg->msnslp_footer.app_id, 4); c += 4; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
412 *c = '\0'; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
413 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
414 gaim_debug_misc("msn", "cur size = %d\n", (c - str)); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
415 gaim_debug_misc("msn", "msg->size = %d\n", msg->size); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
416 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
417 if (msg->size != (c - str)) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
418 { |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
419 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
420 "Outgoing message size (%d) and string length (%d) " |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
421 "do not match!\n", msg->size, (c - str)); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
422 } |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
423 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
424 else |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
425 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
426 g_snprintf(buf, sizeof(buf), "\r\n%s", msn_message_get_body(msg)); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
427 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
428 g_strlcat(str, buf, len); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
429 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
430 if (msg->size != strlen(msg_start)) { |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
431 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
432 "Outgoing message size (%d) and string length (%d) " |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
433 "do not match!\n", msg->size, strlen(msg_start)); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
434 } |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
435 } |
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
436 |
6826
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
437 if (ret_size != NULL) |
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
438 *ret_size = len - 1; |
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
439 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
440 return str; |
4542 | 441 } |
442 | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
443 gboolean |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
444 msn_message_is_outgoing(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
445 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
446 g_return_val_if_fail(msg != NULL, FALSE); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
447 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
448 return !msg->incoming; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
449 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
450 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
451 gboolean |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
452 msn_message_is_incoming(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
453 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
454 g_return_val_if_fail(msg != NULL, FALSE); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
455 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
456 return msg->incoming; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
457 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
458 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
459 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
460 msn_message_set_sender(MsnMessage *msg, MsnUser *user) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
461 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
462 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
463 g_return_if_fail(user != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
464 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
465 msg->sender = user; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
466 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
467 msn_user_ref(msg->sender); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
468 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
469 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
470 MsnUser * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
471 msn_message_get_sender(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
472 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
473 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
474 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
475 return msg->sender; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
476 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
477 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
478 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
479 msn_message_set_receiver(MsnMessage *msg, MsnUser *user) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
480 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
481 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
482 g_return_if_fail(user != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
483 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
484 msg->receiver = user; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
485 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
486 msn_user_ref(msg->receiver); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
487 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
488 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
489 MsnUser * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
490 msn_message_get_receiver(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
491 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
492 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
493 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
494 return msg->receiver; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
495 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
496 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
497 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
498 msn_message_set_transaction_id(MsnMessage *msg, unsigned int tid) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
499 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
500 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
501 g_return_if_fail(tid > 0); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
502 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
503 msg->tid = tid; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
504 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
505 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
506 unsigned int |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
507 msn_message_get_transaction_id(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
508 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
509 g_return_val_if_fail(msg != NULL, 0); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
510 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
511 return msg->tid; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
512 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
513 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
514 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
515 msn_message_set_flag(MsnMessage *msg, char flag) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
516 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
517 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
518 g_return_if_fail(flag != 0); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
519 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
520 msg->flag = flag; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
521 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
522 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
523 char |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
524 msn_message_get_flag(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
525 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
526 g_return_val_if_fail(msg != NULL, 0); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
527 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
528 return msg->flag; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
529 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
530 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
531 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
532 msn_message_set_body(MsnMessage *msg, const char *body) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
533 { |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
534 const char *c; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
535 char *buf, *d; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
536 int newline_count = 0; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
537 size_t new_len; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
538 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
539 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
540 g_return_if_fail(body != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
541 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
542 if (msg->body != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
543 msg->size -= strlen(msg->body); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
544 g_free(msg->body); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
545 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
546 if (msg->msnslp_message) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
547 msg->size--; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
548 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
549 |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
550 for (c = body; *c != '\0'; c++) { |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
551 if (*c == '\n' && (c == body || *(c - 1) != '\r')) |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
552 newline_count++; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
553 } |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
554 |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
555 new_len = strlen(body) + newline_count; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
556 |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
557 buf = g_new0(char, new_len + 1); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
558 |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
559 for (c = body, d = buf; *c != '\0'; c++) { |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
560 if (*c == '\n' && (c == body || *(c - 1) != '\r')) { |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
561 *d++ = '\r'; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
562 *d++ = '\n'; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
563 } |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
564 else |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
565 *d++ = *c; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
566 } |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
567 |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
568 msg->body = buf; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
569 |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
570 msg->size += new_len; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
571 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
572 if (msg->msnslp_message) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
573 msg->size++; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
574 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
575 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
576 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
577 msn_message_get_body(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
578 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
579 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
580 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
581 return msg->body; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
582 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
583 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
584 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
585 msn_message_set_content_type(MsnMessage *msg, const char *type) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
586 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
587 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
588 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
589 if (msg->content_type != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
590 msg->size -= strlen(msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
591 g_free(msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
592 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
593 |
5478
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
594 if (type != NULL) { |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
595 msg->content_type = g_strdup(type); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
596 |
5478
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
597 msg->size += strlen(type); |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
598 } |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
599 else |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
600 msg->content_type = NULL; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
601 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
602 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
603 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
604 msn_message_get_content_type(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
605 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
606 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
607 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
608 return msg->content_type; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
609 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
610 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
611 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
612 msn_message_set_charset(MsnMessage *msg, const char *charset) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
613 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
614 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
615 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
616 if (msg->charset != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
617 msg->size -= strlen(msg->charset) + strlen("; charset="); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
618 g_free(msg->charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
619 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
620 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
621 if (charset != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
622 msg->charset = g_strdup(charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
623 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
624 msg->size += strlen(charset) + strlen("; charset="); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
625 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
626 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
627 msg->charset = NULL; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
628 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
629 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
630 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
631 msn_message_get_charset(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
632 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
633 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
634 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
635 return msg->charset; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
636 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
637 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
638 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
639 msn_message_set_attr(MsnMessage *msg, const char *attr, const char *value) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
640 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
641 const char *temp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
642 char *new_attr; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
643 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
644 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
645 g_return_if_fail(attr != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
646 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
647 temp = msn_message_get_attr(msg, attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
648 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
649 if (value == NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
650 if (temp != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
651 GList *l; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
652 |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
653 msg->size -= strlen(temp) + strlen(attr) + 4; |
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
654 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
655 for (l = msg->attr_list; l != NULL; l = l->next) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
656 if (!g_ascii_strcasecmp(l->data, attr)) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
657 msg->attr_list = g_list_remove(msg->attr_list, l->data); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
658 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
659 break; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
660 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
661 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
662 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
663 g_hash_table_remove(msg->attr_table, attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
664 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
665 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
666 return; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
667 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
668 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
669 new_attr = g_strdup(attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
670 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
671 g_hash_table_insert(msg->attr_table, new_attr, g_strdup(value)); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
672 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
673 if (temp == NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
674 msg->attr_list = g_list_append(msg->attr_list, new_attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
675 msg->size += strlen(attr) + 4; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
676 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
677 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
678 msg->size -= strlen(temp); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
679 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
680 msg->size += strlen(value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
681 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
682 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
683 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
684 msn_message_get_attr(const MsnMessage *msg, const char *attr) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
685 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
686 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
687 g_return_val_if_fail(attr != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
688 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
689 return g_hash_table_lookup(msg->attr_table, attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
690 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
691 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
692 GHashTable * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
693 msn_message_get_hashtable_from_body(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
694 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
695 GHashTable *table; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
696 char *body, *s, *c; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
697 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
698 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
699 g_return_val_if_fail(msn_message_get_body(msg) != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
700 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
701 s = body = g_strdup(msn_message_get_body(msg)); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
702 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
703 table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
704 |
5315
b1c430fbf9d5
[gaim-migrate @ 5687]
Christian Hammond <chipx86@chipx86.com>
parents:
5310
diff
changeset
|
705 while (*s != '\r' && *s != '\0') { |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
706 char *key, *value; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
707 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
708 key = s; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
709 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
710 GET_NEXT(s); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
711 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
712 value = s; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
713 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
714 GET_NEXT_LINE(s); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
715 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
716 if ((c = strchr(key, ':')) != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
717 *c = '\0'; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
718 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
719 g_hash_table_insert(table, g_strdup(key), g_strdup(value)); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
720 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
721 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
722 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
723 g_free(body); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
724 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
725 return table; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
726 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
727 |