libsyncml 0.5.4

- Main Page
- Modules
- Data Structures
- Files

- File List

sml_transport_internals.h
1 /*
2 * libsyncml - A syncml protocol implementation
3 * Copyright (C) 2005 Armin Bauer <armin.bauer@opensync.org>
4 * Copyright (C) 2007-2008 Michael Bell <michael.bell@opensync.org>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22 #ifndef _SML_TRANSPORT_INTERNALS_H_
23 #define _SML_TRANSPORT_INTERNALS_H_
24
25 #include "sml_queue_internals.h"
26
27 typedef SmlBool (* SmlTransportSetConfigOptionFn) (SmlTransport *tsp, const char *name, const char *value, SmlError **error);
28 typedef SmlBool (* SmlTransportSetConnectionTypeFn) (SmlTransport *tsp, SmlTransportConnectionType type, SmlError **error);
29 typedef SmlBool (* SmlTransportInitializeFn) (SmlTransport *tsp, SmlError **error);
30
31 /* This function is used for transport clients
32 * to support redirects from the server.
33 * Example: Funambol works with such redirects
34 * because of Tomcat's session management.
35 */
36 typedef SmlBool (* SmlTransportSetResponseUriFn) (SmlTransport *tsp, const char *uri, SmlError **error);
37
38 /* This function is used to add some kind of session id
39 * to the URL of the server. This is necessary to
40 * avoid session hijacking.
41 */
42 typedef char * (* SmlTransportGetResponseUriFn) (SmlLink *link, SmlSession *session, SmlError **error);
43
44 typedef SmlBool (* SmlTransportFinalizeFn) (void *data, SmlError **error);
45
46 typedef void (* SmlTransportConnectFn) (void *data);
47 typedef void (* SmlTransportDisconnectFn) (void *data, void *link_data);
48 typedef void (* SmlTransportSendFn) (void *userdata, void *link_data, SmlTransportData *data, SmlError *error);
49
50 typedef struct SmlTransportFunctions {
51 SmlTransportSetConfigOptionFn set_config_option;
52 SmlTransportSetConnectionTypeFn set_connection_type;
53 SmlTransportInitializeFn initialize;
54 SmlTransportSetResponseUriFn set_response_uri;
55 SmlTransportGetResponseUriFn get_response_uri;
56 SmlTransportFinalizeFn finalize;
57 SmlTransportConnectFn connect;
58 SmlTransportDisconnectFn disconnect;
59 SmlTransportSendFn send;
60 } SmlTransportFunctions;
61
62 typedef enum SmlTransportState {
63 SML_TRANSPORT_UNINITIALIZED,
64 SML_TRANSPORT_INITIALIZED,
65 SML_TRANSPORT_CONNECTED,
66 SML_TRANSPORT_ERROR
67 } SmlTransportState;
68
69 struct SmlTransport {
70 GMainContext *context;
71 SmlThread *thread;
72
73 SmlTransportState state;
74
75 SmlTransportType type;
76 SmlTransportFunctions functions;
77 void *transport_data;
78
79 SmlQueue *command_queue;
80 SmlTransportEventCb event_callback;
81 void *event_callback_userdata;
82 gint event_callback_ref_count;
83 SmlError *cached_error;
84
85 SmlBool connected;
86 GHashTable *links;
87 GMutex *links_mutex;
88 unsigned int connections;
89 GMutex *connections_mutex;
90 };
91
92 struct SmlLink {
93 SmlTransport *tsp;
94 void *link_data;
95 gint32 refCount;
96 };
97
98 typedef enum SmlTransportCommandType {
99 SML_TRANSPORT_CMD_SEND,
100 SML_TRANSPORT_CMD_CONNECT,
101 SML_TRANSPORT_CMD_DISCONNECT
102 } SmlTransportCommandType;
103
104 typedef struct SmlTransportCommand {
105 SmlTransportCommandType type;
106 SmlTransportData *data;
107 const void *config;
108 SmlLink *link;
109 SmlError *error;
110 } SmlTransportCommand;
111
112 struct SmlTransportData {
113 char *data;
114 unsigned long size;
115 SmlMimeType type;
116 SmlBool ownsData;
117 gint32 refCount;
121 SmlBool needsAnswer;
132 SmlMimeType type_get;
133 };
134
135 void smlTransportWorkerHandler(void *message, void *userdata);
136 SmlBool smlTransportReceiveEvent(SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, SmlError *error);
137
138 SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, SmlError **error);
139 char *smlTransportGetResponseURI(SmlLink *link, SmlSession *session, SmlError **error);
140
141 #endif //_SML_TRANSPORT_INTERNALS_H_