Mercurial > pidgin
annotate src/protocols/novell/nmrequest.c @ 9125:668ffb8fec00
[gaim-migrate @ 9902]
(12:53:05) nosnilmot: LSchiere: not majorly important, but the pref changes
listed in the ChangeLog are out of sync
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sun, 30 May 2004 16:54:40 +0000 |
| parents | 6663ad2386d9 |
| children | d77537e8bfe5 |
| 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 | |
| 23 struct _NMRequest | |
| 24 { | |
| 25 int trans_id; | |
| 26 char *cmd; | |
| 27 int gmt; | |
| 28 gpointer data; | |
| 29 gpointer user_define; | |
| 30 nm_response_cb callback; | |
| 31 int ref_count; | |
| 32 NMERR_T ret_code; | |
| 33 }; | |
| 34 | |
| 35 | |
| 36 NMRequest * | |
| 37 nm_create_request(const char *cmd, int trans_id, int gmt) | |
| 38 { | |
| 39 NMRequest *req; | |
| 40 | |
| 41 if (cmd == NULL) | |
| 42 return NULL; | |
| 43 | |
| 44 req = g_new0(NMRequest, 1); | |
| 45 req->cmd = g_strdup(cmd); | |
| 46 req->trans_id = trans_id; | |
| 47 req->gmt = gmt; | |
| 48 req->ref_count = 1; | |
| 49 | |
| 50 return req; | |
| 51 } | |
| 52 | |
| 53 void | |
| 54 nm_release_request(NMRequest * req) | |
| 55 { | |
| 56 if (req && (--req->ref_count == 0)) { | |
| 57 if (req->cmd) | |
| 58 g_free(req->cmd); | |
| 59 g_free(req); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 void | |
| 64 nm_request_add_ref(NMRequest * req) | |
| 65 { | |
| 66 if (req) | |
| 67 req->ref_count++; | |
| 68 } | |
| 69 | |
| 70 void | |
| 71 nm_request_set_callback(NMRequest * req, nm_response_cb callback) | |
| 72 { | |
| 73 if (req) | |
| 74 req->callback = callback; | |
| 75 } | |
| 76 | |
| 77 void | |
| 78 nm_request_set_data(NMRequest * req, gpointer data) | |
| 79 { | |
| 80 if (req) | |
| 81 req->data = data; | |
| 82 } | |
| 83 | |
| 84 void | |
| 85 nm_request_set_user_define(NMRequest * req, gpointer user_define) | |
| 86 { | |
| 87 if (req) | |
| 88 req->user_define = user_define; | |
| 89 } | |
| 90 | |
| 91 int | |
| 92 nm_request_get_trans_id(NMRequest * req) | |
| 93 { | |
| 94 if (req) | |
| 95 return req->trans_id; | |
| 96 else | |
| 97 return -1; | |
| 98 } | |
| 99 | |
| 100 const char * | |
| 101 nm_request_get_cmd(NMRequest * req) | |
| 102 { | |
| 103 if (req == NULL) | |
| 104 return NULL; | |
| 105 | |
| 106 return req->cmd; | |
| 107 } | |
| 108 | |
| 109 gpointer | |
| 110 nm_request_get_data(NMRequest * req) | |
| 111 { | |
| 112 if (req == NULL) | |
| 113 return NULL; | |
| 114 | |
| 115 return req->data; | |
| 116 } | |
| 117 | |
| 118 gpointer | |
| 119 nm_request_get_user_define(NMRequest * req) | |
| 120 { | |
| 121 if (req == NULL) | |
| 122 return NULL; | |
| 123 | |
| 124 return req->user_define; | |
| 125 } | |
| 126 | |
| 127 nm_response_cb | |
| 128 nm_request_get_callback(NMRequest * req) | |
| 129 { | |
| 130 if (req == NULL) | |
| 131 return NULL; | |
| 132 | |
| 133 return req->callback; | |
| 134 } | |
| 135 | |
| 136 | |
| 137 void | |
| 138 nm_request_set_ret_code(NMRequest * req, NMERR_T rc) | |
| 139 { | |
| 140 if (req) | |
| 141 req->ret_code = rc; | |
| 142 } | |
| 143 | |
| 144 NMERR_T | |
| 145 nm_request_get_ret_code(NMRequest * req) | |
| 146 { | |
| 147 if (req) | |
| 148 return req->ret_code; | |
| 149 else | |
| 150 return (NMERR_T) - 1; | |
| 151 } |
