annotate src/protocols/msn/msg.c @ 11933:1b0c83666f98

[gaim-migrate @ 14224] The mixed whitespace in this file was confusing Evan. I also cleaned up a couple other stylistic things. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 31 Oct 2005 20:33:13 +0000
parents 162dd2f8ad92
children 5e2a365af01b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file msg.c Message functions
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
8 * source distribution.
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
9 *
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * (at your option) any later version.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * GNU General Public License for more details.
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 */
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
25 #include "msg.h"
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
27 MsnMessage *
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
28 msn_message_new(MsnMsgType type)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
29 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
30 MsnMessage *msg;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
31
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
32 msg = g_new0(MsnMessage, 1);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
33 msg->type = type;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
34
10345
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
35 #ifdef MSN_DEBUG_MSG
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
36 gaim_debug_info("msn", "message new (%p)(%d)\n", msg, type);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
37 #endif
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
38
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
39 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
40 g_free, g_free);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
41
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
42 msn_message_ref(msg);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
43
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
44 return msg;
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
45 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
46
10345
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
47 void
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
48 msn_message_destroy(MsnMessage *msg)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
49 {
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
50 g_return_if_fail(msg != NULL);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
51
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
52 if (msg->ref_count > 0)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
53 {
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
54 msn_message_unref(msg);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
55
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
56 return;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
57 }
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
58
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
59 #ifdef MSN_DEBUG_MSG
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
60 gaim_debug_info("msn", "message destroy (%p)\n", msg);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
61 #endif
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
62
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
63 if (msg->remote_user != NULL)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
64 g_free(msg->remote_user);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
65
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
66 if (msg->body != NULL)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
67 g_free(msg->body);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
68
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
69 if (msg->content_type != NULL)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
70 g_free(msg->content_type);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
71
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
72 if (msg->charset != NULL)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
73 g_free(msg->charset);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
74
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
75 g_hash_table_destroy(msg->attr_table);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
76 g_list_free(msg->attr_list);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
77
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
78 g_free(msg);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
79 }
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
80
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
81 MsnMessage *
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
82 msn_message_ref(MsnMessage *msg)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
83 {
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
84 g_return_val_if_fail(msg != NULL, NULL);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
85
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
86 msg->ref_count++;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
87
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
88 #ifdef MSN_DEBUG_MSG
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
89 gaim_debug_info("msn", "message ref (%p)[%d]\n", msg, msg->ref_count);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
90 #endif
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
91
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
92 return msg;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
93 }
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
94
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
95 MsnMessage *
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
96 msn_message_unref(MsnMessage *msg)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
97 {
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
98 g_return_val_if_fail(msg != NULL, NULL);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
99
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
100 if (msg->ref_count <= 0)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
101 return NULL;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
102
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
103 msg->ref_count--;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
104
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
105 #ifdef MSN_DEBUG_MSG
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
106 gaim_debug_info("msn", "message unref (%p)[%d]\n", msg, msg->ref_count);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
107 #endif
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
108
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
109 if (msg->ref_count == 0)
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
110 {
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
111 msn_message_destroy(msg);
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
112
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
113 return NULL;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
114 }
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
115
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
116 return msg;
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
117 }
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
118
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
119 MsnMessage *
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
120 msn_message_new_plain(const char *message)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
121 {
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
122 MsnMessage *msg;
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
123 char *message_cr;
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
124
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
125 msg = msn_message_new(MSN_MSG_TEXT);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
126 msn_message_set_attr(msg, "User-Agent", "Gaim/" VERSION);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
127 msn_message_set_content_type(msg, "text/plain");
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
128 msn_message_set_charset(msg, "UTF-8");
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
129 msn_message_set_flag(msg, 'A');
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
130 msn_message_set_attr(msg, "X-MMS-IM-Format",
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
131 "FN=MS%20Sans%20Serif; EF=; CO=0; PF=0");
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
132
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
133 message_cr = gaim_str_add_cr(message);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
134 msn_message_set_bin_data(msg, message_cr, strlen(message_cr));
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
135 g_free(message_cr);
5506
4f72b611f0ee [gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents: 5478
diff changeset
136
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
137 return msg;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
140 MsnMessage *
6800
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
141 msn_message_new_msnslp(void)
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
142 {
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
143 MsnMessage *msg;
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
144
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
145 msg = msn_message_new(MSN_MSG_SLP);
6800
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
146
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
147 msn_message_set_attr(msg, "User-Agent", NULL);
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
148
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
149 msg->msnslp_message = TRUE;
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
150
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
151 msn_message_set_flag(msg, 'D');
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
152 msn_message_set_content_type(msg, "application/x-msnmsgrp2p");
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
153
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
154 return msg;
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
155 }
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
156
11321
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
157 MsnMessage *
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
158 msn_message_new_nudge(void)
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
159 {
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
160 MsnMessage *msg;
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
161
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
162 msg = msn_message_new(MSN_MSG_NUDGE);
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
163 msn_message_set_content_type(msg, "text/x-msnmsgr-datacast\r\n");
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
164 msn_message_set_flag(msg, 'N');
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
165 msn_message_set_attr(msg,"ID","1\r\n");
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
166
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
167 return msg;
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
168 }
95fa774d216d [gaim-migrate @ 13525]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11235
diff changeset
169
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
170 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
171 msn_message_parse_slp_body(MsnMessage *msg, const char *body, size_t len)
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
172 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
173 MsnSlpHeader header;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
174 const char *tmp;
11001
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
175 int body_len;
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
176
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
177 tmp = body;
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
178
11001
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
179 if (len < sizeof(header)) {
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
180 g_return_if_reached();
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
181 }
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
182
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
183 /* Import the header. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
184 memcpy(&header, tmp, sizeof(header));
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
185 tmp += sizeof(header);
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
186
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
187 msg->msnslp_header.session_id = GUINT32_FROM_LE(header.session_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
188 msg->msnslp_header.id = GUINT32_FROM_LE(header.id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
189 msg->msnslp_header.offset = GUINT64_FROM_LE(header.offset);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
190 msg->msnslp_header.total_size = GUINT64_FROM_LE(header.total_size);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
191 msg->msnslp_header.length = GUINT32_FROM_LE(header.length);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
192 msg->msnslp_header.flags = GUINT32_FROM_LE(header.flags);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
193 msg->msnslp_header.ack_id = GUINT32_FROM_LE(header.ack_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
194 msg->msnslp_header.ack_sub_id = GUINT32_FROM_LE(header.ack_sub_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
195 msg->msnslp_header.ack_size = GUINT64_FROM_LE(header.ack_size);
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
196
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
197 /* Import the body. */
11001
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
198 body_len = len - (tmp - body);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
199 /* msg->body_len = msg->msnslp_header.length; */
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
200
11001
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
201 if (body_len > 0) {
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
202 msg->body_len = len - (tmp - body);
11235
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
203 msg->body = g_malloc0(msg->body_len + 1);
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
204 memcpy(msg->body, tmp, msg->body_len);
11001
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
205 tmp += body_len;
0c9e936c154b [gaim-migrate @ 12851]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10981
diff changeset
206 }
6800
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
207 }
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
208
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
209 void
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
210 msn_message_parse_payload(MsnMessage *msg,
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
211 const char *payload, size_t payload_len)
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
213 char *tmp_base, *tmp;
7845
59f9508c9a31 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
214 const char *content_type;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
215 char *end;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
216 char **elems, **cur, **tokens;
5454
c6efac0e28ff [gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents: 5315
diff changeset
217
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
218 g_return_if_fail(payload != NULL);
7604
43803965ef45 [gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents: 7592
diff changeset
219
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
220 tmp_base = tmp = g_malloc0(payload_len + 1);
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10345
diff changeset
221 memcpy(tmp_base, payload, payload_len);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
222
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
223 /* Parse the attributes. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
224 end = strstr(tmp, "\r\n\r\n");
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
225 /* TODO? some clients use \r delimiters instead of \r\n, the official client
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
226 * doesn't send such messages, but does handle receiving them. We'll just
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
227 * avoid crashing for now */
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
228 if (end == NULL) {
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
229 g_free(tmp_base);
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
230 g_return_if_reached();
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
231 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
232 *end = '\0';
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
233
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
234 elems = g_strsplit(tmp, "\r\n", 0);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
235
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
236 for (cur = elems; *cur != NULL; cur++)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
237 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
238 const char *key, *value;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
239
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
240 tokens = g_strsplit(*cur, ": ", 2);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
241
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
242 key = tokens[0];
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
243 value = tokens[1];
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
244
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
245 if (!strcmp(key, "MIME-Version"))
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
246 {
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
247 g_strfreev(tokens);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
248 continue;
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
249 }
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
250
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
251 if (!strcmp(key, "Content-Type"))
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
252 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
253 char *charset, *c;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
254
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
255 if ((c = strchr(value, ';')) != NULL)
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
256 {
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
257 if ((charset = strchr(c, '=')) != NULL)
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
258 {
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
259 charset++;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
260 msn_message_set_charset(msg, charset);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
261 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
262
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
263 *c = '\0';
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
264 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
265
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
266 msn_message_set_content_type(msg, value);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
267 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
268 else
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
269 {
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
270 msn_message_set_attr(msg, key, value);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
271 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
272
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
273 g_strfreev(tokens);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
274 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
275
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
276 g_strfreev(elems);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
277
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
278 /* Proceed to the end of the "\r\n\r\n" */
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
279 tmp = end + 4;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
280
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
281 /* Now we *should* be at the body. */
7845
59f9508c9a31 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
282 content_type = msn_message_get_content_type(msg);
59f9508c9a31 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
283
59f9508c9a31 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
284 if (content_type != NULL &&
59f9508c9a31 [gaim-migrate @ 8499]
Christian Hammond <chipx86@chipx86.com>
parents: 7604
diff changeset
285 !strcmp(content_type, "application/x-msnmsgrp2p"))
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
286 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
287 MsnSlpHeader header;
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
288 MsnSlpFooter footer;
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
289 int body_len;
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
290
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
291 if (payload_len - (tmp - tmp_base) < sizeof(header)) {
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
292 g_free(tmp_base);
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
293 g_return_if_reached();
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
294 }
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
295
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
296 msg->msnslp_message = TRUE;
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
297
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
298 /* Import the header. */
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
299 memcpy(&header, tmp, sizeof(header));
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
300 tmp += sizeof(header);
7604
43803965ef45 [gaim-migrate @ 8227]
Christian Hammond <chipx86@chipx86.com>
parents: 7592
diff changeset
301
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
302 msg->msnslp_header.session_id = GUINT32_FROM_LE(header.session_id);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
303 msg->msnslp_header.id = GUINT32_FROM_LE(header.id);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
304 msg->msnslp_header.offset = GUINT64_FROM_LE(header.offset);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
305 msg->msnslp_header.total_size = GUINT64_FROM_LE(header.total_size);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
306 msg->msnslp_header.length = GUINT32_FROM_LE(header.length);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
307 msg->msnslp_header.flags = GUINT32_FROM_LE(header.flags);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
308 msg->msnslp_header.ack_id = GUINT32_FROM_LE(header.ack_id);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
309 msg->msnslp_header.ack_sub_id = GUINT32_FROM_LE(header.ack_sub_id);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
310 msg->msnslp_header.ack_size = GUINT64_FROM_LE(header.ack_size);
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
311
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
312 body_len = payload_len - (tmp - tmp_base) - sizeof(footer);
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
313
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
314 /* Import the body. */
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
315 if (body_len > 0) {
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
316 msg->body_len = body_len;
11235
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
317 msg->body = g_malloc0(msg->body_len + 1);
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
318 memcpy(msg->body, tmp, msg->body_len);
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
319 tmp += body_len;
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
320 }
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
321
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
322 /* Import the footer. */
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
323 if (body_len >= 0) {
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
324 memcpy(&footer, tmp, sizeof(footer));
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
325 tmp += sizeof(footer);
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
326 msg->msnslp_footer.value = GUINT32_FROM_BE(footer.value);
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
327 }
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
328 }
6705
cebd49f42b56 [gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
329 else
cebd49f42b56 [gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
330 {
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
331 if (payload_len - (tmp - tmp_base) > 0) {
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
332 msg->body_len = payload_len - (tmp - tmp_base);
11235
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
333 msg->body = g_malloc0(msg->body_len + 1);
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
334 memcpy(msg->body, tmp, msg->body_len);
10981
771c510655c7 [gaim-migrate @ 12812]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10481
diff changeset
335 }
6705
cebd49f42b56 [gaim-migrate @ 7231]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
336 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
337
6011
b8abf266dd3b [gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
338 g_free(tmp_base);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
339 }
6011
b8abf266dd3b [gaim-migrate @ 6459]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
340
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
341 MsnMessage *
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
342 msn_message_new_from_cmd(MsnSession *session, MsnCommand *cmd)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
343 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
344 MsnMessage *msg;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
345
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
346 g_return_val_if_fail(cmd != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
347
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
348 msg = msn_message_new(MSN_MSG_UNKNOWN);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
349
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
350 msg->remote_user = g_strdup(cmd->params[0]);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
351 /* msg->size = atoi(cmd->params[2]); */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
352 msg->cmd = cmd;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
353
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
354 return msg;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
355 }
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
357 char *
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
358 msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
359 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
360 MsnSlpHeader header;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
361
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
362 char *tmp, *base;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
363 const void *body;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
364 size_t len, body_len;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
365
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
366 g_return_val_if_fail(msg != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
367
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
368 len = MSN_BUF_LEN;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
369
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
370 base = tmp = g_malloc(len + 1);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
371
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
372 body = msn_message_get_bin_data(msg, &body_len);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
373
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
374 header.session_id = GUINT32_TO_LE(msg->msnslp_header.session_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
375 header.id = GUINT32_TO_LE(msg->msnslp_header.id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
376 header.offset = GUINT64_TO_LE(msg->msnslp_header.offset);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
377 header.total_size = GUINT64_TO_LE(msg->msnslp_header.total_size);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
378 header.length = GUINT32_TO_LE(msg->msnslp_header.length);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
379 header.flags = GUINT32_TO_LE(msg->msnslp_header.flags);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
380 header.ack_id = GUINT32_TO_LE(msg->msnslp_header.ack_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
381 header.ack_sub_id = GUINT32_TO_LE(msg->msnslp_header.ack_sub_id);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
382 header.ack_size = GUINT64_TO_LE(msg->msnslp_header.ack_size);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
383
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
384 memcpy(tmp, &header, 48);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
385 tmp += 48;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
386
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
387 if (body != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
388 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
389 memcpy(tmp, body, body_len);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
390 tmp += body_len;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
391 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
392
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
393 if (ret_size != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
394 *ret_size = tmp - base;
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
395
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
396 return base;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
397 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
398
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
399 char *
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
400 msn_message_gen_payload(MsnMessage *msg, size_t *ret_size)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
401 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
402 GList *l;
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
403 char *n, *base, *end;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
404 int len;
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
405 size_t body_len;
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
406 const void *body;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
407
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
408 g_return_val_if_fail(msg != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
409
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
410 len = MSN_BUF_LEN;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
411
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
412 base = n = end = g_malloc(len + 1);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
413 end += len;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
414
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
415 /* Standard header. */
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
416 if (msg->charset == NULL)
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
417 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
418 g_snprintf(n, len,
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
419 "MIME-Version: 1.0\r\n"
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
420 "Content-Type: %s\r\n",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
421 msg->content_type);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
422 }
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
423 else
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
424 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
425 g_snprintf(n, len,
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
426 "MIME-Version: 1.0\r\n"
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
427 "Content-Type: %s; charset=%s\r\n",
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
428 msg->content_type, msg->charset);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
429 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
430
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
431 n += strlen(n);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
432
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
433 for (l = msg->attr_list; l != NULL; l = l->next)
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
434 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
435 const char *key;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
436 const char *value;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
437
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
438 key = l->data;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
439 value = msn_message_get_attr(msg, key);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
440
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
441 g_snprintf(n, end - n, "%s: %s\r\n", key, value);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
442 n += strlen(n);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
443 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
444
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
445 n += g_strlcpy(n, "\r\n", end - n);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
446
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
447 body = msn_message_get_bin_data(msg, &body_len);
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
448
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
449 if (msg->msnslp_message)
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
450 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
451 MsnSlpHeader header;
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
452 MsnSlpFooter footer;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
453
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
454 header.session_id = GUINT32_TO_LE(msg->msnslp_header.session_id);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
455 header.id = GUINT32_TO_LE(msg->msnslp_header.id);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
456 header.offset = GUINT64_TO_LE(msg->msnslp_header.offset);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
457 header.total_size = GUINT64_TO_LE(msg->msnslp_header.total_size);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
458 header.length = GUINT32_TO_LE(msg->msnslp_header.length);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
459 header.flags = GUINT32_TO_LE(msg->msnslp_header.flags);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
460 header.ack_id = GUINT32_TO_LE(msg->msnslp_header.ack_id);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
461 header.ack_sub_id = GUINT32_TO_LE(msg->msnslp_header.ack_sub_id);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
462 header.ack_size = GUINT64_TO_LE(msg->msnslp_header.ack_size);
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
463
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
464 memcpy(n, &header, 48);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
465 n += 48;
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
466
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
467 if (body != NULL)
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
468 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
469 memcpy(n, body, body_len);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
470
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
471 n += body_len;
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
472 }
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
473
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
474 footer.value = GUINT32_TO_BE(msg->msnslp_footer.value);
6827
1cfbb731aa1f [gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents: 6826
diff changeset
475
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
476 memcpy(n, &footer, 4);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
477 n += 4;
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
478 }
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
479 else
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6181
diff changeset
480 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
481 if (body != NULL)
8646
1e211dde3cae [gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents: 8475
diff changeset
482 {
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
483 memcpy(n, body, body_len);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
484 n += body_len;
6800
8f228a7d5076 [gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents: 6786
diff changeset
485 }
5310
f4912a833ff6 [gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
486 }
f4912a833ff6 [gaim-migrate @ 5682]
Christian Hammond <chipx86@chipx86.com>
parents: 5309
diff changeset
487
6826
2adf21e70601 [gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents: 6800
diff changeset
488 if (ret_size != NULL)
9092
9e5a709c30a8 [gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents: 8647
diff changeset
489 {
10274
3016b1b32339 [gaim-migrate @ 11424]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
490 *ret_size = n - base;
3016b1b32339 [gaim-migrate @ 11424]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
491
9092
9e5a709c30a8 [gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents: 8647
diff changeset
492 if (*ret_size > 1664)
9e5a709c30a8 [gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents: 8647
diff changeset
493 *ret_size = 1664;
9e5a709c30a8 [gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents: 8647
diff changeset
494 }
9e5a709c30a8 [gaim-migrate @ 9869]
Christian Hammond <chipx86@chipx86.com>
parents: 8647
diff changeset
495
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
496 return base;
4542
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
497 }
86b0a0243be8 [gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
498
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
499 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
500 msn_message_set_flag(MsnMessage *msg, char flag)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
501 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
502 g_return_if_fail(msg != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
503 g_return_if_fail(flag != 0);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
504
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
505 msg->flag = flag;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
506 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
507
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
508 char
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
509 msn_message_get_flag(const MsnMessage *msg)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
510 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
511 g_return_val_if_fail(msg != NULL, 0);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
512
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
513 return msg->flag;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
514 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
515
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
516 void
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
517 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
518 {
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
519 g_return_if_fail(msg != NULL);
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
520
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
521 /* There is no need to waste memory on data we cannot send anyway */
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
522 if (len > 1664)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
523 len = 1664;
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
524
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
525 if (msg->body != NULL)
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
526 g_free(msg->body);
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
527
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
528 if (data != NULL && len > 0)
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
529 {
11235
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
530 msg->body = g_malloc0(len + 1);
5ea38c98ff30 [gaim-migrate @ 13380]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11001
diff changeset
531 memcpy(msg->body, data, len);
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
532 msg->body_len = len;
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
533 }
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
534 else
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
535 {
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
536 msg->body = NULL;
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
537 msg->body_len = 0;
6868
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
538 }
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
539 }
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
540
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
541 const void *
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
542 msn_message_get_bin_data(const MsnMessage *msg, size_t *len)
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
543 {
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
544 g_return_val_if_fail(msg != NULL, NULL);
ab80de7a74d1 [gaim-migrate @ 7414]
Christian Hammond <chipx86@chipx86.com>
parents: 6842
diff changeset
545
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
546 if (len)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
547 *len = msg->body_len;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
548
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
549 return msg->body;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
552 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
553 msn_message_set_content_type(MsnMessage *msg, const char *type)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
554 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
555 g_return_if_fail(msg != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
556
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
557 if (msg->content_type != NULL)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
558 g_free(msg->content_type);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
559
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
560 msg->content_type = (type != NULL) ? g_strdup(type) : NULL;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
561 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
562
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
563 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
564 msn_message_get_content_type(const MsnMessage *msg)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
565 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
566 g_return_val_if_fail(msg != NULL, NULL);
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 return msg->content_type;
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
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
571 void
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
572 msn_message_set_charset(MsnMessage *msg, const char *charset)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
573 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
574 g_return_if_fail(msg != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
575
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
576 if (msg->charset != NULL)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
577 g_free(msg->charset);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
578
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
579 msg->charset = (charset != NULL) ? g_strdup(charset) : NULL;
5309
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 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
583 msn_message_get_charset(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, NULL);
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->charset;
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_attr(MsnMessage *msg, const char *attr, const char *value)
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 const char *temp;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
594 char *new_attr;
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 g_return_if_fail(msg != NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
597 g_return_if_fail(attr != NULL);
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 temp = msn_message_get_attr(msg, attr);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
600
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
601 if (value == NULL)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
602 {
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
603 if (temp != NULL)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
604 {
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
605 GList *l;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
606
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
607 for (l = msg->attr_list; l != NULL; l = l->next)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
608 {
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
609 if (!g_ascii_strcasecmp(l->data, attr))
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
610 {
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
611 msg->attr_list = g_list_remove(msg->attr_list, l->data);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
612
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
613 break;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
614 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
615 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
616
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
617 g_hash_table_remove(msg->attr_table, attr);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
618 }
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 return;
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
621 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
622
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
623 new_attr = g_strdup(attr);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
624
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
625 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
626
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
627 if (temp == NULL)
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
628 msg->attr_list = g_list_append(msg->attr_list, new_attr);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
629 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
630
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
631 const char *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
632 msn_message_get_attr(const MsnMessage *msg, const char *attr)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
633 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
634 g_return_val_if_fail(msg != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
635 g_return_val_if_fail(attr != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
636
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
637 return g_hash_table_lookup(msg->attr_table, attr);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
638 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
639
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
640 GHashTable *
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
641 msn_message_get_hashtable_from_body(const MsnMessage *msg)
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
642 {
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
643 GHashTable *table;
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
644 size_t body_len;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
645 const char *body;
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
646 char **elems, **cur, **tokens, *body_str;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
647
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
648 g_return_val_if_fail(msg != NULL, NULL);
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
649
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
650 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
651
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
652 body = msn_message_get_bin_data(msg, &body_len);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
653
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
654 g_return_val_if_fail(body != NULL, NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
655
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
656 body_str = g_strndup(body, body_len);
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
657 elems = g_strsplit(body_str, "\r\n", 0);
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10275
diff changeset
658 g_free(body_str);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
659
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
660 for (cur = elems; *cur != NULL; cur++)
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
661 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
662 if (**cur == '\0')
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
663 break;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
664
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
665 tokens = g_strsplit(*cur, ": ", 2);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
666
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
667 if (tokens[0] != NULL && tokens[1] != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
668 g_hash_table_insert(table, tokens[0], tokens[1]);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
669
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
670 g_free(tokens);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
671 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
672
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
673 g_strfreev(elems);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
674
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
675 return table;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
676 }
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
677
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
678 char *
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
679 msn_message_to_string(MsnMessage *msg)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
680 {
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
681 size_t body_len;
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
682 const char *body;
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
683
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
684 g_return_val_if_fail(msg != NULL, NULL);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
685 g_return_val_if_fail(msg->type == MSN_MSG_TEXT, NULL);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
686
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
687 body = msn_message_get_bin_data(msg, &body_len);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
688
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
689 return g_strndup(body, body_len);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
690 }
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10112
diff changeset
691
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
692 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
693 msn_message_show_readable(MsnMessage *msg, const char *info,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
694 gboolean text_body)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
695 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
696 GString *str;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
697 size_t body_len;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
698 const char *body;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
699 GList *l;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
700
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
701 g_return_if_fail(msg != NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
702
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
703 str = g_string_new(NULL);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
704
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
705 /* Standard header. */
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
706 if (msg->charset == NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
707 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
708 g_string_append_printf(str,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
709 "MIME-Version: 1.0\r\n"
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
710 "Content-Type: %s\r\n",
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
711 msg->content_type);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
712 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
713 else
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
714 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
715 g_string_append_printf(str,
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
716 "MIME-Version: 1.0\r\n"
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
717 "Content-Type: %s; charset=%s\r\n",
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
718 msg->content_type, msg->charset);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
719 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
720
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
721 for (l = msg->attr_list; l; l = l->next)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
722 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
723 char *key;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
724 const char *value;
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
725
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
726 key = l->data;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
727 value = msn_message_get_attr(msg, key);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
728
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
729 g_string_append_printf(str, "%s: %s\r\n", key, value);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
730 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
731
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
732 g_string_append(str, "\r\n");
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
733
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
734 body = msn_message_get_bin_data(msg, &body_len);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
735
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
736 if (msg->msnslp_message)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
737 {
10092
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
738 g_string_append_printf(str, "Session ID: %u\r\n", msg->msnslp_header.session_id);
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
739 g_string_append_printf(str, "ID: %u\r\n", msg->msnslp_header.id);
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10092
diff changeset
740 g_string_append_printf(str, "Offset: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.offset);
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10092
diff changeset
741 g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.total_size);
10092
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
742 g_string_append_printf(str, "Length: %u\r\n", msg->msnslp_header.length);
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
743 g_string_append_printf(str, "Flags: 0x%x\r\n", msg->msnslp_header.flags);
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
744 g_string_append_printf(str, "ACK ID: %u\r\n", msg->msnslp_header.ack_id);
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
745 g_string_append_printf(str, "SUB ID: %u\r\n", msg->msnslp_header.ack_sub_id);
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10092
diff changeset
746 g_string_append_printf(str, "ACK Size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
747
10345
2e01c503aa4f [gaim-migrate @ 11556]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
748 #ifdef MSN_DEBUG_SLP_VERBOSE
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
749 if (body != NULL)
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 9092
diff changeset
750 {
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
751 if (text_body)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
752 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
753 g_string_append_len(str, body, body_len);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
754 if (body[body_len - 1] == '\0')
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
755 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
756 str->len--;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
757 g_string_append(str, " 0x00");
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
758 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
759 g_string_append(str, "\r\n");
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
760 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
761 else
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
762 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
763 int i;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
764 for (i = 0; i < msg->body_len; i++)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
765 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
766 g_string_append_printf(str, "%.2hhX ", body[i]);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
767 if ((i % 16) == 15)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
768 g_string_append(str, "\r\n");
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
769 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
770 g_string_append(str, "\r\n");
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
771 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
772 }
10092
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
773 #endif
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
774
10092
1843023b8189 [gaim-migrate @ 11109]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9198
diff changeset
775 g_string_append_printf(str, "Footer: %u\r\n", msg->msnslp_footer.value);
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
776 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
777 else
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
778 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
779 if (body != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
780 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
781 g_string_append_len(str, body, body_len);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
782 g_string_append(str, "\r\n");
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
783 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
784 }
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
785
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
786 gaim_debug_info("msn", "Message %s:\n{%s}\n", info, str->str);
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
787
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
788 g_string_free(str, TRUE);
5309
e2e53316a21d [gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents: 5221
diff changeset
789 }