annotate src/protocols/msn/transaction.c @ 8810:a7affa2e2986

[gaim-migrate @ 9572] Forgot these. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 25 Apr 2004 23:40:13 +0000
parents
children c30d81b4dd22
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file transaction.c MSN transaction functions
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org>
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "msn.h"
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "transaction.h"
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 MsnTransaction *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 msn_transaction_new(const char *command, const char *format, ...)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 MsnTransaction *trans;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 va_list arg;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 g_return_val_if_fail(command != NULL, NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 trans = g_new0(MsnTransaction, 1);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 trans->command = g_strdup(command);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 va_start(arg, format);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 trans->params = g_strdup_vprintf(format, arg);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 va_end(arg);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 /* trans->queue = g_queue_new(); */
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 return trans;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 void
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 msn_transaction_destroy(MsnTransaction *trans)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 g_return_if_fail(trans != NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 g_free(trans->command);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 g_free(trans->params);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 g_free(trans->payload);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 #if 0
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 if (trans->pendent_cmd != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 msn_message_unref(trans->pendent_msg);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 #endif
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 #if 0
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 MsnTransaction *elem;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 if (trans->queue != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 while ((elem = g_queue_pop_head(trans->queue)) != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 msn_transaction_destroy(elem);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 g_queue_free(trans->queue);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 #endif
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 g_free(trans);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 char *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 msn_transaction_to_string(MsnTransaction *trans)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 char *str;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 g_return_val_if_fail(trans != NULL, FALSE);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 if (trans->params != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 str = g_strdup_printf("%s %u %s\r\n", trans->command, trans->trId, trans->params);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 else
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 str = g_strdup_printf("%s %u\r\n", trans->command, trans->trId);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 return str;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 void
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 msn_transaction_set_payload(MsnTransaction *trans,
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 const char *payload, int payload_len)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 g_return_if_fail(trans != NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 g_return_if_fail(payload != NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 trans->payload = g_strdup(payload);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 trans->payload_len = payload_len ? payload_len : strlen(trans->payload);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 }