00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef __THREADSERVER_H__
00032 #define __THREADSERVER_H__
00033 
00034 #include <e32base.h>
00035 #include <e32std.h>
00036 #include "shutdownserver.h"
00037 #include "threadclientserver.h"
00038 #include "threadserverstart.h"
00039 #include "driver1.h"
00040 
00041 class CAsyncHandler; 
00042 
00046 class CThreadServer : public CServer2
00047         {
00048 public:
00052         enum TDriverState
00053                 {
00054                 EStateUnknown,
00055                 EDriverLoaded,
00056                 ELogicalChannelOpened,
00057                 ESendingData,
00058                 ELogicalChannelClosed,
00059                 EDriverUnloaded
00060                 };
00064         IMPORT_C static TInt StartThread(TAny* aPointer);
00068         static void NewLC();
00073         ~CThreadServer();
00078         CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
00083         void IncrementRefCount();
00088         void DecrementRefCount();
00092         TInt LoadDevice();
00096         TInt UnloadDevice();
00100         TInt OpenLogicalChannel();
00104         void CloseLogicalChannel();
00108         TInt SendDataToDevice(TRequestStatus& aStatus, const TDesC8& aData);
00112         void CancelSendData();
00116         void UpdateDriverState(TDriverState aState);
00117         
00118         
00119 private:
00120         CThreadServer();
00121         void ConstructL();
00122         
00123         static void StartThreadL();
00124         static void RenameServer();
00125 private:
00126         TInt                                    iRefCount;
00127         CDelayServerShutDown*   iDelayThreadServerShutDown;
00128         RDriver1                                iDriver;
00129         TDriverState                    iDriverState;
00130         };
00131         
00132 
00133 
00134 #endif