Tue, 19 May 2020 10:29:23 +0000
Merged in default (pull request #697)
simple: Fix search for message headers
Approved-by: Gary Kramlich
| 8675 | 1 | /* |
| 2 | * nmconn.h | |
| 3 | * | |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
4 | * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
5 | * |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
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:
8874
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:
8874
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:
8874
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:
8874
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
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:
8874
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:
8874
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15435
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8675 | 18 | * |
| 19 | */ | |
| 20 | ||
|
39819
3554dac2991b
Standardize all protocol header guard macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
21 | #ifndef PURPLE_NOVELL_NMCONN_H |
|
3554dac2991b
Standardize all protocol header guard macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
22 | #define PURPLE_NOVELL_NMCONN_H |
| 8675 | 23 | |
|
40118
621987e8e765
Convert novell to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40099
diff
changeset
|
24 | #include <gio/gio.h> |
|
621987e8e765
Convert novell to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40099
diff
changeset
|
25 | |
| 8675 | 26 | typedef struct _NMConn NMConn; |
| 27 | ||
| 28 | #include "nmfield.h" | |
| 29 | #include "nmuser.h" | |
| 30 | ||
| 31 | typedef int (*nm_ssl_read_cb) (gpointer ssl_data, void *buff, int len); | |
| 32 | typedef int (*nm_ssl_write_cb) (gpointer ssl_data, const void *buff, int len); | |
| 33 | ||
| 34 | struct _NMConn | |
| 35 | { | |
| 36 | ||
| 37 | /* The address of the server that we are connecting to. */ | |
| 38 | char *addr; | |
| 39 | ||
| 40 | /* The port that we are connecting to. */ | |
| 41 | int port; | |
| 42 | ||
| 43 | /* The transaction counter. */ | |
| 44 | int trans_id; | |
| 45 | ||
| 46 | /* A list of requests currently awaiting a response. */ | |
| 47 | GSList *requests; | |
| 48 | ||
|
40118
621987e8e765
Convert novell to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40099
diff
changeset
|
49 | /* Connections to server. */ |
|
621987e8e765
Convert novell to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40099
diff
changeset
|
50 | GSocketClient *client; |
|
621987e8e765
Convert novell to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40099
diff
changeset
|
51 | GIOStream *stream; |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
52 | GDataInputStream *input; |
|
40118
621987e8e765
Convert novell to GIO.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40099
diff
changeset
|
53 | GOutputStream *output; |
| 8675 | 54 | }; |
| 55 | ||
| 56 | /** | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
57 | * Allocate a new NMConn struct |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
58 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
59 | * @param The address of the server that we are connecting to. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
60 | * @param The port that we are connecting to. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
61 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
62 | * @return A pointer to a newly allocated NMConn struct, should |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
63 | * be freed by calling nm_release_conn() |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
64 | */ |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
65 | NMConn *nm_create_conn(const char *addr, int port); |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
66 | |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
67 | /** |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
68 | * Release an NMConn |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
69 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
70 | * @param Pointer to the NMConn to release. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
71 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
72 | */ |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
73 | void nm_release_conn(NMConn *conn); |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
74 | |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
75 | /** |
| 8675 | 76 | * Dispatch a request to the server. |
| 77 | * | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
78 | * @param user The logged-in user. |
| 8675 | 79 | * @param cmd The request to dispatch. |
| 80 | * @param fields The field list for the request. | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
81 | * @param cb The response callback for the new request object. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
82 | * @param data The user defined data for the request (to be passed to the resp cb). |
| 8675 | 83 | * @param req The request. Should be freed with nm_release_request. |
| 84 | * | |
| 85 | * @return NM_OK on success. | |
| 86 | */ | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
87 | NMERR_T |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
88 | nm_send_request(NMUser *user, char *cmd, NMField *fields, nm_response_cb cb, |
|
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
89 | gpointer data, NMRequest **request); |
| 8675 | 90 | |
| 91 | /** | |
| 92 | * Write out the given field list. | |
| 93 | * | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
94 | * @param user The logged-in user. |
| 8675 | 95 | * @param fields The field list to write. |
| 96 | * | |
| 97 | * @return NM_OK on success. | |
| 98 | */ | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
99 | NMERR_T nm_write_fields(NMUser *user, NMField *fields); |
| 8675 | 100 | |
| 101 | /** | |
| 102 | * Read the headers for a response. | |
| 103 | * | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
104 | * @param user The logged-in user. |
| 8675 | 105 | * |
| 106 | * @return NM_OK on success. | |
| 107 | */ | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
108 | NMERR_T nm_read_header(NMUser *user); |
| 8675 | 109 | |
| 110 | /** | |
| 111 | * Read a field list from the connection. | |
| 112 | * | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
113 | * @param user The logged-in user. |
| 8675 | 114 | * @param count The maximum number of fields to read (or -1 for no max). |
| 115 | * @param fields The field list. This is an out param. It | |
| 116 | * should be freed by calling nm_free_fields | |
| 117 | * when finished. | |
| 118 | * | |
| 119 | * @return NM_OK on success. | |
| 120 | */ | |
|
40119
2e1969768857
novell: Replace socket wrappers with GIO functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40118
diff
changeset
|
121 | NMERR_T nm_read_fields(NMUser *user, int count, NMField **fields); |
| 8675 | 122 | |
| 123 | /** | |
| 124 | * Add a request to the connections request list. | |
| 125 | * | |
| 126 | * @param conn The connection. | |
| 127 | * @param request The request to add to the list. | |
| 128 | */ | |
| 129 | void nm_conn_add_request_item(NMConn * conn, NMRequest * request); | |
| 130 | ||
| 131 | /** | |
| 132 | * Remove a request from the connections list. | |
| 133 | * | |
| 134 | * @param conn The connection. | |
| 135 | * @param request The request to remove from the list. | |
| 136 | */ | |
| 137 | void nm_conn_remove_request_item(NMConn * conn, NMRequest * request); | |
| 138 | ||
| 139 | /** | |
| 140 | * Find the request with the given transaction id in the connections | |
| 141 | * request list. | |
| 142 | * | |
| 143 | * @param conn The connection. | |
| 144 | * @param trans_id The transaction id of the request to return. | |
| 145 | * | |
| 146 | * @return The request, or NULL if a matching request is not | |
| 147 | * found. | |
| 148 | */ | |
| 149 | NMRequest *nm_conn_find_request(NMConn * conn, int trans_id); | |
| 150 | ||
|
39819
3554dac2991b
Standardize all protocol header guard macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
19859
diff
changeset
|
151 | #endif /* PURPLE_NOVELL_NMCONN_H */ |