|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 // ConnectionImpl.h: interface for the CConnectionImpl class. |
|
18 // |
|
19 ////////////////////////////////////////////////////////////////////// |
|
20 |
|
21 #if !defined(AFX_CONNECTIONIMPL_H__1D0D5B50_3DDD_49B8_834B_5996D9CC0124__INCLUDED_) |
|
22 #define AFX_CONNECTIONIMPL_H__1D0D5B50_3DDD_49B8_834B_5996D9CC0124__INCLUDED_ |
|
23 |
|
24 #if _MSC_VER > 1000 |
|
25 #pragma once |
|
26 #endif // _MSC_VER > 1000 |
|
27 |
|
28 #include "Connection.h" |
|
29 |
|
30 class CConnectionImpl : public CConnection |
|
31 { |
|
32 public: |
|
33 CConnectionImpl(); |
|
34 CConnectionImpl(ConnectData conData, DWORD connectionId); |
|
35 virtual ~CConnectionImpl(); |
|
36 |
|
37 BOOL IsEqual(CConnection* connection); |
|
38 BOOL IsEqual(pConnectData pConData); |
|
39 |
|
40 BOOL AddClient(CClient* client); // add a client to this connection |
|
41 BOOL RemoveClient(CClient* client); // remove a client from this connection |
|
42 BOOL AddClientToRegistry(CClient* client, long numberIds, BYTE* ids); |
|
43 BOOL RemoveClientFromRegistry(CClient* client); // remove a client from this registry |
|
44 BOOL StartClient(CClient* client){ return TRUE; } // start processing for a specified client |
|
45 BOOL StopClient(CClient* client){ return TRUE; } // stop processing for a specified client |
|
46 long DoConnect(); |
|
47 long DoDisconnect(); |
|
48 long DoSendMessage(long encodeOption, BYTE protocolVersion, BOOL useMsgId, BYTE msgId, DWORD msgLength, BYTE* msg); |
|
49 long DoRetryProcessing(); |
|
50 long EnterRetryPeriod(long err, bool passOsErr, DWORD osErr); |
|
51 |
|
52 BOOL PauseProcessing(); // pause processing thread (not exit) |
|
53 BOOL RestartProcessing(); // restart processing after a pause |
|
54 BOOL StartProcessing(); // start processing thread |
|
55 BOOL ExitProcessing(); // exit processing thread |
|
56 BOOL IsProcessingPaused() { return (m_MessageProcessorState == MP_PAUSE); } |
|
57 BOOL IsProcessingStarted() { return (m_MessageProcessorState == MP_START); } |
|
58 BOOL IsProcessingContinuing() { return (m_MessageProcessorState == MP_PROCESSING); } |
|
59 |
|
60 long GetConnectionId() { return m_ConnectionID; } |
|
61 |
|
62 // m_Status operations |
|
63 BOOL IsConnected() { return ((m_Status == eConnected) || (m_Status == eRetryInProgress)); } |
|
64 BOOL IsDisconnected() { return (m_Status == eDisconnected); } |
|
65 BOOL IsRetryInProgress() { return (m_Status== eRetryInProgress); } |
|
66 BOOL IsRetryTimedOut() { return (m_Status == eRetryTimedOut); } |
|
67 void SetConnected() { m_Status = eConnected; } |
|
68 void SetDisconnected() { m_Status = eDisconnected; } |
|
69 void SetRetryInProgress() { m_Status = eRetryInProgress; } |
|
70 void SetRetryTimedOut() { m_Status = eRetryTimedOut; } |
|
71 void NotifyClientsCommError(long tcfError, bool passOsError=false, DWORD osError=0); |
|
72 BOOL CreateCommProtocols(const char* commLibraryPath, const char* protocolLibraryPath); |
|
73 BOOL HasVersion(); |
|
74 void GetVersion(char* outVersion); |
|
75 |
|
76 long GetNumberClients() { return m_ClientList->size(); } |
|
77 |
|
78 void UnLockAllDestinations(); |
|
79 void FlushAllClientMessageFiles(); |
|
80 |
|
81 ConnectData* m_ConnectSettings; // connection settings |
|
82 ClientList* m_ClientList; // this connection only |
|
83 eConnectionStatus m_Status; // this connection status |
|
84 CRegistry* m_Registry; // registry for this connection |
|
85 long m_ConnectionID; // id for this connection |
|
86 |
|
87 CBaseCom* m_BaseComm; // communication port handler |
|
88 HINSTANCE m_BaseCommHandle; |
|
89 CBaseProtocol* m_BaseProtocol; // protocol for port |
|
90 HINSTANCE m_BaseProtocolHandle; |
|
91 |
|
92 unsigned long m_OsError; // error from OS if applicable |
|
93 |
|
94 |
|
95 char m_DebugLogMsg[2000]; |
|
96 TCDebugLog* m_DebugLog; |
|
97 char m_DebugLogMsg2[2000]; |
|
98 TCDebugLog* m_DebugLog2; |
|
99 |
|
100 // MessageProcessor thread |
|
101 static DWORD WINAPI MessageProcessor(LPVOID lpParam); |
|
102 |
|
103 int m_MessageProcessorState; |
|
104 bool m_ExitMessageProcessor; // flag to tell MessageProcessor thread to exit |
|
105 bool m_PauseMessageProcessing; // flag to tell MessageProcessor thread to stop all message processing (temporarily) |
|
106 bool m_StartMessageProcessing; // flag to tell MessageProcessor thread to start message processing |
|
107 HANDLE m_hMessageProcessorExittedEvent; // event to tell main thread that MessageProcessor thread has exitted |
|
108 HANDLE m_hMessageProcessorStoppedEvent; // event to tell main thread that MessageProcessor thread has stopped processing |
|
109 HANDLE m_hMessageProcessorStartedEvent; // event to tell main thread that MessageProcessor thread has started processing |
|
110 |
|
111 HANDLE m_hMessageProcessorThread; // handle to MessageProcessor thread |
|
112 DWORD m_dwMessageProcessorThreadId; // ID for " " |
|
113 |
|
114 // com errors and retry stuff |
|
115 time_t m_NextRetryTime; |
|
116 time_t m_RetryTimeoutTime; |
|
117 |
|
118 // client flush times |
|
119 DWORD m_NextFlushFileTime; |
|
120 |
|
121 }; |
|
122 |
|
123 #endif // !defined(AFX_CONNECTIONIMPL_H__1D0D5B50_3DDD_49B8_834B_5996D9CC0124__INCLUDED_) |