connectivity/com.nokia.tcf/native/TCFNative/TCFClient/ClientManager.h
changeset 60 9d2210c8eed2
child 914 46f36a149510
equal deleted inserted replaced
59:c892c53c664e 60:9d2210c8eed2
       
     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 // ClientManager.h: interface for the CClientManager class.
       
    18 //
       
    19 //////////////////////////////////////////////////////////////////////
       
    20 
       
    21 #if !defined(AFX_CLIENTMANAGER_H__D8CD8281_5D57_43E9_922D_9532DC8669C4__INCLUDED_)
       
    22 #define AFX_CLIENTMANAGER_H__D8CD8281_5D57_43E9_922D_9532DC8669C4__INCLUDED_
       
    23 
       
    24 #if _MSC_VER > 1000
       
    25 #pragma once
       
    26 #endif // _MSC_VER > 1000
       
    27 #include <vector>
       
    28 #include <list>
       
    29 #include "ServerClient.h"
       
    30 #include "InputStream.h"
       
    31 #include "ErrorMonitorData.h"
       
    32 #include "TCErrorConstants.h"
       
    33 #include "TCDebugLog.h"
       
    34 
       
    35 typedef std::vector<CInputStream*> InputStreamList;
       
    36 typedef std::vector<CErrorMonitor*> ErrorMonitorList;
       
    37 //typedef std::vector<CInputStream> InputStreamList;
       
    38 
       
    39 #define ERRORMONITORLIST_MUTEX_BASENAME		"TCFErrorMonitorList"
       
    40 #define ERRORMONITORLIST_MUTEX_TIMEOUT		(60000L)
       
    41 #define INPUTSTREAMLIST_MUTEX_BASENAME		"TCFInputStreamList"
       
    42 #define INPUTSTREAMLIST_MUTEX_TIMEOUT		(60000L)
       
    43 
       
    44 #ifdef WIN32
       
    45 #define SERVER_PROCESS_NAME		"TCFServer.exe"
       
    46 #define SERVER_LOCKFILE_NAME	"TCFServer.lock"
       
    47 #define PATH_DELIMITER			'\\'
       
    48 #else
       
    49 #error not WIN32
       
    50 #endif
       
    51 
       
    52 #define MAX_DLLPATHNAME (2048)
       
    53 
       
    54 class CClientManager  
       
    55 {
       
    56 public:
       
    57 	CClientManager();
       
    58 	CClientManager(HINSTANCE hinstDLL);
       
    59 	virtual ~CClientManager();
       
    60 
       
    61 	// starting/stopping server
       
    62 	BOOL StartServer(pServerProcessData pData);
       
    63 	BOOL StopServer(pServerProcessData pData);
       
    64 	long StartServer();
       
    65 	long StopServer();
       
    66 	BOOL IsServerRunning(); // { return m_ServerRunning; }
       
    67 	BOOL m_ServerRunning;
       
    68 	void TerminateServerThroughLockFile(pServerProcessData pData);
       
    69 	void CreateLockFile(DWORD processId);
       
    70 	void AppendToLockFile(DWORD processId);
       
    71 	void DeleteLockFile();
       
    72 	void DeleteFromLockFile(DWORD processId);
       
    73 
       
    74 	// input stream
       
    75 	CInputStream* FindInputStream(long inClientId);
       
    76 	long InputStreamListSize();
       
    77 	void RemoveInputStream(CInputStream* inputStream);
       
    78 	void AddInputStream(CInputStream* stream);
       
    79 	BOOL WaitForStreamListAccess() { return m_StreamListMutex.Wait(); }
       
    80 	BOOL ReleaseStreamListAccess() { return m_StreamListMutex.Release(); }
       
    81 	Mutex m_StreamListMutex;
       
    82 
       
    83 	// error monitors
       
    84 	CErrorMonitor* FindErrorMonitor(long inClientId);
       
    85 	long ErrorMonitorListSize();
       
    86 	void RemoveErrorMonitor(CErrorMonitor* errorMonitor);
       
    87 	void AddErrorMonitor(CErrorMonitor* monitor);
       
    88 	BOOL WaitForErrorMonitorListAccess() { return m_ErrorMonitorListMutex.Wait(); }
       
    89 	BOOL ReleaseErrorMonitorListAccess() { return m_ErrorMonitorListMutex.Release(); }
       
    90 	Mutex m_ErrorMonitorListMutex;
       
    91 
       
    92 	CServerCommand* m_Server;
       
    93 	TCDebugLog* m_DebugLog;
       
    94 	InputStreamList* m_StreamList;
       
    95 	ErrorMonitorList* m_ErrorMonitorList;
       
    96 	char* m_DllLocation;
       
    97 	HANDLE m_hServer;			// our handle to the server process (per process)
       
    98 	HANDLE m_hServerThread;		// handle to server main thread (creator process only)
       
    99 	char m_Version[MAX_VERSION_STRING]; // our version string
       
   100 
       
   101 	char* m_ServerLockFile; // TCFServer lock file name at the DLL location
       
   102 	char* m_ServerExeFile;	// TCFServer exe
       
   103 
       
   104 };
       
   105 
       
   106 #endif // !defined(AFX_CLIENTMANAGER_H__D8CD8281_5D57_43E9_922D_9532DC8669C4__INCLUDED_)