usbmgmt/usbmgrtest/t_ncm/inc/ncmtestconsole.h
branchRCL_3
changeset 16 012cc2ee6408
parent 15 f92a4f87e424
equal deleted inserted replaced
15:f92a4f87e424 16:012cc2ee6408
     1 /*
       
     2 * Copyright (c) 2002-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 "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 /** @file
       
    19  @internalComponent
       
    20  @test
       
    21  */
       
    22 
       
    23 
       
    24 #ifndef NCMTESTCONSOLE_H
       
    25 #define NCMTESTCONSOLE_H
       
    26 
       
    27 #include <usbman.h>
       
    28 #include <e32cons.h>
       
    29 #include <usb/usblogger.h>
       
    30 #include <comms-infras/commsdebugutility.h>
       
    31 #include <in_sock.h>
       
    32 
       
    33 void Panic(TInt aPanic);
       
    34 
       
    35 #ifdef __FLOG_ACTIVE
       
    36 _LIT8(KSubSys, "NCM");
       
    37 _LIT8(KLogComponent, "TEST");
       
    38 #endif
       
    39 
       
    40 
       
    41 class CConsoleBase;
       
    42 class CNcmCommandEngine;
       
    43 class CDeviceWatcher;
       
    44 class CServiceWatcher;
       
    45 class CSharedStateWatcher;
       
    46 
       
    47 _LIT(KUsbNcmConsoleTitle, "NCM Test Console");
       
    48 
       
    49 //Display item index
       
    50 enum TDisplayItemIndex
       
    51 	{	
       
    52 	EUsbServiceStateItem = 0,		
       
    53 	EUsbDeviceStateItem,			
       
    54 	ENcmConnStatusItem,			
       
    55 	ENcmConnIpItem,				
       
    56 	EUplinkConnStatusItem,			
       
    57 	EUplinkConnIpItem,				
       
    58 	ENcmBtPanItem,				
       
    59 	ENcmAgentStateItem,			
       
    60 	EAuthorisationSettingItem,		
       
    61 	ENcmConnectionStateItem,
       
    62 	ELastItem						//not used, just for count
       
    63 	};
       
    64 
       
    65 #define DISPLAY_USB_SERVICE_STATE_LEN	11			//EUsbServiceStateItem
       
    66 #define DISPLAY_USB_DEVICE_STATE_LEN	11			//EUsbDeviceStateItem
       
    67 #define DISPLAY_NCM_CONN_STATE_LEN	16			//ENcmConnStatusItem
       
    68 #define DISPLAY_NCM_CONN_IP_LEN		15			//ENcmConnIpItem
       
    69 #define DISPLAY_UPLINK_CONN_STATE_LEN	16			//EUplinkConnStatusItem
       
    70 #define DISPLAY_UPLINK_CONN_IP_LEN		15			//EUplinkConnIpItem
       
    71 #define DISPLAY_NCM_BTPAN_LEN			10			//ENcmBtPanItem
       
    72 #define DISPLAY_AGENT_STATE_LEN			30			//ENcmAgentStateItem
       
    73 #define DISPLAY_AUTH_SETTING_LEN		15			//EAuthorisationSettingItem
       
    74 #define DISPLAY_NCM_CONNECTION_STATE    16
       
    75 
       
    76 //The SID of Ncm state P&S key used
       
    77 const TUid KC32ExeSid = {0x101F7989};
       
    78 
       
    79 NONSHARABLE_CLASS(CUsbNcmConsoleEvent)
       
    80 /**
       
    81 Event reported by running commands and watcher classes 
       
    82 */
       
    83 	{
       
    84 public:
       
    85 	static CUsbNcmConsoleEvent* NewL();
       
    86 	~CUsbNcmConsoleEvent();
       
    87 private:
       
    88 	CUsbNcmConsoleEvent();
       
    89 	void ConstructL();
       
    90 public:
       
    91 	//Event queue link
       
    92 	TDblQueLink	iLink;
       
    93 	//Event description
       
    94 	RBuf		iEvent;
       
    95 	};
       
    96 
       
    97 
       
    98 NONSHARABLE_CLASS(CUsbNcmConsole) : public CActive
       
    99 /**
       
   100 The Main Console of NCM manual test
       
   101 */
       
   102 	{
       
   103 friend class CNcmCommandEngine;
       
   104 
       
   105 public:
       
   106 	static CUsbNcmConsole* NewLC(TBool aDemo);
       
   107 	~CUsbNcmConsole();
       
   108 
       
   109 public:
       
   110 	void StartL();
       
   111 	void Stop() const;
       
   112 	
       
   113 	RUsb& Usb();
       
   114 
       
   115 public:
       
   116 	//commands use it to report event to main console
       
   117 	void NotifyEvent(CUsbNcmConsoleEvent* aEvent);
       
   118 	
       
   119 	//Set the Ncm IAP and monitor the related connection status
       
   120 	void SetLocalIapId(TInt aId);
       
   121 	//Set the Uplink IAP and monitor the related connection status
       
   122 	void SetUplinkIapId(TInt aId);
       
   123 
       
   124 	//Get Ncm Iap ID
       
   125 	TInt LocalIapId() const;
       
   126 	//Get Uplink Iap ID
       
   127 	TInt UplinkIapId() const;
       
   128 	
       
   129 	//Called by commands and watchers to notify main console refresh the screen
       
   130 	void ScheduleDraw(TUint aKey);
       
   131 	
       
   132 	//Set the permanent info to display on screen 
       
   133 	void SetDisplayItem(TInt aIndex, TDes& aInfo);
       
   134 	//Get the permanent info on screen
       
   135 	const TDes& GetDisplayItem(TInt aIndex);
       
   136 
       
   137 	//Display all Iaps configured in commsdb
       
   138 	TInt DrawAvailableIapsL();
       
   139 	
       
   140 	//Attach the connection specified by aIap
       
   141 	TBool AttachConnectionL(TInt aIap, RConnection& aConnection);
       
   142 	
       
   143 private:
       
   144 	CUsbNcmConsole(TBool aDemo);
       
   145 	void ConstructL();
       
   146 	
       
   147 	//Display all kinds of info.
       
   148 	void DrawL();
       
   149 	//Init the items which are displayed on screen permanently
       
   150 	void CreateDisplayItemL();
       
   151 
       
   152 	//Call back function 
       
   153 	static TInt DoCommandCallback(TAny *aThisPtr);
       
   154 
       
   155 private:
       
   156 	//From Active
       
   157 	void DoCancel();
       
   158 	void RunL();
       
   159 	TInt RunError(TInt aError);
       
   160 
       
   161 private:
       
   162     CConsoleBase* iConsole;
       
   163 	RUsb iUsb;
       
   164 	
       
   165 	//The info displayed on screen permanently
       
   166 	RArray<RBuf> iDisplayArray;
       
   167 
       
   168 	TVersion	iVersion;
       
   169 	
       
   170 	//The Uplink IAP id	
       
   171 	TInt	iLocalIapId;
       
   172 	
       
   173 	CNcmCommandEngine* iKeys;
       
   174 
       
   175 	//monitor the USB device state
       
   176 	CDeviceWatcher* iDeviceWatcher;
       
   177 	//monitor the USB service state
       
   178 	CServiceWatcher* iServiceWatcher;
       
   179 
       
   180 	//Get the agent state of Ncm
       
   181 	CSharedStateWatcher*    iSharedStateWatcher; 
       
   182 	//Indicate current operation is display the help or not.
       
   183 	TInt 		iHelp;
       
   184 	
       
   185 	//If 'DEMO' is used as application parameter, iDemo will be set true. The Ncm
       
   186 	//Control app will be started automaticly and start Ncm automicly when usb cable
       
   187 	//plugin. This is used to demo for licencee.
       
   188 	TBool iDemo;	
       
   189 //	CAsyncCallBack* iStartWatcherCallback;
       
   190 	
       
   191 	// Event list
       
   192 	TDblQue<CUsbNcmConsoleEvent>	iEventList;
       
   193 	};
       
   194 
       
   195 
       
   196 #endif // NCMTESTCONSOLE_H