annotate src/protocols/msn/page.c @ 6826:2adf21e70601

[gaim-migrate @ 7371] Fixed message length problems for binary and text. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 13 Sep 2003 23:28:08 +0000
parents b7e113a59b51
children 414c701ef1ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5370
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file page.c Paging functions
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 5370
diff changeset
7 *
5370
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "msn.h"
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "page.h"
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #define GET_NEXT(tmp) \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 while (*(tmp) && *(tmp) != ' ' && *(tmp) != '\r') \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 (tmp)++; \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 if (*(tmp) != '\0') *(tmp)++ = '\0'; \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 if (*(tmp) == '\n') *(tmp)++; \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 while (*(tmp) && *(tmp) == ' ') \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 (tmp)++
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 #define GET_NEXT_LINE(tmp) \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 while (*(tmp) && *(tmp) != '\r') \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 (tmp)++; \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 if (*(tmp) != '\0') *(tmp)++ = '\0'; \
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 if (*(tmp) == '\n') *(tmp)++
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 /*
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 * "<TEXT>" == 6
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 * "</TEXT>" == 7
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 * ----
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 * 13
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 */
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 #define MSN_PAGE_BASE_SIZE 13
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 MsnPage *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 msn_page_new(void)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 MsnPage *page;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 page = g_new0(MsnPage, 1);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 page->size = MSN_PAGE_BASE_SIZE;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 return page;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 MsnPage *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 msn_page_new_from_str(MsnSession *session, const char *str)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 g_return_val_if_fail(str != NULL, NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 return NULL;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 msn_page_destroy(MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 if (page->sender != NULL)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 msn_user_unref(page->sender);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 if (page->receiver != NULL)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 msn_user_unref(page->receiver);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 if (page->body != NULL)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 g_free(page->body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 if (page->from_location != NULL)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 g_free(page->from_location);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 if (page->from_phone != NULL)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 g_free(page->from_phone);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 g_free(page);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 char *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 msn_page_build_string(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 char *page_start;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 char *str;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 char buf[MSN_BUF_LEN];
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 int len;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 /*
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 * Okay, how we do things here is just bad. I don't like writing to
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 * a static buffer and then copying to the string. Unfortunately,
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 * just trying to append to the string is causing issues.. Such as
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 * the string you're appending to being erased. Ugh. So, this is
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 * good enough for now.
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 * -- ChipX86
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 */
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 g_return_val_if_fail(page != NULL, NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 if (msn_page_is_incoming(page)) {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 /* We don't know this yet :) */
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 return NULL;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 else {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 MsnUser *receiver = msn_page_get_receiver(page);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 g_snprintf(buf, sizeof(buf), "PAG %d %s %d\r\n",
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 msn_page_get_transaction_id(page),
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 msn_user_get_passport(receiver),
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 page->size);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 len = strlen(buf) + page->size + 1;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 str = g_new0(char, len);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 g_strlcpy(str, buf, len);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 page_start = str + strlen(str);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 g_snprintf(buf, sizeof(buf), "<TEXT>%s</TEXT>", msn_page_get_body(page));
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 g_strlcat(str, buf, len);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 if (page->size != strlen(page_start)) {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 gaim_debug(GAIM_DEBUG_ERROR, "msn",
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 "Outgoing page size (%d) and string length (%d) "
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 "do not match!\n", page->size, strlen(page_start));
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 return str;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 gboolean
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 msn_page_is_outgoing(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 g_return_val_if_fail(page != NULL, FALSE);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 return !page->incoming;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 gboolean
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 msn_page_is_incoming(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 g_return_val_if_fail(page != NULL, FALSE);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 return page->incoming;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 msn_page_set_sender(MsnPage *page, MsnUser *user)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 g_return_if_fail(user != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 page->sender = user;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 msn_user_ref(page->sender);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 MsnUser *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 msn_page_get_sender(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 g_return_val_if_fail(page != NULL, NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 return page->sender;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 msn_page_set_receiver(MsnPage *page, MsnUser *user)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 g_return_if_fail(user != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 page->receiver = user;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 msn_user_ref(page->receiver);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 MsnUser *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 msn_page_get_receiver(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 g_return_val_if_fail(page != NULL, NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 return page->receiver;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 msn_page_set_transaction_id(MsnPage *page, unsigned int tid)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 g_return_if_fail(tid > 0);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 page->trId = tid;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 unsigned int
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 msn_page_get_transaction_id(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 g_return_val_if_fail(page != NULL, 0);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 return page->trId;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 msn_page_set_body(MsnPage *page, const char *body)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 g_return_if_fail(body != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 if (page->body != NULL) {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 page->size -= strlen(page->body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 g_free(page->body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 page->body = g_strdup(body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 page->size += strlen(body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 const char *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 msn_page_get_body(const MsnPage *page)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 g_return_val_if_fail(page != NULL, NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 return page->body;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237