Mercurial > pidgin
annotate src/protocols/msn/msg.c @ 6877:1b5b0cea6915
[gaim-migrate @ 7423]
Fixed an assertion warning for buddy icons on every conversation without a
buddy icon.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 17 Sep 2003 06:46:36 +0000 |
parents | ab80de7a74d1 |
children | 4c29ee932d67 |
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 |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
39 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
40 #define msn_put16(buf, data) ( \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
41 (*(buf) = (u_char)((data)>>8)&0xff), \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
42 (*((buf)+1) = (u_char)(data)&0xff), \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
43 2) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
44 #define msn_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
45 #define msn_put32(buf, data) ( \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
46 (*((buf)) = (u_char)((data)>>24)&0xff), \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
47 (*((buf)+1) = (u_char)((data)>>16)&0xff), \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
48 (*((buf)+2) = (u_char)((data)>>8)&0xff), \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
49 (*((buf)+3) = (u_char)(data)&0xff), \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
50 4) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
51 #define msn_get32(buf) ((((*(buf))<<24)&0xff000000) + \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
52 (((*((buf)+1))<<16)&0x00ff0000) + \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
53 (((*((buf)+2))<< 8)&0x0000ff00) + \ |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
54 (((*((buf)+3) )&0x000000ff))) |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
55 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
56 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
57 /* |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
58 * "MIME-Version: 1.0\r\n" == 19 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
59 * "Content-Type: " == 14 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
60 * "\r\n" == 2 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
61 * "\r\n" before body == 2 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
62 * ---- |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
63 * 37 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
64 * MATH PAYS OFF!! |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
65 */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
66 #define MSN_MESSAGE_BASE_SIZE 37 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
67 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
68 MsnMessage * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
69 msn_message_new(void) |
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 *msg; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
72 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
73 msg = g_new0(MsnMessage, 1); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
74 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
75 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
|
76 g_free, g_free); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
77 msg->size = MSN_MESSAGE_BASE_SIZE; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
78 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
79 msn_message_set_attr(msg, "User-Agent", "Gaim/" VERSION); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
80 msn_message_set_content_type(msg, "text/plain"); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
81 msn_message_set_charset(msg, "UTF-8"); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
82 msn_message_set_flag(msg, 'N'); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
83 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
84 msn_message_ref(msg); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
85 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
86 return msg; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
87 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
88 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
89 MsnMessage * |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
90 msn_message_new_msnslp(void) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
91 { |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
92 MsnMessage *msg; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
93 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
94 msg = msn_message_new(); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
95 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
96 msn_message_set_attr(msg, "User-Agent", NULL); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
97 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
98 msg->msnslp_message = TRUE; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
99 msg->size += 52; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
100 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
101 msn_message_set_flag(msg, 'D'); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
102 msn_message_set_content_type(msg, "application/x-msnmsgrp2p"); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
103 msn_message_set_charset(msg, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
104 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
105 return msg; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
106 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
107 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
108 MsnMessage * |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
109 msn_message_new_msnslp_ack(MsnMessage *acked_msg) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
110 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
111 MsnMessage *msg; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
112 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
113 g_return_val_if_fail(acked_msg != NULL, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
114 g_return_val_if_fail(acked_msg->msnslp_message, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
115 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
116 msg = msn_message_new_msnslp(); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
117 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
118 msg->msnslp_ack_message = TRUE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
119 msg->acked_msg = msn_message_ref(acked_msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
120 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
121 msg->msnslp_header.session_id = acked_msg->msnslp_header.session_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
122 msg->msnslp_header.total_size_1 = acked_msg->msnslp_header.total_size_1; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
123 msg->msnslp_header.total_size_2 = acked_msg->msnslp_header.total_size_2; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
124 msg->msnslp_header.flags = 0x02; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
125 msg->msnslp_header.ack_session_id = acked_msg->msnslp_header.session_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
126 msg->msnslp_header.ack_unique_id = acked_msg->msnslp_header.ack_session_id; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
127 msg->msnslp_header.ack_length_1 = acked_msg->msnslp_header.total_size_1; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
128 msg->msnslp_header.ack_length_2 = acked_msg->msnslp_header.total_size_2; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
129 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
130 return msg; |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
131 } |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
132 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
133 MsnMessage * |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
134 msn_message_new_from_str(MsnSession *session, const char *str) |
4542 | 135 { |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
136 MsnMessage *msg; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
137 char *tmp_base, *msg_base, *tmp, *field1, *field2, *c; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
138 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
139 g_return_val_if_fail(str != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
140 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
|
141 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
142 msg = msn_message_new(); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
143 |
5454
c6efac0e28ff
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5315
diff
changeset
|
144 /* Clear out the old stuff. */ |
c6efac0e28ff
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5315
diff
changeset
|
145 msn_message_set_attr(msg, "User-Agent", NULL); |
5455
f9658a84d1ed
[gaim-migrate @ 5843]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
146 msn_message_set_content_type(msg, NULL); |
f9658a84d1ed
[gaim-migrate @ 5843]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
147 msn_message_set_charset(msg, NULL); |
5454
c6efac0e28ff
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5315
diff
changeset
|
148 |
6011
b8abf266dd3b
[gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
149 tmp_base = tmp = g_strdup(str); |
5309
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 GET_NEXT(tmp); /* Skip MSG */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
152 field1 = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
153 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
154 GET_NEXT(tmp); /* Skip the passport or TID */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
155 field2 = 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(tmp); /* Skip the username or flag */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
158 msg->size = atoi(tmp); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
159 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
160 if (msg->size != strlen(strchr(str, '\n') + 1)) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
161 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
162 "Incoming message size (%d) and string length (%d) " |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
163 "do not match!\n", msg->size, strlen(str)); |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
166 /* |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
167 * 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
|
168 * 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
|
169 */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
170 msg->incoming = FALSE; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
171 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
172 for (c = field1; *c != '\0'; c++) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
173 if (*c < '0' || *c > '9') { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
174 msg->incoming = TRUE; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
175 break; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
176 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
177 } |
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 if (msg->incoming) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
180 msg->sender = msn_users_find_with_passport(session->users, field1); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
181 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
182 if (msg->sender == NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
183 msg->sender = msn_user_new(session, field1, field2); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
184 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
185 msn_user_ref(msg->sender); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
186 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
187 else { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
188 msg->tid = atoi(field1); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
189 msg->flag = *field2; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
190 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
191 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
192 msg_base = tmp; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
193 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
194 /* Back to the parsination. */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
195 while (*tmp != '\r') { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
196 char *key, *value; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
197 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
198 key = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
199 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
200 GET_NEXT(tmp); /* Key */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
201 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
202 value = tmp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
203 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
204 GET_NEXT_LINE(tmp); /* Value */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
205 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
206 if ((c = strchr(key, ':')) != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
207 *c = '\0'; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
208 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
209 if (!g_ascii_strcasecmp(key, "Content-Type")) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
210 char *charset; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
211 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
212 if ((c = strchr(value, ';')) != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
213 if ((charset = strchr(c, '=')) != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
214 charset++; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
215 msn_message_set_charset(msg, charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
216 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
217 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
218 *c = '\0'; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
219 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
220 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
221 msn_message_set_content_type(msg, value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
222 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
223 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
224 msn_message_set_attr(msg, key, value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
225 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
226 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
227 /* "\r\n" */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
228 tmp += 2; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
229 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
230 /* Now we *should* be at the body. */ |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
231 if (!strcmp(msn_message_get_content_type(msg), "application/x-msnmsgrp2p")) |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
232 { |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
233 char header[48]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
234 char footer[4]; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
235 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
236 msg->msnslp_message = TRUE; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
237 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
238 memcpy(header, tmp, 48); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
239 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
240 tmp += 48; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
241 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
242 msg->body = g_memdup(tmp, msg->size - (tmp - msg_base) + 1); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
243 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
244 tmp++; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
245 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
246 memcpy(footer, tmp, 4); |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
247 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
248 /* Import the header. */ |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
249 msg->msnslp_header.session_id = msn_get32(tmp); tmp += 4; |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
250 msg->msnslp_header.id = msn_get32(tmp); tmp += 4; |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
251 msg->msnslp_header.offset_1 = msn_get32(tmp); tmp += 4; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
252 msg->msnslp_header.offset_2 = msn_get32(tmp); tmp += 4; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
253 msg->msnslp_header.total_size_1 = msn_get32(tmp); tmp += 4; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
254 msg->msnslp_header.total_size_2 = msn_get32(tmp); tmp += 4; |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
255 msg->msnslp_header.length = msn_get32(tmp); tmp += 4; |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
256 msg->msnslp_header.flags = msn_get32(tmp); tmp += 4; |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
257 msg->msnslp_header.ack_session_id = msn_get32(tmp); tmp += 4; |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
258 msg->msnslp_header.ack_unique_id = msn_get32(tmp); tmp += 4; |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
259 msg->msnslp_header.ack_length_1 = msn_get32(tmp); tmp += 4; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
260 msg->msnslp_header.ack_length_2 = msn_get32(tmp); tmp += 4; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
261 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
262 /* Convert to the right endianness */ |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
263 msg->msnslp_header.session_id = ntohl(msg->msnslp_header.session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
264 msg->msnslp_header.id = ntohl(msg->msnslp_header.id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
265 msg->msnslp_header.length = ntohl(msg->msnslp_header.length); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
266 msg->msnslp_header.flags = ntohl(msg->msnslp_header.flags); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
267 msg->msnslp_header.ack_length_1 = |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
268 ntohl(msg->msnslp_header.ack_length_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
269 msg->msnslp_header.ack_length_2 = |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
270 ntohl(msg->msnslp_header.ack_length_2); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
271 msg->msnslp_header.ack_session_id = |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
272 ntohl(msg->msnslp_header.ack_session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
273 msg->msnslp_header.ack_unique_id = |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
274 ntohl(msg->msnslp_header.ack_unique_id); |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
275 |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
276 /* Import the footer. */ |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
277 msg->msnslp_footer.app_id = (long)footer; |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
278 } |
6705
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
279 else |
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
280 { |
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
281 msn_message_set_body(msg, tmp); |
cebd49f42b56
[gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents:
6701
diff
changeset
|
282 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
283 |
6011
b8abf266dd3b
[gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
284 g_free(tmp_base); |
b8abf266dd3b
[gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
285 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
286 /* Done! */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
287 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
288 return msg; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
289 } |
4542 | 290 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
291 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
292 msn_message_destroy(MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
293 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
294 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
295 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
296 if (msg->ref_count > 0) { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
297 msn_message_unref(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 return; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
300 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
301 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
302 if (msg->sender != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
303 msn_user_unref(msg->sender); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
304 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
305 if (msg->receiver != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
306 msn_user_unref(msg->receiver); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
307 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
308 if (msg->body != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
309 g_free(msg->body); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
310 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
311 if (msg->content_type != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
312 g_free(msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
313 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
314 if (msg->charset != NULL) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
315 g_free(msg->charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
316 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
317 g_hash_table_destroy(msg->attr_table); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
318 g_list_free(msg->attr_list); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
319 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
320 if (msg->msnslp_ack_message) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
321 msn_message_unref(msg->acked_msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
322 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
323 gaim_debug(GAIM_DEBUG_INFO, "msn", "Destroying message\n"); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
324 g_free(msg); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
325 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
326 |
5506
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
327 MsnMessage * |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
328 msn_message_ref(MsnMessage *msg) |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
329 { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
330 g_return_val_if_fail(msg != NULL, NULL); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
331 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
332 msg->ref_count++; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
333 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
334 return msg; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
335 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
336 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
337 MsnMessage * |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
338 msn_message_unref(MsnMessage *msg) |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
339 { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
340 g_return_val_if_fail(msg != NULL, NULL); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
341 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
342 if (msg->ref_count <= 0) |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
343 return NULL; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
344 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
345 msg->ref_count--; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
346 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
347 if (msg->ref_count == 0) { |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
348 msn_message_destroy(msg); |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
349 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
350 return NULL; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
351 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
352 |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
353 return msg; |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
354 } |
4f72b611f0ee
[gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents:
5478
diff
changeset
|
355 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
356 char * |
6826
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
357 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
|
358 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
359 GList *l; |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
360 char *msg_start; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
361 char *str; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
362 char buf[MSN_BUF_LEN]; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
363 int len; |
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 /* |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
366 * 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
|
367 * a static buffer and then copying to the string. Unfortunately, |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
368 * 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
|
369 * 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
|
370 * good enough for now. |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
371 * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
372 * -- ChipX86 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
373 */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
374 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
375 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
376 if (msn_message_is_incoming(msg)) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
377 MsnUser *sender = msn_message_get_sender(msg); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
378 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
379 g_snprintf(buf, sizeof(buf), "MSG %s %s %d\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
380 msn_user_get_passport(sender), msn_user_get_name(sender), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
381 msg->size); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
382 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
383 else { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
384 g_snprintf(buf, sizeof(buf), "MSG %d %c %d\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
385 msn_message_get_transaction_id(msg), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
386 msn_message_get_flag(msg), msg->size); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
387 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
388 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
389 len = strlen(buf) + msg->size + 1; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
390 |
6826
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
391 str = g_new0(char, len + 1); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
392 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
393 g_strlcpy(str, buf, len); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
394 |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
395 msg_start = str + strlen(str); |
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
396 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
397 /* Standard header. */ |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
398 if (msg->charset == NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
399 g_snprintf(buf, sizeof(buf), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
400 "MIME-Version: 1.0\r\n" |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
401 "Content-Type: %s\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
402 msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
403 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
404 else { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
405 g_snprintf(buf, sizeof(buf), |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
406 "MIME-Version: 1.0\r\n" |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
407 "Content-Type: %s; charset=%s\r\n", |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
408 msg->content_type, msg->charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
409 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
410 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
411 g_strlcat(str, buf, len); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
412 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
413 for (l = msg->attr_list; l != NULL; l = l->next) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
414 const char *key = (char *)l->data; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
415 const char *value; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
416 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
417 value = msn_message_get_attr(msg, key); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
418 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
419 g_snprintf(buf, sizeof(buf), "%s: %s\r\n", key, value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
420 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
421 g_strlcat(str, buf, len); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
422 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
423 |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
424 g_strlcat(str, "\r\n", len); |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
425 |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
426 if (msg->msnslp_message) |
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 char *c; |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
429 long session_id, id, offset_1, offset_2, total_size_1, total_size_2; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
430 long length, flags; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
431 long ack_session_id, ack_unique_id, ack_length_1, ack_length_2; |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
432 |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
433 c = str + strlen(str); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
434 |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
435 session_id = htonl(msg->msnslp_header.session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
436 id = htonl(msg->msnslp_header.id); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
437 offset_1 = htonl(msg->msnslp_header.offset_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
438 offset_2 = htonl(msg->msnslp_header.offset_2); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
439 total_size_1 = htonl(msg->msnslp_header.total_size_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
440 total_size_2 = htonl(msg->msnslp_header.total_size_2); |
6786
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
441 length = htonl(msg->msnslp_header.length); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
442 flags = htonl(msg->msnslp_header.flags); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
443 ack_session_id = htonl(msg->msnslp_header.ack_session_id); |
8efafdc38718
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6705
diff
changeset
|
444 ack_unique_id = htonl(msg->msnslp_header.ack_unique_id); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
445 ack_length_1 = htonl(msg->msnslp_header.ack_length_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
446 ack_length_2 = htonl(msg->msnslp_header.ack_length_2); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
447 |
6831
a372cf34387e
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
448 c += msn_put32(c, session_id); |
a372cf34387e
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
449 c += msn_put32(c, id); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
450 c += msn_put32(c, offset_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
451 c += msn_put32(c, offset_2); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
452 c += msn_put32(c, total_size_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
453 c += msn_put32(c, total_size_2); |
6831
a372cf34387e
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
454 c += msn_put32(c, length); |
a372cf34387e
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
455 c += msn_put32(c, flags); |
a372cf34387e
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
456 c += msn_put32(c, ack_session_id); |
a372cf34387e
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
457 c += msn_put32(c, ack_unique_id); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
458 c += msn_put32(c, ack_length_1); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
459 c += msn_put32(c, ack_length_2); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
460 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
461 if (msg->bin_content) |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
462 { |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
463 size_t bin_len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
464 const void *body = msn_message_get_bin_data(msg, &bin_len); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
465 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
466 if (body != NULL) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
467 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
468 memcpy(c, body, msg->size - (c - msg_start)); |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
469 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
470 c += bin_len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
471 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
472 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
473 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
474 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
475 const char *body = msn_message_get_body(msg); |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
476 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
477 if (body != NULL) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
478 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
479 g_strlcpy(c, body, msg->size - (c - msg_start)); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
480 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
481 c += strlen(body); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
482 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
483 if (strlen(body) > 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
484 *c++ = '\0'; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
485 } |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
486 } |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
487 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
488 c += msn_put32(c, msg->msnslp_footer.app_id); |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
489 |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
490 if (msg->size != (c - msg_start)) |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
491 { |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
492 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
493 "Outgoing message size (%d) and data length (%d) " |
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
494 "do not match!\n", msg->size, (c - msg_start)); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
495 } |
6701
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
496 } |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
497 else |
b7e113a59b51
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
6181
diff
changeset
|
498 { |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
499 const char *body = msn_message_get_body(msg); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
500 |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
501 g_strlcat(str, body, len); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
502 |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
503 if (msg->size != strlen(msg_start)) { |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
504 gaim_debug(GAIM_DEBUG_ERROR, "msn", |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
505 "Outgoing message size (%d) and string length (%d) " |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
506 "do not match!\n", msg->size, strlen(msg_start)); |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
507 } |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
508 } |
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
509 |
6826
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
510 if (ret_size != NULL) |
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
511 *ret_size = len - 1; |
2adf21e70601
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
512 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
513 return str; |
4542 | 514 } |
515 | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
516 gboolean |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
517 msn_message_is_outgoing(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
518 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
519 g_return_val_if_fail(msg != NULL, FALSE); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
520 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
521 return !msg->incoming; |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
524 gboolean |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
525 msn_message_is_incoming(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
526 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
527 g_return_val_if_fail(msg != NULL, FALSE); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
528 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
529 return msg->incoming; |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
532 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
533 msn_message_set_sender(MsnMessage *msg, MsnUser *user) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
534 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
535 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
536 g_return_if_fail(user != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
537 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
538 msg->sender = user; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
539 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
540 msn_user_ref(msg->sender); |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
543 MsnUser * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
544 msn_message_get_sender(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
545 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
546 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
547 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
548 return msg->sender; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
549 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
550 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
551 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
552 msn_message_set_receiver(MsnMessage *msg, MsnUser *user) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
553 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
554 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
555 g_return_if_fail(user != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
556 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
557 msg->receiver = user; |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
558 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
559 if (msg->msnslp_message) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
560 msn_message_set_attr(msg, "P2P-Dest", msn_user_get_passport(user)); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
561 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
562 msn_user_ref(msg->receiver); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
563 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
564 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
565 MsnUser * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
566 msn_message_get_receiver(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
567 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
568 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
569 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
570 return msg->receiver; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
571 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
572 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
573 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
574 msn_message_set_transaction_id(MsnMessage *msg, unsigned int tid) |
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 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
577 g_return_if_fail(tid > 0); |
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 msg->tid = tid; |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
582 unsigned int |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
583 msn_message_get_transaction_id(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
584 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
585 g_return_val_if_fail(msg != NULL, 0); |
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 return msg->tid; |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
590 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
591 msn_message_set_flag(MsnMessage *msg, char flag) |
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 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
594 g_return_if_fail(flag != 0); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
595 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
596 msg->flag = flag; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
597 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
598 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
599 char |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
600 msn_message_get_flag(const MsnMessage *msg) |
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 g_return_val_if_fail(msg != NULL, 0); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
603 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
604 return msg->flag; |
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 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
607 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
608 msn_message_set_body(MsnMessage *msg, const char *body) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
609 { |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
610 const char *c; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
611 char *buf, *d; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
612 int newline_count = 0; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
613 size_t new_len; |
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
614 |
6827
1cfbb731aa1f
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
615 g_return_if_fail(msg != NULL); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
616 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
617 if (msg->bin_content) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
618 msn_message_set_bin_data(msg, NULL, 0); |
5309
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 if (msg->body != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
621 msg->size -= strlen(msg->body); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
622 g_free(msg->body); |
6800
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
623 |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
624 if (msg->msnslp_message) |
8f228a7d5076
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
625 msg->size--; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
626 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
627 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
628 if (body != NULL) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
629 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
630 for (c = body; *c != '\0'; c++) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
631 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
632 if (*c == '\n' && (c == body || *(c - 1) != '\r')) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
633 newline_count++; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
634 } |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
635 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
636 new_len = strlen(body) + newline_count; |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
637 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
638 buf = g_new0(char, new_len + 1); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
639 |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
640 for (c = body, d = buf; *c != '\0'; c++) { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
641 if (*c == '\n' && (c == body || *(c - 1) != '\r')) { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
642 *d++ = '\r'; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
643 *d++ = '\n'; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
644 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
645 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
646 *d++ = *c; |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
647 } |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
648 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
649 msg->body = buf; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
650 msg->size += new_len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
651 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
652 msg->bin_content = FALSE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
653 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
654 if (msg->msnslp_message) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
655 msg->size++; |
6181
29fef9695c4d
[gaim-migrate @ 6667]
Christian Hammond <chipx86@chipx86.com>
parents:
6075
diff
changeset
|
656 } |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
657 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
658 msg->body = NULL; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
659 } |
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 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
662 msn_message_get_body(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
663 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
664 g_return_val_if_fail(msg != NULL, NULL); |
6868
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
665 g_return_val_if_fail(!msg->bin_content, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
666 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
667 return msg->body; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
668 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
669 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
670 void |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
671 msn_message_set_bin_data(MsnMessage *msg, const void *data, size_t len) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
672 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
673 g_return_if_fail(msg != NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
674 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
675 if (!msg->bin_content) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
676 msn_message_set_body(msg, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
677 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
678 msg->bin_content = TRUE; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
679 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
680 if (msg->body != NULL) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
681 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
682 msg->size -= msg->bin_len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
683 g_free(msg->body); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
684 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
685 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
686 if (data != NULL && len > 0) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
687 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
688 msg->body = g_memdup(data, len); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
689 msg->bin_len = len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
690 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
691 msg->size += len; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
692 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
693 else |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
694 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
695 msg->body = NULL; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
696 msg->bin_len = 0; |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
697 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
698 } |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
699 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
700 const void * |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
701 msn_message_get_bin_data(const MsnMessage *msg, size_t *len) |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
702 { |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
703 g_return_val_if_fail(msg != NULL, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
704 g_return_val_if_fail(len != NULL, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
705 g_return_val_if_fail(msg->bin_content, NULL); |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
706 |
ab80de7a74d1
[gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
707 *len = msg->bin_len; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
708 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
709 return msg->body; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
710 } |
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 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
713 msn_message_set_content_type(MsnMessage *msg, const char *type) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
714 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
715 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
716 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
717 if (msg->content_type != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
718 msg->size -= strlen(msg->content_type); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
719 g_free(msg->content_type); |
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 |
5478
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
722 if (type != NULL) { |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
723 msg->content_type = g_strdup(type); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
724 |
5478
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
725 msg->size += strlen(type); |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
726 } |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
727 else |
bae3c48b9b4c
[gaim-migrate @ 5874]
Christian Hammond <chipx86@chipx86.com>
parents:
5455
diff
changeset
|
728 msg->content_type = NULL; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
729 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
730 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
731 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
732 msn_message_get_content_type(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
733 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
734 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
735 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
736 return msg->content_type; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
737 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
738 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
739 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
740 msn_message_set_charset(MsnMessage *msg, const char *charset) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
741 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
742 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
743 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
744 if (msg->charset != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
745 msg->size -= strlen(msg->charset) + strlen("; charset="); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
746 g_free(msg->charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
747 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
748 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
749 if (charset != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
750 msg->charset = g_strdup(charset); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
751 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
752 msg->size += strlen(charset) + strlen("; charset="); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
753 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
754 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
755 msg->charset = NULL; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
756 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
757 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
758 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
759 msn_message_get_charset(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
760 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
761 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
762 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
763 return msg->charset; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
764 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
765 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
766 void |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
767 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
|
768 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
769 const char *temp; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
770 char *new_attr; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
771 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
772 g_return_if_fail(msg != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
773 g_return_if_fail(attr != NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
774 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
775 temp = msn_message_get_attr(msg, attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
776 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
777 if (value == NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
778 if (temp != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
779 GList *l; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
780 |
5310
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
781 msg->size -= strlen(temp) + strlen(attr) + 4; |
f4912a833ff6
[gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
782 |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
783 for (l = msg->attr_list; l != NULL; l = l->next) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
784 if (!g_ascii_strcasecmp(l->data, attr)) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
785 msg->attr_list = g_list_remove(msg->attr_list, l->data); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
786 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
787 break; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
788 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
789 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
790 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
791 g_hash_table_remove(msg->attr_table, attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
792 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
793 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
794 return; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
795 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
796 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
797 new_attr = g_strdup(attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
798 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
799 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
|
800 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
801 if (temp == NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
802 msg->attr_list = g_list_append(msg->attr_list, new_attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
803 msg->size += strlen(attr) + 4; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
804 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
805 else |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
806 msg->size -= strlen(temp); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
807 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
808 msg->size += strlen(value); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
809 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
810 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
811 const char * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
812 msn_message_get_attr(const MsnMessage *msg, const char *attr) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
813 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
814 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
815 g_return_val_if_fail(attr != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
816 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
817 return g_hash_table_lookup(msg->attr_table, attr); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
818 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
819 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
820 GHashTable * |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
821 msn_message_get_hashtable_from_body(const MsnMessage *msg) |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
822 { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
823 GHashTable *table; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
824 char *body, *s, *c; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
825 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
826 g_return_val_if_fail(msg != NULL, NULL); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
827 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
|
828 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
829 s = body = g_strdup(msn_message_get_body(msg)); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
830 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
831 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
|
832 |
5315
b1c430fbf9d5
[gaim-migrate @ 5687]
Christian Hammond <chipx86@chipx86.com>
parents:
5310
diff
changeset
|
833 while (*s != '\r' && *s != '\0') { |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
834 char *key, *value; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
835 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
836 key = s; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
837 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
838 GET_NEXT(s); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
839 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
840 value = s; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
841 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
842 GET_NEXT_LINE(s); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
843 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
844 if ((c = strchr(key, ':')) != NULL) { |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
845 *c = '\0'; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
846 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
847 g_hash_table_insert(table, g_strdup(key), g_strdup(value)); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
848 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
849 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
850 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
851 g_free(body); |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
852 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
853 return table; |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
854 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
855 |