Main Page | Modules | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

exgmgrd.h

Go to the documentation of this file.
00001 /********************************************************************
00002 
00003 Copyright 2006, ACCESS Systems Americas, Inc. All rights reserved.
00004 
00005 The contents of this file are subject to the Mozilla Public License Version
00006 1.1 (the "License"); you may not use this file except in compliance with
00007 the License. You may obtain a copy of the License at
00008 http://www.mozilla.org/MPL/
00009 
00010 Software distributed under the License is distributed on an "AS IS" basis,
00011 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012 for the specific language governing rights and limitations under the
00013 License.
00014 
00015 The Original Code is the entire contents of this file.
00016 
00017 The Initial Developer of the Original Code is ACCESS Systems Americas, Inc.
00018 
00019 Portions created by ACCESS Systems Americas, Inc. are Copyright © 2006. All
00020 Rights Reserved.
00021 
00022 Contributor(s): none.
00023 
00024 ********************************************************************/
00030 #ifndef EXGMGRD_H_
00031 #define EXGMGRD_H_
00032 
00033 #include "exgtransport.h"
00034 #include <hiker/prv/exgmgr_prv.h>
00035 #include <hiker/bundlemgr.h>
00036 
00037 // Different ways a handler can be invoked
00038 #define ALP_EXG_DAEMON_HANDLER_INVOKE_BY_BUNDLE 1
00039 #define ALP_EXG_DAEMON_HANDLER_INVOKE_BY_NOTIFICATION 2
00040 
00041 // AlpExgMgrdHandlerInfoType contains the info about one handler.
00042 typedef struct _AlpExgMgrdHandlerInfoType AlpExgMgrdHandlerInfoType;
00043 struct _AlpExgMgrdHandlerInfoType {
00044         char *itsVerb;
00045         char *itsLocalizedVerb;
00046         char *itsMIMEType;
00047         int itsInvokeType;              // launch package or invoke notification
00048         union
00049         {
00050                 struct _byBundle
00051                 {
00052                         char *itsBundleName;
00053                 } byBundle;
00054                 
00055                 struct _byNotification
00056                 {
00057                         char *itsNotificationType;
00058                 } byNotification;
00059         } params;
00060         int itsLocalOnly;
00061         int itsSerializeMe;
00062         int itsMustBeUnique;
00063         int itsAcceptGenericInvocation;
00064         AlpExgMgrdHandlerInfoType *itsNext;
00065         AlpExgMgrdHandlerInfoType *itsPrev;     // not sure I need to double link...
00066 };
00067 
00068 // AlpExgMgrdTransportInfoType contains info about each open transport.
00069 typedef struct _AlpExgMgrdTransportInfoType AlpExgMgrdTransportInfoType;
00070 struct _AlpExgMgrdTransportInfoType {
00071         AlpBundleRef itsBundleRef;
00072         gchar *itsNameId;               // internal name, non localizable, as used in the transport params
00073         void *itsLibRef;
00074         int itsInited;  // 1 when itsTransportInitFunc has been called successfully 
00075         alp_exg_transport_init_func itsTransportInitFunc;
00076         alp_exg_transport_deinit_func itsTransportDeinitFunc;
00077         alp_exg_transport_dispatch_result_func itsTransportDispatchResultFunc;
00078         alp_exg_transport_cancel_func itsTransportCancelFunc;
00079 };
00080 
00081 // States used to run the dispatcher
00082 #define ALP_EXG_DAEMON_STATE_WAIT_CXN_MESSAGE 1
00083 #define ALP_EXG_DAEMON_STATE_SEND_FINAL_REPLY_STATUS 2
00084 #define ALP_EXG_DAEMON_STATE_SEND_RCV_REQ_REPLY_STATUS 3
00085 #define ALP_EXG_DAEMON_STATE_SEND_REQUEST_DATA_SIZE 4
00086 #define ALP_EXG_DAEMON_STATE_SEND_REQUEST_DATA 5
00087 #define ALP_EXG_DAEMON_STATE_SEND_REQUEST_FD_PRESENT 6
00088 #define ALP_EXG_DAEMON_STATE_WAIT_HANDLER_REPLY 7
00089 #define ALP_EXG_DAEMON_STATE_WAIT_REQUEST_DATA_SIZE 8
00090 #define ALP_EXG_DAEMON_STATE_WAIT_REQUEST_DATA 9
00091 #define ALP_EXG_DAEMON_STATE_WAIT_REQUEST_FD_PRESENT 10
00092 #define ALP_EXG_DAEMON_STATE_WAIT_REQUEST_FD 11
00093 #define ALP_EXG_DAEMON_STATE_SEND_GENERIC_VERBS_REPLY_STATUS 12
00094 #define ALP_EXG_DAEMON_STATE_SEND_GENERIC_VERBS_SIZE 13
00095 #define ALP_EXG_DAEMON_STATE_SEND_GENERIC_VERBS 14
00096 
00097 // AlpExgMgrdDispatchInfotype contains the info about each incoming
00098 // request waiting to be executed by its handler. Once the handler has connected,
00099 // the entry is removed from the list, and the request and transportId are stored in the connection
00100 typedef struct _AlpExgMgrdDispatchInfoType AlpExgMgrdDispatchInfoType;
00101 struct _AlpExgMgrdDispatchInfoType {
00102         int itsDispatchInProgress;      // 0 = waiting in queue, 1 = handler invoked.
00103         guint itsTimeoutSourceId;       // gsource implementing the handler connection timeout.
00104         AlpExgRequest itsRequest;       // The request we received
00105         int itsTransportId;             // Id of the transport which delivered the request to us
00106         AlpExgMgrdHandlerInfoType *itsLastHandlerInfoP; // not NULL if handler did not require to be unique
00107         char *itsTmpDatafile;           // used to save data between invocation of multiple handlers.
00108         AlpExgMgrdDispatchInfoType *itsNext;
00109         AlpExgMgrdDispatchInfoType *itsPrev;
00110 };
00111 
00112 // The daemon use a list of AlpExgDaemonCxnState entries to manage connections from clients or handlers.
00113 typedef struct _AlpExgDaemonCxnState AlpExgDaemonCxnState;
00114 struct _AlpExgDaemonCxnState {
00115         int isUsed;
00116         GPollFD itsPollFD;
00117         int itsState;
00118         char itsTempBuf[sizeof(AlpExgMgrdMessageOrReplyType)];
00119         size_t itsTempBufUsed;
00120         int itsOpcode;
00121         union
00122         {
00123                 struct _clientCxn       // exgmgr lib client connection
00124                 {
00125                         // nothing more than the initial message is sent for client connections.
00126                 } clientCxn;
00127                 
00128                 struct _handlerCxn      // an invoked handler is now running and has connected to the daemon to receive the request
00129                 {
00130                         AlpExgMgrdDispatchInfoType *itsDispatchInfoP;   // The dispatch info that was associated to this handler
00131                         char *itsInfoP;         // pointer to the request info field. will contain the parameters returned by handler
00132                         size_t itsInfoLen2;
00133                         alp_status_t itsReplyStatus;    // the status returned by the handler and forwarded to the transport.
00134                 } handlerCxn;
00135                 
00136                 struct _queryGenericVerbsCxn    // this connection must return a list of generic verbs
00137                 {
00138                         size_t itsDataSize;             // size of itsData
00139                         char *itsData;  // int entrycount + list of verbs and verb descriptions.
00140                 } queryGenericVerbsCxn;
00141         } params;
00142         
00143 };
00144 
00145 #endif /*EXGMGRD_H_*/

Generated on Sat Dec 16 20:29:47 2006 for hiker-0.9 by  doxygen 1.4.4