Mercurial > pidgin
annotate src/protocols/novell/nmrequest.c @ 10831:ea65b2abd8d2
[gaim-migrate @ 12499]
Fix bug #1083465 - don't automatically add yourself to your buddy list with
the gevolution plugin, this is probably what caused complaint #59 that Ubuntu
interface designer had.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 16 Apr 2005 16:53:05 +0000 |
parents | d77537e8bfe5 |
children |
rev | line source |
---|---|
8675 | 1 /* |
2 * nmrequest.c | |
3 * | |
8933 | 4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; version 2 of the License. | |
8675 | 9 * |
8933 | 10 * This program is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
8684
046dd8ef2920
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
14 * |
8933 | 15 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
8675 | 18 * |
19 */ | |
20 | |
21 #include "nmrequest.h" | |
22 | |
9360 | 23 static int count = 0; |
24 | |
8675 | 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 | |
9360 | 37 NMRequest *nm_create_request(const char *cmd, int trans_id, int gmt, nm_response_cb cb, |
38 gpointer resp_data, gpointer user_define) | |
8675 | 39 { |
40 NMRequest *req; | |
41 | |
42 if (cmd == NULL) | |
43 return NULL; | |
44 | |
45 req = g_new0(NMRequest, 1); | |
46 req->cmd = g_strdup(cmd); | |
47 req->trans_id = trans_id; | |
48 req->gmt = gmt; | |
9360 | 49 req->callback = cb; |
50 req->data = resp_data; | |
51 req->user_define = user_define; | |
8675 | 52 req->ref_count = 1; |
53 | |
9360 | 54 gaim_debug_info("novell", "Creating NMRequest instance, total=%d\n", ++count); |
55 | |
8675 | 56 return req; |
57 } | |
58 | |
59 void | |
60 nm_release_request(NMRequest * req) | |
61 { | |
62 if (req && (--req->ref_count == 0)) { | |
63 if (req->cmd) | |
64 g_free(req->cmd); | |
65 g_free(req); | |
9360 | 66 |
67 gaim_debug_info("novell", | |
68 "Releasing NMRequest instance, total=%d\n", --count); | |
8675 | 69 } |
9360 | 70 |
8675 | 71 } |
72 | |
73 void | |
74 nm_request_add_ref(NMRequest * req) | |
75 { | |
76 if (req) | |
77 req->ref_count++; | |
78 } | |
79 | |
80 void | |
81 nm_request_set_callback(NMRequest * req, nm_response_cb callback) | |
82 { | |
83 if (req) | |
84 req->callback = callback; | |
85 } | |
86 | |
87 void | |
88 nm_request_set_data(NMRequest * req, gpointer data) | |
89 { | |
90 if (req) | |
91 req->data = data; | |
92 } | |
93 | |
94 void | |
95 nm_request_set_user_define(NMRequest * req, gpointer user_define) | |
96 { | |
97 if (req) | |
98 req->user_define = user_define; | |
99 } | |
100 | |
101 int | |
102 nm_request_get_trans_id(NMRequest * req) | |
103 { | |
104 if (req) | |
105 return req->trans_id; | |
106 else | |
107 return -1; | |
108 } | |
109 | |
110 const char * | |
111 nm_request_get_cmd(NMRequest * req) | |
112 { | |
113 if (req == NULL) | |
114 return NULL; | |
115 | |
116 return req->cmd; | |
117 } | |
118 | |
119 gpointer | |
120 nm_request_get_data(NMRequest * req) | |
121 { | |
122 if (req == NULL) | |
123 return NULL; | |
124 | |
125 return req->data; | |
126 } | |
127 | |
128 gpointer | |
129 nm_request_get_user_define(NMRequest * req) | |
130 { | |
131 if (req == NULL) | |
132 return NULL; | |
133 | |
134 return req->user_define; | |
135 } | |
136 | |
137 nm_response_cb | |
138 nm_request_get_callback(NMRequest * req) | |
139 { | |
140 if (req == NULL) | |
141 return NULL; | |
142 | |
143 return req->callback; | |
144 } | |
145 | |
146 | |
147 void | |
148 nm_request_set_ret_code(NMRequest * req, NMERR_T rc) | |
149 { | |
150 if (req) | |
151 req->ret_code = rc; | |
152 } | |
153 | |
154 NMERR_T | |
155 nm_request_get_ret_code(NMRequest * req) | |
156 { | |
157 if (req) | |
158 return req->ret_code; | |
159 else | |
160 return (NMERR_T) - 1; | |
161 } |