# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1273583655 -10800 # Node ID 454d022d514be0d53d4e222c8eeea3439c914578 # Parent 404ad6c9bc207900abbef4c1e51af124793c55a1 Revision: 201017 Kit: 201019 diff -r 404ad6c9bc20 -r 454d022d514b creator/inc/creator_accesspoint.h --- a/creator/inc/creator_accesspoint.h Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/inc/creator_accesspoint.h Tue May 11 16:14:15 2010 +0300 @@ -27,11 +27,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff -r 404ad6c9bc20 -r 454d022d514b creator/inc/creator_browser.h --- a/creator/inc/creator_browser.h Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/inc/creator_browser.h Tue May 11 16:14:15 2010 +0300 @@ -25,9 +25,9 @@ #include "creator_modulebase.h" #include -#include -#include -#include +#include +#include +#include diff -r 404ad6c9bc20 -r 454d022d514b creator/inc/creator_phonebook.h --- a/creator/inc/creator_phonebook.h Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/inc/creator_phonebook.h Tue May 11 16:14:15 2010 +0300 @@ -31,11 +31,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include diff -r 404ad6c9bc20 -r 454d022d514b creator/src/creator_accesspoint.cpp --- a/creator/src/creator_accesspoint.cpp Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/src/creator_accesspoint.cpp Tue May 11 16:14:15 2010 +0300 @@ -19,8 +19,8 @@ #include "creator_accesspoint.h" #include "creator_traces.h" -#include -#include +#include +#include static const TInt KAccessPointsFieldLength = 128; diff -r 404ad6c9bc20 -r 454d022d514b creator/src/creator_browser.cpp --- a/creator/src/creator_browser.cpp Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/src/creator_browser.cpp Tue May 11 16:14:15 2010 +0300 @@ -20,7 +20,7 @@ #include "creator_browser.h" #include "creator_traces.h" -#include +#include static const TInt KBrowserFieldLength = 128; diff -r 404ad6c9bc20 -r 454d022d514b creator/src/creator_factory.cpp --- a/creator/src/creator_factory.cpp Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/src/creator_factory.cpp Tue May 11 16:14:15 2010 +0300 @@ -20,7 +20,7 @@ #if( defined __SERIES60_30__ || defined __SERIES60_31__ ) #include "creator_phonebook.h" - #include "creator_accessPoint.h" + #include "creator_accesspoint.h" #else #include "creator_virtualphonebook.h" #include "creator_connectionmethod.h" diff -r 404ad6c9bc20 -r 454d022d514b creator/src/creator_phonebook.cpp --- a/creator/src/creator_phonebook.cpp Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/src/creator_phonebook.cpp Tue May 11 16:14:15 2010 +0300 @@ -20,7 +20,7 @@ #include "creator_phonebook.h" #include "creator_traces.h" -#include +#include //---------------------------------------------------------------------------- diff -r 404ad6c9bc20 -r 454d022d514b creator/src/creator_wepsecuritysettings.cpp --- a/creator/src/creator_wepsecuritysettings.cpp Tue Apr 27 16:38:40 2010 +0300 +++ b/creator/src/creator_wepsecuritysettings.cpp Tue May 11 16:14:15 2010 +0300 @@ -20,7 +20,7 @@ #include "creator_wepsecuritysettings.h" #include //#include -#include +#include //#include //#include diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/HtiAdmin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/HtiAdmin.pro Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,33 @@ +TEMPLATE = app +TARGET = HtiAdmin +DEPENDPATH += . +INCLUDEPATH += . +INCLUDEPATH += . /epoc32/include/mw/hb/hbcore /epoc32/include/mw/hb/hbwidgets /epoc32/include/mw/hb/hbtools +LIBS += -lhbcore -lhbwidgets + +HEADERS += mainview.h +SOURCES += main.cpp mainview.cpp + +symbian: { + + LIBS += -lestor -lws32 -lPlatformEnv -limageconversion -leikcore -lfbscli -lapgrfx -lcommonengine -lgdi -lhticfg -lbafl -lecom -lcommdb + + + HEADERS += htienginewrapper.h chtiadminengine.h + SOURCES += htienginewrapper.cpp chtiadminengine.cpp + RSS_RULES += "group_name = \"RnD Tools\""; + TARGET.CAPABILITY = ALL -TCB + TARGET.UID2 = 0x100039CE + + TARGET.UID3 = 0x1020DEB5 + + + # TARGET.SID = 0x1020DEB5 + TARGET.VID = 0x101FB657 + + # TARGET.EPOCHEAPSIZE = 0x020000 0x800000 // Min 128Kb, Max 16Mb + # TARGET.EPOCSTACKSIZE = 0x5000 +}else { + error("Only Symbian supported!") +} + diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/chtiadminengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/chtiadminengine.cpp Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,905 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of HtiAdmin main. +* +*/ + +#include +#include +#include + +#include +#include // for KHTICommInterfaceUid + + +#include "htienginewrapper.h" +#include "chtiadminengine.h" + + +#ifdef __ENABLE_LOGGING__ + +#include + +_LIT(KLogFolder, "hti"); +_LIT(KLogFile, "htiadmin.txt"); +#define HTI_LOG_TEXT(a1) {_LIT(temp, a1); RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, temp);} +#define HTI_LOG_FORMAT(a1,a2) {_LIT(temp, a1); RFileLogger::WriteFormat(KLogFolder, KLogFile, EFileLoggingModeAppend, temp, (a2));} +#define HTI_LOG_DES(a1) {RFileLogger::Write(KLogFolder, KLogFile, EFileLoggingModeAppend, (a1));} + +#else // __ENABLE_LOGGING__ + +#define HTI_LOG_TEXT(a1) +#define HTI_LOG_FORMAT(a1,a2) +#define HTI_LOG_DES(a1) + +#endif // __ENABLE_LOGGING__ + +// CONSTANTS +_LIT( KHtiWatchDogMatchPattern, "HtiWatchDog*" ); +_LIT( KHtiFrameworkExe, "HtiFramework.exe" ); +_LIT( KHtiMatchPattern, "HtiFramework*" ); +_LIT( KHtiFrameworkCaption, "HTI status: " ); +_LIT( KHtiAutoStartCaption, "AutoStart: " ); +_LIT( KHtiVersionCaption, "Version: " ); +_LIT( KHtiSelectedCommCaption, "Communication: " ); +_LIT( KHtiAdminStartParameter, "admin" ); +_LIT( KHtiAdminVersionFormat, "%u.%u.%u (%uwk%02u)" ); +_LIT( KHtiAdminAboutVersionFormat, "Version %u.%u.%u - " ); +const static TInt KTerminateReason = 1; + +const TInt32 KHTIImplUidIsaComm = {0x1020DEBD}; +const TInt32 KHTIImplUidSerial = {0x10210CCA}; +const TInt32 KHTIImplUidBluetooth = {0x200212CC}; +const TInt32 KHTIImplUidIPComm = {0x200212CE}; +const TInt32 KHTIImplUidUsbSerialComm = {0x200212D0}; +const TInt32 KHTIImplUidTraceComm = {0x200212D8}; + +// configuration file constants +_LIT( KCfgFilePath, "\\"); +_LIT( KHtiCfg, "hti.cfg" ); +_LIT( KHtiBtCommCfg, "HTIBtComm.cfg" ); +_LIT( KHtiSerialCommCfg , "HTISerialComm.cfg" ); +_LIT( KHtiIPCommCfg, "HTIIPComm.cfg" ); +// hti.cfg +_LIT8( KCommPlugin, "CommPlugin" ); +_LIT8( KPriority, "Priority" ); +_LIT8( KShowConsole, "ShowConsole" ); +_LIT8( KEnableHtiWatchDog, "EnableHtiWatchDog" ); +_LIT8( KEnableHtiAutoStart, "EnableHtiAutoStart" ); +_LIT8( KShowErrorDialogs, "ShowErrorDialogs" ); +// HtiBtComm.cfg +_LIT8( KBtDeviceAddress, "BtDeviceAddress" ); +_LIT8( KBtDeviceName, "BtDeviceName" ); +// HtiSerialComm.cfg +_LIT8( KCommPortNumber, "CommPort" ); +// HTIIPComm.cfg +_LIT8( KLocalPort, "LocalPort" ); +_LIT8( KRemoteHost, "RemoteHost" ); +_LIT8( KRemotePort, "RemotePort" ); +_LIT8( KIAPName, "IAPName"); + + +// --------------------------------------------------------------------------- + +CHtiAdminEngine::CHtiAdminEngine() +{ + iIAPsArray = NULL; +} + +// --------------------------------------------------------------------------- +CHtiAdminEngine* CHtiAdminEngine::NewLC(HtiEngineWrapper *aEngineWrapper) + { + CHtiAdminEngine* self = new (ELeave) CHtiAdminEngine(); + CleanupStack::PushL(self); + self->ConstructL(aEngineWrapper); + return self; + } + +// --------------------------------------------------------------------------- +CHtiAdminEngine* CHtiAdminEngine::NewL(HtiEngineWrapper *aEngineWrapper) + { + CHtiAdminEngine* self = CHtiAdminEngine::NewLC(aEngineWrapper); + CleanupStack::Pop(); // self; + return self; + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::ConstructL(HtiEngineWrapper *aEngineWrapper) + { + iEngineWrapper = aEngineWrapper; + iHtiCfg = CHtiCfg::NewL(); + + CheckStatusesL(); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::CheckStatusesL() + { + UpdateConsoleStatus(); + UpdateWatchDogStatus(); + UpdateAutoStartStatus(); + UpdateSelectedComm(); + UpdateStatusL(); + } + + +// --------------------------------------------------------------------------- +CHtiAdminEngine::~CHtiAdminEngine() +{ + KillTimer(); + delete iHtiCfg; + delete iPluginNameArray; + delete iPluginDataTypeArray; +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::StartHtiL() +{ + + RProcess prs; + TInt err; + TBool isRunning = EFalse; + if ( OpenHtiProcess( prs ) ) + { + if ( prs.ExitType() == EExitPending ) + { + isRunning = ETrue; + iEngineWrapper->updateStatus(HtiEngineWrapper::Running); + } + prs.Close(); + } + + if ( !isRunning ) + { + HTI_LOG_TEXT( "create process" ); + err = prs.Create( KHtiFrameworkExe, KHtiAdminStartParameter ); + if ( err == KErrNone ) + { + prs.Resume(); + prs.Close(); + UpdateStatusL(); + HTI_LOG_TEXT("create done"); + } + else + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Error); + HTI_LOG_TEXT("create error"); + } + } + +} + + +// --------------------------------------------------------------------------- + +void CHtiAdminEngine::StopHtiL() +{ + HTI_LOG_TEXT("Stop"); + + // kill the watchdog to prevent it from restarting HTI again + KillHtiWatchDogL(); + + RProcess prs; + if ( OpenHtiProcess( prs ) ) + { + if ( prs.ExitType() == EExitPending ) + { + HTI_LOG_TEXT("try to kill"); + prs.Kill( KTerminateReason ); + UpdateStatusL(); + } + else + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Stopped); + } + prs.Close(); + } + +} + +// --------------------------------------------------------------------------- + +void CHtiAdminEngine::EnableBtByAddressL(const TDesC& aAddress) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); + iHtiCfg->RemoveParameterL( KBtDeviceName ); + iHtiCfg->RemoveParameterL( KBtDeviceAddress ); + + TBuf8 value; + value.Copy(aAddress); + iHtiCfg->SetParameterL( KBtDeviceAddress, value); + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg); + UpdateSelectedComm(); + +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::EnableBtByNameL(const TDesC& aAddress) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); + iHtiCfg->RemoveParameterL( KBtDeviceName ); + iHtiCfg->RemoveParameterL( KBtDeviceAddress ); + + TBuf8 value; + value.Copy(aAddress); + iHtiCfg->SetParameterL( KBtDeviceName, value); + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg ); + UpdateSelectedComm(); +} + + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::BtSearchL() +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KCommPlugin, _L8( "BTSERIAL" ) ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); + iHtiCfg->RemoveParameterL( KBtDeviceName ); + iHtiCfg->RemoveParameterL( KBtDeviceAddress ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiBtCommCfg ); + UpdateSelectedComm(); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::IPListenL(const TDesC& aPort, const TDesC& aIAP) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KCommPlugin, _L8("IPCOMM")); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) ); + + TBuf8 port; + port.Copy(aPort); + iHtiCfg->SetParameterL( KLocalPort, port); + + TBuf8 iap; + iap.Copy(aIAP); + iHtiCfg->SetParameterL(KIAPName, iap); + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiIPCommCfg ); + UpdateSelectedComm(); + +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::IPConnectL(const TDesC& aHost, const TDesC& aPort, const TDesC& aIAP) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KCommPlugin, _L8( "IPCOMM" ) ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) ); + iHtiCfg->RemoveParameterL( KLocalPort ); + + TBuf8 value; + value.Copy(aHost); + iHtiCfg->SetParameterL( KRemoteHost, value); + + TBuf8 port; + port.Copy(aPort); + iHtiCfg->SetParameterL(KRemotePort, port); + + TBuf8 iap; + iap.Copy(aIAP); + iHtiCfg->SetParameterL(KIAPName, iap); + + iHtiCfg->SaveCfgL(KCfgFilePath, KHtiIPCommCfg); + UpdateSelectedComm(); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::EnableSerialL(const TDesC& aComPortNumber) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KCommPlugin, _L8( "SERIAL" ) ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + + TBuf8 value; + value.Copy(aComPortNumber); + iHtiCfg->SetParameterL( KCommPortNumber, value ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiSerialCommCfg ); + UpdateSelectedComm(); +} + + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::EnableOtherCommL(const TDesC& aSelectedPluginName) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + + TInt namePosition; + iPluginNameArray->Find(aSelectedPluginName, namePosition); + + //Save correct data type for selected plugin + iHtiCfg->SetParameterL( KCommPlugin, iPluginDataTypeArray->MdcaPoint(namePosition) ); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + UpdateSelectedComm(); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetPriorityBackgroundL() +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KPriority, _L8("1")); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetPriorityForegroundL() +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KPriority, _L8("2")); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetPriorityHighL() +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KPriority, _L8("3")); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetPriorityAbsoluteHighL() +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + iHtiCfg->SetParameterL( KPriority, _L8("4")); + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::AutoStartEnableL(TBool aEnableAutoStart) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + if(aEnableAutoStart) + { + iHtiCfg->SetParameterL( KEnableHtiAutoStart, _L8("1")); + } + else + { + iHtiCfg->SetParameterL( KEnableHtiAutoStart, _L8("0")); + } + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + UpdateAutoStartStatus(); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::WatchDogEnableL(TBool aEnableWDog) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + + if(aEnableWDog) + { + iHtiCfg->SetParameterL( KEnableHtiWatchDog, _L8("1")); + } + else + { + iHtiCfg->SetParameterL( KEnableHtiWatchDog, _L8("0")); + } + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + UpdateWatchDogStatus(); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::ConsoleEnableL(TBool aEnableConsole) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + + if(aEnableConsole) + { + iHtiCfg->SetParameterL( KShowConsole, _L8("1")); + } + else + { + iHtiCfg->SetParameterL( KShowConsole, _L8("0")); + } + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); + UpdateConsoleStatus(); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::ErrorDialogsEnableL(TBool aEnableErrorDialogs) +{ + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + + if(aEnableErrorDialogs) + { + iHtiCfg->SetParameterL( KShowErrorDialogs, _L8("1")); + } + else + { + iHtiCfg->SetParameterL( KShowErrorDialogs, _L8("0")); + } + + iHtiCfg->SaveCfgL( KCfgFilePath, KHtiCfg ); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetHtiCfgParamL(const TDesC& aParamName, const TDesC& aParamValue) +{ + SetCfgParamL(aParamName, aParamValue, KHtiCfg); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetBtCfgParamL(const TDesC& aParamName, const TDesC& aParamValue) +{ + SetCfgParamL(aParamName, aParamValue, KHtiBtCommCfg); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetSerialCfgParamL(const TDesC& aParamName, const TDesC& aParamValue) +{ + SetCfgParamL(aParamName, aParamValue, KHtiSerialCommCfg); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetIPCfgParamL(const TDesC& aParamName, const TDesC& aParamValue) +{ + SetCfgParamL(aParamName, aParamValue, KHtiIPCommCfg); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::SetCfgParamL(const TDesC& aParamName, const TDesC& aParamValue, const TDesC& aFileName) +{ + TBuf8 name; + name.Copy(aParamName); + + TBuf8 value; + value.Copy(aParamValue); + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, aFileName ) ); + + iHtiCfg->SetParameterL( name, value ); + iHtiCfg->SaveCfgL( KCfgFilePath, aFileName); +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::GetHtiCfgParamL(const TDesC& aParamName, TDes& aParamValue) + { + GetCfgParamL(aParamName, aParamValue, KHtiCfg); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::GetBtCfgParamL(const TDesC& aParamName, TDes& aParamValue) + { + GetCfgParamL(aParamName, aParamValue, KHtiBtCommCfg); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::GetSerialCfgParamL(const TDesC& aParamName, TDes& aParamValue) + { + GetCfgParamL(aParamName, aParamValue, KHtiSerialCommCfg); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::GetIPCfgParamL(const TDesC& aParamName, TDes& aParamValue) + { + GetCfgParamL(aParamName, aParamValue, KHtiIPCommCfg); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::GetCfgParamL(const TDesC& aParamName, TDes& aParamValue, const TDesC& aFileName) + { + TBuf8 name; + name.Copy(aParamName); + + TBuf value; + + TRAP_IGNORE( iHtiCfg->LoadCfgL( KCfgFilePath, aFileName ) ); + aParamValue.Copy(iHtiCfg->GetParameterL(name)); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::GetSelectedComm(TDes& aPluginName) + { + TBuf8 commValue; + TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + if ( !err ) + { + TRAP( err, commValue = iHtiCfg->GetParameterL( KCommPlugin ) ); + } + // Use default if not found from config + if ( commValue.Length() == 0 ) + { + commValue.Copy(KCommDefaultImplementation ); + } + TInt typePosition; + iPluginDataTypeArray->Find(commValue, typePosition); + aPluginName.Copy(iPluginNameArray->MdcaPoint(typePosition)); + } + +// --------------------------------------------------------------------------- +TBool CHtiAdminEngine::OpenHtiProcess( RProcess& aPrs ) +{ + HTI_LOG_TEXT( "OpenHtiProcess" ); + + TFullName processName; + TInt err; + + TFindProcess finder( KHtiMatchPattern ); + err = finder.Next( processName ); + if ( err == KErrNone ) + { + HTI_LOG_TEXT( "try to open..." ); + err = aPrs.Open( finder ); + HTI_LOG_TEXT( "opened" ); + + if ( err == KErrNone ) + { + HTI_LOG_TEXT( "OpenHtiProcess OK" ); + return ETrue; + } + else + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Error); + } + } + else if ( err == KErrNotFound ) + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Stopped); + } + else + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Error); + } + + HTI_LOG_TEXT( "OpenHtiProcess NOK" ); + + return EFalse; +} + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::UpdateStatusL() + { + HTI_LOG_TEXT( "UpdateStatusL" ); + RProcess prs; + if ( OpenHtiProcess( prs ) ) + { + HTI_LOG_TEXT( "Update display" ); + TExitType exT = prs.ExitType(); + + switch ( exT ) + { + case EExitPending: + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Running); + + // start timer to watch the status + if ( !iPeriodic ) + { + iPeriodic = CPeriodic::NewL( CActive::EPriorityStandard ); + iPeriodic->Start( 5 * 1000 * 1000, + 5 * 1000 * 1000, + TCallBack( TimerCallBackL, this ) ); + } + } + break; + + case EExitKill: + case EExitTerminate: + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Stopped); + KillTimer(); + } + break; + + case EExitPanic: + { + iEngineWrapper->updateStatus(HtiEngineWrapper::Panic); + KillTimer(); + } + break; + }; + prs.Close(); + } + else + { + KillTimer(); + } + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::KillHtiWatchDogL() + { + TFullName processName; + TFindProcess finder( KHtiWatchDogMatchPattern ); + TInt err = finder.Next( processName ); + if ( err == KErrNone ) + { + HTI_LOG_TEXT( "HTI watchdog process found. Trying to open and kill it..." ); + RProcess prs; + User::LeaveIfError( prs.Open( finder ) ); + prs.Kill( KTerminateReason ); + prs.Close(); + HTI_LOG_TEXT( "HTI watchdog killed" ); + } + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::KillTimer() + { + if ( iPeriodic ) + { + iPeriodic->Cancel(); + delete iPeriodic; + iPeriodic = NULL; + } + } + +// --------------------------------------------------------------------------- +TInt CHtiAdminEngine::TimerCallBackL( TAny* aPtr ) + { + ( (CHtiAdminEngine*)aPtr )->UpdateStatusL(); + return ETrue; + } + + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::UpdateAutoStartStatus() + { + HTI_LOG_TEXT( "UpdateAutoStartStatus" ); + TInt value = KErrNotFound; + TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + if ( !err ) + { + TRAP( err, value = iHtiCfg->GetParameterIntL(KEnableHtiAutoStart) ); + } + + if ( value == KErrNotFound ) + { + // Use default values if not found from config. +#ifdef __WINS__ + value = 0; +#else + value = 1; +#endif + } + + if ( value == 0 ) + { + iEngineWrapper->updateAutostartStatus( HtiEngineWrapper::AutoStartDisabled ); + } + else if ( value == 1 ) + { + iEngineWrapper->updateAutostartStatus( HtiEngineWrapper::AutoStartEnabled ); + } + else + { + iEngineWrapper->updateAutostartStatus( HtiEngineWrapper::AutoStartUnknown ); + } + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::UpdateConsoleStatus() + { + HTI_LOG_TEXT( "UpdateConsoleStatus" ); + TInt value = KErrNotFound; + TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + if(!err) + { + TRAP( err, value = iHtiCfg->GetParameterIntL(KShowConsole) ); + } + + if ( value == KErrNotFound ) + { + value = 0; + } + + iEngineWrapper->updateConsoleStatus(value); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::UpdateWatchDogStatus() + { + HTI_LOG_TEXT( "UpdateWatchDogStatus" ); + TInt value = KErrNotFound; + TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + if(!err) + { + TRAP( err, value = iHtiCfg->GetParameterIntL(KEnableHtiWatchDog) ); + } + + if ( value == KErrNotFound ) + { + value = 0; + } + + iEngineWrapper->updateWatchDogStatus(value); + } + +// --------------------------------------------------------------------------- +void CHtiAdminEngine::UpdateSelectedComm() + { + HTI_LOG_TEXT( "UpdateSelectedComm" ); + TBuf<64> commPlugin; + TRAPD( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiCfg ) ); + if ( !err ) + { + TBuf8 commValue; + TRAP( err, commValue = iHtiCfg->GetParameterL( KCommPlugin ) ); + if ( err == KErrNone ) + { + commPlugin.Copy( commValue ); + } + } + // Use default if not found from config + if ( commPlugin.Length() == 0 ) + { + commPlugin.Copy(KCommDefaultImplementation ); + } + iEngineWrapper->updateSelectedComm( commPlugin ); + + if ( commPlugin.Compare( _L( "SERIAL" ) ) == 0 ) + { + TInt portNum = 0; + TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiSerialCommCfg ) ); + if ( err == KErrNone ) + { + TRAP( err, portNum = iHtiCfg->GetParameterIntL( KCommPortNumber ) ); + } + TBuf<16> portBuf; + portBuf.Copy( _L( "Port: " ) ); + portBuf.AppendNum( portNum ); + iEngineWrapper->updateCommDetails( portBuf ); + } + + else if ( commPlugin.Compare( _L( "BTSERIAL" ) ) == 0 ) + { + TBuf<64> hostBuf; + TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiBtCommCfg ) ); + if ( err == KErrNone ) + { + TBuf8 hostValue; + TRAP( err, hostValue = iHtiCfg->GetParameterL( KBtDeviceAddress ) ); + if ( err != KErrNone ) + { + TRAP( err, hostValue = iHtiCfg->GetParameterL( KBtDeviceName ) ); + } + if ( err == KErrNone ) + { + hostBuf.Copy( hostValue ); + } + } + if ( hostBuf.Length() > 0 ) + { + hostBuf.Insert( 0, _L( "Host: " ) ); + } + iEngineWrapper->updateCommDetails(hostBuf); + } + + else if ( commPlugin.Compare( _L( "IPCOMM" ) ) == 0 ) + { + TBuf<128> hostBuf; + TRAP( err, iHtiCfg->LoadCfgL( KCfgFilePath, KHtiIPCommCfg ) ); + if ( err == KErrNone ) + { + TInt localPort = 0; + TRAP( err, localPort = iHtiCfg->GetParameterIntL( KLocalPort ) ); + if ( err == KErrNone && localPort > 0 ) + { + hostBuf.Copy( _L( "Listen: " ) ); + hostBuf.AppendNum( localPort ); + } + else + { + TBuf8 remoteHost; + TInt remotePort = 0; + TRAP( err, remoteHost = iHtiCfg->GetParameterL( KRemoteHost ) ); + if ( err == KErrNone ) + { + TRAP( err, remotePort = iHtiCfg->GetParameterIntL( + KRemotePort ) ); + } + if ( err == KErrNone ) + { + hostBuf.Copy( remoteHost ); + hostBuf.Insert( 0, _L("Connect: " ) ); + hostBuf.Append( ':' ); + hostBuf.AppendNum( remotePort ); + } + else + { + hostBuf.Copy( _L( "Invalid config!" ) ); + } + } + } + iEngineWrapper->updateCommDetails(hostBuf); + } + + else + { + iEngineWrapper->updateCommDetails(KNullDesC); + } + } + +// --------------------------------------------------------------------------- +void CleanupRArray( TAny* object ) + { + ( ( RImplInfoPtrArray* ) object )->ResetAndDestroy(); + } + +// --------------------------------------------------------------------------- +CDesCArray* CHtiAdminEngine::SearchCommPluginsL() + { + const TInt pluginNameArrayGranularity (15); + iPluginNameArray = new (ELeave) CDesCArrayFlat(pluginNameArrayGranularity); + iPluginDataTypeArray = new (ELeave) CDesC8ArrayFlat(pluginNameArrayGranularity); + + RImplInfoPtrArray implInfoArray; + CleanupStack::PushL( TCleanupItem( CleanupRArray, &implInfoArray ) ); + + REComSession::ListImplementationsL( KHTICommInterfaceUid, implInfoArray ); + + for ( TInt i = 0; i < implInfoArray.Count(); ++i ) + { + iPluginNameArray->AppendL(implInfoArray[i]->DisplayName()); + iPluginDataTypeArray->AppendL(implInfoArray[i]->DataType()); + } + + CleanupStack::PopAndDestroy(); //implInfoArray + + return iPluginNameArray; + } + +// --------------------------------------------------------------------------- +CDesCArray* CHtiAdminEngine::SearchIAPsL() + { + if(iIAPsArray) + { + return iIAPsArray; + } + + TBuf name; + const TInt arrayGranularity (10); + iIAPsArray = new (ELeave) CDesCArrayFlat(arrayGranularity); + + // Get IAP names from the database + CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeIAP);; + CleanupStack::PushL(db); + db->ShowHiddenRecords(); + CCommsDbTableView* view = db->OpenTableLC(TPtrC(IAP)); + TInt res = view->GotoFirstRecord(); + + while(res == KErrNone) + { + view->ReadTextL(TPtrC(COMMDB_NAME), name); + iIAPsArray->InsertL(0, name); + res = view->GotoNextRecord(); + } + + CleanupStack::PopAndDestroy(view); //view + CleanupStack::PopAndDestroy(db); //db + + return iIAPsArray; + } diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/chtiadminengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/chtiadminengine.h Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,182 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of HtiAdmin main. +* +*/ + +#ifndef CHTIADMINENGINE_H +#define CHTIADMINENGINE_H + +#include +#include +#include + + +class HtiEngineWrapper; +class CPeriodic; +class CHtiCfg; + + +class CHtiAdminEngine : public CBase + { + public: + + /** + * Constructor + */ + CHtiAdminEngine(); + + /** + * Destructor + */ + ~CHtiAdminEngine(); + + /** + * Two-phased constructor. + */ + static CHtiAdminEngine* NewL(HtiEngineWrapper *aEngineWrapper); + + /** + * Two-phased constructor. + */ + static CHtiAdminEngine* NewLC(HtiEngineWrapper *aEngineWrapper); + + void StartHtiL(); + + void StopHtiL(); + + void EnableBtByAddressL(const TDesC& aAddress); + + void EnableBtByNameL(const TDesC& aAddress); + + void BtSearchL(); + + void IPListenL(const TDesC& aPort, const TDesC& aIAP); + + void IPConnectL(const TDesC& aHost, const TDesC& aPort, const TDesC& aIAP); + + void EnableSerialL(const TDesC& aComPortNumber); + + void EnableOtherCommL(const TDesC& aSelectedPluginName); + + void SetPriorityBackgroundL(); + + void SetPriorityForegroundL(); + + void SetPriorityHighL(); + + void SetPriorityAbsoluteHighL(); + + void AutoStartEnableL(TBool aEnableAutoStart); + + void ConsoleEnableL(TBool aEnableConsole); + + void ErrorDialogsEnableL(TBool aEnableErrorDialogs); + + void SetHtiCfgParamL(const TDesC& aParamName, const TDesC& aParamValue); + void GetHtiCfgParamL(const TDesC& aParamName, TDes& aParamValue); + + void SetBtCfgParamL(const TDesC& aParamName, const TDesC& aParamValue); + void GetBtCfgParamL(const TDesC& aParamName, TDes& aParamValue); + + void SetSerialCfgParamL(const TDesC& aParamName, const TDesC& aParamValue); + void GetSerialCfgParamL(const TDesC& aParamName, TDes& aParamValue); + + void SetIPCfgParamL(const TDesC& aParamName, const TDesC& aParamValue); + void GetIPCfgParamL(const TDesC& aParamName, TDes& aParamValue); + + void GetSelectedComm(TDes& aPluginName); + + void CheckStatusesL(); + + CDesCArray* SearchCommPluginsL(); + + CDesCArray* SearchIAPsL(); + + void CHtiAdminEngine::WatchDogEnableL(TBool aEnableWDog); + + /** + * Kills the HtiWatchDog process if it is running. + */ + void KillHtiWatchDogL(); + + /** + * Stops the timer issuing the periodical HTI Framework process + * status checks. + */ + void KillTimer(); + + /** + * The method called by the periodic timer. + * @param aPtr pointer to this CHtiAdminAppUi instance + * @return zero if the callback function should not be called again, + * otherwise non-zero. Current implementation returns always ETrue. + */ + static TInt TimerCallBackL( TAny* aPtr ); + + /** + * Tries to find the HTIFramework.exe process and open a handle to it. + * @param aPrs on return contains an open handle to the HTIFramework.exe + * process if process found and opened successfully + * @return ETrue if process found and opened successfully, + * otherwise EFalse + */ + TBool OpenHtiProcess( RProcess& aPrs ); + + /** + * Updates the HTI Framework process status in the display. + */ + void UpdateStatusL(); + + /** + * Updates the HTI auto start status in the display. + */ + void UpdateAutoStartStatus(); + + + void UpdateConsoleStatus(); + + void UpdateWatchDogStatus(); + + /** + * Updates the selected communication in the display. + */ + void UpdateSelectedComm(); + + private: + void ConstructL(HtiEngineWrapper *aEngineWrapper); + + void SetCfgParamL(const TDesC& aParamName, const TDesC& aParamValue, const TDesC& aFileName); + void GetCfgParamL(const TDesC& aParamName, TDes& aParamValue, const TDesC& aFileName); + + private: + // Enginewrapper that is used for communicating between QT and Symbian + HtiEngineWrapper* iEngineWrapper; + + // Timer triggering periodic checking of HTIFramework process status + CPeriodic* iPeriodic; + + // For reading and writing HTI configuration files + CHtiCfg* iHtiCfg; + + CDesCArrayFlat* iPluginNameArray; + + CDesC8ArrayFlat* iPluginDataTypeArray; + + CDesCArrayFlat* iIAPsArray; + + + }; + +#endif //CHTIADMINENGINE_H diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/htienginewrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/htienginewrapper.cpp Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,563 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of HtiAdmin main. +* +*/ + + +#include "htienginewrapper.h" +#include "chtiadminengine.h" + +#include +#include +#include + + +#include + + + +// --------------------------------------------------------------------------- + +HtiEngineWrapper::HtiEngineWrapper(): + iEngine(0) +{ +} +// --------------------------------------------------------------------------- +HtiEngineWrapper::~HtiEngineWrapper() +{ + delete iEngine; +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::init() +{ + TRAPD(error, iEngine = CHtiAdminEngine::NewL(this)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::startHti() +{ + TRAPD(error, iEngine->StartHtiL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::stopHti() +{ + TRAPD(error, iEngine->StopHtiL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::enableBtByAddress(QString& address) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedAddress(address.utf16()); + + + TRAPD(error, iEngine->EnableBtByAddressL(convertedAddress)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::ipListen(QString& port, QString& iap) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedPort(port.utf16()); + TBuf<64> convertedIAP(iap.utf16()); + + TRAPD(error, iEngine->IPListenL(convertedPort, convertedIAP)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::ipConnect(QString& host, QString& port, QString& iap) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedHostAddress(host.utf16()); + TBuf<64> convertedPort(port.utf16()); + TBuf<64> convertedIAP(iap.utf16()); + + TRAPD(error, iEngine->IPConnectL(convertedHostAddress, convertedPort, convertedIAP)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::enableBtByName(QString& address) + { + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedAddress(address.utf16()); + + + TRAPD(error, iEngine->EnableBtByNameL(convertedAddress)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::btSearch() + { + TRAPD(error, iEngine->BtSearchL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::enableSerial(QString& commPort) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedText(commPort.utf16()); + + TRAPD(error, iEngine->EnableSerialL(convertedText)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::enableOtherComm(QString& pluginName) + { + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedText(pluginName.utf16()); + + TRAPD(error, iEngine->EnableOtherCommL(convertedText)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setPriorityBackground() + { + TRAPD(error, iEngine->SetPriorityBackgroundL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setPriorityForeground() + { + TRAPD(error, iEngine->SetPriorityForegroundL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setPriorityHigh() + { + TRAPD(error, iEngine->SetPriorityHighL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setPriorityAbsoluteHigh() + { + TRAPD(error, iEngine->SetPriorityAbsoluteHighL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::watchDogEnable(bool enable) + { + TRAPD(error, iEngine->WatchDogEnableL(enable)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::autoStartEnable(bool enable) + { + TRAPD(error, iEngine->AutoStartEnableL(enable)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::consoleEnable(bool enable) + { + TRAPD(error, iEngine->ConsoleEnableL(enable)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::errorDialogsEnable(bool enable) + { + TRAPD(error, iEngine->ErrorDialogsEnableL(enable)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } + } + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setHtiCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> convertedValue(paramValue.utf16()); + + TRAPD(error, iEngine->SetHtiCfgParamL(convertedName, convertedValue)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::getHtiCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> value; + + TRAPD(error, iEngine->GetHtiCfgParamL(convertedName, value)); + + paramValue = QString((QChar*)value.Ptr(),value.Length()); + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setBtCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> convertedValue(paramValue.utf16()); + + TRAPD(error, iEngine->SetBtCfgParamL(convertedName, convertedValue)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::getBtCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> value; + + TRAPD(error, iEngine->GetBtCfgParamL(convertedName, value)); + paramValue = QString((QChar*)value.Ptr(),value.Length()); + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setSerialCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> convertedValue(paramValue.utf16()); + + TRAPD(error, iEngine->SetSerialCfgParamL(convertedName, convertedValue)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::getSerialCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> value; + + TRAPD(error, iEngine->GetSerialCfgParamL(convertedName, value)); + paramValue = QString((QChar*)value.Ptr(),value.Length()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::setIPCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> convertedValue(paramValue.utf16()); + + TRAPD(error, iEngine->SetIPCfgParamL(convertedName, convertedValue)); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::getIPCfgParam(QString& paramName, QString& paramValue) +{ + // A conversion between a TBuf and QString is needed here. + TBuf<64> convertedName(paramName.utf16()); + TBuf<64> value; + + TRAPD(error, iEngine->GetIPCfgParamL(convertedName, value)); + paramValue = QString((QChar*)value.Ptr(),value.Length()); + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +void HtiEngineWrapper::getVersionIfo(QString& version) +{ + version= QString("%1.%2.%3 (%4 wk%5)") + .arg(KHtiVersionMajor).arg(KHtiVersionMinor).arg(KHtiVersionBuild) + .arg(KHtiVersionYear).arg(KHtiVersionWeek); +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::updateStatuses() +{ + TRAPD(error, iEngine->CheckStatusesL()); + + if (error != KErrNone) { + return false; + } + else { + return true; + } +} + +// --------------------------------------------------------------------------- +void HtiEngineWrapper::updateStatus(HtiStatus status) +{ + emit statusChanged(status); +} + +// --------------------------------------------------------------------------- +void HtiEngineWrapper::updateSelectedComm(const TDesC& aText) +{ + iSelectedCommText = QString((QChar*)aText.Ptr(),aText.Length()); + + emit commSet(iSelectedCommText); +} + +// --------------------------------------------------------------------------- +void HtiEngineWrapper::updateCommDetails(const TDesC& aText) +{ + iCommDetailsText = QString((QChar*)aText.Ptr(),aText.Length()); + + emit commDetails(iCommDetailsText); +} + +// --------------------------------------------------------------------------- +void HtiEngineWrapper::updateAutostartStatus(AutoStartStatus status) +{ + emit autostartSet(status); +} + +void HtiEngineWrapper::updateConsoleStatus(bool bEnabled) +{ + emit consoleSet(bEnabled); +} + +void HtiEngineWrapper::updateWatchDogStatus(bool bEnabled) +{ + emit watchDogSet(bEnabled); +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::listCommPlugins() +{ + CDesCArray* pluginsArray = NULL; + + TRAPD(error, pluginsArray = iEngine->SearchCommPluginsL()); + + if (error != KErrNone) { + return false; + } + else { + for(TInt i = 0; i < pluginsArray->Count(); ++i) + { + TPtrC16 plugin (pluginsArray->MdcaPoint(i)); + int len = pluginsArray->MdcaPoint(i).Length(); + + QString name ((QChar*)plugin.Ptr(), len); + iPluginNames << name; + } + + emit commPluginsRetrieved(iPluginNames); + + return true; + } +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::listIAPs(QStringList& list) +{ + CDesCArray* arrayIAPs = NULL; + + TRAPD(error, arrayIAPs = iEngine->SearchIAPsL()); + + if (error != KErrNone) { + return false; + } + else { + for(TInt i = 0; i < arrayIAPs->Count(); ++i) + { + TPtrC16 iap (arrayIAPs->MdcaPoint(i)); + int len = arrayIAPs->MdcaPoint(i).Length(); + + QString name ((QChar*)iap.Ptr(), len); + list << name; + } + + return true; + } + return true; +} + +// --------------------------------------------------------------------------- +bool HtiEngineWrapper::getSelectedComm(QString& commName) +{ + TBuf<64> pluginName; + iEngine->GetSelectedComm(pluginName); + commName = QString((QChar*)pluginName.Ptr(), pluginName.Length()); + return true; +} diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/htienginewrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/htienginewrapper.h Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of HtiAdmin main. +* +*/ + +#ifndef HTIENGINEWRAPPER_H +#define HTIENGINEWRAPPER_H + +#include +#include +#include + +class CHtiAdminEngine; +class QString; + + + + +/** + * class that is used for communicating between Symbian and Qt code. + */ +class HtiEngineWrapper : public QObject + { + Q_OBJECT +public: + enum AutoStartStatus{ + AutoStartDisabled, + AutoStartEnabled, + AutoStartUnknown + }; + + enum HtiStatus{ + Running, + Stopped, + Panic, + Error + }; + + /** + * Constructor + */ + HtiEngineWrapper(); + + /** + * Destructor + */ + ~HtiEngineWrapper(); + + + bool init(); + bool stopHti(); + bool startHti(); + bool enableBtByAddress(QString& address); + bool enableBtByName(QString& address); + bool ipListen(QString& port, QString& iap); + bool ipConnect(QString& host, QString& port, QString& iap); + bool enableSerial(QString& commPort); + bool btSearch(); + bool enableOtherComm(QString& pluginName); + bool setPriorityBackground(); + bool setPriorityForeground(); + bool setPriorityHigh(); + bool setPriorityAbsoluteHigh(); + bool watchDogEnable(bool enable); + bool autoStartEnable(bool enable); + bool consoleEnable(bool enable); + bool errorDialogsEnable(bool enable); + bool setHtiCfgParam(QString& paramName, QString& paramValue); + bool getHtiCfgParam(QString& paramName, QString& paramValue); + bool setBtCfgParam(QString& paramName, QString& paramValue); + bool getBtCfgParam(QString& paramName, QString& paramValue); + bool setSerialCfgParam(QString& paramName, QString& paramValue); + bool getSerialCfgParam(QString& paramName, QString& paramValue); + bool setIPCfgParam(QString& paramName, QString& paramValue); + bool getIPCfgParam(QString& paramName, QString& paramValue); + void getVersionIfo(QString& version); + bool updateStatuses(); + bool listCommPlugins(); + bool listIAPs(QStringList& list); + bool getSelectedComm(QString& commName); + + //Called from engine side + void updateStatus(HtiStatus status); + void updateSelectedComm(const TDesC& aText); + void updateAutostartStatus(AutoStartStatus status); + void updateConsoleStatus(bool bEnabled); + void updateWatchDogStatus(bool bEnabled); + void updateCommDetails(const TDesC& aText); + + + +signals: + void statusChanged(HtiEngineWrapper::HtiStatus status); + void commSet(QString& statusText); + void commDetails(QString& statusText); + void commPluginsRetrieved(QStringList& pluginNames); + void autostartSet(HtiEngineWrapper::AutoStartStatus status); + void consoleSet(bool enabled); + void watchDogSet(bool enabled); + +private: + CHtiAdminEngine* iEngine; + QString iSelectedCommText; + QString iCommDetailsText; + QStringList iPluginNames; + + }; + +#endif //HTIENGINEWRAPPER_H diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/main.cpp Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of HtiAdmin main. +* +*/ + +#include +//#include +#include +#include + + +#include "mainview.h" +#include "htienginewrapper.h" + + + + + +int main(int argc, char *argv[]) +{ + // Initialization + HbApplication app(argc, argv); + + // Create HtiEngineWrapper + HtiEngineWrapper engineWrapper; + + if (!engineWrapper.init()) { + return EXIT_FAILURE; + } + + // Main window widget. + // Includes decorators such as signal strength and battery life indicator. + HbMainWindow mainWindow; + + //Create main view + MainView* view = new MainView(mainWindow, engineWrapper); + + //initialize main view + view->init(app); + + // Add View to main window and reveal it. + mainWindow.addView(view); + + // Show widget + //mainWindow.show(); + mainWindow.showFullScreen(); + + int result = app.exec(); + + return result; +} diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiAdminQt/mainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htiui/HtiAdminQt/mainview.cpp Tue May 11 16:14:15 2010 +0300 @@ -0,0 +1,554 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of HtiAdmin main. +* +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include "htienginewrapper.h" +#include "mainview.h" +#include "hbtoolbar.h" + +// --------------------------------------------------------------------------- + +MainView::MainView(HbMainWindow &mainWindow, HtiEngineWrapper& engineWrapper): + mMainWindow(mainWindow), + mEngineWrapper(engineWrapper) +{ +} + +// --------------------------------------------------------------------------- + +MainView::~MainView() +{ + +} + +// --------------------------------------------------------------------------- + +void MainView::init(HbApplication &app) +{ + this->setTitle("Hti Admin"); + createToolbar(); + createMenu(app); + createTexts(); + + mEngineWrapper.updateStatuses(); + + QString version; + mEngineWrapper.getVersionIfo(version); + mEngineWrapper.listCommPlugins(); + + mHtiVersionTxt->setPlainText("Hti Version: " + version); +} + +// --------------------------------------------------------------------------- +void MainView::createMenu(HbApplication& app) +{ + + HbMenu* menu = new HbMenu(); + + if (menu != NULL) { + + mActionExit = menu->addAction("Exit"); + connect(mActionExit, SIGNAL(triggered()), &app, SLOT( quit() ) ); + + connect(mActionStartHti, SIGNAL(triggered()), this, SLOT( startHti() ) ); + connect(mActionStopHti, SIGNAL(triggered()), this, SLOT( stopHti() ) ); + + mActionSelectComm = menu->addAction("Select Communication"); + connect(mActionSelectComm, SIGNAL(triggered()), this, SLOT( enableComm() ) ); + + mActionSetPriority = menu->addAction("Set Priority"); + connect(mActionSetPriority, SIGNAL(triggered()), this, SLOT( setPriority() ) ); + + mActionEnableAuto = menu->addAction("Enable Auto Start"); + connect(mActionEnableAuto, SIGNAL(triggered()), this, SLOT( enableAutoStart() ) ); + + mActionDisableAuto = menu->addAction("Disable Auto Start"); + connect(mActionDisableAuto, SIGNAL(triggered()), this, SLOT( disableAutoStart() ) ); + + mActionEnableWdog = menu->addAction("Enable Watchdog"); + connect(mActionEnableWdog, SIGNAL(triggered()), this, SLOT( enableWatchdog() ) ); + + mActionDisableWdog = menu->addAction("Disable Watchdog"); + connect(mActionDisableWdog, SIGNAL(triggered()), this, SLOT( disableWatchdog() ) ); + + mActionEnableConsole = menu->addAction("Enable Console"); + connect(mActionEnableConsole, SIGNAL(triggered()), this, SLOT( enableConsole() ) ); + + mActionDisableConsole = menu->addAction("Disable Console"); + connect(mActionDisableConsole, SIGNAL(triggered()), this, SLOT( disableConsole() ) ); + + mActionSetParameter = menu->addAction("Set Parameter"); + connect(mActionSetParameter, SIGNAL(triggered()), this, SLOT( showParamList() ) ); + + this->setMenu(menu); + } + + + connect(&mEngineWrapper, SIGNAL(statusChanged(HtiEngineWrapper::HtiStatus)), this, SLOT(htiStatusChanged(HtiEngineWrapper::HtiStatus))); + connect(&mEngineWrapper, SIGNAL(commSet(QString&)), this, SLOT(commStatusChanged(QString&))); + connect(&mEngineWrapper, SIGNAL(commDetails(QString&)), this, SLOT(commDetailsChanged(QString&))); + connect(&mEngineWrapper, SIGNAL(autostartSet(HtiEngineWrapper::AutoStartStatus)), this, SLOT(autostartStatusChanged(HtiEngineWrapper::AutoStartStatus))); + connect(&mEngineWrapper, SIGNAL(consoleSet(bool)), this, SLOT(consoleStatusChanged(bool))); + connect(&mEngineWrapper, SIGNAL(watchDogSet(bool)), this, SLOT(watchDogStatusChanged(bool))); + connect(&mEngineWrapper, SIGNAL(commPluginsRetrieved(QStringList&)), this, SLOT(updatePluginInfo(QStringList&))); + + +} + +// --------------------------------------------------------------------------- +void MainView::createTexts() +{ + QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); + + mCommDetailsTxt = new HbLabel(this); + mHtiStatusTxt = new HbLabel(this); + mHtiVersionTxt = new HbLabel(this); + + mHtiAutoStartStatusTxt = new HbLabel(this); + mCommunicationTxt = new HbLabel(this); + + mHtiStatusTxt->setPlainText("Hti Status:"); + mHtiVersionTxt->setPlainText("Hti Version:"); + mHtiAutoStartStatusTxt->setPlainText("Auto Start:"); + mCommunicationTxt->setPlainText("Communication "); + + layout->addItem(mHtiStatusTxt); + layout->addItem(mHtiVersionTxt); + layout->addItem(mHtiAutoStartStatusTxt); + layout->addItem(mCommunicationTxt); + layout->addItem(mCommDetailsTxt); + + layout->setMaximumHeight(300); + this->setLayout(layout); +} + +// --------------------------------------------------------------------------- +void MainView::htiStatusChanged(HtiEngineWrapper::HtiStatus newStatus) +{ + switch(newStatus) + { + case HtiEngineWrapper::Running: + mHtiStatusTxt->setPlainText("Hti Status: Running" ); + break; + case HtiEngineWrapper::Stopped: + mHtiStatusTxt->setPlainText("Hti Status: Stopped" ); + break; + case HtiEngineWrapper::Panic: + mHtiStatusTxt->setPlainText("Hti Status: Panic" ); + break; + default: + mHtiStatusTxt->setPlainText("Hti Status: Error" ); + } + + // Update menu items status + bool isRunning = (newStatus == HtiEngineWrapper::Running); + mActionStartHti->setEnabled(!isRunning); + mActionStopHti->setEnabled(isRunning); + mActionSelectComm->setEnabled(!isRunning); + mActionSetPriority->setEnabled(!isRunning); + mActionEnableAuto->setEnabled(!isRunning); + mActionDisableAuto->setEnabled(!isRunning); + mActionEnableWdog->setEnabled(!isRunning); + mActionDisableWdog->setEnabled(!isRunning); + mActionEnableConsole->setEnabled(!isRunning); + mActionDisableConsole->setEnabled(!isRunning); + mActionSetParameter->setEnabled(!isRunning); +} + +// --------------------------------------------------------------------------- +void MainView::commStatusChanged(QString& newStatus) +{ + if (mCommunicationTxt) { + mCommunicationTxt->setPlainText("Communication: " + newStatus); + } +} + +// --------------------------------------------------------------------------- +void MainView::commDetailsChanged(QString& newStatus) +{ + if (mCommDetailsTxt) { + mCommDetailsTxt->setPlainText(newStatus); + } +} + +// --------------------------------------------------------------------------- +void MainView::updatePluginInfo(QStringList& pluginList) +{ + mPluginList = pluginList; +} + +// --------------------------------------------------------------------------- +void MainView::autostartStatusChanged(HtiEngineWrapper::AutoStartStatus newStatus) +{ + switch(newStatus) + { + case HtiEngineWrapper::AutoStartDisabled: + mHtiAutoStartStatusTxt->setPlainText("Auto Start: Disabled" ); + break; + case HtiEngineWrapper::AutoStartEnabled: + mHtiAutoStartStatusTxt->setPlainText("Auto Start: Enabled" ); + break; + default: + mHtiAutoStartStatusTxt->setPlainText("Auto Start: Unknown" ); + } + + bool isAutoStartEnabled = (newStatus == HtiEngineWrapper::AutoStartEnabled); + mActionEnableAuto->setVisible(!isAutoStartEnabled); + mActionDisableAuto->setVisible(isAutoStartEnabled); +} + +// --------------------------------------------------------------------------- +void MainView::consoleStatusChanged(bool enabled) +{ + mActionEnableConsole->setVisible(!enabled); + mActionDisableConsole->setVisible(enabled); +} + +// --------------------------------------------------------------------------- +void MainView::watchDogStatusChanged(bool enabled) +{ + mActionEnableWdog->setVisible(!enabled); + mActionDisableWdog->setVisible(enabled); +} + + +// --------------------------------------------------------------------------- + +void MainView::createToolbar() +{ + mActionStartHti = toolBar()->addAction("Start Hti"); + mActionStopHti = toolBar()->addAction("Stop Hti"); +} + +// --------------------------------------------------------------------------- + +void MainView::startHti() +{ + mEngineWrapper.startHti(); +} + +// --------------------------------------------------------------------------- + +void MainView::stopHti() +{ + mEngineWrapper.stopHti(); +} + +// --------------------------------------------------------------------------- +void MainView::enableComm() +{ + //Get current selection + QString currentComm; + mEngineWrapper.getSelectedComm(currentComm); + int curSelection = mPluginList.indexOf(currentComm, 0); + + QStringList selection; + bool ok = false; + selection = HbListDialog::getStringItems("Select Comm", mPluginList, curSelection, &ok, HbAbstractItemView::SingleSelection); + + if(ok){ + if(selection[0] == QString("Bt serial comm")){ + enableBTComm(); + } + else if(selection[0] == QString("IP comm")){ + enableIPComm(); + } + else if(selection[0] == QString("SERIAL comm")){ + enableSerialComm(); + } + else{ + //All other comm plugins + mEngineWrapper.enableOtherComm(selection[0]); + } + } +} + +// --------------------------------------------------------------------------- +void MainView::enableSerialComm() +{ + bool ok = false; + QString str = HbInputDialog::getText( + "Set Comm Port number ", + "", + &ok); + + if(ok){ + mEngineWrapper.enableSerial(str); + } +} + + +// --------------------------------------------------------------------------- +void MainView::enableIPComm() +{ + // Get IAPs list + QStringList iapsList; + mEngineWrapper.listIAPs(iapsList); + if(iapsList.count() == 0) + { + HbMessageBox msg("No IAPs for selection!", HbMessageBox::MessageTypeWarning); + msg.exec(); + return; + } + + // Get current selection + QString curIapName; + QString param = "IAPName"; + mEngineWrapper.getIPCfgParam(param, curIapName); + int curSelction = iapsList.indexOf(curIapName, 0); + + QString iap; + QStringList selection; + bool ok = false; + selection = HbListDialog::getStringItems("Select IAP:", iapsList, curSelction, &ok, HbAbstractItemView::SingleSelection); + + if(ok) + { + iap = selection[0]; + } + else + { + return; + } + + QStringList srcList; + srcList <<"Listen" <<"Connect"; + + selection = HbListDialog::getStringItems("Select IP Comm", srcList, 0, &ok, HbAbstractItemView::SingleSelection); + + if(ok){ + if(selection[0] == srcList[0]){ + QString port = HbInputDialog::getText( + "Local port", + "", + &ok); + + if(ok){ + mEngineWrapper.ipListen(port, iap); + } + + } + else{ + QString host = HbInputDialog::getText( + "Remote Host", + "", + &ok); + + if(ok){ + QString port = HbInputDialog::getText( + "Remote port", + "", + &ok); + + if(ok){ + mEngineWrapper.ipConnect(host, port, iap); + } + } + } + + } +} + +// --------------------------------------------------------------------------- +void MainView::enableBTComm() +{ + QStringList srcList; + QStringList selection; + + srcList <<"BT address" <<"BT name" <<"Search when starting" ; + + bool ok = false; + selection = HbListDialog::getStringItems("", srcList, 0, &ok, HbAbstractItemView::SingleSelection); + + if(ok){ + if(selection[0] == srcList[0]){ + QString address = HbInputDialog::getText( + "BT address", + "", + &ok); + + if(ok){ + mEngineWrapper.enableBtByAddress(address); + } + } + else if(selection[0] == srcList[1]){ + QString name = HbInputDialog::getText( + "BT name", + "", + &ok); + + if(ok){ + mEngineWrapper.enableBtByName(name); + } + } + else if(selection[0] == srcList[2]){ + mEngineWrapper.btSearch(); + } + } +} + + +// --------------------------------------------------------------------------- +void MainView::setPriority() +{ + // Get current priority + bool ok = false; + QString curPriority; + QString param = "Priority"; + mEngineWrapper.getHtiCfgParam(param, curPriority); + int curSelection = curPriority.toInt(&ok); + if(ok){ + curSelection--; + } + else{ + curSelection = 2; + } + + QStringList srcList; + QStringList selection; + + srcList <<"Backgroung" <<"Foregound" <<"High" << "Absolute High"; + + + selection = HbListDialog::getStringItems("Select Hti Priority", srcList, curSelection, &ok, HbAbstractItemView::SingleSelection); + + if(ok){ + if(selection[0] == srcList[0]){ + mEngineWrapper.setPriorityBackground(); + } + else if(selection[0] == srcList[1]){ + mEngineWrapper.setPriorityForeground(); + } + else if(selection[0] == srcList[2]){ + mEngineWrapper.setPriorityHigh(); + } + else{ + mEngineWrapper.setPriorityAbsoluteHigh(); + } + } +} + +// --------------------------------------------------------------------------- +void MainView::enableAutoStart() +{ + mEngineWrapper.autoStartEnable(true); +} + +// --------------------------------------------------------------------------- +void MainView::disableAutoStart() +{ + mEngineWrapper.autoStartEnable(false); +} + +// --------------------------------------------------------------------------- +void MainView::enableWatchdog() +{ + mEngineWrapper.watchDogEnable(true); +} + +// --------------------------------------------------------------------------- +void MainView::disableWatchdog() +{ + mEngineWrapper.watchDogEnable(false); +} + +// --------------------------------------------------------------------------- +void MainView::enableConsole() +{ + mEngineWrapper.consoleEnable(true); +} + +// --------------------------------------------------------------------------- +void MainView::disableConsole() +{ + mEngineWrapper.consoleEnable(false); +} + +// --------------------------------------------------------------------------- +void MainView::showParamList() +{ + QStringList srcList; + QStringList selection; + QString value; + QString name; + QString cfgSelection; + QString paramSelection; + QString cfgHti = "Hti.cfg"; + QString cfgBtComm ="HtiBtComm.cfg"; + QString cfgSerialComm = "HtiSerialComm.cfg"; + QString cfgIPComm = "HtiIPComm.cfg"; + + srcList < +#include "htienginewrapper.h" + + +class HbMainWindow; +class HbApplication; +class SettingsView; +class HbAction; +class HbTextEdit; +class HbTextItem; +class HbLabel; +class QGraphicsLinearLayout; +class QGraphicsGridLayout; + + +/** + * Class that implements the main view of Screen Grabber + */ +class MainView : public HbView +{ + Q_OBJECT + +public: + + /** + * Constructor + */ + MainView(HbMainWindow &mainWindow, HtiEngineWrapper &engineWrapper); + + /** + * Destructor + */ + ~MainView(); + + /** + * Initializes Engine Wrapper + * @param app application class of Screen Grabber + */ + void init(HbApplication &app); + + void enableSerialComm(); + void enableBTComm(); + void enableIPComm(); + + +private slots: + void htiStatusChanged(HtiEngineWrapper::HtiStatus newStatus); + void commStatusChanged(QString& newStatus); + void updatePluginInfo(QStringList& pluginList); + void autostartStatusChanged(HtiEngineWrapper::AutoStartStatus newStatus); + void consoleStatusChanged(bool enabled); + void watchDogStatusChanged(bool enabled); + void commDetailsChanged(QString& newStatus); + + void startHti(); + void stopHti(); + void enableComm(); + void setPriority(); + void enableAutoStart(); + void disableAutoStart(); + void enableWatchdog(); + void disableWatchdog(); + void enableConsole(); + void disableConsole(); + void showParamList (); + + +private: + + /** + * Creates menu + */ + void createMenu(HbApplication &app); + + /** + * Creates toolbar components + */ + void createToolbar(); + + void createTexts(); + +public: + +private: + /* Main windo of Screen Grabber */ + HbMainWindow &mMainWindow; + + /* Hti Engine Wrapper */ + HtiEngineWrapper& mEngineWrapper; + + /* Actions that are used in toolbars and menus */ + HbAction* mActionExit; + HbAction* mActionStartHti; + HbAction* mActionStopHti; + HbAction* mActionSelectComm; + HbAction* mActionSetPriority; + HbAction* mActionEnableAuto; + HbAction* mActionDisableAuto; + HbAction* mActionEnableWdog; + HbAction* mActionDisableWdog; + HbAction* mActionEnableConsole; + HbAction* mActionDisableConsole; + HbAction* mActionSetParameter; + + HbLabel* mHtiStatusTxt; + HbLabel* mHtiVersionTxt; + HbLabel* mHtiAutoStartStatusTxt; + HbLabel* mCommunicationTxt; + HbLabel* mCommDetailsTxt; + + QStringList mPluginList; + +}; + +#endif // MAINVIEW_H + + diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommInterfaceu.def --- a/htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommInterfaceu.def Tue Apr 27 16:38:40 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -EXPORTS - ??0RHtiBtCommInterface@@QAE@XZ @ 1 NONAME ; RHtiBtCommInterface::RHtiBtCommInterface(void) - ?CancelReceive@RHtiBtCommInterface@@QAEXXZ @ 2 NONAME ; void RHtiBtCommInterface::CancelReceive(void) - ?CancelSend@RHtiBtCommInterface@@QAEXXZ @ 3 NONAME ; void RHtiBtCommInterface::CancelSend(void) - ?Close@RHtiBtCommInterface@@QAEXXZ @ 4 NONAME ; void RHtiBtCommInterface::Close(void) - ?Connect@RHtiBtCommInterface@@QAEHAAVTDesC8@@H@Z @ 5 NONAME ; int RHtiBtCommInterface::Connect(class TDesC8 &, int) - ?GetPortNumber@RHtiBtCommInterface@@QBEHXZ @ 6 NONAME ; int RHtiBtCommInterface::GetPortNumber(void) const - ?GetReceiveBufferSize@RHtiBtCommInterface@@QBEHXZ @ 7 NONAME ; int RHtiBtCommInterface::GetReceiveBufferSize(void) const - ?GetSendBufferSize@RHtiBtCommInterface@@QBEHXZ @ 8 NONAME ; int RHtiBtCommInterface::GetSendBufferSize(void) const - ?Receive@RHtiBtCommInterface@@QAEXAAVTDes8@@AAVTRequestStatus@@@Z @ 9 NONAME ; void RHtiBtCommInterface::Receive(class TDes8 &, class TRequestStatus &) - ?Send@RHtiBtCommInterface@@QAEXABVTDesC8@@AAVTRequestStatus@@@Z @ 10 NONAME ; void RHtiBtCommInterface::Send(class TDesC8 const &, class TRequestStatus &) - ?Version@RHtiBtCommInterface@@QBE?AVTVersion@@XZ @ 11 NONAME ; class TVersion RHtiBtCommInterface::Version(void) const - diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommServeru.def --- a/htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtCommServeru.def Tue Apr 27 16:38:40 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?StartThread@@YAHXZ @ 1 NONAME ; int StartThread(void) - diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtSerialComHelperu.def --- a/htiui/HtiCommPlugins/HtiBtCommPlugin/BWINS/HtiBtSerialComHelperu.def Tue Apr 27 16:38:40 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -EXPORTS - ??1CBtSerialClient@@UAE@XZ @ 1 NONAME ; CBtSerialClient::~CBtSerialClient(void) - ?ConnectL@CBtSerialClient@@QAEXABVTDesC16@@H@Z @ 2 NONAME ; void CBtSerialClient::ConnectL(class TDesC16 const &, int) - ?ConnectL@CBtSerialClient@@QAEXVTBTDevAddr@@H@Z @ 3 NONAME ; void CBtSerialClient::ConnectL(class TBTDevAddr, int) - ?ConnectL@CBtSerialClient@@QAEXXZ @ 4 NONAME ; void CBtSerialClient::ConnectL(void) - ?Connected@CBtSerialClient@@QAEHXZ @ 5 NONAME ; int CBtSerialClient::Connected(void) - ?Connecting@CBtSerialClient@@QAEHXZ @ 6 NONAME ; int CBtSerialClient::Connecting(void) - ?Disconnect@CBtSerialClient@@QAEXXZ @ 7 NONAME ; void CBtSerialClient::Disconnect(void) - ?FreeSpaceInSendBuffer@CBtSerialClient@@QAEHXZ @ 8 NONAME ; int CBtSerialClient::FreeSpaceInSendBuffer(void) - ?NewL@CBtSerialClient@@SAPAV1@AAVMBtSerialClientObserver@@@Z @ 9 NONAME ; class CBtSerialClient * CBtSerialClient::NewL(class MBtSerialClientObserver &) - ?ReadAsyncL@CBtSerialClient@@QAEXXZ @ 10 NONAME ; void CBtSerialClient::ReadAsyncL(void) - ?SendBufferMaxSize@CBtSerialClient@@QAEHXZ @ 11 NONAME ; int CBtSerialClient::SendBufferMaxSize(void) - ?SendL@CBtSerialClient@@QAEXABVTDesC8@@@Z @ 12 NONAME ; void CBtSerialClient::SendL(class TDesC8 const &) - ?ServerAddressL@CBtSerialClient@@QAE?AVTBTDevAddr@@XZ @ 13 NONAME ; class TBTDevAddr CBtSerialClient::ServerAddressL(void) - ?ServicePort@CBtSerialClient@@QAEHXZ @ 14 NONAME ; int CBtSerialClient::ServicePort(void) - diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialClient.h --- a/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialClient.h Tue Apr 27 16:38:40 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,255 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Bluetooth serial client. -* -*/ - - -#ifndef __BTSERIALCLIENT_H__ -#define __BTSERIALCLIENT_H__ - -// INCLUDES -#include -#include -#include -#include -#include - -#include "SocketObserver.h" - -// FORWARD DECLARATIONS -class CMessageServiceSearcher; -class CSocketsReader; -class CSocketsWriter; - - -class MBtSerialClientObserver - { -public: - virtual void ConnectedToServer(TInt aError) = 0; - virtual void DisconnectedFromServer() = 0; - virtual void DataFromServer(const TDesC8& aData) = 0; - virtual void AllBufferedDataSent() = 0; - }; - -/** -* CBtSerialClient -* Connects and sends messages to a remote machine using bluetooth -*/ -class CBtSerialClient : public CActive, public MSocketObserver - { - public: // Constructors and destructor - - /** - * NewL() - * Construct a CBtSerialClient - * @param aObserver the observer for this BT serial client - * @return a pointer to the created instance of CBtSerialClient - */ - IMPORT_C static CBtSerialClient* NewL( MBtSerialClientObserver& aObserver ); - - /** - * ~CBtSerialClient() - * Destroy the object and release all memory objects. - * Close any open sockets. - */ - IMPORT_C virtual ~CBtSerialClient(); - - public: // New functions - - /** - * ConnectL() - * Connect to remote device. Query user for a device. - */ - IMPORT_C void ConnectL(); - - /** - * ConnectL() - * Connect to remote device. - */ - IMPORT_C void ConnectL(const TBTDevAddr aBTServerDevice, const TInt aPort ); - - /** - * ConnectL() - * Connect to remote device by device name. - */ - IMPORT_C void ConnectL( const TDesC& aBTServerDeviceName, const TInt aPort ); - - /** - * DisconnectL() - * Disconnect from remote machine - */ - IMPORT_C void Disconnect(); - - /** - * IsConnecting() - * @return ETrue if the client is establishing a - * connection to the server. - */ - IMPORT_C TBool Connecting(); - - /** - * Connected() - * @return ETrue if the client is fully connected to the server. - */ - IMPORT_C TBool Connected(); - - /** - * ServerAddressL() - * @return address of connected server. Leaves with KErrNotReady, if - * not connected. - */ - TBTDevAddr ServerAddressL(); - - /** - * Add data to outgoing buffer and start sending it to client. - * - * Leaves with KErrOverflow, if the outgoing buffer cannot - * be added all of the aData. - * Leaves with KErrNotReady, if client is not connected. - * When all data in internal buffer has been sent, observer - * is notified (AllBufferedDataSent) - */ - IMPORT_C void SendL(const TDesC8& aData); - - /** - * Issue read operation. Will complete asyncronously. - * - * Leaves with KErrNotReady, if client is not connected. - * Notifies observer, when some data has been read. Caller - * is responsible for calling this method again to receive - * more data. - */ - IMPORT_C void ReadAsyncL(); - - /** - * Query free size of outgoing buffer. - */ - IMPORT_C TInt FreeSpaceInSendBuffer(); - - /** - * Query max size of outgoing buffer. - */ - IMPORT_C TInt SendBufferMaxSize(); - - /** - * Query the port of the service we are connected with - * @return Port number or KErrDisconnected if not connected to a service - */ - IMPORT_C TInt ServicePort(); - - protected: // from CActive - - /** - * DoCancel() - * Cancel any outstanding requests - */ - void DoCancel(); - - /** - * RunL() - * Respond to an event - */ - void RunL(); - - protected: // from MSocketObserver - - void ReportError( TErrorType aErrorType, TInt aErrorCode ); - void NewData( const TDesC8& aData ); - void AllBufferedDataSent(); - - private: - - /** - * ConnectToServerL - * Connects to the service - */ - void ConnectToServerL(); - - /** - * DisconnectFromServer() - * Disconnects from the service - */ - void DisconnectFromServer(); - - /** - * CBtSerialClient() - * Constructs this object - */ - CBtSerialClient( MBtSerialClientObserver& aObserver ); - - /** - * ConstructL() - * Performs second phase construction of this object - */ - void ConstructL(); - - private: // data - - /** - * TState - * The state of the active object, determines behaviour within - * the RunL method. - * EWaitingToGetDevice waiting for the user to select a device - * EGettingDevice searching for a device - * EGettingService searching for a service - * EGettingConnection connecting to a service on a remote machine - * EConnected connected to a service on a remote machine - */ - enum TState - { - EWaitingToGetDevice, // phase 1 of Connect - EGettingDevice, // phase 2 of Connect - EGettingService, // phase 3 of Connect - EGettingConnection, // phase 4 of Connect - EConnected, // sending and receiving data - EDisconnecting - }; - - MBtSerialClientObserver& iObserver; - - /** iState the current state of the client */ - TState iState; - - /** - * iServiceSearcher searches for service this - * client can connect to. - * Owned by CBtSerialClient - */ - CMessageServiceSearcher* iServiceSearcher; - - /** - * iCurrentServiceIndex the index number of the service we are - * currently connecting/connected to - */ - TInt iCurrentServiceIndex; - - /** iSocketServer a connection to the socket server */ - RSocketServ iSocketServer; - - /** iSocket a socket to connect with */ - RSocket iSocket; - - /** iServiceClass the service class UUID to search for */ - TUUID iServiceClass; - - TBTDevAddr iBTServerDevice; - - CSocketsReader* iSocketReader; - CSocketsWriter* iSocketWriter; - }; - -#endif // __BTSERIALCLIENT_H__ - -// End of File diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialEngine.pan --- a/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/BtSerialEngine.pan Tue Apr 27 16:38:40 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Bluetooth serial engine panic codes. -* -*/ - - -#ifndef __BTSERIALENGINE_PAN__ -#define __BTSERIALENGINE_PAN__ - -#include -#include - -/** Panic Categories */ -_LIT( KPanicSerialEngine, "BTSerialEngine" ); // All engine classes -_LIT( KPanicBTServiceAdvertiser, "BTServiceAdvertiser" ); // only service advertiser - - -enum TBTSerialEnginePanics - { - EBTPointToPointReceiverInvalidState = 1, - EBTPointToPointSenderExists = 2, - EBTPointToPointReceiverExists = 3, - EBTPointToPointSenderInvalidState = 4, - EBTPointToPointNoSender = 5, - EBTPointToPointAddMessage = 6, - EBTPointToPointNextRecordRequestComplete = 7, - EBTPointToPointAttributeRequestResult = 8, - EBTPointToPointAttributeRequestComplete = 9, - EBTPointToPointProtocolRead = 10, - EBTPointToPointAttributeRequest = 11, - EBTPointToPointSdpRecordDelete = 12, - EBTPointToPointServerStop = 13, - EBTPointToPointInvalidLogicState = 14, - EBTPointToPointUnableToDisconnect = 15, - - EBTSerialEngineReadSocketBadState = 16, - EBTSerialEngineWriteSocketBadState = 17 - }; - -inline void Panic( TBTSerialEnginePanics aReason ) - { - User::Panic( KPanicSerialEngine, aReason ); - } - - -#endif // __BTSERIALENGINE_PAN__ - -// End of File diff -r 404ad6c9bc20 -r 454d022d514b htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/HtiBtEngineLogging.h --- a/htiui/HtiCommPlugins/HtiBtCommPlugin/BtEngine/inc/HtiBtEngineLogging.h Tue Apr 27 16:38:40 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Logging for Bluetooth engine. -* -*/ - - -#ifndef __HTIBTENGINELOGGING_H__ -#define __HTIBTENGINELOGGING_H__ - -// INCLUDES -#include - -/******************************************************/ -/** LOG SETUP **/ -/******************************************************/ -_LIT(KLogFolder, "Hti"); -_LIT(KLogFile, "BtSerialEngine.log"); - -#ifdef __ENABLE_LOGGING__ -// Comment out the levels which are marked supported in the build -// (and which are used runtime). -// -#define LOG_LEVEL_ERROR_SUPPORTED -#define LOG_LEVEL_WARN_SUPPORTED -#define LOG_LEVEL_INFO_SUPPORTED -//#define LOG_LEVEL_DEBUG_SUPPORTED -#endif - -/******************************************************/ -/** MACRO DEFINITIONS **/ -/******************************************************/ - -// Macros: Example: Result: -// LOGFMT_E(formatstring, parameter) LOGFMT_E("Leave in RunL: %d", -6)