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 |
|
|
18 |
#include "stdafx.h"
|
|
19 |
#include "BaseCom.h"
|
|
20 |
|
|
21 |
CBaseCom::CBaseCom()
|
|
22 |
{
|
|
23 |
#ifdef _DEBUG
|
|
24 |
if (gDoLogging)
|
|
25 |
{
|
|
26 |
FILE* f = fopen("c:\\tcf\\basecommlog.txt", "at");
|
|
27 |
fprintf(f, "CBaseCom::CBaseCom() (default constructor)\n");
|
|
28 |
fclose(f);
|
|
29 |
}
|
|
30 |
#endif
|
|
31 |
m_isConnected = false;
|
|
32 |
m_pBuffer = NULL;
|
|
33 |
m_numberBytes = 0;
|
|
34 |
m_ConnectSettings = NULL;
|
|
35 |
m_lastCommError = 0;
|
|
36 |
m_CommDebugLog = NULL;
|
|
37 |
m_ProcDebugLog = NULL;
|
|
38 |
m_connId = -1;
|
|
39 |
m_Protocol = NULL;
|
|
40 |
}
|
|
41 |
|
|
42 |
CBaseCom::CBaseCom(ConnectData* connectSettings, DWORD connectionId, CBaseProtocol* protocol)
|
|
43 |
{
|
|
44 |
#ifdef _DEBUG
|
|
45 |
if (gDoLogging)
|
|
46 |
{
|
|
47 |
FILE* f = fopen("c:\\tcf\\basecommlog.txt", "at");
|
|
48 |
fprintf(f, "connectSettings=%x connectionId=%d, protocol=%x\n", connectSettings, connectionId, protocol);
|
|
49 |
fclose(f);
|
|
50 |
}
|
|
51 |
#endif
|
|
52 |
m_isConnected = false;
|
|
53 |
m_pBuffer = NULL;
|
|
54 |
m_numberBytes = 0;
|
|
55 |
m_ConnectSettings = NULL;
|
|
56 |
m_lastCommError = 0;
|
|
57 |
m_CommDebugLog = NULL;
|
|
58 |
m_ProcDebugLog = NULL;
|
|
59 |
|
|
60 |
m_connId = connectionId;
|
|
61 |
m_Protocol = protocol;
|
|
62 |
|
|
63 |
m_ConnectSettings = new ConnectData();
|
|
64 |
memcpy(m_ConnectSettings, connectSettings, sizeof(ConnectData));
|
|
65 |
|
|
66 |
#if (defined(LOG_COMM) || defined(LOG_PROCCOMM)) && defined(_DEBUG)
|
|
67 |
if (gDoLogging)
|
|
68 |
{
|
|
69 |
m_CommDebugLog = new TCDebugLog("TCF_Comm", connectionId, 2000L);
|
|
70 |
m_ProcDebugLog = new TCDebugLog("TCF_CommP", connectionId, 2000L);
|
|
71 |
}
|
|
72 |
#endif
|
|
73 |
}
|
|
74 |
|
|
75 |
CBaseCom::~CBaseCom()
|
|
76 |
{
|
|
77 |
#ifdef _DEBUG
|
|
78 |
if (gDoLogging)
|
|
79 |
{
|
|
80 |
FILE* f = fopen("c:\\tcf\\basecommlog.txt", "at");
|
|
81 |
fprintf(f, "CBaseCom::~CBaseCom()\n");
|
|
82 |
fclose(f);
|
|
83 |
}
|
|
84 |
#endif
|
|
85 |
if (m_pBuffer)
|
|
86 |
delete[] m_pBuffer;
|
|
87 |
|
|
88 |
if (m_ConnectSettings)
|
|
89 |
delete m_ConnectSettings;
|
|
90 |
|
|
91 |
if (m_CommDebugLog)
|
|
92 |
delete m_CommDebugLog;
|
|
93 |
|
|
94 |
if (m_ProcDebugLog)
|
|
95 |
delete m_ProcDebugLog;
|
|
96 |
}
|