Mercurial > pidgin
annotate src/protocols/novell/nmrequest.c @ 8718:6ab61697426e
[gaim-migrate @ 9473]
simguy wants this
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 20 Apr 2004 04:04:41 +0000 |
parents | 046dd8ef2920 |
children | 6663ad2386d9 |
rev | line source |
---|---|
8675 | 1 /* |
2 * nmrequest.c | |
3 * | |
4 * Copyright © 2004 Unpublished Work of Novell, Inc. All Rights Reserved. | |
5 * | |
6 * THIS WORK IS AN UNPUBLISHED WORK OF NOVELL, INC. NO PART OF THIS WORK MAY BE | |
7 * USED, PRACTICED, PERFORMED, COPIED, DISTRIBUTED, REVISED, MODIFIED, | |
8 * TRANSLATED, ABRIDGED, CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, | |
9 * RECAST, TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF NOVELL, | |
10 * INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT AUTHORIZATION COULD SUBJECT | |
11 * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY. | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
12 * |
8675 | 13 * AS BETWEEN [GAIM] AND NOVELL, NOVELL GRANTS [GAIM] THE RIGHT TO REPUBLISH |
14 * THIS WORK UNDER THE GPL (GNU GENERAL PUBLIC LICENSE) WITH ALL RIGHTS AND | |
15 * LICENSES THEREUNDER. IF YOU HAVE RECEIVED THIS WORK DIRECTLY OR INDIRECTLY | |
16 * FROM [GAIM] AS PART OF SUCH A REPUBLICATION, YOU HAVE ALL RIGHTS AND LICENSES | |
17 * GRANTED BY [GAIM] UNDER THE GPL. IN CONNECTION WITH SUCH A REPUBLICATION, IF | |
18 * ANYTHING IN THIS NOTICE CONFLICTS WITH THE TERMS OF THE GPL, SUCH TERMS | |
19 * PREVAIL. | |
20 * | |
21 */ | |
22 | |
23 #include "nmrequest.h" | |
24 | |
25 struct _NMRequest | |
26 { | |
27 int trans_id; | |
28 char *cmd; | |
29 int gmt; | |
30 gpointer data; | |
31 gpointer user_define; | |
32 nm_response_cb callback; | |
33 int ref_count; | |
34 NMERR_T ret_code; | |
35 }; | |
36 | |
37 | |
38 NMRequest * | |
39 nm_create_request(const char *cmd, int trans_id, int gmt) | |
40 { | |
41 NMRequest *req; | |
42 | |
43 if (cmd == NULL) | |
44 return NULL; | |
45 | |
46 req = g_new0(NMRequest, 1); | |
47 req->cmd = g_strdup(cmd); | |
48 req->trans_id = trans_id; | |
49 req->gmt = gmt; | |
50 req->ref_count = 1; | |
51 | |
52 return req; | |
53 } | |
54 | |
55 void | |
56 nm_release_request(NMRequest * req) | |
57 { | |
58 if (req && (--req->ref_count == 0)) { | |
59 if (req->cmd) | |
60 g_free(req->cmd); | |
61 g_free(req); | |
62 } | |
63 } | |
64 | |
65 void | |
66 nm_request_add_ref(NMRequest * req) | |
67 { | |
68 if (req) | |
69 req->ref_count++; | |
70 } | |
71 | |
72 void | |
73 nm_request_set_callback(NMRequest * req, nm_response_cb callback) | |
74 { | |
75 if (req) | |
76 req->callback = callback; | |
77 } | |
78 | |
79 void | |
80 nm_request_set_data(NMRequest * req, gpointer data) | |
81 { | |
82 if (req) | |
83 req->data = data; | |
84 } | |
85 | |
86 void | |
87 nm_request_set_user_define(NMRequest * req, gpointer user_define) | |
88 { | |
89 if (req) | |
90 req->user_define = user_define; | |
91 } | |
92 | |
93 int | |
94 nm_request_get_trans_id(NMRequest * req) | |
95 { | |
96 if (req) | |
97 return req->trans_id; | |
98 else | |
99 return -1; | |
100 } | |
101 | |
102 const char * | |
103 nm_request_get_cmd(NMRequest * req) | |
104 { | |
105 if (req == NULL) | |
106 return NULL; | |
107 | |
108 return req->cmd; | |
109 } | |
110 | |
111 gpointer | |
112 nm_request_get_data(NMRequest * req) | |
113 { | |
114 if (req == NULL) | |
115 return NULL; | |
116 | |
117 return req->data; | |
118 } | |
119 | |
120 gpointer | |
121 nm_request_get_user_define(NMRequest * req) | |
122 { | |
123 if (req == NULL) | |
124 return NULL; | |
125 | |
126 return req->user_define; | |
127 } | |
128 | |
129 nm_response_cb | |
130 nm_request_get_callback(NMRequest * req) | |
131 { | |
132 if (req == NULL) | |
133 return NULL; | |
134 | |
135 return req->callback; | |
136 } | |
137 | |
138 | |
139 void | |
140 nm_request_set_ret_code(NMRequest * req, NMERR_T rc) | |
141 { | |
142 if (req) | |
143 req->ret_code = rc; | |
144 } | |
145 | |
146 NMERR_T | |
147 nm_request_get_ret_code(NMRequest * req) | |
148 { | |
149 if (req) | |
150 return req->ret_code; | |
151 else | |
152 return (NMERR_T) - 1; | |
153 } |