Wed, 12 Nov 2008 05:14:03 +0000
merge of '77693555855fe9cd3215414f79964dba346cc5fa'
and '19a87e98e5857ad0289f2c760d460f7f1dbbb42d'
| 8675 | 1 | /* |
| 2 | * nmrequest.h | |
| 3 | * | |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
4 | * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
5 | * |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
8 | * the Free Software Foundation; version 2 of the License. |
| 8675 | 9 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
13 | * GNU General Public License for more details. |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
14 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8735
diff
changeset
|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 8675 | 18 | * |
| 19 | */ | |
| 20 | ||
| 21 | #ifndef __NM_REQUEST_H__ | |
| 22 | #define __NM_REQUEST_H__ | |
| 23 | ||
| 24 | typedef struct _NMRequest NMRequest; | |
| 25 | ||
| 26 | #include "nmuser.h" | |
| 27 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
28 | /** |
| 8675 | 29 | * Create a new request object. Object must be release with nm_release_object. |
| 30 | * | |
| 31 | * @param cmd The request command string (e.g. "login") | |
| 32 | * @param trans_id The request transaction id | |
| 33 | * @param gmt The time in seconds that the request was created | |
| 34 | * | |
| 35 | * @return The new request object | |
| 36 | */ | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
37 | NMRequest *nm_create_request(const char *cmd, int trans_id, int gmt, nm_response_cb cb, |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
38 | gpointer resp_data, gpointer user_define); |
| 8675 | 39 | |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
40 | /** |
| 8675 | 41 | * Release a request object. |
| 42 | * | |
| 43 | * @param req The request to release | |
| 44 | */ | |
| 45 | void nm_release_request(NMRequest * req); | |
| 46 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
47 | /** |
| 8675 | 48 | * Add a new reference to this object. This reference must be released by |
| 49 | * a call to nm_release_object. | |
| 50 | * | |
| 51 | * @param req The request object | |
| 52 | */ | |
| 53 | void nm_request_add_ref(NMRequest * req); | |
| 54 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
55 | /** |
| 8675 | 56 | * Set the response callback for this request object. This is the callback |
| 57 | * that will be made when we get a response from the server. | |
| 58 | * | |
| 59 | * @param req The request object | |
| 60 | * @param callback The response callback | |
| 61 | * | |
| 62 | */ | |
| 63 | void nm_request_set_callback(NMRequest * req, nm_response_cb callback); | |
| 64 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
65 | /** |
|
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
66 | * Set the response data. This will be set differently depending on |
| 8675 | 67 | * the request type (for example to nm_send_get_details will set this |
| 68 | * to be the newly create NMUserRecord object). | |
| 69 | * | |
| 70 | * @param req The request object | |
| 71 | * @param data Pointer to some data | |
| 72 | * | |
| 73 | */ | |
| 74 | void nm_request_set_data(NMRequest * req, gpointer data); | |
| 75 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
76 | /** |
| 8675 | 77 | * Set the user defined data. This is the data that the client |
| 78 | * passes to the various nm_send_* functions. We will pass it | |
| 79 | * back when we make the callback. | |
| 80 | * | |
| 81 | * @param req The request object | |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
82 | * @param user_define Pointer to some data |
| 8675 | 83 | * |
| 84 | */ | |
| 85 | void nm_request_set_user_define(NMRequest * req, gpointer user_define); | |
| 86 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
87 | /** |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8684
diff
changeset
|
88 | * Set the return code. This is the return code that we received in |
| 8675 | 89 | * the server response fields. |
| 90 | * | |
| 91 | * @param req The request object | |
| 92 | * @param rc The return code to set | |
| 93 | */ | |
| 94 | void nm_request_set_ret_code(NMRequest * req, NMERR_T rc); | |
| 95 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
96 | /** |
| 8675 | 97 | * Get the transaction id for this request. |
| 98 | * | |
| 99 | * @param req The request object | |
| 100 | * | |
| 101 | * @return The transaction id. | |
| 102 | */ | |
| 103 | int nm_request_get_trans_id(NMRequest * req); | |
| 104 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
105 | /** |
| 8675 | 106 | * Get the command (request type) for this request. |
| 107 | * | |
| 108 | * @param req The request object | |
| 109 | * | |
| 110 | * @return The request cmd | |
| 111 | */ | |
| 112 | const char *nm_request_get_cmd(NMRequest * req); | |
| 113 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
114 | /** |
| 8675 | 115 | * Get the response data for this request |
| 116 | * | |
| 117 | * @param req The request object | |
| 118 | * | |
| 119 | * @return The response data | |
| 120 | */ | |
| 121 | gpointer nm_request_get_data(NMRequest * req); | |
| 122 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
123 | /** |
| 8675 | 124 | * Get the user defined data for this request |
| 125 | * | |
| 126 | * @param req The request object | |
| 127 | * | |
| 128 | * @return The user defined data | |
| 129 | */ | |
| 130 | gpointer nm_request_get_user_define(NMRequest * req); | |
| 131 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
132 | /** |
| 8675 | 133 | * Get the response callback for this request |
| 134 | * | |
| 135 | * @param req The request object | |
| 136 | * | |
| 137 | * @return The response callback | |
| 138 | */ | |
| 139 | nm_response_cb nm_request_get_callback(NMRequest * req); | |
| 140 | ||
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
141 | /** |
| 8675 | 142 | * Get the return code |
| 143 | * | |
| 144 | * @param req The request object | |
| 145 | * | |
| 146 | * @return The return code (from the response fields) | |
| 147 | */ | |
| 148 | NMERR_T nm_request_get_ret_code(NMRequest * req); | |
| 149 | ||
| 150 | #endif |