connectivity/com.nokia.tcf/native/TCFNative/TCFCommVirtualSerial/TCFCommVirtualSerial.cpp
author dadubrow
Mon, 15 Feb 2010 13:20:54 -0600
branchRCL_2_4
changeset 954 c018961ec23d
parent 60 9d2210c8eed2
permissions -rw-r--r--
merge commit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     1
/*
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     3
* All rights reserved.
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     4
* This component and the accompanying materials are made available
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     6
* which accompanies this distribution, and is available
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     8
*
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
     9
* Initial Contributors:
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    11
*
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    12
* Contributors:
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    13
*
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    14
* Description: 
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    15
*
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    16
*/
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    17
// TCFCommVirtualSerial.cpp : Defines the entry point for the DLL application.
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    18
//
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    19
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    20
#include "stdafx.h"
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    21
#include <sys/stat.h>
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    22
#include "TCFCommVirtualSerial.h"
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    23
#include "VirtualSerialComm.h"
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    24
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    25
static const char* pCommType="virtualserial";
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    26
static CBaseCom* pCommClass=NULL;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    27
#ifdef _DEBUG
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    28
BOOL gDoLogging = FALSE;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    29
#endif
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    30
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    31
BOOL APIENTRY DllMain( HANDLE hModule, 
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    32
                       DWORD  ul_reason_for_call, 
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    33
                       LPVOID lpReserved
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    34
					 )
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    35
{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    36
    switch (ul_reason_for_call)
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    37
	{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    38
		case DLL_PROCESS_ATTACH:
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    39
			{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    40
#ifdef _DEBUG
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    41
				struct _stat buf;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    42
				char* dirname = "c:\\tcf";
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    43
				int result = _stat(dirname, &buf);
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    44
				if (result == 0) // exists
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    45
				{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    46
					gDoLogging = TRUE;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    47
				}
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    48
				else
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    49
				{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    50
					gDoLogging = FALSE;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    51
				}
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    52
#endif
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    53
			}
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    54
			break;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    55
		case DLL_THREAD_ATTACH:
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    56
		case DLL_THREAD_DETACH:
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    57
		case DLL_PROCESS_DETACH:
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    58
			break;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    59
    }
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    60
    return TRUE;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    61
}
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    62
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    63
// register this connection type
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    64
TCFCOMMVIRTUALSERIAL_API const char* RegisterComm()
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    65
{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    66
	return pCommType;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    67
}
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    68
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    69
// create this connection type
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    70
TCFCOMMVIRTUALSERIAL_API CBaseCom* CreateComm(ConnectData* connectSettings, DWORD connectionId, CBaseProtocol* protocol)
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    71
{
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    72
	pCommClass = new VirtualSerialComm(connectSettings, connectionId, protocol);
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    73
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    74
	return pCommClass;
9d2210c8eed2 Commit changes for 2.1.0
chpeckha
parents:
diff changeset
    75
}