00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _SML_TRANSPORT_INTERNALS_H_
00023 #define _SML_TRANSPORT_INTERNALS_H_
00024
00025 #include "sml_queue_internals.h"
00026
00027 typedef SmlBool (* SmlTransportSetConfigOptionFn) (SmlTransport *tsp, const char *name, const char *value, SmlError **error);
00028 typedef SmlBool (* SmlTransportSetConnectionTypeFn) (SmlTransport *tsp, SmlTransportConnectionType type, SmlError **error);
00029 typedef SmlBool (* SmlTransportInitializeFn) (SmlTransport *tsp, SmlError **error);
00030
00031
00032
00033
00034
00035
00036 typedef SmlBool (* SmlTransportSetResponseUriFn) (SmlTransport *tsp, const char *uri, SmlError **error);
00037
00038
00039
00040
00041
00042 typedef char * (* SmlTransportGetResponseUriFn) (SmlLink *link, SmlSession *session, SmlError **error);
00043
00044 typedef SmlBool (* SmlTransportFinalizeFn) (void *data, SmlError **error);
00045
00046 typedef void (* SmlTransportConnectFn) (void *data);
00047 typedef void (* SmlTransportDisconnectFn) (void *data, void *link_data);
00048 typedef void (* SmlTransportSendFn) (void *userdata, void *link_data, SmlTransportData *data, SmlError *error);
00049
00050 typedef struct SmlTransportFunctions {
00051 SmlTransportSetConfigOptionFn set_config_option;
00052 SmlTransportSetConnectionTypeFn set_connection_type;
00053 SmlTransportInitializeFn initialize;
00054 SmlTransportSetResponseUriFn set_response_uri;
00055 SmlTransportGetResponseUriFn get_response_uri;
00056 SmlTransportFinalizeFn finalize;
00057 SmlTransportConnectFn connect;
00058 SmlTransportDisconnectFn disconnect;
00059 SmlTransportSendFn send;
00060 } SmlTransportFunctions;
00061
00062 typedef enum SmlTransportState {
00063 SML_TRANSPORT_UNINITIALIZED,
00064 SML_TRANSPORT_INITIALIZED,
00065 SML_TRANSPORT_CONNECTED,
00066 SML_TRANSPORT_ERROR
00067 } SmlTransportState;
00068
00069 struct SmlTransport {
00070 GMainContext *context;
00071 SmlThread *thread;
00072
00073 SmlTransportState state;
00074
00075 SmlTransportType type;
00076 SmlTransportFunctions functions;
00077 void *transport_data;
00078
00079 SmlQueue *command_queue;
00080 SmlTransportEventCb event_callback;
00081 void *event_callback_userdata;
00082 gint event_callback_ref_count;
00083 SmlError *cached_error;
00084
00085 SmlBool connected;
00086 GHashTable *links;
00087 GMutex *links_mutex;
00088 unsigned int connections;
00089 GMutex *connections_mutex;
00090 };
00091
00092 struct SmlLink {
00093 SmlTransport *tsp;
00094 void *link_data;
00095 gint32 refCount;
00096 };
00097
00098 typedef enum SmlTransportCommandType {
00099 SML_TRANSPORT_CMD_SEND,
00100 SML_TRANSPORT_CMD_CONNECT,
00101 SML_TRANSPORT_CMD_DISCONNECT
00102 } SmlTransportCommandType;
00103
00104 typedef struct SmlTransportCommand {
00105 SmlTransportCommandType type;
00106 SmlTransportData *data;
00107 const void *config;
00108 SmlLink *link;
00109 SmlError *error;
00110 } SmlTransportCommand;
00111
00112 struct SmlTransportData {
00113 char *data;
00114 unsigned long size;
00115 SmlMimeType type;
00116 SmlBool ownsData;
00117 gint32 refCount;
00121 SmlBool needsAnswer;
00132 SmlMimeType type_get;
00133 };
00134
00135 void smlTransportWorkerHandler(void *message, void *userdata);
00136 SmlBool smlTransportReceiveEvent(SmlTransport *tsp, SmlLink *link, SmlTransportEventType type, SmlTransportData *data, SmlError *error);
00137
00138 SmlBool smlTransportSetResponseURI(SmlTransport *tsp, const char *uri, SmlError **error);
00139 char *smlTransportGetResponseURI(SmlLink *link, SmlSession *session, SmlError **error);
00140
00141 #endif //_SML_TRANSPORT_INTERNALS_H_