author | wpaul |
Thu, 09 Sep 2010 16:48:02 -0500 | |
changeset 1979 | 59f66d6a7b33 |
parent 1473 | 6c45b7c9cdac |
permissions | -rw-r--r-- |
60 | 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); |
|
1473
6c45b7c9cdac
Close ports when there is a fatal error allowing OS to free all handles to it. Do not report OSErrors on sending messages as these are confusing.
Chad Peckham <chad.peckham@nokia.com>
parents:
60
diff
changeset
|
51 |
long HandleFatalPortError(long err, bool passOsErr, DWORD osErr); |
60 | 52 |
|
53 |
BOOL PauseProcessing(); // pause processing thread (not exit) |
|
54 |
BOOL RestartProcessing(); // restart processing after a pause |
|
55 |
BOOL StartProcessing(); // start processing thread |
|
56 |
BOOL ExitProcessing(); // exit processing thread |
|
57 |
BOOL IsProcessingPaused() { return (m_MessageProcessorState == MP_PAUSE); } |
|
58 |
BOOL IsProcessingStarted() { return (m_MessageProcessorState == MP_START); } |
|
59 |
BOOL IsProcessingContinuing() { return (m_MessageProcessorState == MP_PROCESSING); } |
|
60 |
||
61 |
long GetConnectionId() { return m_ConnectionID; } |
|
62 |
||
63 |
// m_Status operations |
|
64 |
BOOL IsConnected() { return ((m_Status == eConnected) || (m_Status == eRetryInProgress)); } |
|
65 |
BOOL IsDisconnected() { return (m_Status == eDisconnected); } |
|
66 |
BOOL IsRetryInProgress() { return (m_Status== eRetryInProgress); } |
|
67 |
BOOL IsRetryTimedOut() { return (m_Status == eRetryTimedOut); } |
|
68 |
void SetConnected() { m_Status = eConnected; } |
|
69 |
void SetDisconnected() { m_Status = eDisconnected; } |
|
70 |
void SetRetryInProgress() { m_Status = eRetryInProgress; } |
|
71 |
void SetRetryTimedOut() { m_Status = eRetryTimedOut; } |
|
72 |
void NotifyClientsCommError(long tcfError, bool passOsError=false, DWORD osError=0); |
|
73 |
BOOL CreateCommProtocols(const char* commLibraryPath, const char* protocolLibraryPath); |
|
74 |
BOOL HasVersion(); |
|
75 |
void GetVersion(char* outVersion); |
|
76 |
||
77 |
long GetNumberClients() { return m_ClientList->size(); } |
|
78 |
||
79 |
void UnLockAllDestinations(); |
|
80 |
void FlushAllClientMessageFiles(); |
|
81 |
||
82 |
ConnectData* m_ConnectSettings; // connection settings |
|
83 |
ClientList* m_ClientList; // this connection only |
|
84 |
eConnectionStatus m_Status; // this connection status |
|
85 |
CRegistry* m_Registry; // registry for this connection |
|
86 |
long m_ConnectionID; // id for this connection |
|
87 |
||
88 |
CBaseCom* m_BaseComm; // communication port handler |
|
89 |
HINSTANCE m_BaseCommHandle; |
|
90 |
CBaseProtocol* m_BaseProtocol; // protocol for port |
|
91 |
HINSTANCE m_BaseProtocolHandle; |
|
92 |
||
93 |
unsigned long m_OsError; // error from OS if applicable |
|
94 |
||
95 |
||
96 |
char m_DebugLogMsg[2000]; |
|
97 |
TCDebugLog* m_DebugLog; |
|
98 |
char m_DebugLogMsg2[2000]; |
|
99 |
TCDebugLog* m_DebugLog2; |
|
100 |
||
101 |
// MessageProcessor thread |
|
102 |
static DWORD WINAPI MessageProcessor(LPVOID lpParam); |
|
103 |
||
104 |
int m_MessageProcessorState; |
|
105 |
bool m_ExitMessageProcessor; // flag to tell MessageProcessor thread to exit |
|
106 |
bool m_PauseMessageProcessing; // flag to tell MessageProcessor thread to stop all message processing (temporarily) |
|
107 |
bool m_StartMessageProcessing; // flag to tell MessageProcessor thread to start message processing |
|
108 |
HANDLE m_hMessageProcessorExittedEvent; // event to tell main thread that MessageProcessor thread has exitted |
|
109 |
HANDLE m_hMessageProcessorStoppedEvent; // event to tell main thread that MessageProcessor thread has stopped processing |
|
110 |
HANDLE m_hMessageProcessorStartedEvent; // event to tell main thread that MessageProcessor thread has started processing |
|
111 |
||
112 |
HANDLE m_hMessageProcessorThread; // handle to MessageProcessor thread |
|
113 |
DWORD m_dwMessageProcessorThreadId; // ID for " " |
|
114 |
||
115 |
// com errors and retry stuff |
|
116 |
time_t m_NextRetryTime; |
|
117 |
time_t m_RetryTimeoutTime; |
|
118 |
||
119 |
// client flush times |
|
120 |
DWORD m_NextFlushFileTime; |
|
121 |
||
122 |
}; |
|
123 |
||
124 |
#endif // !defined(AFX_CONNECTIONIMPL_H__1D0D5B50_3DDD_49B8_834B_5996D9CC0124__INCLUDED_) |