annotate src/protocols/msn/page.c @ 7834:99ffabc6ce73

[gaim-migrate @ 8487] This patch from Mike Hearn should fix HTTP proxy support for MSN, and provides another step toward the MSN HTTP access method working. The HTTP proxy may need testing from other people, but looks like it shouldn't give any problems. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 12 Dec 2003 00:14:40 +0000
parents 4ab8ec97576c
children 06f57183e29f
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 /*
7468
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
40 * <TEXT xml:space="preserve" enc="utf-8"> == 39
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
41 * </TEXT> == 7
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
42 * ----
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
43 * 46
5370
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 */
7468
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
45 #define MSN_PAGE_BASE_SIZE 46
5370
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
7468
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
116 g_snprintf(buf, sizeof(buf), "PGD %d %s 1 %d\r\n",
5370
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),
7386
414c701ef1ff [gaim-migrate @ 7981]
Luke Schierer <lschiere@pidgin.im>
parents: 6701
diff changeset
119 (int)page->size);
5370
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
7468
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
130 g_snprintf(buf, sizeof(buf),
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
131 "<TEXT xml:space=\"preserve\" enc=\"utf-8\">%s</TEXT>",
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
132 msn_page_get_body(page));
5370
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 g_strlcat(str, buf, len);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 if (page->size != strlen(page_start)) {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 gaim_debug(GAIM_DEBUG_ERROR, "msn",
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 "Outgoing page size (%d) and string length (%d) "
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 "do not match!\n", page->size, strlen(page_start));
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 }
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 return str;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 gboolean
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 msn_page_is_outgoing(const MsnPage *page)
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 g_return_val_if_fail(page != NULL, FALSE);
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 return !page->incoming;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 gboolean
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 msn_page_is_incoming(const MsnPage *page)
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 g_return_val_if_fail(page != NULL, FALSE);
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 return page->incoming;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 msn_page_set_sender(MsnPage *page, MsnUser *user)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 g_return_if_fail(user != NULL);
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 page->sender = user;
7468
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
168
5370
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 msn_user_ref(page->sender);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 MsnUser *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 msn_page_get_sender(const MsnPage *page)
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 g_return_val_if_fail(page != NULL, NULL);
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 return page->sender;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 msn_page_set_receiver(MsnPage *page, MsnUser *user)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 g_return_if_fail(user != NULL);
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 page->receiver = user;
7468
4ab8ec97576c [gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents: 7386
diff changeset
187
5370
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 msn_user_ref(page->receiver);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 MsnUser *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 msn_page_get_receiver(const MsnPage *page)
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 g_return_val_if_fail(page != NULL, NULL);
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 return page->receiver;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 msn_page_set_transaction_id(MsnPage *page, unsigned int tid)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 g_return_if_fail(tid > 0);
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 page->trId = tid;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 unsigned int
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 msn_page_get_transaction_id(const MsnPage *page)
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 g_return_val_if_fail(page != NULL, 0);
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 return page->trId;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 void
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 msn_page_set_body(MsnPage *page, const char *body)
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 g_return_if_fail(page != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 g_return_if_fail(body != NULL);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 if (page->body != NULL) {
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 page->size -= strlen(page->body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 g_free(page->body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 }
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->body = g_strdup(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 page->size += strlen(body);
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 const char *
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 msn_page_get_body(const MsnPage *page)
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 g_return_val_if_fail(page != NULL, NULL);
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 return page->body;
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 }
058230cccebb [gaim-migrate @ 5746]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239