# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1271419716 -10800 # Node ID 00f9ee97d89557e1fe1ee73a23ae90a759a6ae9d # Parent 0b192a3a05a41332fea1d70e7c6ea8f5d4ffb854 Revision: 201011 Kit: 201015 diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006 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: Build information file for project ?myapp +* +*/ + + +PRJ_PLATFORMS +DEFAULT + + +#include "../modematplugin/group/bld.inf" +#include "../lccustomplugin/group/bld.inf" + +PRJ_EXPORTS + + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +PRJ_TESTEXPORTS diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,29 @@ +/* +* 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: This file provides the information required for building the +* whole of DUN utilities +* +*/ + +#include + +PRJ_PLATFORMS + +PRJ_EXPORTS +../rom/lccustomplugin.iby CORE_MW_LAYER_IBY_EXPORT_PATH(lccustomplugin.iby) + +PRJ_MMPFILES +lccustomplugin.mmp + +PRJ_TESTMMPFILES diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/group/lccustomplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/group/lccustomplugin.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,52 @@ +/* +* 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: Project definition file for project LCCustomPlugin +* +*/ + + +#include + +TARGET lccustomplugin.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x20021360 + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE proxy.cpp +SOURCE lccustomplugin.cpp +SOURCE lclistallcmd.cpp + +START RESOURCE ../src/20021360.rss +TARGET lccustomplugin.rsc +END + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +// Note: +// The only other SYSTEMINCLUDE should you shall add are Symbian specific ones. +// If there is a S60 header in the subdirectory then that should be +// added into the include statements (like #include ) +//SYSTEMINCLUDE /epoc32/include/ecom +SYSTEMINCLUDE /epoc32/include/ecom + +LIBRARY ecom.lib +LIBRARY euser.lib +LIBRARY atextpluginbase.lib + +DEBUGLIBRARY flogger.lib diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/inc/debug.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2008 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 definitions +* +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); +#endif + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); +#endif + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + User::Leave(aReason); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, PTR);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE_IF_NULL(PTR) {static_cast(User::LeaveIfNull(PTR));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_STATIC_FUNC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/inc/debugconfig.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008 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 configure file +* +*/ + + +#ifndef ATEXT_DEBUGCONFIG_H +#define ATEXT_DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"lccustomplugin.txt"); +_LIT(KLogDir,"LCCUSTOMPLUGIN"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[LCCUSTOMPLUGIN] "); +_LIT8(KTracePrefix8, "[LCCUSTOMPLUGIN] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "lccustomplugin"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // ATEXT_DEBUGCONFIG_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/inc/lccustomplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/inc/lccustomplugin.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,476 @@ +/* +* Copyright (c) 2010 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: Main handler for incoming requests +* +*/ + +#ifndef C_LCCUSTOMPLUGIN_H +#define C_LCCUSTOMPLUGIN_H + +#include + +class CLcCustomPlugin; + +/** Character types: carriage return, line feed or backspace */ +enum TCharacterTypes + { + ECharTypeCR, // Carriage return + ECharTypeLF, // Line feed + ECharTypeBS // Backspace + }; + +/** Type of modes (quiet, verbose) */ +enum TModeTypes + { + EModeTypeQuiet, // Quiet mode + EModeTypeVerbose // Verbose mode + }; + +/** Handler types for the four types */ +enum TCmdHandlerType + { + ECmdHandlerTypeUndefined = KErrNotFound, + ECmdHandlerTypeBase = 0x01, // For command "AT+COMMAND" + ECmdHandlerTypeSet = 0x02, // For command "AT+COMMAND=" + ECmdHandlerTypeRead = 0x04, // For command "AT+COMMAND?" + ECmdHandlerTypeTest = 0x08, // For command "AT+COMMAND=?" + }; + +/** Detected commands */ +enum TDetectedCmd + { + EDetectedCmdUndefined, + EDetectedCmdCLAC // For command "AT+CLAC" + }; + +/** + * Class for common AT command handler interface + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CLcCustomPluginBase ) + { + +public: + + virtual ~CLcCustomPluginBase() {}; + + /** + * Reports the support status of an AT command. This is a synchronous API. + * + * @param aCmd The AT command. Its format may vary depending on the + * specification. E.g. in BT HFP case, the command may contain + * a character carriage return () in the end. + * @return ETrue if the command is supported; EFalse otherwise. + */ + virtual TBool IsCommandSupported( const TDesC8& aCmd ) = 0; + + /** + * Handles an AT command. Cancelling of the pending request is done by + * HandleCommandCancel(). The implementation in the extension plugin should + * be asynchronous. + * + * The extension plugin which accepts this command is responsible to supply + * the result codes and response and to format result codes properly, e.g. + * in BT HFP case, the format should be + * + * After an extension plugin has handled or decided to reject the given AT + * command, it must inform ATEXT by HandleCommandCompleted() with a proper + * error code. + * + * @since S60 5.0 + * @param aCmd The AT command to be handled. Its format may vary depending + * on the specification. E.g. in BT HFP case, the command may + * contain a character carriage return () in the end. + * @param aReply When passed in, contains the built in answer filled by + * ATEXT if it is not empty; when command handling completes + * successfully, contains the result codes and responses to + * this command; Its ownership always belongs to ATEXT, plugin + * may reallocate its space when needed. + * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse, + * the aReply must not contain the reply, otherwise it + * must contain verbose or numeric reply (ATV0/1) or an + * empty string reply (with ATQ). + * @return None + */ + virtual void HandleCommand( const TDesC8& aCmd, + RBuf8& aReply, + TBool aReplyNeeded ) = 0; + + /** + * Cancels a pending HandleCommand request. + * + * @since S60 5.0 + * @return None + */ + virtual void HandleCommandCancel() = 0; + + }; + +/** + * Class for accessing plugin information and common functionality + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( MLcCustomPlugin ) + { + +public: + + /** + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. Uses iReplyBuffer for reply storage. + * + * @since S60 5.0 + * @param aReplyType Type of reply + * @param aSrcBuffer Source buffer; used only if aReplyType is EReplyTypeOther + * @param aError Completion code. If not KErrNone then other arguments are + * ignored and the request is completed to ATEXT with + * EReplyTypeUndefined. + * @return None + */ + virtual TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer=KNullDesC8, + TInt aError=KErrNone ) = 0; + + /** + * Creates a buffer for "OK" or "ERROR" reply based on the line settings + * + * @since S60 5.0 + * @param aReplyBuffer Destination buffer for the created reply + * @param aOkReply ETrue if "OK" reply needed, + * EFalse if "ERROR" reply needed + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ) = 0; + + /** + * Checks if the command is a base, set, read or test type of command + * + * @since TB9.2 + * @param aCmdBase Base part of the command to check + * @param aCmdFull Full command to check + * @return Type of command + */ + virtual TCmdHandlerType CheckCommandType( const TDesC8& aCmdBase, + const TDesC8& aCmdFull ) = 0; + + /** + * Returns the array of supported commands + * + * @since S60 5.0 + * @param aCmd Array of supported commands + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetSupportedCommands( RPointerArray& aCmds ) = 0; + + /** + * Returns plugin's character value settings (from CATExtPluginBase) + * + * @since S60 5.0 + * @param aCharType Character's type + * @param aChar Character's value matching aCharType + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetCharacterValue( TCharacterTypes aCharType, TChar& aChar ) = 0; + + /** + * Returns plugin's mode value settings (from CATExtPluginBase) + * + * @since S60 5.0 + * @param aModeType Mode type + * @param aMode Mode value matching aModeType + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetModeValue( TModeTypes aModeType, TBool& aMode ) = 0; + + }; + +/** + * Class for selecting handlers for different AT commands + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CLcCustomPlugin ) : public CATExtPluginBase, + public MLcCustomPlugin + { + +public: + + /** + * Two-phased constructor. + * @return Instance of self + */ + static CLcCustomPlugin* NewL(); + + /** + * Destructor. + */ + virtual ~CLcCustomPlugin(); + +private: + + CLcCustomPlugin(); + + void ConstructL(); + + /** + * Reports connection identifier name to the extension plugin. + * + * @since S60 5.0 + * @param aName Connection identifier name + * @return None + */ + void ReportConnectionName( const TDesC8& aName ); + + /** + * Reports the support status of an AT command. This is a synchronous API. + * + * @param aCmd The AT command. Its format may vary depending on the + * specification. E.g. in BT HFP case, the command may contain + * a character carriage return () in the end. + * @return ETrue if the command is supported; EFalse otherwise. + */ + TBool IsCommandSupported( const TDesC8& aCmd ); + + /** + * Handles an AT command. Cancelling of the pending request is done by + * HandleCommandCancel(). The implementation in the extension plugin should + * be asynchronous. + * + * The extension plugin which accepts this command is responsible to supply + * the result codes and response and to format result codes properly, e.g. + * in BT HFP case, the format should be + * + * After an extension plugin has handled or decided to reject the given AT + * command, it must inform ATEXT by HandleCommandCompleted() with a proper + * error code. + * + * @since S60 5.0 + * @param aCmd The AT command to be handled. Its format may vary depending + * on the specification. E.g. in BT HFP case, the command may + * contain a character carriage return () in the end. + * @param aReply When passed in, contains the built in answer filled by + * ATEXT if it is not empty; when command handling completes + * successfully, contains the result codes and responses to + * this command; Its ownership always belongs to ATEXT, plugin + * may reallocate its space when needed. + * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse, + * the aReply must not contain the reply, otherwise it + * must contain verbose or numeric reply (ATV0/1) or an + * empty string reply (with ATQ). + * @return None + */ + void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + + /** + * Cancels a pending HandleCommand request. + * + * @since S60 5.0 + * @return None + */ + void HandleCommandCancel(); + + /** + * Next reply part's length. + * The value must be equal or less than KDefaultCmdBufLength. + * When the reply from this method is zero, ATEXT stops calling + * GetNextPartOfReply(). + * + * @since S60 5.0 + * @return Next reply part's length if zero or positive + */ + TInt NextReplyPartLength(); + + /** + * Gets the next part of reply initially set by HandleCommandComplete(). + * Length of aNextReply must be equal or less than KDefaultCmdBufLength. + * + * @since S60 5.0 + * @param aNextReply Next reply + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetNextPartOfReply( RBuf8& aNextReply ); + + /** + * Receives unsolicited results. Cancelling of the pending request is done + * by ReceiveUnsolicitedResultCancel(). The implementation in the extension + * plugin should be asynchronous. + * + * @since S60 5.0 + * @return None + */ + void ReceiveUnsolicitedResult(); + + /** + * Cancels a pending ReceiveUnsolicitedResult request. + * + * @since S60 5.0 + * @return None + */ + void ReceiveUnsolicitedResultCancel(); + + /** + * Reports NVRAM status change to the plugins. + * + * @since S60 5.0 + * @param aNvram New NVRAM status. Each call of this function is a result + * of DUN extracting the form notified by + * CATExtCommonBase::SendNvramStatusChange(). Each of the + * settings from SendNvramStatusChange() is separated to + * one call of ReportNvramStatusChange(). + * @return None + */ + void ReportNvramStatusChange( const TDesC8& aNvram ); + + /** + * Reports about external handle command error condition. + * This is for cases when for example DUN decided the reply contained an + * error condition but the plugin is still handling the command internally. + * Example: in command line "AT+TEST;ATDT1234" was given. "AT+TEST" returns + * "OK" and "ATDT" returns "CONNECT". Because "OK" and "CONNECT" are + * different reply types the condition is "ERROR" and DUN ends processing. + * This solution keeps the pointer to the last AT command handling plugin + * inside ATEXT and calls this function there to report the error. + * It is to be noted that HandleCommandCancel() is not sufficient to stop + * the processing as the command handling has already finished. + * + * @since S60 5.0 + * @return None + */ + void ReportExternalHandleCommandError(); + + /** + * Creates part of reply from the global reply buffer to the destination + * buffer. Used with APIs which need the next part of reply in multipart + * reply requests. + * + * @since S60 5.0 + * @param aDstBuffer Destination buffer; the next part of reply is stored to + * this buffer. + * @return None + */ + TInt CreatePartOfReply( RBuf8& aDstBuffer ); + +// from base class MLcCustomPlugin + + /** + * From MLcCustomPlugin. + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. Uses iReplyBuffer for reply storage. + * + * @since S60 5.0 + * @param aReplyType Type of reply + * @param aSrcBuffer Source buffer; used only if aReplyType is EReplyTypeOther + * @param aError Completion code. If not KErrNone then other arguments are + * ignored and the request is completed to ATEXT with + * EReplyTypeUndefined. + * @return None + */ + TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer=KNullDesC8, + TInt aError=KErrNone ); + + /** + * From MLcCustomPlugin. + * Creates a buffer for "OK" or "ERROR" reply based on the line settings + * + * @since S60 5.0 + * @param aReplyBuffer Destination buffer for the created reply + * @param aOkReply ETrue if "OK" reply needed, + * EFalse if "ERROR" reply needed + * @return Symbian error code on error, KErrNone otherwise + */ + TInt CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ); + + /** + * From MLcCustomPlugin. + * Checks if the command is a base, set, read or test type of command + * + * @since S60 5.0 + * @param aCmdBase Base part of the command to check + * @param aCmdFull Full command to check + * @return Type of command + */ + TCmdHandlerType CheckCommandType( const TDesC8& aCmdBase, + const TDesC8& aCmdFull ); + + /** + * From MLcCustomPlugin. + * Returns the array of supported commands + * + * @since S60 5.0 + * @param aCmd Array of supported commands + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetSupportedCommands( RPointerArray& aCmds ); + + /** + * From MLcCustomPlugin. + * Returns plugin's character value settings (from CATExtPluginBase) + * + * @since S60 5.0 + * @param aCharType Character's type + * @param aChar Character's value matching aCharType + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetCharacterValue( TCharacterTypes aCharType, TChar& aChar ); + + /** + * From MLcCustomPlugin. + * Returns plugin's mode value settings (from CATExtPluginBase) + * + * @since S60 5.0 + * @param aModeType Mode type + * @param aMode Mode value matching aModeType + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetModeValue( TModeTypes aModeType, TBool& aMode ); + +private: // data + + /** + * AT commands handler array. Used for mapping HandleCommand() to + * IsCommandSupported() and to limit the number of string comparisons. + */ + RPointerArray iHandlers; + + /** + * Current AT command handler in iHandlers. + * Used when IsCommandSupported() detects a matching handler class. + */ + CLcCustomPluginBase* iHandler; + + /** + * Buffer for handle command's command + * Not own. + */ + const TDesC8* iHcCmd; + + /** + * Buffer for handle command reply + * Not own. + */ + RBuf8* iHcReply; + + /** + * Global reply buffer for the AT command replies + */ + RBuf8 iReplyBuffer; + + }; + +#endif // C_LCCUSTOMPLUGIN_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/inc/lclistallcmd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/inc/lclistallcmd.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,146 @@ +/* +* Copyright (c) 2010 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: Handles the commands "AT+CLAC=?" and "AT+CLAC" +* +*/ + +#ifndef C_LCLISTALLCMD_H +#define C_LCLISTALLCMD_H + +#include "lccustomplugin.h" + +/** + * Class for handling commands "AT+CLAC=?" and "AT+CLAC" + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( CLcListAllCmd ) : public CLcCustomPluginBase +{ + +public: + + /** + * Two-phased constructor. + * @param aCallback Callback + * @return Instance of self + */ + static CLcListAllCmd* NewL( MLcCustomPlugin* aCallback ); + + /** + * Destructor. + */ + virtual ~CLcListAllCmd(); + +private: + + CLcListAllCmd( MLcCustomPlugin* aCallback ); + + void ConstructL(); + + /** + * Checks command types + * + * @since TB9.2 + * @param aCmd Command to check + * @return ETrue if command understood, EFalse otherwise + */ + TBool CheckCommand( const TDesC8& aCmd ); + + /** + * Main command handler (leaving version) + * + * @since TB9.2 + * @return ETrue if command understood, EFalse otherwise + */ + TBool HandleCommandL(); + +// from base class MLcCustomPluginBase + + /** + * Reports the support status of an AT command. This is a synchronous API. + * + * @param aCmd The AT command. Its format may vary depending on the + * specification. E.g. in BT HFP case, the command may contain + * a character carriage return () in the end. + * @return ETrue if the command is supported; EFalse otherwise. + */ + TBool IsCommandSupported( const TDesC8& aCmd ); + + /** + * Handles an AT command. Cancelling of the pending request is done by + * HandleCommandCancel(). The implementation in the extension plugin should + * be asynchronous. + * + * The extension plugin which accepts this command is responsible to supply + * the result codes and response and to format result codes properly, e.g. + * in BT HFP case, the format should be + * + * After an extension plugin has handled or decided to reject the given AT + * command, it must inform ATEXT by HandleCommandCompleted() with a proper + * error code. + * + * @since S60 5.0 + * @param aCmd The AT command to be handled. Its format may vary depending + * on the specification. E.g. in BT HFP case, the command may + * contain a character carriage return () in the end. + * @param aReply When passed in, contains the built in answer filled by + * ATEXT if it is not empty; when command handling completes + * successfully, contains the result codes and responses to + * this command; Its ownership always belongs to ATEXT, plugin + * may reallocate its space when needed. + * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse, + * the aReply must not contain the reply, otherwise it + * must contain verbose or numeric reply (ATV0/1) or an + * empty string reply (with ATQ). + * @return None + */ + void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + + /** + * Cancels a pending HandleCommand request. + * + * @since S60 5.0 + * @return None + */ + void HandleCommandCancel(); + + /** + * Creates a linearized list of supported commands + * + * @since S60 5.0 + * @param aReply List of supported commands + * @return ETrue if "ERROR" condition detected, EFalse otherwise + */ + TBool CreateSupportedList( RBuf8& aReply ); + +private: // data + + /** + * Callback to call when accessing plugin information + */ + MLcCustomPlugin* iCallback; + + /** + * Handler type for the two AT commands + */ + TCmdHandlerType iCmdHandlerType; + + /** + * Detected command + */ + TDetectedCmd iDetectedCmd; + +}; + +#endif // C_LCLISTALLCMD_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/inc/prjconfig.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2008 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: Project configure file +* +*/ + + +#ifndef ATEXT_PRJCONFIG_H +#define ATEXT_PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // ATEXT_PRJCONFIG_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/rom/lccustomplugin.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/rom/lccustomplugin.iby Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,24 @@ +/* +* 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: Image description file for project LCCustomPlugin +* +*/ + + +#ifndef __LCCUSTOMPLUGIN_IBY__ +#define __LCCUSTOMPLUGIN_IBY__ + +ECOM_PLUGIN( lccustomplugin.dll, lccustomplugin.rsc ) + +#endif diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/src/20021360.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/src/20021360.rss Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,65 @@ +/* +* 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: Resource definitions for project lccustomplugin +* +*/ + + +#include +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x20021360; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = ATEXT_INTERFACE_DUN_UID; + implementations = + { + // Info for BTSAC + IMPLEMENTATION_INFO + { + implementation_uid = 0x20021375; + version_no = 1; + display_name = "LC Custom Plugin DUN"; + default_data= "MAT+CLAC"; + opaque_data = ""; + } + }; + }, + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = ATEXT_INTERFACE_HFP_UID; + implementations = + { + // Info for BTSAC + IMPLEMENTATION_INFO + { + implementation_uid = 0x20021376; + version_no = 1; + display_name = "LC Custom Plugin HFP"; + default_data= "MAT+CLAC"; + opaque_data = ""; + } + }; + } + }; + } diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/src/lccustomplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/src/lccustomplugin.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,476 @@ +/* +* Copyright (c) 2010 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: Main handler for incoming requests +* +*/ + +#include "lccustomplugin.h" +#include "lclistallcmd.h" +#include "debug.h" + +const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CLcCustomPlugin* CLcCustomPlugin::NewL() + { + CLcCustomPlugin* self = new (ELeave) CLcCustomPlugin(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CLcCustomPlugin::~CLcCustomPlugin() + { + iHandlers.ResetAndDestroy(); + iHandlers.Close(); + iReplyBuffer.Close(); + } + +// --------------------------------------------------------------------------- +// CLcCustomPlugin::CLcCustomPlugin +// --------------------------------------------------------------------------- +// +CLcCustomPlugin::CLcCustomPlugin() : CATExtPluginBase() + { + iHandler = NULL; + iHcCmd = NULL; + iHcReply = NULL; + } + +// --------------------------------------------------------------------------- +// CLcCustomPlugin::ConstructL +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::ConstructL() + { + CLcCustomPluginBase* handler = NULL; + handler = CLcListAllCmd::NewL( this ); + CleanupStack::PushL( handler ); + iHandlers.AppendL( handler ); + CleanupStack::Pop( handler ); + } + +// --------------------------------------------------------------------------- +// Reports connection identifier name to the extension plugin. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::ReportConnectionName( const TDesC8& /*aName*/ ) + { + } + +// --------------------------------------------------------------------------- +// Reports the support status of an AT command. This is a synchronous API. +// --------------------------------------------------------------------------- +// +TBool CLcCustomPlugin::IsCommandSupported( const TDesC8& aCmd ) + { + TRACE_FUNC_ENTRY + iHcCmd = NULL; + iHcReply = NULL; + TInt i; + TInt count = iHandlers.Count(); + for ( i=0; iIsCommandSupported( aCmd ); + if ( supported ) + { + iHandler = handler; + TRACE_FUNC_EXIT + return ETrue; + } + } + iHandler = NULL; + TRACE_FUNC_EXIT + return EFalse; + } + +// --------------------------------------------------------------------------- +// Handles an AT command. Cancelling of the pending request is done by +// HandleCommandCancel(). The implementation in the extension plugin should +// be asynchronous. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::HandleCommand( const TDesC8& aCmd, + RBuf8& aReply, + TBool aReplyNeeded ) + { + TRACE_FUNC_ENTRY + if ( iHandler ) + { + iHcCmd = &aCmd; + iHcReply = &aReply; + iHandler->HandleCommand( aCmd, aReply, aReplyNeeded ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels a pending HandleCommand request. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + if ( iHandler ) + { + iHandler->HandleCommandCancel(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Next reply part's length. +// The value must be equal or less than KDefaultCmdBufLength. +// When the reply from this method is zero, ATEXT stops calling +// GetNextPartOfReply(). +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::NextReplyPartLength() + { + TRACE_FUNC_ENTRY + if ( iReplyBuffer.Length() < KDefaultCmdBufLength ) + { + TRACE_FUNC_EXIT + return iReplyBuffer.Length(); + } + TRACE_FUNC_EXIT + return KDefaultCmdBufLength; + } + +// --------------------------------------------------------------------------- +// Gets the next part of reply initially set by HandleCommandComplete(). +// Length of aNextReply must be equal or less than KDefaultCmdBufLength. +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::GetNextPartOfReply( RBuf8& aNextReply ) + { + TRACE_FUNC_ENTRY + TInt retVal = CreatePartOfReply( aNextReply ); + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// Receives unsolicited results. Cancelling of the pending request is done by +// by ReceiveUnsolicitedResultCancel(). The implementation in the extension +// plugin should be asynchronous. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::ReceiveUnsolicitedResult() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels a pending ReceiveUnsolicitedResult request. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::ReceiveUnsolicitedResultCancel() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Reports NVRAM status change to the plugins. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::ReportNvramStatusChange( const TDesC8& /*aNvram*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Reports about external handle command error condition. +// This is for cases when for example DUN decided the reply contained an +// error condition but the plugin is still handling the command internally. +// Example: "AT+TEST;+TEST2" was given in command line; "AT+TEST" returns +// non-EReplyTypeError condition and "AT+TEST2" returns EReplyTypeError. +// As the plugin(s) returning the non-EReplyTypeError may still have some +// ongoing operation then these plugins are notified about the external +// EReplyTypeError in command line processing. It is to be noted that +// HandleCommandCancel() is not sufficient to stop the processing as the +// command handling has already finished. +// --------------------------------------------------------------------------- +// +void CLcCustomPlugin::ReportExternalHandleCommandError() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Creates part of reply from the global reply buffer to the destination +// buffer. Used with APIs which need the next part of reply in multipart reply +// requests. +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::CreatePartOfReply( RBuf8& aDstBuffer ) + { + TRACE_FUNC_ENTRY + if ( iReplyBuffer.Length() <= 0 ) + { + TRACE_FUNC_EXIT + return KErrGeneral; + } + TInt partLength = NextReplyPartLength(); + if ( iReplyBuffer.Length() < partLength ) + { + TRACE_FUNC_EXIT + return KErrNotFound; + } + aDstBuffer.Create( iReplyBuffer, partLength ); + iReplyBuffer.Delete( 0, partLength ); + if ( iReplyBuffer.Length() == 0 ) + { + iReplyBuffer.Close(); + } + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Creates an AT command reply based on the reply type and completes the +// request to ATEXT. Uses iReplyBuffer for reply storage. +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer, + TInt aError ) + { + TRACE_FUNC_ENTRY + iReplyBuffer.Close(); + if ( aError != KErrNone ) + { + HandleCommandCompleted( aError, EReplyTypeUndefined ); + iHcCmd = NULL; + iHcReply = NULL; + TRACE_FUNC_EXIT + return KErrNone; + } + if ( !iHcReply ) + { + TRACE_FUNC_EXIT + return KErrGeneral; + } + switch ( aReplyType ) + { + case EReplyTypeOther: + if ( iQuietMode ) + { + iReplyBuffer.Create( KNullDesC8 ); + } + else + { + iReplyBuffer.Create( aSrcBuffer ); + } + break; + case EReplyTypeOk: + CreateOkOrErrorReply( iReplyBuffer, ETrue ); + break; + case EReplyTypeError: + CreateOkOrErrorReply( iReplyBuffer, EFalse ); + break; + default: + TRACE_FUNC_EXIT + return KErrGeneral; + } + CreatePartOfReply( *iHcReply ); + HandleCommandCompleted( KErrNone, aReplyType ); + iHcCmd = NULL; + iHcReply = NULL; + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Creates a buffer for "OK" or "ERROR" reply based on the line settings +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ) + { + TRACE_FUNC_ENTRY + if ( iQuietMode ) + { + TRACE_FUNC_EXIT + return iReplyBuffer.Create( KNullDesC8 ); + } + _LIT8( KErrorReplyVerbose, "ERROR" ); + _LIT8( KOkReplyVerbose, "OK" ); + _LIT8( KErrorReplyNumeric, "4" ); + _LIT8( KOkReplyNumeric, "0" ); + TBuf8 replyBuffer; + if ( iVerboseMode ) + { + replyBuffer.Append( iCarriageReturn ); + replyBuffer.Append( iLineFeed ); + if ( aOkReply ) + { + replyBuffer.Append( KOkReplyVerbose ); + } + else + { + replyBuffer.Append( KErrorReplyVerbose ); + } + replyBuffer.Append( iCarriageReturn ); + replyBuffer.Append( iLineFeed ); + } + else + { + if ( aOkReply ) + { + replyBuffer.Append( KOkReplyNumeric ); + } + else + { + replyBuffer.Append( KErrorReplyNumeric ); + } + replyBuffer.Append( iCarriageReturn ); + } + TInt retVal = aReplyBuffer.Create( replyBuffer ); + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Checks if the command is a base, set, read or test type of command +// --------------------------------------------------------------------------- +// +TCmdHandlerType CLcCustomPlugin::CheckCommandType( + const TDesC8& aCmdBase, + const TDesC8& aCmdFull ) + { + TRACE_FUNC_ENTRY + TInt retTemp = KErrNone; + TBuf8 atCmdBuffer; + atCmdBuffer.Copy( aCmdBase ); + // Check "base" command ("AT+COMMAND") + retTemp = aCmdFull.Compare( atCmdBuffer ); + if ( retTemp == 0 ) + { + TRACE_FUNC_EXIT + return ECmdHandlerTypeBase; + } + // Check "read" command ("AT+COMMAND?") + // Add last question mark + atCmdBuffer.Append( '?' ); + retTemp = aCmdFull.Compare( atCmdBuffer ); + if ( retTemp == 0 ) + { + TRACE_FUNC_EXIT + return ECmdHandlerTypeRead; + } + // Check "test" command ("AT+COMMAND=?") + // Add "=" before the question mark + _LIT8( KAssignmentMark, "=" ); + atCmdBuffer.Insert( atCmdBuffer.Length()-1, KAssignmentMark ); + retTemp = aCmdFull.Compare( atCmdBuffer ); + if ( retTemp == 0 ) + { + TRACE_FUNC_EXIT + return ECmdHandlerTypeTest; + } + // Check "set" command ("AT+COMMAND=") + // Remove last question mark + atCmdBuffer.SetLength( atCmdBuffer.Length() - 1 ); + retTemp = aCmdFull.Compare( atCmdBuffer ); + if ( retTemp == 0 ) + { + TRACE_FUNC_EXIT + return ECmdHandlerTypeSet; + } + TRACE_FUNC_EXIT + return ECmdHandlerTypeUndefined; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Returns the array of supported commands +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::GetSupportedCommands( RPointerArray& aCmds ) + { + TRACE_FUNC_ENTRY + // Force superclass call here: + TInt retVal = CATExtPluginBase::GetSupportedCommands( aCmds ); + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Returns plugin's character value settings (from CATExtPluginBase) +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::GetCharacterValue( TCharacterTypes aCharType, + TChar& aChar ) + { + TRACE_FUNC_ENTRY + TInt retVal = KErrNone; + switch ( aCharType ) + { + case ECharTypeCR: + aChar = iCarriageReturn; + break; + case ECharTypeLF: + aChar = iLineFeed; + break; + case ECharTypeBS: + aChar = iBackspace; + break; + default: + retVal = KErrNotFound; + break; + } + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Returns plugin's mode value settings (from CATExtPluginBase) +// --------------------------------------------------------------------------- +// +TInt CLcCustomPlugin::GetModeValue( TModeTypes aModeType, TBool& aMode ) + { + TRACE_FUNC_ENTRY + TInt retVal = KErrNone; + switch ( aModeType ) + { + case EModeTypeQuiet: + aMode = iQuietMode; + break; + case EModeTypeVerbose: + aMode = iVerboseMode; + break; + default: + retVal = KErrNotFound; + break; + } + TRACE_FUNC_EXIT + return retVal; + } diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/lccustomplugin/src/lclistallcmd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/lccustomplugin/src/lclistallcmd.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,239 @@ +/* +* Copyright (c) 2010 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: Handles the commands "AT+CLAC?" and "AT+CLAC" +* +*/ + +#include "lclistallcmd.h" +#include "debug.h" + +const TInt KCrLfLength = 2; // CR+LF +const TInt KOkReplyLength = 6; // CR+LF+"OK"+CR+LF + +_LIT8( KClacCmd, "AT+CLAC" ); + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CLcListAllCmd* CLcListAllCmd::NewL( MLcCustomPlugin* aCallback ) + { + CLcListAllCmd* self = new (ELeave) CLcListAllCmd( aCallback ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CLcListAllCmd::~CLcListAllCmd() + { + } + +// --------------------------------------------------------------------------- +// CLcListAllCmd::CLcListAllCmd +// --------------------------------------------------------------------------- +// +CLcListAllCmd::CLcListAllCmd( MLcCustomPlugin* aCallback ) : + iCallback( aCallback ) + { + iCmdHandlerType = ECmdHandlerTypeUndefined; + } + +// --------------------------------------------------------------------------- +// CLcListAllCmd::ConstructL +// --------------------------------------------------------------------------- +// +void CLcListAllCmd::ConstructL() + { + if ( !iCallback ) + { + User::Leave( KErrGeneral ); + } + } + +// --------------------------------------------------------------------------- +// Checks command types +// --------------------------------------------------------------------------- +// +TBool CLcListAllCmd::CheckCommand( const TDesC8& aCmd ) + { + TRACE_FUNC_ENTRY + // The AT+CLAC command supports two types: base and test + iCmdHandlerType = iCallback->CheckCommandType( KClacCmd, aCmd ); + if ( iCmdHandlerType==ECmdHandlerTypeBase || + iCmdHandlerType==ECmdHandlerTypeTest ) + { + iDetectedCmd = EDetectedCmdCLAC; + TRACE_FUNC_EXIT + return ETrue; + } + TRACE_FUNC_EXIT + return EFalse; + } + +// --------------------------------------------------------------------------- +// Reports the support status of an AT command. This is a synchronous API. +// --------------------------------------------------------------------------- +// +TBool CLcListAllCmd::IsCommandSupported( const TDesC8& aCmd ) + { + TRACE_FUNC_ENTRY + // Set all to undefined if either the command or its type is unknown + // HandleCommand() should be round only when both are set + TBool cmdUnderstood = CheckCommand( aCmd ); + if ( cmdUnderstood ) + { + TRACE_FUNC_EXIT + return ETrue; + } + iCmdHandlerType = ECmdHandlerTypeUndefined; + iDetectedCmd = EDetectedCmdUndefined; + TRACE_FUNC_EXIT + return EFalse; + } + +// --------------------------------------------------------------------------- +// Handles an AT command. Cancelling of the pending request is done by +// HandleCommandCancel(). The implementation in the extension plugin should +// be asynchronous. +// --------------------------------------------------------------------------- +// +void CLcListAllCmd::HandleCommand( const TDesC8& /*aCmd*/, + RBuf8& /*aReply*/, + TBool aReplyNeeded ) + { + TRACE_FUNC_ENTRY + if ( !aReplyNeeded ) + { + TRACE_FUNC_EXIT + return; + } + if ( iCmdHandlerType == ECmdHandlerTypeTest ) + { + iCallback->CreateReplyAndComplete( EReplyTypeOk ); + TRACE_FUNC_EXIT + return; + } + // Else here means ECmdHandlerTypeBase + // First check the quiet mode and verbose mode. + // These are handled in CreateReplyAndComplete() + TInt retTemp; + TBool quietMode = EFalse; + retTemp = iCallback->GetModeValue( EModeTypeQuiet, quietMode ); + if ( retTemp != KErrNone ) + { + iCallback->CreateReplyAndComplete( EReplyTypeError ); + TRACE_FUNC_EXIT + return; + } + RBuf8 reply; + if ( quietMode ) + { + iCallback->CreateReplyAndComplete( EReplyTypeOther, reply ); + reply.Close(); + TRACE_FUNC_EXIT + return; + } + TBool error = CreateSupportedList( reply ); + if ( error ) + { + iCallback->CreateReplyAndComplete( EReplyTypeError ); + reply.Close(); + TRACE_FUNC_EXIT + return; + } + RBuf8 okReply; + iCallback->CreateOkOrErrorReply( okReply, ETrue ); + reply.Append( okReply ); + okReply.Close(); + iCallback->CreateReplyAndComplete( EReplyTypeOther, reply ); + reply.Close(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels a pending HandleCommand request. +// --------------------------------------------------------------------------- +// +void CLcListAllCmd::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Creates a linearized list of supported commands +// --------------------------------------------------------------------------- +// +TBool CLcListAllCmd::CreateSupportedList( RBuf8& aReply ) + { + TRACE_FUNC_ENTRY + // First get the unsorted list from ATEXT + RPointerArray commands; + iCallback->GetSupportedCommands( commands ); + // Next linearize the list for a reply + if ( commands.Count() <= 0 ) + { + commands.Close(); + TRACE_FUNC_EXIT + return EFalse; + } + TInt i; + TInt linearSize = KOkReplyLength; + TInt count = commands.Count(); + for ( i=0; iGetCharacterValue( ECharTypeCR, carriageReturn ); + retTemp |= iCallback->GetCharacterValue( ECharTypeLF, lineFeed ); + if ( retTemp != KErrNone ) + { + commands.ResetAndDestroy(); + commands.Close(); + TRACE_FUNC_EXIT + return ETrue; + } + for ( i=0; i +#include +#include "lccustomplugin.h" + +// --------------------------------------------------------------------------- +// An array of TImplementationProxy objects which onnect each +// implemeation with its instantiation function +// --------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x20021375, CLcCustomPlugin::NewL), // DUN + IMPLEMENTATION_PROXY_ENTRY(0x20021376, CLcCustomPlugin::NewL) // HFP + }; + +// --------------------------------------------------------------------------- +// Exported proxy function to resolve instantiation methods for an Ecom +// plug-in DLL +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,29 @@ +/* +* 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: This file provides the information required for building the +* modem at plugin +* +*/ + +#include + +PRJ_PLATFORMS + +PRJ_EXPORTS +../rom/modematplugin.iby CORE_MW_LAYER_IBY_EXPORT_PATH(modematplugin.iby) + +PRJ_MMPFILES +modematplugin.mmp + +PRJ_TESTMMPFILES diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/group/modematplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/group/modematplugin.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,51 @@ +/* +* 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: Project definition file for project modematplugin +* +*/ + + +#include + +TARGET modematplugin.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x20029FBF + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +SOURCEPATH ../src +SOURCE proxy.cpp +SOURCE modematplugin.cpp +SOURCE atcopscmd.cpp + +START RESOURCE ../src/20029fbf.rss +TARGET modematplugin.rsc +END + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +SYSTEMINCLUDE /epoc32/include/ecom + +LIBRARY ECom.lib +LIBRARY euser.lib +LIBRARY atextpluginbase.lib +LIBRARY etelmm.lib +LIBRARY etel.lib +LIBRARY etelpckt.lib +LIBRARY customapi.lib + +DEBUGLIBRARY flogger.lib diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/inc/atcopscmd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/inc/atcopscmd.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,434 @@ +/* +* 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: Handles the commands "AT+COPS=..." and "AT+COPS?" +* +*/ + + +#ifndef C_CATCOPSCMD_H +#define C_CATCOPSCMD_H + +#include +#include +#include +#include +#include +#include +#include "modematplugin.h" + +class MCmdPluginObserver; +class CRetrieveMobilePhoneDetectedNetworks; + +/** Handler types for the AT commands */ +enum TCmdHandlerType + { + ECmdHandlerTypeUndefined, + ECmdHandlerTypeTest, // For command "AT+COPS=?" + ECmdHandlerTypeRead, // For command "AT+COPS?" + ECmdHandlerTypeSet // For command "AT+COPS=..." + }; + +/** Keeps track of the current operation for the state machine */ +enum TCurrentOperation + { + EIdle = 0, + EInspectModeAndProcessCommand = 1, + EAutomaticallyRegisterToNetwork = 2, + EManuallyRegisterToNetwork = 3, + EManuallyRegisterToNetworkAndChooseAccTech = 4, + EGetNetworkInfoOperatorName = 5, + ESetSystemNetworkBand = 6, + EUpdateAvailableNetworkOperators = 7, + EListAvailableNetworkOperators = 8 + }; + +/** These are in the same order as in 3GPP TS 27.007 V8.4.1 */ +enum TOperatorFormat + { + EFormatLong, + EFormatShort, + EFormatNumeric + }; + +/** These are in the same order as in 3GPP TS 27.007 V8.4.1 */ +enum TNetworkRegistrationMode + { + EModeAutomatic, + EModeManual, + EModeDeregister, + EModeSetFormatParameter, + EModeManualAutomatic, + }; + +/** Currently selected access technology for outgoing replies. +* S60 uses definitions from RMobilePhone class, but they are +* in diffent order and cannot be used directly. +* These are in the same order as in 3GPP TS 27.007 V8.4.1 */ +enum TAccessTechnology + { + EGSM = 0, + EGSMCompact = 1, + EUDMA = 2, + EGSMwithEGPRS = 3, + EHSDPA = 4, + EHSUPA = 5, + EUDMAwithHSDPAandHSUPA = 6, + EAccTechNotSet = 255 + }; + +/** + * Class for handling commands "AT+COPS?" and "AT+COPS=..." + * + * @since TB9.2 + */ +NONSHARABLE_CLASS( CATCOPSCmd ) : public CActive, public CATCommandHandlerBase +{ + +public: + + /** + * Two-phased constructor. + * @param aCallback Callback + * @return Instance of self + */ + static CATCOPSCmd* NewL( MCmdPluginObserver* aCallback ); + + /** + * Destructor. + */ + virtual ~CATCOPSCmd(); + +protected: + /** + * From CActive. Called when asynchronous request completes. + * @since TB9.2 + * @param None + * @return None + */ + virtual void RunL(); + + virtual void DoCancel(); + +private: + + CATCOPSCmd( MCmdPluginObserver* aCallback ); + + void ConstructL(); + + /** + * Reports the support status of an AT command. This is a synchronous API. + * + * @param aCmd The AT command. Its format may vary depending on the + * specification. E.g. in BT HFP case, the command may contain + * a character carriage return () in the end. + * @return ETrue if the command is supported; EFalse otherwise. + */ + TBool IsCommandSupported( const TDesC8& aCmd ); + + /** + * Handles an AT command. Cancelling of the pending request is done by + * HandleCommandCancel(). The implementation in the extension plugin should + * be asynchronous. + * + * The extension plugin which accepts this command is responsible to supply + * the result codes and response and to format result codes properly, e.g. + * in BT HFP case, the format should be + * + * After an extension plugin has handled or decided to reject the given AT + * command, it must inform ATEXT by HandleCommandCompleted() with a proper + * error code. + * + * @since TB9.2 + * @param aCmd The AT command to be handled. Its format may vary depending + * on the specification. E.g. in BT HFP case, the command may + * contain a character carriage return () in the end. + * @param aReply When passed in, contains the built in answer filled by + * ATEXT if it is not empty; when command handling completes + * successfully, contains the result codes and responses to + * this command; Its ownership always belongs to ATEXT, plugin + * may reallocate its space when needed. + * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse, + * the aReply must not contain the reply, otherwise it + * must contain verbose or numeric reply (ATV0/1) or an + * empty string reply (with ATQ). + * @return None + */ + void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + + /** + * Cancels a pending HandleCommand request. + * + * @since TB9.2 + * @return None + */ + void HandleCommandCancel(); + + +private: + + + void HandleCommandTest( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + void HandleCommandRead( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + void HandleCommandSet( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + + void HandleError(); + + /** + * This method parses the parameter part of command and populates + * iParamArray class member. Quotation marks are removed in process. + * + * @since TB9.2 + * @param aCmd The AT command. + * @return Leaves in out of memory case. + */ + void ExtractParametersL(const TDesC8& aCmd); + + /** + * This method strips all quotation parms from the string passed in. + * + * @since TB9.2 + * @param aParameter one parameter from AT command as extracted by ExtractParametersL. + * @return None + */ + void RemoveQuotationMarks(TPtr8& aParameter); + + /** + * This method returns the selected mode in aMode. + * It also checks that there are enough parameters for the mode in question. + * + * @since TB9.2 + * @param aParameter one parameter from AT command as extracted by ExtractParametersL. + * @param aMode contains the converted parameter if method completed successfully. + * @return KErrArgument if mode is invalid or there is not enough parameters. + * KErrNone if iParamArray contains all the parameters the mode requires. + */ + TInt GetModeAndCheckParameterCount(const TDesC8& aParameter, TNetworkRegistrationMode &aMode); + + /** + * This method converts an AT command parameter to numeric format value and checks it is valid. + * + * @since TB9.2 + * @param aParameter one parameter from AT command as extracted by ExtractParametersL. + * @param aFormat contains the converted parameter if method completed successfully. + * @return KErrArgument if format is invalid. + * KErrNone if format is valid. + */ + TInt GetFormatFromParameter(const TDesC8& aParameter, RMmCustomAPI::TOperatorNameType &aFormat); + + /** + * This method converts an AT command parameter to numeric access technology value and checks it is valid. + * + * @since TB9.2 + * @param aParameter one parameter from AT command as extracted by ExtractParametersL. + * @param aAccTech contains the converted parameter if method completed successfully. + * @return KErrArgument if acc. tech. is invalid. + * KErrNone if acc. tech. is valid. + */ + TInt GetAccTechFromParameter(const TDesC8& aParameter, TAccessTechnology &aAccTech); + + /** + * This method converts an AT command parameter to ETel compatible operator values + * + * @since TB9.2 + * @param aDetectedNetworks contains the list of networks. May be NULL. + * @param aFormat contains the format (numeric/text) of operator parameter. + * @param aOperatorParameter contains the operator parameter string. + * @param aMcc contains the converted parameter if method completed successfully. + * @param aMnc contains the converted parameter if method completed successfully. + * @return KErrArgument if operator parameter invalid, + * KErrNotFound if operator list exists but the operator is not in it, + * or the operator list is missing. (Required if aFormat is text.) + * KErrNone if conversion succeeds. aMcc and aMnc contain ETel compatible operator values. + */ + TInt ConvertOperatorToMccMnc(const CMobilePhoneNetworkListV2 *aDetectedNetworks, + const RMmCustomAPI::TOperatorNameType aFormat, + const TBuf& aOperatorParameter, + RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc, + RMobilePhone::TMobilePhoneNetworkIdentity& aMnc); + + /** + * This method initiates an automatic network registration. + * + * @since TB9.2 + * @return None + */ + void AutomaticNetworkRegistration(); + + /** + * This method initiates a manual network registration. + * + * @since TB9.2 + * @param aMcc contains the country code part of ETel operator info. + * @param aMnc contains the network code part of ETel operator info. + * @return None + */ + void ManualNetworkRegistration(const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc, + const RMobilePhone::TMobilePhoneNetworkIdentity& aMnc); + + /** + * This method initiates a manual network registration and access technology selection. + * + * @since TB9.2 + * @param aMcc contains the country code part of ETel operator info. + * @param aMnc contains the network code part of ETel operator info. + * @param aAccTech contains the access technology in ETel compatible format. + * @return None + */ + void ManualNetworkRegistration( const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc, + const RMobilePhone::TMobilePhoneNetworkIdentity& aMnc, + const TAccessTechnology aAccTech); + + /** + * This is a helper function used by RunL + * + * @since TB9.2 + * @return standard Symbian OS return code. + */ + TInt InspectModeAndProcessCommand(); + + /** + * This method contructs a response for the test command. + * + * @since TB9.2 + * @return None. Leaves with standar symbian OS error code on error. + */ + void ConstructNetworkListResponseL(); + + /** + * This method contructs a response for the read command. + * + * @since TB9.2 + * @return standard Symbian OS return code. + */ + TInt ConstructNetworkInfoResponse(); + + /** + * This helper method converts the ETel access technology into + * 3GPP TS 27.007 V8.4.1 compatible format. + * + * @since TB9.2 + * @param aAccTech contains the access technology in ETel compatible format. + * @return Standard Symbian OS return code. + */ + TInt SolveAccessTechnology(RMobilePhone::TMobilePhoneNetworkAccess &aAccessTech); + + /** + * This helper method finalises the response and sends it. + * + * @since TB9.2 + * @param aIsOK tells whether to create an OK or ERROR response. + * @param aReply contains the response string to be sent before OK, if any. + * @return None + */ + void CreateReply(TBool aIsOK, const TDesC8 &aReply = KNullDesC8); + +private: // data + + /** + * Callback to call when accessing plugin information + */ + MCmdPluginObserver* iCallback; + + /** + * Handler type for the three AT commands + */ + TCmdHandlerType iCmdHandlerType; + + /** + * Telephony server instance. + */ + RTelServer iServer; + + /** + * Phone instance, used for network selection. + */ + RMobilePhone iPhone; + + /** + * Telephony Custom API instance, used for setting + * the access technology (only GSM and UDMA supported). + */ + RMmCustomAPI iCustomApi; + + /** + * Current network info collected via the RMobilePhone is stored here. + */ + RMobilePhone::TMobilePhoneNetworkInfoV2 iNetworkInfo; + + /** + * The parameters extracted from the AT command are stored here. + */ + RPointerArray iParamArray; + + /** + * Used for getting the static packet capabilities of the phone. + * This is needed for supporting more detailed access technology. + */ + RPacketService iPacketService; + + /** + * The format of the operator parameter is stored here. + * it is used both for interpreting the incoming operator and + * responding with correctly formatted outgoing operator info. + * this can be done because it is specified that the latest incoming + * format info is also used for responses from that onwards. + */ + RMmCustomAPI::TOperatorNameType iFormat; + + /** + * The requested/current network registration mode is stored here. It is used + * also when responding to the Read command. This can be done because the two + * operations are completely independent. + */ + TNetworkRegistrationMode iRegistrationMode; + + /** + * The requested/current access tehcnology is stored here. It is used + * also when responding to the Read and Test commands. This can be done + * because the operations are completely independent. + */ + TAccessTechnology iAccTech; + + /** + * The incoming reply buffer is kept here. Not owned. + */ + RBuf8* iReply; + + /** + * The currently running operation is kept here. + */ + TCurrentOperation iCurrentOperation; + + /** + * The country code part of ETel compatible operator info. + */ + RMobilePhone::TMobilePhoneNetworkCountryCode iMcc; + + /** + * The network code part of ETel compatible operator info. + */ + RMobilePhone::TMobilePhoneNetworkIdentity iMnc; + + /** + * Used for retrieving a list of networks the phone detected. + */ + CRetrieveMobilePhoneDetectedNetworks *iRetrieveDetectedNetworks; + + /** + * Used for reading the list the CRetrieveMobilePhoneDetectedNetworks returned. + */ + CMobilePhoneNetworkListV2 *iDetectedNetworks; +}; + +#endif // C_LCLISTALLCMD_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/inc/cmdpluginobserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/inc/cmdpluginobserver.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,109 @@ +/* +* 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: Handles the commands "AT+COPS=..." and "AT+COPS?" +* +*/ + + +#ifndef M_CMDPLUGINOBSERVER_H +#define M_CMDPLUGINOBSERVER_H + + +enum TCharacterTypes + { + ECharTypeCR, // Carriage return + ECharTypeLF, // Line feed + ECharTypeBS // Backspace + }; + +enum TModeTypes + { + EModeTypeQuiet, // Quiet mode + EModeTypeVerbose // Verbose mode + }; + + +/** + * Class for accessing plugin information and common functionality + * + * @since S60 v5.0 + */ +NONSHARABLE_CLASS( MCmdPluginObserver ) + { + +public: + + /** + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. Uses iReplyBuffer for reply storage. + * + * @since TB9.2 + * @param aReplyType Type of reply + * @param aDstBuffer Destination buffer; used for the API requiring the + * AT command reply + * @param aSrcBuffer Source buffer; used only if aReplyType is EReplyTypeOther + * @param aError Completion code. If not KErrNone then other arguments are + * ignored and the request is completed to ATEXT with + * EReplyTypeUndefined. + * @return None + */ + virtual TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer=KNullDesC8, + TInt aError=KErrNone ) = 0; + + /** + * Creates a buffer for "OK" or "ERROR" reply based on the line settings + * + * @since TB9.2 + * @param aReplyBuffer Destination buffer for the created reply + * @param aOkReply ETrue if "OK" reply needed, + * EFalse if "ERROR" reply needed + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ) = 0; + + /** + * Returns the array of supported commands + * + * @since TB9.2 + * @param aCmd Array of supported commands + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetSupportedCommands( RPointerArray& aCmds ) = 0; + + /** + * Returns plugin's character value settings (from CATExtPluginBase) + * + * @since TB9.2 + * @param aCharType Character's type + * @param aChar Character's value matching aCharType + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetCharacterValue( TCharacterTypes aCharType, TChar& aChar ) = 0; + + /** + * Returns plugin's mode value settings (from CATExtPluginBase) + * + * @since TB9.2 + * @param aModeType Mode type + * @param aMode Mode value matching aModeType + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetModeValue( TModeTypes aModeType, TBool& aMode ) = 0; + + }; + + +#endif // M_CMDPLUGINOBSERVER_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/inc/debug.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2008 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 definitions +* +*/ + + +#ifndef PRJ_LOGGING_H +#define PRJ_LOGGING_H + +#include +#include "debugconfig.h" + +#ifdef PRJ_ENABLE_TRACE + +#ifdef PRJ_FILE_TRACE +#include +#else +#include +#endif + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TBuf16 theFinalString; + theFinalString.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + theFinalString.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(theFinalString); +#endif + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); +#ifdef PRJ_FILE_TRACE + RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list); +#else + TOverflowTruncate8 overflow; + TBuf8 buf8; + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + TBuf16 buf16(buf8.Length()); + buf16.Copy(buf8); + TRefByValue tmpFmt(_L("%S")); + RDebug::Print(tmpFmt, &buf16); +#endif + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + TBuf8 buf; + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + User::Leave(aReason); + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE_IF_NULL(PTR) {if (!PTR) TraceLeave(__FILE__, __LINE__, PTR);} + +#define LEAVE(REASON) {TraceLeave(__FILE__, __LINE__, REASON);} + +#define TRACE_STATIC_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_STATIC_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncThisFormat8, &ptr8, this);}} + +#define RETURN_IF_ERR(ERR) {if(ERR) {TPtrC8 ptr8((TUint8*)__FILE__); Trace(_L8(" RETURN %d at file %S line %d"), ERR, &ptr8, __LINE__); return ERR;}} + +#else // PRJ_ENABLE_TRACE not defined + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE_IF_NULL(PTR) {static_cast(User::LeaveIfNull(PTR));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_STATIC_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_EXIT + +#define TRACE_STATIC_FUNC + +#define TRACE_FUNC + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} +#endif // PRJ_ENABLE_TRACE + +#endif // PRJ_LOGGING_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/inc/debugconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/inc/debugconfig.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2008 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 configure file +* +*/ + + +#ifndef MODEMATPLUGIN_DEBUGCONFIG_H +#define MODEMATPLUGIN_DEBUGCONFIG_H + +#include "prjconfig.h" + +/** + * Custom logging variations. + */ +#ifdef PRJ_FILE_TRACE +_LIT(KLogFile,"modematplugin.txt"); +_LIT(KLogDir,"MODEMATPLUGIN"); +#endif + +#ifdef PRJ_ENABLE_TRACE +_LIT(KTracePrefix16, "[MODEMATPLUGIN] "); +_LIT8(KTracePrefix8, "[MODEMATPLUGIN] "); +_LIT8(KFuncFormat8, "><%S"); +_LIT8(KFuncThisFormat8, "><%S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, ">%S"); +_LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); +_LIT8(KFuncExitFormat8, "<%S"); + +_LIT(KPanicCategory, "modematplugin"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); +#endif + +const TInt KMaxLogLineLength = 512; + +#define KPRINTERROR 0x00000001 // Tracing level: error +#define KPRINTINFO 0x00000002 // Tracing level: function trace +#define KPRINTSTATE 0x00000004 // Tracing level: state machine info +#define KPRINTWARNING 0x00000008 // Tracing level: warning + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +#endif // MODEMATPLUGIN_DEBUGCONFIG_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/inc/modematplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/inc/modematplugin.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,356 @@ +/* +* 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: Main handler for incoming requests +* +*/ + + +#ifndef C_MODEMATPLUGIN_H +#define C_MODEMATPLUGIN_H + +#include +#include "cmdpluginobserver.h" + + +/** + * Class for common AT command handler interface + * + * @since S60 TB9.2 + */ +NONSHARABLE_CLASS( CATCommandHandlerBase ) + { + +public: + + virtual ~CATCommandHandlerBase() {}; + + /** + * Reports the support status of an AT command. This is a synchronous API. + * + * @param aCmd The AT command. Its format may vary depending on the + * specification. E.g. in BT HFP case, the command may contain + * a character carriage return () in the end. + * @return ETrue if the command is supported; EFalse otherwise. + */ + virtual TBool IsCommandSupported( const TDesC8& aCmd ) = 0; + + /** + * Handles an AT command. Cancelling of the pending request is done by + * HandleCommandCancel(). The implementation in the extension plugin should + * be asynchronous. + * + * The extension plugin which accepts this command is responsible to supply + * the result codes and response and to format result codes properly, e.g. + * in BT HFP case, the format should be + * + * After an extension plugin has handled or decided to reject the given AT + * command, it must inform ATEXT by HandleCommandCompleted() with a proper + * error code. + * + * @since S60 TB9.2 + * @param aCmd The AT command to be handled. Its format may vary depending + * on the specification. E.g. in BT HFP case, the command may + * contain a character carriage return () in the end. + * @param aReply When passed in, contains the built in answer filled by + * ATEXT if it is not empty; when command handling completes + * successfully, contains the result codes and responses to + * this command; Its ownership always belongs to ATEXT, plugin + * may reallocate its space when needed. + * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse, + * the aReply must not contain the reply, otherwise it + * must contain verbose or numeric reply (ATV0/1) or an + * empty string reply (with ATQ). + * @return None + */ + virtual void HandleCommand( const TDesC8& aCmd, + RBuf8& aReply, + TBool aReplyNeeded ) = 0; + + /** + * Cancels a pending HandleCommand request. + * + * @since S60 TB9.2 + * @return None + */ + virtual void HandleCommandCancel() = 0; + + }; + + +/** + * Class for selecting handlers for different AT commands + * + * @since TB9.2 + */ +NONSHARABLE_CLASS( CModemAtPlugin ) : public CATExtPluginBase, public MCmdPluginObserver + { + +public: + + /** + * Two-phased constructor. + * @return Instance of self + */ + static CModemAtPlugin* NewL(); + + /** + * Destructor. + */ + virtual ~CModemAtPlugin(); + +private: + + CModemAtPlugin(); + + void ConstructL(); + + /** + * Reports connection identifier name to the extension plugin. + * + * @since TB9.2 + * @param aName Connection identifier name + * @return None + */ + void ReportConnectionName( const TDesC8& aName ); + + /** + * Reports the support status of an AT command. This is a synchronous API. + * + * @param aCmd The AT command. Its format may vary depending on the + * specification. E.g. in BT HFP case, the command may contain + * a character carriage return () in the end. + * @return ETrue if the command is supported; EFalse otherwise. + */ + TBool IsCommandSupported( const TDesC8& aCmd ); + + /** + * Handles an AT command. Cancelling of the pending request is done by + * HandleCommandCancel(). The implementation in the extension plugin should + * be asynchronous. + * + * The extension plugin which accepts this command is responsible to supply + * the result codes and response and to format result codes properly, e.g. + * in BT HFP case, the format should be + * + * After an extension plugin has handled or decided to reject the given AT + * command, it must inform ATEXT by HandleCommandCompleted() with a proper + * error code. + * + * @since TB9.2 + * @param aCmd The AT command to be handled. Its format may vary depending + * on the specification. E.g. in BT HFP case, the command may + * contain a character carriage return () in the end. + * @param aReply When passed in, contains the built in answer filled by + * ATEXT if it is not empty; when command handling completes + * successfully, contains the result codes and responses to + * this command; Its ownership always belongs to ATEXT, plugin + * may reallocate its space when needed. + * @param aReplyNeeded Reply needed if ETrue, no reply otherwise. If EFalse, + * the aReply must not contain the reply, otherwise it + * must contain verbose or numeric reply (ATV0/1) or an + * empty string reply (with ATQ). + * @return None + */ + void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + + /** + * Cancels a pending HandleCommand request. + * + * @since TB9.2 + * @return None + */ + void HandleCommandCancel(); + + /** + * Next reply part's length. + * The value must be equal or less than KDefaultCmdBufLength. + * When the reply from this method is zero, ATEXT stops calling + * GetNextPartOfReply(). + * + * @since TB9.2 + * @return Next reply part's length if zero or positive + */ + TInt NextReplyPartLength(); + + /** + * Gets the next part of reply initially set by HandleCommandComplete(). + * Length of aNextReply must be equal or less than KDefaultCmdBufLength. + * + * @since TB9.2 + * @param aNextReply Next reply + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetNextPartOfReply( RBuf8& aNextReply ); + + /** + * Receives unsolicited results. Cancelling of the pending request is done + * by ReceiveUnsolicitedResultCancel(). The implementation in the extension + * plugin should be asynchronous. + * + * @since TB9.2 + * @return None + */ + void ReceiveUnsolicitedResult(); + + /** + * Cancels a pending ReceiveUnsolicitedResult request. + * + * @since TB9.2 + * @return None + */ + void ReceiveUnsolicitedResultCancel(); + + /** + * Reports NVRAM status change to the plugins. + * + * @since TB9.2 + * @param aNvram New NVRAM status. Each call of this function is a result + * of DUN extracting the form notified by + * CATExtCommonBase::SendNvramStatusChange(). Each of the + * settings from SendNvramStatusChange() is separated to + * one call of ReportNvramStatusChange(). + * @return None + */ + void ReportNvramStatusChange( const TDesC8& aNvram ); + + /** + * Reports about external handle command error condition. + * This is for cases when for example DUN decided the reply contained an + * error condition but the plugin is still handling the command internally. + * Example: in command line "AT+TEST;ATDT1234" was given. "AT+TEST" returns + * "OK" and "ATDT" returns "CONNECT". Because "OK" and "CONNECT" are + * different reply types the condition is "ERROR" and DUN ends processing. + * This solution keeps the pointer to the last AT command handling plugin + * inside ATEXT and calls this function there to report the error. + * It is to be noted that HandleCommandCancel() is not sufficient to stop + * the processing as the command handling has already finished. + * + * @since TB9.2 + * @return None + */ + void ReportExternalHandleCommandError(); + + /** + * Creates part of reply from the global reply buffer to the destination + * buffer. Used with APIs which need the next part of reply in multipart + * reply requests. + * + * @since TB9.2 + * @param aDstBuffer Destination buffer; the next part of reply is stored to + * this buffer. + * @return None + */ + TInt CreatePartOfReply( RBuf8& aDstBuffer ); + +// from base class MCmdPluginObserver + + /** + * From MCmdPluginObserver. + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. Uses iReplyBuffer for reply storage. + * + * @since TB9.2 + * @param aReplyType Type of reply + * @param aDstBuffer Destination buffer; used for the API requiring the + * AT command reply + * @param aSrcBuffer Source buffer; used only if aReplyType is EReplyTypeOther + * @param aError Completion code. If not KErrNone then other arguments are + * ignored and the request is completed to ATEXT with + * EReplyTypeUndefined. + * @return None + */ + TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer=KNullDesC8, + TInt aError=KErrNone ); + + /** + * From MCmdPluginObserver. + * Creates a buffer for "OK" or "ERROR" reply based on the line settings + * + * @since TB9.2 + * @param aReplyBuffer Destination buffer for the created reply + * @param aOkReply ETrue if "OK" reply needed, + * EFalse if "ERROR" reply needed + * @return Symbian error code on error, KErrNone otherwise + */ + TInt CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ); + + /** + * From MCmdPluginObserver. + * Returns the array of supported commands + * + * @since TB9.2 + * @param aCmd Array of supported commands + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetSupportedCommands( RPointerArray& aCmds ); + + /** + * From MCmdPluginObserver. + * Returns plugin's character value settings (from CATExtPluginBase) + * + * @since TB9.2 + * @param aCharType Character's type + * @param aChar Character's value matching aCharType + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetCharacterValue( TCharacterTypes aCharType, TChar& aChar ); + + /** + * From MCmdPluginObserver. + * Returns plugin's mode value settings (from CATExtPluginBase) + * + * @since TB9.2 + * @param aModeType Mode type + * @param aMode Mode value matching aModeType + * @return Symbian error code on error, KErrNone otherwise + */ + TInt GetModeValue( TModeTypes aModeType, TBool& aMode ); + +private: // data + + /** + * AT commands handler array. Used for mapping HandleCommand() to + * IsCommandSupported() and to limit the number of string comparisons. + */ + RPointerArray iHandlers; + + /** + * Current AT command handler in iHandlers. + * Used when IsCommandSupported() detects a matching handler class. + */ + CATCommandHandlerBase* iHandler; + + /** + * Buffer for handle command's command + * Not own. + */ + const TDesC8* iHcCmd; + + /** + * Buffer for handle command reply + * Not own. + */ + RBuf8* iHcReply; + + + /** + * Global reply buffer for the AT command replies + */ + RBuf8 iReplyBuffer; + + }; + +#endif // C_MODEMPLUGIN_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/inc/prjconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/inc/prjconfig.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2008 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: Project configure file +* +*/ + + +#ifndef MODEMATPLUGIN_PRJCONFIG_H +#define MODEMATPLUGIN_PRJCONFIG_H + +/** + * Traces are enabled in _DEBUG build, by default. + */ +#ifdef _DEBUG +#define PRJ_ENABLE_TRACE +#endif + +/** + * traces to file if this is defined. + */ +//#define PRJ_FILE_TRACE + + +/** + * build the project for module test purpose if this is defined + */ +//#define PRJ_MODULETEST_BUILD + +/** + * build the project using stubs to replace the dependencies if this is defined + */ +//#define PRJ_USE_STUB + + +#endif // MODEMATPLUGIN_PRJCONFIG_H diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/rom/modematplugin.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/rom/modematplugin.iby Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,24 @@ +/* +* 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: Image description file for project modematplugin +* +*/ + + +#ifndef __MODEMATPLUGIN_IBY__ +#define __MODEMATPLUGIN_IBY__ + +ECOM_PLUGIN( modematplugin.dll, modematplugin.rsc ) + +#endif diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/src/20029fbf.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/src/20029fbf.rss Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,47 @@ +/* +* 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: Resource definitions for project modematplugin +* +*/ + + +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x20029FBF; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001CBEE; // ATEXT_INTERFACE_DUN_UID + implementations = + { + // Info for modematplugin + IMPLEMENTATION_INFO + { + implementation_uid = 0x2002B3EB; + version_no = 1; + display_name = "Modem AT Plugin"; + default_data= "MAT+COPS"; + opaque_data = ""; + } + }; + } + }; + } diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/src/atcopscmd.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/src/atcopscmd.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,1120 @@ +/* +* 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: Handles the commands "AT+COPS?", "AT+COPS=?" and "AT+COPS=..." +* +*/ + + +#include +#include "atcopscmd.h" +#include "cmdpluginobserver.h" +#include "debug.h" + +_LIT8( KCOPSTestCmd, "AT+COPS=?"); +_LIT8( KCOPSReadCmd, "AT+COPS?"); +_LIT8( KCOPSSetCmd, "AT+COPS="); + +_LIT8(KSupportedModesStr, ",(0,1,3,4)"); +_LIT8(KSupportedFormatsStr, ",(0,1,2)"); + +// The parameters are in predefined indexes in an incoming AT command. +const TInt KModeParameterIndex = 0; +const TInt KFormatParameterIndex = 1; +const TInt KOperatorParameterIndex = 2; +const TInt KAccessTechnologyParameterIndex = 3; + +const TInt KMinimumParameterCountWhenModePresent = 1; +const TInt KMinimumParameterCountWhenFormatPresent = 2; +const TInt KMinimumParameterCountWhenOperatorPresent = 3; +const TInt KMinimumParameterCountWhenAccTechPresent = 4; + +// These parameter lengths are derived from 3GPP TS 27.007 V8.4.1 +const TInt KShortOperatorNameFormatLength = 10; +const TInt KLongOperatorNameFormatLength = 20; +const TInt KNumericOperatorNameFormatLength = 5; +const TInt KMaxNetworkTestResponseAdditionalSize = 17; // The maximun length of parts of fixed length. +const TInt KMaxNetworkReadResponseAdditionalSize = 28 ; // The maximun length of parts fixed length. + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CATCOPSCmd* CATCOPSCmd::NewL( MCmdPluginObserver* aCallback ) + { + CATCOPSCmd* self = new (ELeave) CATCOPSCmd( aCallback ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CATCOPSCmd::~CATCOPSCmd() + { + iParamArray.ResetAndDestroy(); + iParamArray.Close(); + iPacketService.Close(); + iCustomApi.Close(); + iPhone.Close(); + iServer.Close(); + delete iDetectedNetworks; + delete iRetrieveDetectedNetworks; + } + +// --------------------------------------------------------------------------- +// CATCOPSCmd::CATCOPSCmd +// --------------------------------------------------------------------------- +// +CATCOPSCmd::CATCOPSCmd( MCmdPluginObserver* aCallback ) : + CActive(EPriorityStandard), + iCallback( aCallback ), + iFormat(RMmCustomAPI::EOperatorNameMccMnc), + iRegistrationMode(EModeAutomatic), + iAccTech(EAccTechNotSet), + iCurrentOperation(EIdle) + { + iCmdHandlerType = ECmdHandlerTypeUndefined; + } + +// --------------------------------------------------------------------------- +// CATCOPSCmd::ConstructL +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::ConstructL() + { + if ( !iCallback ) + { + User::Leave( KErrGeneral ); + } + CActiveScheduler::Add(this); + LEAVE_IF_ERROR(iServer.Connect()); + LEAVE_IF_ERROR(iServer.LoadPhoneModule(KMmTsyModuleName)); + LEAVE_IF_ERROR(iPhone.Open(iServer, KMmTsyPhoneName)); + LEAVE_IF_ERROR(iCustomApi.Open(iPhone)); + LEAVE_IF_ERROR(iPacketService.Open(iPhone)); + iRetrieveDetectedNetworks = CRetrieveMobilePhoneDetectedNetworks::NewL(iPhone); + } + +// --------------------------------------------------------------------------- +// Reports the support status of an AT command. This is a synchronous API. +// --------------------------------------------------------------------------- +// +TBool CATCOPSCmd::IsCommandSupported( const TDesC8& aCmd ) + { + TRACE_FUNC_ENTRY + TInt retTemp = KErrNone; + + // First test if "test" command, because the pattern is similar with the "set" command, + // this is just one extra question mark longer than that. + retTemp = aCmd.Compare( KCOPSTestCmd ); + if ( retTemp == 0 ) + { + iCmdHandlerType = ECmdHandlerTypeTest; + TRACE_FUNC_EXIT + return ETrue; + } + + retTemp = aCmd.Compare( KCOPSReadCmd ); + if ( retTemp == 0 ) + { + iCmdHandlerType = ECmdHandlerTypeRead; + TRACE_FUNC_EXIT + return ETrue; + } + + // Test if the beginning matches the test command pattern. We're skipping parameters + // here on purpose, because "set" handler will create an error reply later if + // parameters are not valid. + retTemp = aCmd.Left(KCOPSSetCmd().Length()).Compare(KCOPSSetCmd); + if ( retTemp == 0 ) + { + iCmdHandlerType = ECmdHandlerTypeSet; + TRACE_FUNC_EXIT + return ETrue; + } + + iCmdHandlerType = ECmdHandlerTypeUndefined; + TRACE_FUNC_EXIT + return EFalse; + } + +// --------------------------------------------------------------------------- +// Handles an AT command. Cancelling of the pending request is done by +// HandleCommandCancel(). The implementation in the extension plugin should +// be asynchronous. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::HandleCommand( const TDesC8& aCmd, + RBuf8& aReply, + TBool aReplyNeeded ) + { + TRACE_FUNC_ENTRY + + if ( !aReplyNeeded ) + { + TRACE_FUNC_EXIT + return; + } + + if(iCurrentOperation != EIdle) + { + // only one call at time allowed. If another one is passed in, + // then cancel the previous and reply with an error. + HandleCommandCancel(); + CreateReply(EFalse); + } + + if ( iCmdHandlerType == ECmdHandlerTypeUndefined ) + { + CreateReply(EFalse); + } + + if ( iCmdHandlerType == ECmdHandlerTypeTest ) + { + // Collect network data and complete in RunL + iRetrieveDetectedNetworks->StartV2(iStatus); + iCurrentOperation = EListAvailableNetworkOperators; + SetActive(); + TRACE_FUNC_EXIT + return; + } + +/* +Read command returns the current mode, the currently selected operator +and the current Access Technology. If no operator is selected, , + and < AcT> are omitted. +*/ + if ( iCmdHandlerType == ECmdHandlerTypeRead ) + { + // Collect data in two steps. First read operator name. Continue in RunL() + RMobilePhone::TMobilePhoneNetworkSelectionV1 selection; + RMobilePhone::TMobilePhoneNetworkSelectionV1Pckg nwSelectionSetting(selection); + iPhone.GetNetworkSelectionSetting(nwSelectionSetting); + switch(selection.iMethod) + { + case RMobilePhone::ENetworkSelectionAutomatic: + iRegistrationMode = EModeAutomatic; + break; + case RMobilePhone::ENetworkSelectionManual: + iRegistrationMode = EModeManual; + break; + default: + // Cannot get a known selection mode! + TRACE_INFO(_L("CATCOPSCmd::HandleCommand() -- Cannot get a known selection mode!")); + CreateReply(EFalse); + TRACE_FUNC_EXIT + return; + } + RMobilePhone::TMobilePhoneNetworkInfoV2Pckg nwInfo(iNetworkInfo); + iPhone.GetCurrentNetwork(iStatus, nwInfo); + iCurrentOperation = EGetNetworkInfoOperatorName; + SetActive(); + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() starting operation (%d)"), iCurrentOperation)); + TRACE_FUNC_EXIT + return; + } + + // Getting this far means ECmdHandlerTypeSet. There must be parameter(s), too. + TRAPD(err, ExtractParametersL(aCmd)); + + // Check that we got some parameters, at least the "mode". If not, return an error: + if(iParamArray.Count() < KMinimumParameterCountWhenModePresent) + { + // Return error response, there were no parameters! + TRACE_INFO(_L("CATCOPSCmd::HandleCommand() -- no parameters!")); + CreateReply(EFalse); + TRACE_FUNC_EXIT + return; + } + + // At least the mode parameter is present at this point. Inspect it and check other parameters. + TNetworkRegistrationMode mode; + err = GetModeAndCheckParameterCount(iParamArray[KModeParameterIndex]->Des(), mode); + if(err != KErrNone) + { + // Return error response, invalid mode or other parameters! + TRACE_INFO(_L("CATCOPSCmd::HandleCommand() -- invalid mode or other parameters!")); + CreateReply(EFalse); + TRACE_FUNC_EXIT + return; + } + + // At this point the iRegistrationMode is stored and the parameters are valid. + iRegistrationMode = mode; + TRACE_INFO(( _L("CATCOPSCmd::HandleCommand() mode stored (%d)"), iRegistrationMode)); + + if(iParamArray.Count() > 1) + { + // If also format is present, extract it and store for later reference. + RMmCustomAPI::TOperatorNameType format; + err = GetFormatFromParameter(iParamArray[KFormatParameterIndex]->Des(), format); + if(err != KErrNone) + { + // Return an error, invalid format. + // Previously set format is still in use. + TRACE_INFO(_L("CATCOPSCmd::HandleCommand() -- invalid format!")); + CreateReply(EFalse); + TRACE_FUNC_EXIT + return; + } + // Format parameter is OK, keep it. + iFormat = format; + TRACE_INFO(( _L("CATCOPSCmd::HandleCommand() format stored (%d)"), iFormat)); + } + + // We're done with the required parameters, it's time to start processing the command. + // So do a self complete and continue in RunL(): + iReply = &aReply; // Store the reply for later reference in RunL. + iCurrentOperation = EInspectModeAndProcessCommand; + TRequestStatus *status = &iStatus; + User::RequestComplete(status, KErrNone); + SetActive(); + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() starting operation (%d)"), iCurrentOperation)); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Parses the aCmd parameter and stores results in iParamArray. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::ExtractParametersL(const TDesC8& aCmd) + { + TRACE_FUNC_ENTRY + + TRACE_INFO(( _L8("CATCOPSCmd::ExtractParameters() extracting (%S)"), &aCmd)); + + TPtrC8 parameters = aCmd.Right(aCmd.Length() - KCOPSSetCmd().Length()); + + iParamArray.ResetAndDestroy(); + + // Parse the parameters into the parameter array: + TInt separatorPos; + while((separatorPos = parameters.Locate(',')) != KErrNotFound) + { + TRACE_INFO(( _L("CATCOPSCmd::ExtractParameters() separator position (%d)"), separatorPos)); + TPtrC8 param = parameters.Left(separatorPos); + parameters.Set(parameters.Right(parameters.Length() - (separatorPos + 1))); // Remove the extracted part + separator + HBufC8 *heapParam = param.AllocL(); + CleanupStack::PushL( heapParam ); + // Strip the quotation marks from the parameter: + TPtr8 ptr = heapParam->Des(); + RemoveQuotationMarks(ptr); + TRACE_INFO(( _L8("CATCOPSCmd::ExtractParameters() appending (%S)"), &ptr)); + iParamArray.Append(heapParam); + CleanupStack::Pop( heapParam ); + } + + // Finally append the last piece of parameters: + HBufC8 *param = parameters.AllocL(); + CleanupStack::PushL( param ); + TPtr8 ptr = param->Des(); + RemoveQuotationMarks(ptr); + TRACE_INFO(( _L8("CATCOPSCmd::ExtractParameters() appending (%S)"), &ptr)); + iParamArray.Append(param); + CleanupStack::Pop( param ); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Strips all quotation parms from the string passed in. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::RemoveQuotationMarks(TPtr8& aParameter) + { + TRACE_FUNC_ENTRY + // Strip the quotation marks from the parameter: + TInt quotePos; + while((quotePos = aParameter.Locate('"')) != KErrNotFound) + { + aParameter.Delete(quotePos,1); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Returns the selected mode in aMode and checks the parameter count. +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::GetModeAndCheckParameterCount(const TDesC8& aParameter, TNetworkRegistrationMode &aMode) + { + TRACE_FUNC_ENTRY + TLex8 lex; + lex.Assign(aParameter); + TInt mode(0); + + TInt err = lex.Val(mode); + TRACE_INFO(( _L("CATCOPSCmd::GetModeAndCheckParameterCount() mode (%d)"), mode)); + + if( err != KErrNone ) + { + TRACE_INFO(_L("CATCOPSCmd::GetModeAndCheckParameterCount() TLex error!)")); + TRACE_FUNC_EXIT + return KErrArgument; + } + + if(mode < EModeAutomatic || mode > EModeManualAutomatic || mode == EModeDeregister) + { + // Not a valid mode. + TRACE_FUNC_EXIT + return KErrArgument; + } + + if( (mode == EModeManual || mode == EModeManualAutomatic) && iParamArray.Count() < KMinimumParameterCountWhenOperatorPresent ) + { + // Valid modes but not enough parameters. At least format and operator needed. + TRACE_INFO(( _L("CATCOPSCmd::GetModeAndCheckParameterCount() not enough parameters (%d)"), iParamArray.Count())); + TRACE_FUNC_EXIT + return KErrArgument; + } + if( mode == EModeSetFormatParameter && iParamArray.Count() < KMinimumParameterCountWhenFormatPresent ) + { + // Valid mode, but not enough parameters. Format is needed. + TRACE_INFO(_L("CATCOPSCmd::GetModeAndCheckParameterCount() no format parameter)")); + TRACE_FUNC_EXIT + return KErrArgument; + } + + // Valid mode and enough parameters. + aMode = static_cast(mode); + + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Converts an AT command parameter to numeric format value and checks it is valid. +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::GetFormatFromParameter(const TDesC8& aParameter, RMmCustomAPI::TOperatorNameType &aFormat) + { + TRACE_FUNC_ENTRY + TLex8 lex; + lex.Assign(aParameter); + TInt format(0); + TInt err = lex.Val(format); + + if(err != KErrNone) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + switch(format) + { + case EFormatLong: // long by 3GPP TS 27.007 V8.4.1 + TRACE_INFO(_L("Format is long by 3GPP TS 27.007 V8.4.1")); + aFormat = RMmCustomAPI::EOperatorNameNitzFull; + break; + case EFormatShort: // short by 3GPP TS 27.007 V8.4.1 + TRACE_INFO(_L("Format is short by 3GPP TS 27.007 V8.4.1")); + aFormat = RMmCustomAPI::EOperatorNameNitzShort; + break; + case EFormatNumeric: // numeric by 3GPP TS 27.007 V8.4.1 + TRACE_INFO(_L("Format is numeric by 3GPP TS 27.007 V8.4.1")); + aFormat = RMmCustomAPI::EOperatorNameMccMnc; + // Operator is numeric, conver it into S60 style. + break; + default: + TRACE_FUNC_EXIT + return KErrArgument; + } + + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Converts an AT command parameter to numeric access technology value and checks it is valid. +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::GetAccTechFromParameter(const TDesC8& aParameter, TAccessTechnology& aAccTech) + { + TRACE_FUNC_ENTRY + TLex8 lex; + lex.Assign(aParameter); + TInt accTech(0); + TInt err = lex.Val(accTech); + + if(err != KErrNone) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + if(accTech != EGSM && accTech != EUDMA) // The only allowed access technologies. + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + aAccTech = static_cast(accTech); + + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Converts an AT command parameter to ETel compatible operator values +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::ConvertOperatorToMccMnc(const CMobilePhoneNetworkListV2 *aDetectedNetworks, + const RMmCustomAPI::TOperatorNameType aFormat, + const TBuf& aOperatorParameter, + RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc, + RMobilePhone::TMobilePhoneNetworkIdentity& aMnc) + { + TRACE_FUNC_ENTRY + + if(aFormat == RMmCustomAPI::EOperatorNameMccMnc) + { + // Check first that there are at least five characters passed in. + TChar nextChar; + if(aOperatorParameter.Length() < 5) + { + return KErrArgument; + } + for(int i = 0; i < 5; ++i) + { + nextChar = aOperatorParameter[i]; + if(!nextChar.IsDigit()) + { + return KErrArgument; + } + } + // Operator is in three digit country code + two digit network code format. + // Must be converted to ETel style. The possible extra will be simply discarded. + TRACE_INFO(_L("CATCOPSCmd::ConvertOperatorToMccMnc() operator is all digits, convert it into ETel data types.")); + aMcc.Copy(aOperatorParameter.Left(3)); + aMnc.Copy(aOperatorParameter.Right(2)); + } + else // The short or long text string formats. + { + // Find the requested operator from the operator array. + // If array is empty, return an error. + if(!aDetectedNetworks) + { + TRACE_INFO(_L("CATCOPSCmd::ConvertOperatorToMccMnc() No detected networks!")); + TRACE_FUNC_EXIT + return KErrNotFound; + } + + RMobilePhone::TMobilePhoneNetworkInfoV2 nwInfo; + for(TInt i=0; i < iDetectedNetworks->Enumerate(); ++i) + { + TRAPD(err, nwInfo = iDetectedNetworks->GetEntryL(i)) + if(err != KErrNone) + { + return KErrNotFound; + } + + if(aFormat == RMmCustomAPI::EOperatorNameNitzShort) + { + TRACE_INFO(_L("CATCOPSCmd::ConvertOperatorToMccMnc() Operator is in short format, comparing.")); + if(nwInfo.iShortName.Compare(aOperatorParameter) == 0) + { + TRACE_INFO(_L("Match found.")); + aMcc = nwInfo.iCountryCode; + aMnc = nwInfo.iNetworkId; + TRACE_FUNC_EXIT + return KErrNone; + } + } + else if(aFormat == RMmCustomAPI::EOperatorNameNitzFull) + { + TRACE_INFO(_L("CATCOPSCmd::ConvertOperatorToMccMnc() Operator is in long format, comparing.")); + if(nwInfo.iLongName.Compare(aOperatorParameter) == 0) + { + TRACE_INFO(_L("Match found.")); + aMcc = nwInfo.iCountryCode; + aMnc = nwInfo.iNetworkId; + TRACE_FUNC_EXIT + return KErrNone; + } + } + else + { + TRACE_INFO(_L("CATCOPSCmd::ConvertOperatorToMccMnc() Unknown operator format!")); + TRACE_FUNC_EXIT + return KErrArgument; + } + } + TRACE_INFO(_L("CATCOPSCmd::ConvertOperatorToMccMnc() Operator was not found in list!")); + TRACE_FUNC_EXIT + return KErrNotFound; + } + + TRACE_FUNC_EXIT + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// Initiates an automatic network registration. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::AutomaticNetworkRegistration() + { + TRACE_FUNC_ENTRY + RMobilePhone::TMobilePhoneNetworkManualSelection nwInfo; + iCurrentOperation = EAutomaticallyRegisterToNetwork; + nwInfo.iCountry = KNullDesC; + nwInfo.iNetwork = KNullDesC; + iPhone.SelectNetwork(iStatus, EFalse, nwInfo); + SetActive(); // Response will be sent in RunL + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() starting operation (%d)"), iCurrentOperation)); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initiates a manual network registration. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::ManualNetworkRegistration(const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc, + const RMobilePhone::TMobilePhoneNetworkIdentity& aMnc) + { + TRACE_FUNC_ENTRY + RMobilePhone::TMobilePhoneNetworkManualSelection nwInfo; + iCurrentOperation = EManuallyRegisterToNetwork; + nwInfo.iCountry.Append(aMcc); + nwInfo.iNetwork.Append(aMnc); + iPhone.SelectNetwork(iStatus, ETrue, nwInfo); + SetActive(); // Response will be sent in RunL + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() starting operation (%d)"), iCurrentOperation)); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initiates a manual network registration and access technology selection. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::ManualNetworkRegistration(const RMobilePhone::TMobilePhoneNetworkCountryCode& aMcc, + const RMobilePhone::TMobilePhoneNetworkIdentity& aMnc, + const TAccessTechnology aAccTech) + { + TRACE_FUNC_ENTRY + // Store access technology for later reference: + iAccTech = aAccTech; + // Call another overload to start the first phase of the operation: + ManualNetworkRegistration(aMcc, aMnc); + // Set the state again so the RunL knows to launch the next phase: + iCurrentOperation = EManuallyRegisterToNetworkAndChooseAccTech; + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() starting operation (%d)"), iCurrentOperation)); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CATCOPSCmd::RunL +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::RunL() + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + if(iStatus != KErrNone) + { + HandleError(); + TRACE_FUNC_EXIT + return; + } + // Proceed to next step or return a response if all is done. + switch(iCurrentOperation) + { + case EListAvailableNetworkOperators: + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() completing operation (%d)"), iCurrentOperation)); + if(iDetectedNetworks) + { + delete iDetectedNetworks; + iDetectedNetworks = NULL; + } + iDetectedNetworks = iRetrieveDetectedNetworks->RetrieveListV2L(); + // Then create a response. + TRAP(err, ConstructNetworkListResponseL()); + if(err != KErrNone) + { + // An error here means that no response has been sent. Reply with an error. + CreateReply(EFalse); + } + break; + + case EInspectModeAndProcessCommand: + // Check the mode and act accordingly + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() completing operation (%d)"), iCurrentOperation)); + err = InspectModeAndProcessCommand(); + if(err != KErrNone) + { + CreateReply(EFalse); + } + break; + + case EGetNetworkInfoOperatorName: + if(ConstructNetworkInfoResponse() != KErrNone) + { + // An error means that no response has been sent. Reply with an error. + CreateReply(EFalse); + } + break; + + case EManuallyRegisterToNetworkAndChooseAccTech: + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() completing operation (%d)"), iCurrentOperation)); + switch(iAccTech) + { + case EGSM: + iCustomApi.SetSystemNetworkMode(iStatus, RMmCustomAPI::KCapsNetworkModeGsm); + iCurrentOperation = ESetSystemNetworkBand; + SetActive(); + break; + case EUDMA: + iCustomApi.SetSystemNetworkMode(iStatus, RMmCustomAPI::KCapsNetworkModeUmts); + iCurrentOperation = ESetSystemNetworkBand; + SetActive(); + break; + default: + // No automatic registering requested, so send back an error response. + TRACE_INFO( _L("CATCOPSCmd::RunL() incorrect acc.tech., reply an error.")); + CreateReply(EFalse); + } + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() starting operation (%d)"), iCurrentOperation)); + break; + + case EManuallyRegisterToNetwork: + case EAutomaticallyRegisterToNetwork: + case ESetSystemNetworkBand: + TRACE_INFO((_L("CATCOPSCmd::HandleCommand() completing operation (%d)"), iCurrentOperation)); + // Last step completed successfully, so create OK response. + CreateReply(ETrue); + break; + + default: + TRACE_INFO(( _L("CATCOPSCmd::RunL() default operation (%d)!"), iCurrentOperation)); + break; + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Handles an error in async call. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::HandleError() + { + TRACE_FUNC_ENTRY + TRACE_INFO(( _L("CATCOPSCmd::RunL() failure (%d) in operation (%d)!"), iStatus.Int(), iCurrentOperation)); + + // In case of failure check the operation. In some cases failures are OK. + switch(iCurrentOperation) + { + case EManuallyRegisterToNetwork: + if(iRegistrationMode == EModeManualAutomatic) + { + // Manual registration failed, try automatic next. + TRACE_INFO( _L("CATCOPSCmd::RunL() registration mode manual automatic, try automatic.")); + AutomaticNetworkRegistration(); + } + else + { + // No automatic registering requested, so send back an error response. + TRACE_INFO( _L("CATCOPSCmd::RunL() reply an error.")); + CreateReply(EFalse); + } + break; + case ESetSystemNetworkBand: + case EManuallyRegisterToNetworkAndChooseAccTech: + if(iRegistrationMode == EModeManualAutomatic) + { + // Manual registration failed, try automatic next. + TRACE_INFO( _L("CATCOPSCmd::RunL() registration mode manual automatic, try automatic.")); + AutomaticNetworkRegistration(); + break; + } + else + { + // Cannot set the access technology, so set it back to EAccTechNotSet. + // This prevents replying to queries with outdated or incorrect acc tech information. + TRACE_INFO( _L("CATCOPSCmd::RunL() couldn't set system network band, so reset access tech.")); + iAccTech = EAccTechNotSet; + // Fall through to default, because these require an error response. + } + default: + // In all other cases send back an error response. + TRACE_INFO( _L("CATCOPSCmd::RunL() reply an error.")); + CreateReply(EFalse); + break; + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Cancels a pending HandleCommand request. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CATCOPSCmd::DoCancel +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::DoCancel() + { + TRACE_FUNC_ENTRY + switch(iCurrentOperation) + { + case EAutomaticallyRegisterToNetwork: + case EManuallyRegisterToNetwork: + case EManuallyRegisterToNetworkAndChooseAccTech: + iPhone.CancelAsyncRequest(EMobilePhoneSelectNetworkCancel); + break; + case EGetNetworkInfoOperatorName: + iPhone.CancelAsyncRequest(EMobilePhoneGetCurrentNetworkCancel); + break; + case ESetSystemNetworkBand: + iCustomApi.CancelAsyncRequest(ECustomSetSystemNetworkModeIPC); + break; + case EListAvailableNetworkOperators: + iRetrieveDetectedNetworks->Cancel(); + break; + default: + break; + } + + iCurrentOperation = EIdle; + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Helper method for RunL() +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::InspectModeAndProcessCommand() + { + TRACE_FUNC_ENTRY + TBuf buf; + TInt err; + + switch (iRegistrationMode) + { + case EModeAutomatic: + AutomaticNetworkRegistration(); + break; + case EModeManual: + case EModeManualAutomatic: // see also RunL() + if(iParamArray.Count() < KMinimumParameterCountWhenOperatorPresent) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + // At least the operator is present, so convert it into S60 format. + buf.Copy(iParamArray[KOperatorParameterIndex]->Des()); + err = ConvertOperatorToMccMnc(iDetectedNetworks, iFormat, buf, iMcc, iMnc); + if(err != KErrNone) + { + TRACE_INFO(_L("CATCOPSCmd::HandleCommand() -- operator conversion failed!")); + TRACE_FUNC_EXIT + return KErrArgument; + } + + if (iParamArray.Count() >= KMinimumParameterCountWhenAccTechPresent) + { + // Also access tech. is present. Convert it to ETel compatible value. + TAccessTechnology accTech; + TInt err = GetAccTechFromParameter(iParamArray[KAccessTechnologyParameterIndex]->Des(), accTech); + if(err != KErrNone) + { + // Parameter problem, return an error. + TRACE_FUNC_EXIT + return KErrArgument; + } + // Register both operator and access technology manually. + ManualNetworkRegistration(iMcc, iMnc, accTech); + } + else + { + // No access technology parameter, so register just the operator. + ManualNetworkRegistration(iMcc, iMnc); + } + break; + case EModeDeregister: // Deregister from network + // Not supported, return an error. + TRACE_FUNC_EXIT + return KErrArgument; + case EModeSetFormatParameter: + // Storing format parameter was done already, so just reply OK. + CreateReply(ETrue); + TRACE_FUNC_EXIT + return KErrNone; + default: + return KErrArgument; + } + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Converts the ETel access technology into 3GPP TS 27.007 V8.4.1 compatible format. +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::SolveAccessTechnology(RMobilePhone::TMobilePhoneNetworkAccess &aAccessTech) + { + TRACE_FUNC_ENTRY + + TUint caps; + if(iPacketService.GetStaticCaps(caps, RPacketContext::EPdpTypePPP) != KErrNone) + { + TRACE_FUNC_EXIT + return KErrGeneral; + } + + TRACE_INFO(( _L8("CATCOPSCmd::SolveAccessTechnology() static caps gotten (%b)"), caps)); + + switch(aAccessTech) + { + case RMobilePhone::ENetworkAccessGsm: + if(caps & RPacketService::KCapsEGPRSSupported) + { + iAccTech = EGSMwithEGPRS; + } + else + { + iAccTech = EGSM; + } + break; + case RMobilePhone::ENetworkAccessGsmCompact: + iAccTech = EGSMCompact; + break; + case RMobilePhone::ENetworkAccessUtran: + if(caps & RPacketService::KCapsHSDPASupported) + { + if(caps & RPacketService::KCapsHSUPASupported) + { + iAccTech = EUDMAwithHSDPAandHSUPA; + } + else + { + iAccTech = EHSDPA; + } + } + else if(caps & RPacketService::KCapsHSUPASupported) + { + iAccTech = EHSUPA; + } + else + { + iAccTech = EUDMA; + } + break; + default: + TRACE_INFO( _L("CATCOPSCmd::SolveAccessTechnology() unknown access tech!")); + iAccTech = EAccTechNotSet; + return KErrArgument; + } + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Contructs a response for the read command. +// --------------------------------------------------------------------------- +// +TInt CATCOPSCmd::ConstructNetworkInfoResponse() + { + TRACE_FUNC_ENTRY + RBuf8 reply; + TInt size(KMaxNetworkTestResponseAdditionalSize + KLongOperatorNameFormatLength); + TChar carriageReturn; + TChar lineFeed; + TInt err; + err = reply.Create(size); + err |= iCallback->GetCharacterValue( ECharTypeCR, carriageReturn ); + err |= iCallback->GetCharacterValue( ECharTypeLF, lineFeed ); + if(err != KErrNone) + { + return err; + } + + // Some PC Software expects and extra CR+LF, hence those are added twice: + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + reply.Append(_L("+COPS: ")); + reply.AppendNum(iRegistrationMode); + reply.Append(_L(",")); + switch(iFormat) + { + case RMmCustomAPI::EOperatorNameNitzFull: + reply.AppendNum(EFormatLong); + reply.Append(_L(",")); + reply.Append(_L("\"")); + TRACE_INFO(( _L8("CATCOPSCmd::ConstructNetworkInfoResponse() appending (%S)"), + &iNetworkInfo.iLongName)); + reply.Append(iNetworkInfo.iLongName); + break; + case RMmCustomAPI::EOperatorNameNitzShort: + reply.AppendNum(EFormatShort); + reply.Append(_L(",")); + reply.Append(_L("\"")); + TRACE_INFO(( _L8("CATCOPSCmd::ConstructNetworkInfoResponse() appending (%S)"), + &iNetworkInfo.iShortName)); + reply.Append(iNetworkInfo.iShortName); + break; + case RMmCustomAPI::EOperatorNameMccMnc: + reply.AppendNum(EFormatNumeric); + reply.Append(_L(",")); + reply.Append(_L("\"")); + TRACE_INFO(( _L8("CATCOPSCmd::ConstructNetworkInfoResponse() appending codes (%S) and (%S)"), + &iNetworkInfo.iCountryCode, &iNetworkInfo.iNetworkId)); + reply.Append(iNetworkInfo.iCountryCode); + reply.Append(iNetworkInfo.iNetworkId); + break; + } + reply.Append(_L("\"")); + + if(SolveAccessTechnology(iNetworkInfo.iAccess) == KErrNone && iAccTech != EAccTechNotSet) + { + TRACE_INFO((_L("CATCOPSCmd::ConstructNetworkInfoResponse() appending acc. tech. (%d)"), + iAccTech)); + reply.Append(_L(",")); + reply.AppendNum(iAccTech); + } + + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + + CreateReply(ETrue, reply); + + TRACE_FUNC_EXIT + return KErrNone; + } + + +// --------------------------------------------------------------------------- +// Contructs a response for the test command. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::ConstructNetworkListResponseL() + { + TRACE_FUNC_ENTRY + RBuf8 reply; + TChar carriageReturn; + TChar lineFeed; + + TInt maxItemSize(KMaxNetworkReadResponseAdditionalSize + + KShortOperatorNameFormatLength + + KLongOperatorNameFormatLength + + KNumericOperatorNameFormatLength + + KSupportedModesStr().Length() + + KSupportedFormatsStr().Length()); + + CleanupClosePushL(reply); + + User::LeaveIfNull(iDetectedNetworks); + User::LeaveIfError(reply.Create( maxItemSize * iDetectedNetworks->Enumerate())); + User::LeaveIfError(iCallback->GetCharacterValue( ECharTypeCR, carriageReturn )); + User::LeaveIfError(iCallback->GetCharacterValue( ECharTypeLF, lineFeed )); + + // Some PC Software expects and extra CR+LF, hence those are added twice: + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + reply.Append( _L("+COPS: ") ); + + RMobilePhone::TMobilePhoneNetworkInfoV2 nwInfo; + for(TInt i = 0; i < iDetectedNetworks->Enumerate(); ++i) + { + if(i > 0) // Add CR+LF after the first cycle. + { + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + } + nwInfo = iDetectedNetworks->GetEntryL(i); + + reply.Append(_L("(")); + reply.AppendNum(nwInfo.iStatus); + reply.Append(_L(",")); + reply.Append(_L("\"")); + reply.Append(nwInfo.iLongName); + reply.Append(_L("\"")); + reply.Append(_L(",")); + reply.Append(_L("\"")); + reply.Append(nwInfo.iShortName); + reply.Append(_L("\"")); + reply.Append(_L(",")); + reply.Append(_L("\"")); + reply.Append(nwInfo.iCountryCode); + reply.Append(nwInfo.iNetworkId); + reply.Append(_L("\"")); + if(SolveAccessTechnology(nwInfo.iAccess) == KErrNone && iAccTech != EAccTechNotSet) + { + TRACE_INFO((_L("CATCOPSCmd::ConstructNetworkListResponse() appending acc. tech. (%d)"), iAccTech)); + reply.Append(_L(",")); + reply.AppendNum(iAccTech); + } + reply.Append(_L(")")); + reply.Append(_L(",")); + TRACE_INFO( _L("CATCOPSCmd::ConstructNetworkListResponse() -- entry added to reply.")); + } + reply.Append(KSupportedModesStr); // Supported modes as defined in 3GPP TS 27.007 V8.4.1 + reply.Append(KSupportedFormatsStr); // Supported formats as defined in 3GPP TS 27.007 V8.4.1 + + reply.Append( carriageReturn ); + reply.Append( lineFeed ); + + // Finally append the "OK". CreateOkOrErrorReply returns verbose or numeric version. + RBuf8 okReply; + CleanupClosePushL(okReply); + iCallback->CreateOkOrErrorReply( okReply, ETrue ); + reply.Append( okReply); + CreateReply(ETrue, reply); + CleanupStack::PopAndDestroy(&okReply); + CleanupStack::PopAndDestroy(&reply); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Finalises the response and sends it. +// --------------------------------------------------------------------------- +// +void CATCOPSCmd::CreateReply(TBool aIsOK, const TDesC8 &aReply) + { + if(aIsOK == EFalse) + { + iCallback->CreateReplyAndComplete( EReplyTypeError); + } + else + { + if(aReply.Length() > 0) + { + iCallback->CreateReplyAndComplete( EReplyTypeOther, + aReply ); + } + else + { + iCallback->CreateReplyAndComplete( EReplyTypeOk); + } + } + iCurrentOperation = EIdle; + TRACE_FUNC_EXIT + } diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/src/modematplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/src/modematplugin.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,429 @@ +/* +* 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: Main handler for incoming requests +* +*/ + + +#include "modematplugin.h" +#include "atcopscmd.h" +#include "debug.h" + +const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CModemAtPlugin* CModemAtPlugin::NewL() + { + CModemAtPlugin* self = new (ELeave) CModemAtPlugin(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CModemAtPlugin::~CModemAtPlugin() + { + TRACE_FUNC_ENTRY + iHandlers.ResetAndDestroy(); + iHandlers.Close(); + iReplyBuffer.Close(); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CModemAtPlugin::CModemAtPlugin +// --------------------------------------------------------------------------- +// +CModemAtPlugin::CModemAtPlugin() : CATExtPluginBase() + { + TRACE_FUNC_ENTRY + iHandler = NULL; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// CModemAtPlugin::ConstructL +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::ConstructL() + { + TRACE_FUNC_ENTRY + CATCommandHandlerBase* handler = NULL; + handler = CATCOPSCmd::NewL( this ); + CleanupStack::PushL( handler ); + iHandlers.AppendL( handler ); + CleanupStack::Pop( handler ); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Reports connection identifier name to the extension plugin. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::ReportConnectionName( const TDesC8& /*aName*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Reports the support status of an AT command. This is a synchronous API. +// --------------------------------------------------------------------------- +// +TBool CModemAtPlugin::IsCommandSupported( const TDesC8& aCmd ) + { + TRACE_FUNC_ENTRY + TInt i; + TInt count = iHandlers.Count(); + for ( i=0; iIsCommandSupported( aCmd ); + if ( supported ) + { + iHandler = handler; + TRACE_FUNC_EXIT + return ETrue; + } + } + iHandler = NULL; + TRACE_FUNC_EXIT + return EFalse; + } + +// --------------------------------------------------------------------------- +// Handles an AT command. Cancelling of the pending request is done by +// HandleCommandCancel(). The implementation in the extension plugin should +// be asynchronous. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::HandleCommand( const TDesC8& aCmd, + RBuf8& aReply, + TBool aReplyNeeded ) + { + TRACE_FUNC_ENTRY + if ( iHandler ) + { + iHcCmd = &aCmd; + iHcReply = &aReply; + iHandler->HandleCommand( aCmd, aReply, aReplyNeeded ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels a pending HandleCommand request. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + if ( iHandler ) + { + iHandler->HandleCommandCancel(); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Next reply part's length. +// The value must be equal or less than KDefaultCmdBufLength. +// When the reply from this method is zero, ATEXT stops calling +// GetNextPartOfReply(). +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::NextReplyPartLength() + { + TRACE_FUNC_ENTRY + if ( iReplyBuffer.Length() < KDefaultCmdBufLength ) + { + TRACE_FUNC_EXIT + return iReplyBuffer.Length(); + } + TRACE_FUNC_EXIT + return KDefaultCmdBufLength; + } + +// --------------------------------------------------------------------------- +// Gets the next part of reply initially set by HandleCommandComplete(). +// Length of aNextReply must be equal or less than KDefaultCmdBufLength. +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::GetNextPartOfReply( RBuf8& aNextReply ) + { + TRACE_FUNC_ENTRY + TInt retVal = CreatePartOfReply( aNextReply ); + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// Receives unsolicited results. Cancelling of the pending request is done by +// by ReceiveUnsolicitedResultCancel(). The implementation in the extension +// plugin should be asynchronous. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::ReceiveUnsolicitedResult() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Cancels a pending ReceiveUnsolicitedResult request. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::ReceiveUnsolicitedResultCancel() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Reports NVRAM status change to the plugins. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::ReportNvramStatusChange( const TDesC8& /*aNvram*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Reports about external handle command error condition. +// This is for cases when for example DUN decided the reply contained an +// error condition but the plugin is still handling the command internally. +// Example: in command line "AT+TEST;ATDT1234" was given. "AT+TEST" returns +// "OK" and "ATDT" returns "CONNECT". Because "OK" and "CONNECT" are +// different reply types the condition is "ERROR" and DUN ends processing. +// This solution keeps the pointer to the last AT command handling plugin +// inside ATEXT and calls this function there to report the error. +// It is to be noted that HandleCommandCancel() is not sufficient to stop +// the processing as the command handling has already finished. +// --------------------------------------------------------------------------- +// +void CModemAtPlugin::ReportExternalHandleCommandError() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Creates part of reply from the global reply buffer to the destination +// buffer. Used with APIs which need the next part of reply in multipart reply +// requests. +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::CreatePartOfReply( RBuf8& aDstBuffer ) + { + TRACE_FUNC_ENTRY + if ( iReplyBuffer.Length() <= 0 ) + { + TRACE_FUNC_EXIT + return KErrGeneral; + } + TInt partLength = NextReplyPartLength(); + if ( iReplyBuffer.Length() < partLength ) + { + TRACE_FUNC_EXIT + return KErrNotFound; + } + aDstBuffer.Create( iReplyBuffer, partLength ); + iReplyBuffer.Delete( 0, partLength ); + if ( iReplyBuffer.Length() == 0 ) + { + iReplyBuffer.Close(); + } + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Creates an AT command reply based on the reply type and completes the +// request to ATEXT. Uses iReplyBuffer for reply storage. +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer, + TInt aError ) + { + TRACE_FUNC_ENTRY + iReplyBuffer.Close(); + if ( aError != KErrNone ) + { + HandleCommandCompleted( aError, EReplyTypeUndefined ); + iHcCmd = NULL; + iHcReply = NULL; + TRACE_FUNC_EXIT + return KErrNone; + } + if ( !iHcReply ) + { + TRACE_FUNC_EXIT + return KErrGeneral; + } + switch ( aReplyType ) + { + case EReplyTypeOther: + if ( iQuietMode ) // In quite mode there should be no response at all. + { + iReplyBuffer.Create( KNullDesC8 ); + } + else + { + iReplyBuffer.Create( aSrcBuffer ); + } + break; + case EReplyTypeOk: + CreateOkOrErrorReply( iReplyBuffer, ETrue ); + break; + case EReplyTypeError: + CreateOkOrErrorReply( iReplyBuffer, EFalse ); + break; + default: + TRACE_FUNC_EXIT + return KErrGeneral; + } + CreatePartOfReply( *iHcReply ); + HandleCommandCompleted( KErrNone, aReplyType ); + iHcCmd = NULL; + iHcReply = NULL; + TRACE_FUNC_EXIT + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Creates a buffer for "OK" or "ERROR" reply based on the line settings +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ) + { + TRACE_FUNC_ENTRY + if ( iQuietMode ) + { + TRACE_FUNC_EXIT + return iReplyBuffer.Create( KNullDesC8 ); + } + _LIT8( KErrorReplyVerbose, "ERROR" ); + _LIT8( KOkReplyVerbose, "OK" ); + _LIT8( KErrorReplyNumeric, "4" ); + _LIT8( KOkReplyNumeric, "0" ); + TBuf8 replyBuffer; + if ( iVerboseMode ) + { + replyBuffer.Append( iCarriageReturn ); + replyBuffer.Append( iLineFeed ); + if ( aOkReply ) + { + replyBuffer.Append( KOkReplyVerbose ); + } + else + { + replyBuffer.Append( KErrorReplyVerbose ); + } + replyBuffer.Append( iCarriageReturn ); + replyBuffer.Append( iLineFeed ); + } + else + { + if ( aOkReply ) + { + replyBuffer.Append( KOkReplyNumeric ); + } + else + { + replyBuffer.Append( KErrorReplyNumeric ); + } + replyBuffer.Append( iCarriageReturn ); + } + TInt retVal = aReplyBuffer.Create( replyBuffer ); + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Returns the array of supported commands +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::GetSupportedCommands( RPointerArray& aCmds ) + { + TRACE_FUNC_ENTRY + // Force superclass call here: + TInt retVal = CATExtPluginBase::GetSupportedCommands( aCmds ); + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Returns plugin's character value settings (from CATExtPluginBase) +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::GetCharacterValue( TCharacterTypes aCharType, + TChar& aChar ) + { + TRACE_FUNC_ENTRY + TInt retVal = KErrNone; + switch ( aCharType ) + { + case ECharTypeCR: + aChar = iCarriageReturn; + break; + case ECharTypeLF: + aChar = iLineFeed; + break; + case ECharTypeBS: + aChar = iBackspace; + break; + default: + retVal = KErrNotFound; + break; + } + TRACE_FUNC_EXIT + return retVal; + } + +// --------------------------------------------------------------------------- +// From MLcCustomPlugin. +// Returns plugin's mode value settings (from CATExtPluginBase) +// --------------------------------------------------------------------------- +// +TInt CModemAtPlugin::GetModeValue( TModeTypes aModeType, TBool& aMode ) + { + TRACE_FUNC_ENTRY + TInt retVal = KErrNone; + switch ( aModeType ) + { + case EModeTypeQuiet: + aMode = iQuietMode; + break; + case EModeTypeVerbose: + aMode = iVerboseMode; + break; + default: + retVal = KErrNotFound; + break; + } + TRACE_FUNC_EXIT + return retVal; + } diff -r 0b192a3a05a4 -r 00f9ee97d895 atcommands/modematplugin/src/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/atcommands/modematplugin/src/proxy.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,48 @@ +/* +* 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: Export ECom interface implementations +* +*/ + + +#ifndef REFERENCE_ATEXT_H +#define REFERENCE_ATEXT_H + +#include +#include +#include "modematplugin.h" + +// --------------------------------------------------------------------------- +// An array of TImplementationProxy objects which onnect each +// implemeation with its instantiation function +// --------------------------------------------------------------------------- +// +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(0x2002B3EB, CModemAtPlugin::NewL), // DUN + }; + +// --------------------------------------------------------------------------- +// Exported proxy function to resolve instantiation methods for an Ecom +// plug-in DLL +// --------------------------------------------------------------------------- +// +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } + +#endif diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/group/remconbeareravrcp.mmp --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/group/remconbeareravrcp.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/group/remconbeareravrcp.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -64,7 +64,6 @@ USERINCLUDE ../../common MW_LAYER_SYSTEMINCLUDE_SYMBIAN -USERINCLUDE ../../../../../../os/bt/bluetoothmgmt/btcommon/inc LIBRARY avc.lib LIBRARY ecom.lib diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommand.h --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommand.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcpcommand.h Fri Apr 16 15:08:36 2010 +0300 @@ -25,7 +25,7 @@ #include #include #include -#include "internaltypes.h" +#include "avrcputils.h" class CAvrcpPlayerInfoManager; /** @@ -68,9 +68,9 @@ const TBTDevAddr& aAddr); public: - TBTDblQueLink iHandlingLink; // Used to form handling queue in command handlers - TBTDblQueLink iReadyLink; // Used to form ready command queue in CRemConBearerAvrcp - TBTDblQueLink iSendLink; // Used to form send queue in CRcpRouter + TAvrcpDblQueLink iHandlingLink; // Used to form handling queue in command handlers + TAvrcpDblQueLink iReadyLink; // Used to form ready command queue in CRemConBearerAvrcp + TAvrcpDblQueLink iSendLink; // Used to form send queue in CRcpRouter protected: TUint iRemConId; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcputils.h --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcputils.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/avrcputils.h Fri Apr 16 15:08:36 2010 +0300 @@ -170,4 +170,22 @@ CSpecificThreadCallBackBody* iBody; }; +/** +An extended double queue link class to provide additional features. +*/ +NONSHARABLE_CLASS(TAvrcpDblQueLink) : public TDblQueLink + { + public: + inline TBool IsQueued() const; + }; + +/** +Indicates whether the queue link is attached to a queue. +@return True if the link is queued, false otherwise. +*/ +inline TBool TAvrcpDblQueLink::IsQueued() const + { + return iNext ? ETrue : EFalse; + } + #endif // AVRCPUTILS_H diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/bulkbearer.h Fri Apr 16 15:08:36 2010 +0300 @@ -46,6 +46,7 @@ void MrcciNewCommand(CAvrcpCommand& aCommand,const TRemConClientId& aClientId); TUint MrcciNewTransactionId(); + void MrcciCommandExpired(TUint aTransactionId); TInt MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient); void MrcbciRemoveAddressing(const TRemConAddress& aAddr); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlbearer.h Fri Apr 16 15:08:36 2010 +0300 @@ -59,6 +59,8 @@ void MrccciNewNotifyResponse(CControlCommand& aCommand); TUint MrcciNewTransactionId(); + void MrcciCommandExpired(TUint aTransactionId); + void MrccciSetAddressedClient(const TRemConClientId& aClient); private: // MRemConBearerInterfaceV3 functions called from RemCon diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlcommand.h --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlcommand.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/controlcommand.h Fri Apr 16 15:08:36 2010 +0300 @@ -27,7 +27,6 @@ #include #include #include -#include "internaltypes.h" #include diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/inc/remconcommandinterface.h Fri Apr 16 15:08:36 2010 +0300 @@ -31,6 +31,7 @@ virtual void MrcciNewCommand(CAvrcpCommand& aCommand, const TRemConClientId& aClientId) = 0; virtual TUint MrcciNewTransactionId() = 0; + virtual void MrcciCommandExpired(TUint aTransactionId) = 0; }; NONSHARABLE_CLASS(MRemConBulkCommandInterface) : public MRemConCommandInterface diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/bulkbearer.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -201,6 +201,12 @@ return iObserver->NewTransactionId(); } +void CAvrcpBulkBearer::MrcciCommandExpired(TUint aTransactionId) + { + LOG_FUNC + iObserver->CommandExpired(aTransactionId); + } + TInt CAvrcpBulkBearer::MrcbciSetAddressedClient(const TRemConAddress& aAddr, const TRemConClientId& aClient) { LOG_FUNC diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/src/controlcommand.cpp --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/controlcommand.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/controlcommand.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -608,6 +608,7 @@ { case KErrNone: case KErrCompletion: + case KErrAvrcpHandledInternallyRespondNow: if (cType == AVC::EControl) { iFrame->SetType(AVC::EAccepted); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerstatewatcher.cpp --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerstatewatcher.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/playerstatewatcher.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -40,6 +40,9 @@ CInternalCommand* command = *iCommands.Find(aClientId); __ASSERT_DEBUG(command, AVRCP_PANIC(ENotWatchingPlayer)); + TUint transId = command->RemConCommandId(); + iCommandInterface.MrcciCommandExpired(transId); + iCommands.Remove(aClientId); command->DecrementUsers(); } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp --- a/bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothappprofiles/avrcp/remconbeareravrcp/src/remconbeareravrcp.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -858,10 +858,15 @@ return Observer().NewTransactionId(); } +void CRemConBearerAvrcp::MrcciCommandExpired(TUint aTransactionId) + { + LOG_FUNC + Observer().CommandExpired(aTransactionId); + } + void CRemConBearerAvrcp::MrccciSetAddressedClient(const TRemConClientId& aClientId) { LOG_FUNC - Observer().SetRemoteAddressedClient(TUid::Uid(KRemConBearerAvrcpImplementationUid), aClientId); } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/btaccpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/btaccpanic.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 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: Declares authorisation notifier class. +* +*/ + +#ifndef BTACCPANIC_H +#define BTACCPANIC_H + +_LIT(KBtAccPanicName, "BtAcc Panic"); + +enum TBtAccPanic + { + ENoShutdownTimer = 0, + }; + +template +struct TBtAccPanicCodeTypeChecker + { + inline static void Check(XAny) { } + }; + +#define BTACC_PANIC(CODE) \ + TBtAccPanicCodeTypeChecker::Check(CODE), \ + User::Panic(KBtAccPanicName, CODE) + + +#endif // BTACCPANIC_H + + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/data/10208970.rss --- a/bluetoothengine/btaudioman/data/10208970.rss Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/data/10208970.rss Fri Apr 16 15:08:36 2010 +0300 @@ -37,7 +37,7 @@ { implementation_uid = 0x1020897C; version_no = 1; - display_name = "0x1020897B"; + display_name = "0x10208970"; default_data = KACCESSORYPLUGINAPIMAINSERVICE; opaque_data = "Heap=0x1000|Stack=0x1000"; rom_only = 1; @@ -46,7 +46,7 @@ { implementation_uid = 0x1020897D; version_no = 1; - display_name = "0x1020897B"; + display_name = "0x10208970"; default_data = KACCESSORYPLUGINAPIHANDLER; opaque_data = ""; rom_only = 1; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/group/btaudioman.mmp --- a/bluetoothengine/btaudioman/group/btaudioman.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/group/btaudioman.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -49,8 +49,6 @@ SOURCE BTAccSession.cpp SOURCE basrvpowercontrolagent.cpp SOURCE basrvrvc.cpp -SOURCE BTAccSession_accfw_var.cpp -SOURCE basrvaccman_accfw_var.cpp SOURCE basrvaccfwconn.cpp USERINCLUDE ../inc diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/BTAccClient.h --- a/bluetoothengine/btaudioman/inc/BTAccClient.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/BTAccClient.h Fri Apr 16 15:08:36 2010 +0300 @@ -93,34 +93,6 @@ */ void GetInfoOfConnectedAcc(TPckg& aInfoPckg, TRequestStatus& aStatus ); - - /** - * Transfer audio to phone - * @param None - * @return TInt indicating the success of call. - */ - TInt AudioToPhone(); - - /** - * Routes the audio paths from the phone to the accessory from which they - * have been earlier on moved to the phone with the audio to phone - * operation. In practice also reconnects to the accessory. - * @param aStatus When the request completes contains the - * success status of the operation. - * @return None. - */ - void AudioToAccessory( TRequestStatus& aStatus ); - - /** - * Cancels the audio to accessory operation. - * Note that if this request is made after the point when it is not - * possible to cancel the actual operation any more, the audio paths - * might still be routed to the accessory again. - * @param TRequestStatus status to be cancelled. - * @return None. - */ - void CancelAudioToAccessory(); - public: // Functions from base classes /** diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/BTAccClientSrv.h --- a/bluetoothengine/btaudioman/inc/BTAccClientSrv.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/BTAccClientSrv.h Fri Apr 16 15:08:36 2010 +0300 @@ -47,9 +47,6 @@ EBTAccSrvCancelNotifyConnectionStatus, EBTAccSrvConnectionStatus, EBTAccSrvGetInfoOfConnectedAcc, - EBTAccSrvAudioToPhone, - EBTAccSrvAudioToAccessory, - EBTAccSrvCancelAudioToAccessory, EBTAccSrvInvalidIpc, }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/BTAccServer.h --- a/bluetoothengine/btaudioman/inc/BTAccServer.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/BTAccServer.h Fri Apr 16 15:08:36 2010 +0300 @@ -49,7 +49,7 @@ void StartShutdownTimerIfNoSessions(); - void ClientOpened(CBTAccSession& aSession); + void ClientOpenedL(CBTAccSession& aSession); void ClientClosed(CBTAccSession& aSession); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/BTAccSession.h --- a/bluetoothengine/btaudioman/inc/BTAccSession.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/BTAccSession.h Fri Apr 16 15:08:36 2010 +0300 @@ -58,13 +58,6 @@ void NotifyClientNewProfile(TInt aProfile, const TBTDevAddr& aAddr); void NotifyClientNoProfile(TInt aProfile, const TBTDevAddr& aAddr); - - // For DosServer version only - void AudioToPhone(const RMessage2& aMessage); - void AudioToAccessory(const RMessage2& aMessage); - void CancelAudioToAccessory(); - void AudioToPhoneComplete(); - void AudioToAccessoryComplete(TInt aErr); private: /** @@ -114,10 +107,6 @@ */ CBTAccSession(CBasrvAccMan& aAccMan); - void HandleAudio4DosRequest(const RMessage2 &aMessage); - - void DestructVariant(); - void UpdateProfileStatusCache(const TProfileStatus& aStatus); private: // Data diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/basrvaccman.h --- a/bluetoothengine/btaudioman/inc/basrvaccman.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/basrvaccman.h Fri Apr 16 15:08:36 2010 +0300 @@ -16,7 +16,7 @@ * Name : basrvaccman.h * Part of : BTEng / Bluetooth Accessory Server * Description : -* Version : %version: 3.1.4.1.2.2.11 % +* Version : %version: 3.1.4.1.2.2.13 % * */ @@ -100,10 +100,6 @@ TBTEngConnectionStatus ConnectionStatus4Client(const TBTDevAddr& aAddr) const; - // For DosServer version only - void AudioToPhone(CBasrvAudio4Dos& aAudio4Dos); - void AudioToAccessory(CBasrvAudio4Dos& aAudio4Dos); - TBool IsAvrcpVolCTSupported(); TBool IsAbsoluteVolumeSupported(const TBTDevAddr& aAddr); TBool DisconnectIfAudioOpenFails(); @@ -153,6 +149,9 @@ */ void CancelRequest(CBasrvActive& aActive); +private: + void DoShowNoteL(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr); + protected: /** * Default constructor @@ -164,8 +163,6 @@ void HandleNewAudioRequestL(); void DoAudioRequestL(); - - void DestructVariant(); TInt FindAcc(const TBTDevAddr& aRemote) const; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/basrvaccstate.h --- a/bluetoothengine/btaudioman/inc/basrvaccstate.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/basrvaccstate.h Fri Apr 16 15:08:36 2010 +0300 @@ -132,7 +132,7 @@ /** * Default constructor */ - CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest); + CBasrvAccState(CBasrvAcc& aParent); /** * Gets the owner of the state machine @@ -142,24 +142,6 @@ */ CBasrvAcc& Parent(); - /** - * Completes the pending request in this state with specified error code - * and then zero the pointer. - * - * @since S60 v3.1 - * @param aErr the completion error code - */ - void CompleteStateRequest(TInt aErr); - - /** - * Completes the give pending request with specified error code.. - * - * @since S60 v3.1 - * @param aRequest the request to be completed - * @param aErr the completion error code - */ - void CompleteRequest(TRequestStatus* aRequest, TInt aErr); - void StatePrint(const TDesC& aStateName); TAccInfo& AccInfo(); @@ -173,12 +155,6 @@ protected: CBasrvAcc& iParent; - - /** - * Possible to be NULL. - * The async request performed in this state if it is not NULL. - */ - TRequestStatus* iRequest; }; #endif // C_BTASRVACCSTATE_H diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/btaccpanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btaudioman/inc/btaccpanic.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2010 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: Declares authorisation notifier class. +* +*/ + +#ifndef BTACCPANIC_H +#define BTACCPANIC_H + +_LIT(KBtAccPanicName, "BtAcc Panic"); + +enum TBtAccPanic + { + ENoShutdownTimer = 0, + EMaxNumberOfConflictsExceeded = 1, + }; + +template +struct TBtAccPanicCodeTypeChecker + { + inline static void Check(XAny) { } + }; + +#define BTACC_PANIC(CODE) \ + TBtAccPanicCodeTypeChecker::Check(CODE), \ + User::Panic(KBtAccPanicName, CODE) + + +#endif // BTACCPANIC_H + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/btaudiomanplugin.h --- a/bluetoothengine/btaudioman/inc/btaudiomanplugin.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/btaudiomanplugin.h Fri Apr 16 15:08:36 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 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" @@ -171,7 +171,10 @@ void ConstructL(); - TInt HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId); + TInt PrepareAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId); + + void NotifyConnectionStatus(); + TInt ReconnectIfNeccessary(); void ReportProfileConnectionEvents(const TBTDevAddr& aAddr, const TInt aProfiles, TBool aConnected); @@ -187,6 +190,7 @@ CBasrvActive* iActive4ProfileStatus; TProfileStatus iProfileStatus; TProfileStatusPckg iProfileStatusPckg; + TInt iNotifyConnectionStatusFailure; }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/debug.h --- a/bluetoothengine/btaudioman/inc/debug.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/debug.h Fri Apr 16 15:08:36 2010 +0300 @@ -22,6 +22,11 @@ #include #include "debugconfig.h" +enum TPanic + { + EInvalidNullState = 1, + }; + #ifdef PRJ_ENABLE_TRACE #ifdef PRJ_FILE_TRACE diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/inc/debugconfig.h --- a/bluetoothengine/btaudioman/inc/debugconfig.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/inc/debugconfig.h Fri Apr 16 15:08:36 2010 +0300 @@ -38,11 +38,12 @@ _LIT8(KFuncEntryThisFormat8, ">%S, [0x%08X]"); _LIT8(KFuncExitFormat8, "<%S"); -_LIT(KPanicCategory, "BTAccServer"); _LIT8(KPanicPrefix8, "PANIC code "); _LIT8(KLeavePrefix8, "LEAVE code "); #endif +_LIT(KPanicCategory, "BTAccServer"); // need it also for release + const TInt KMaxLogLineLength = 512; #define KPRINTERROR 0x00000001 // Tracing level: error diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/BTAccClient.cpp --- a/bluetoothengine/btaudioman/src/BTAccClient.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/BTAccClient.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -164,32 +164,5 @@ SendReceive(EBTAccSrvGetInfoOfConnectedAcc, TIpcArgs(&aInfoPckg), aStatus); } -// --------------------------------------------------------- -// AudioToPhone -// Dos Related functionality only. -// --------------------------------------------------------- -// -TInt RBTAccClient::AudioToPhone() - { - TRACE_FUNC - return SendReceive(EBTAccSrvAudioToPhone); - } - -// --------------------------------------------------------- -// AudioToAccessory -// Dos Related functionality only. -// --------------------------------------------------------- -// -void RBTAccClient::AudioToAccessory( TRequestStatus& aStatus ) - { - TRACE_FUNC - SendReceive(EBTAccSrvAudioToAccessory, aStatus); - } - -void RBTAccClient::CancelAudioToAccessory() - { - SendReceive(EBTAccSrvCancelAudioToAccessory); - } - // End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/BTAccServer.cpp --- a/bluetoothengine/btaudioman/src/BTAccServer.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/BTAccServer.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -30,6 +30,7 @@ #include "btmanclient.h" // TBTDevAddrPckgBug #include "basrvaccman.h" #include "BTAccInfo.h" +#include "btaccpanic.h" /** PubSub key read and write policies */ _LIT_SECURITY_POLICY_C1( KBTEngPSKeyReadPolicy, @@ -78,33 +79,25 @@ } void CBTAccServer::StartShutdownTimerIfNoSessions() - { - if (iSessions.Count() == 0 && (!iTimer || !iTimer->IsActive())) - { - if (!iTimer) - { - TRAP_IGNORE(iTimer = CPeriodic::NewL(CActive::EPriorityStandard)); - } - - if (iTimer) - { - iTimer->Start(KShutdownDelay, 0, TCallBack(CBTAccServer::TimerFired, this)); - } - - TRACE_FUNC - } - } + { + TRACE_FUNC + __ASSERT_DEBUG(iTimer, BTACC_PANIC(ENoShutdownTimer)); + if (iSessions.Count() == 0 && !iTimer->IsActive()) + { + iTimer->Start(KShutdownDelay, 0, TCallBack(CBTAccServer::TimerFired, this)); + } + } -void CBTAccServer::ClientOpened(CBTAccSession& aSession) - { - TRACE_FUNC - - //cancel the timer to prevent the server from shutting down +void CBTAccServer::ClientOpenedL(CBTAccSession& aSession) + { + TRACE_FUNC + + //add the session to the array of sessions + iSessions.AppendL(&aSession); + + //cancel the timer to prevent the server from shutting down CancelShutdownTimer(); - - //add the session to the array of sessions - (void)iSessions.Append(&aSession); - } + } void CBTAccServer::ClientClosed(CBTAccSession& aSession) { @@ -148,8 +141,9 @@ void CBTAccServer::ConstructL() { iAccMan = CBasrvAccMan::NewL(); - iAccMan->LoadServicesL(); - + + iTimer = CPeriodic::NewL(CActive::EPriorityStandard); + User::LeaveIfError(RProperty::Define(KPSUidBluetoothEnginePrivateCategory, KBTHfpATCommand, RProperty::EByteArray, KBTEngPSKeyReadPolicy, @@ -162,8 +156,7 @@ void CBTAccServer::CancelShutdownTimer() { - delete iTimer; - iTimer = NULL; + iTimer->Cancel(); } TInt CBTAccServer::TimerFired(TAny* /*aThis*/) diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/BTAccSession.cpp --- a/bluetoothengine/btaudioman/src/BTAccSession.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/BTAccSession.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -27,6 +27,7 @@ #include "BTAccServer.h" #include "basrvaccman.h" #include "BTAccInfo.h" +#include "btaccpanic.h" typedef TPckgBuf TBTDevAddrPckgBuf; @@ -64,7 +65,6 @@ iNotifyProfileMsg.Complete(KErrAbort); } iProfileStatusCache.Close(); - DestructVariant(); //clear the accessory managers pointer to this session if it has one iAccMan.ClearProfileNotifySession(*this); @@ -78,7 +78,7 @@ TRACE_FUNC //use CreateL instead of NewSessionL when using Server() to ensure the //session has been created correctly and Server() returns a valid pointer - Server().ClientOpened(*this); + Server().ClientOpenedL(*this); } void CBTAccSession::ConnectCompleted(TInt aErr, TInt aProfile, const RArray* aConflicts) @@ -89,10 +89,24 @@ TRACE_INFO((_L("CBTAccSession::ConnectCompleted err %d"), aErr)) if (aConflicts) { - TBuf8 buf; + if (aErr == KErrNone) + { + //we need to error so the client knows there are conflicts which need handling + aErr = KErrGeneral; + } + + const TInt KMaxNumberOfConflicts = 2; + + TBuf8 buf; TInt count = aConflicts->Count(); + __ASSERT_DEBUG(count <= KMaxNumberOfConflicts, BTACC_PANIC(EMaxNumberOfConflictsExceeded)); + for (TInt i = 0; i < count; i++) { + if(i >= KMaxNumberOfConflicts) + { + break; //prevent descriptor overflow + } buf.Append((*aConflicts)[i].Des()); } @@ -101,10 +115,10 @@ iConnectMsg.Write(1, buf); } } - else if (!aErr) + else if (aErr == KErrNone) { TPckgBuf buf(aProfile); - iConnectMsg.Write(1, buf); + aErr = iConnectMsg.Write(1, buf); } iConnectMsg.Complete(aErr); } @@ -116,10 +130,10 @@ if (iDisconnectMsg.Handle()) { TRACE_FUNC - if (!aErr) + if (aErr == KErrNone) { TPckgBuf buf(aProfile); - iDisconnectMsg.Write(1, buf); + aErr = iDisconnectMsg.Write(1, buf); } iDisconnectMsg.Complete(aErr); } @@ -239,6 +253,11 @@ //finished with the accessory info array infos.Close(); + if(buf.Length() <= 0) + { + ret = KErrNotFound; + } + //if there is no error and the buffer has something in, //write the buffer to the message if (ret == KErrNone) @@ -451,13 +470,6 @@ GetInfoOfConnectedAcc(aMessage); break; } - case EBTAccSrvAudioToPhone: - case EBTAccSrvAudioToAccessory: - case EBTAccSrvCancelAudioToAccessory: - { - HandleAudio4DosRequest(aMessage); - break; - } default: { PanicClient(aMessage, EBTAccBadRequest); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/BTAccSession_accfw_var.cpp --- a/bluetoothengine/btaudioman/src/BTAccSession_accfw_var.cpp Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* -* Copyright (c) 2006-2007 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: Variants for Dos Server version -* -* -*/ - - -// INCLUDE FILES -#include "BTAccSession.h" -#include "debug.h" - -void CBTAccSession::HandleAudio4DosRequest(const RMessage2 &aMessage) - { - aMessage.Complete(KErrNotSupported); - } - -void CBTAccSession::DestructVariant() - { - } - -// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvacc.cpp --- a/bluetoothengine/btaudioman/src/basrvacc.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvacc.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -107,30 +107,35 @@ void CBasrvAcc::AccOpenedAudio(TProfiles aProfile) { TRACE_FUNC + __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState)); iState->AccOpenedAudio(aProfile); } void CBasrvAcc::AccClosedAudio(TProfiles aProfile) { TRACE_FUNC + __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState)); iState->AccClosedAudio(aProfile); } void CBasrvAcc::AccessoryDisconnectedL(TProfiles aProfile) { TRACE_FUNC + __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState)); iState->AccessoryDisconnectedL(aProfile); } void CBasrvAcc::OpenAudioL(TAccAudioType aType) { TRACE_FUNC + __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState)); iState->OpenAudioL(aType); } void CBasrvAcc::CloseAudioL(TAccAudioType aType) { TRACE_FUNC + __ASSERT_ALWAYS(iState, User::Panic(KPanicCategory, EInvalidNullState)); iState->CloseAudioL(aType); } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccman.cpp --- a/bluetoothengine/btaudioman/src/basrvaccman.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccman.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -12,13 +12,14 @@ * Contributors: * * Description: Implementation of an accessory management. -* Version : %version: 14.1.8 % +* Version : %version: 14.1.10 % * */ // INCLUDE FILES #include +#include #include "basrvaccman.h" #include "BTAccSession.h" #include "BTAccClientSrv.h" @@ -44,6 +45,28 @@ return self; } +void CBasrvAccMan::ConstructL() + { + iAsyncHandlingActive = + CBasrvActive::NewL(*this, CActive::EPriorityStandard, KAsyncHandlingRequest); + + CRepository* cenrep = NULL; + TRAP_IGNORE(cenrep = CRepository::NewL(KCRUidBluetoothEngine)); + TInt avrcpVol = EBTAvrcpVolCTNotSupported; + TInt autoDisconnect = EBTDisconnectIfAudioOpenFails; + if (cenrep) + { + cenrep->Get(KBTAvrcpVolCTLV, avrcpVol); + cenrep->Get(KBTDisconnectIfAudioOpenFailsLV, autoDisconnect); + delete cenrep; + } + iAvrcpVolCTSupported = (avrcpVol == EBTAvrcpVolCTSupported); + iDisconnectIfAudioOpenFails = (autoDisconnect == EBTDisconnectIfAudioOpenFails); + TRACE_INFO((_L("[AVRCP_Vol_CT] %d [DisconnectIfAudioOpenFails] %d"), + iAvrcpVolCTSupported, iDisconnectIfAudioOpenFails)) + LoadServicesL(); + } + CBasrvAccMan::~CBasrvAccMan() { delete iOpenListener; @@ -77,7 +100,6 @@ iNotifierArray.ResetAndDestroy(); iNotifierArray.Close(); iClientRequests.Close(); - DestructVariant(); TRACE_FUNC } @@ -152,7 +174,14 @@ request.iRequest = EBTAccSrvDisconnectAccessory; request.iAddr = aAddr; iClientRequests.AppendL(request); + + //remove the last item from the RArray if a leave occurs later + TCleanupItem cleanupItem(CleanupLastItemFromClientRequestsArray, &iClientRequests); + CleanupStack::PushL(cleanupItem); + iAccs[idx]->DisconnectL(); + + CleanupStack::Pop(&iClientRequests); } else { @@ -416,14 +445,23 @@ void CBasrvAccMan::ShowNote(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr) { TRACE_INFO((_L("CBasrvAccMan::ShowNote %d"), aNote)) - TRAPD(err, iNotifierArray.Append(CBasrvActiveNotifier::NewL(*this, CActive::EPriorityStandard, KShowNoteRequest, aAddr, aNote))); - if (err) + TRAPD(err, DoShowNoteL(aNote, aAddr)); + if (err != KErrNone) { TRACE_ERROR((_L("could not construct active notifer object"))) return; } } +void CBasrvAccMan::DoShowNoteL(TBTGenericInfoNoteType aNote, const TBTDevAddr& aAddr) + { + CBasrvActiveNotifier* activeNotifier = CBasrvActiveNotifier::NewL(*this, CActive::EPriorityStandard, KShowNoteRequest, aAddr, aNote); + + CleanupStack::PushL(activeNotifier); + iNotifierArray.AppendL(activeNotifier); + CleanupStack::Pop(activeNotifier); + } + void CBasrvAccMan::FilterProfileSupport(TAccInfo& aInfo) { TInt pluginbit = iPluginMan->AvailablePlugins(); @@ -729,8 +767,6 @@ case KAsyncHandlingRequest: { DoAudioRequestL(); - delete iAsyncHandlingActive; - iAsyncHandlingActive = NULL; break; } default: @@ -760,7 +796,7 @@ void CBasrvAccMan::DoAudioRequestL() { TRACE_FUNC - if (iAudioRequests.Count() && !iAudioRequests[0].iOngoing && (!iAsyncHandlingActive || !iAsyncHandlingActive->IsActive())) + if (iAudioRequests.Count() && !iAudioRequests[0].iOngoing && !iAsyncHandlingActive->IsActive()) { iAudioRequests[0].iOngoing = ETrue; TInt err = KErrNotFound; @@ -827,7 +863,7 @@ req.iReqType = ERejectAudioOpenedByAcc; req.iOngoing = EFalse; TInt idx = 0; - if (iAudioRequests.Count() && iAudioRequests[0].iOngoing) + if (iAudioRequests.Count() && iAudioRequests[0].iOngoing && !iAsyncHandlingActive->IsActive()) { idx = 1; } @@ -839,18 +875,12 @@ Trace(_L("[Audio Request buf] 2(Reject) %d at '%S', to index %d"), iCloseType, &buf, idx); }); - if (!err && !iAsyncHandlingActive && !iAudioRequests[0].iOngoing) + if ((err == KErrNone) && !iAudioRequests[0].iOngoing) { - // Start rejection asynchronously - iAsyncHandlingActive = - CBasrvActive::New(*this, CActive::EPriorityStandard, KAsyncHandlingRequest); - if (iAsyncHandlingActive) - { - iAsyncHandlingActive->iStatus = KRequestPending; - TRequestStatus* sta = &(iAsyncHandlingActive->iStatus); - User::RequestComplete(sta, KErrNone); - iAsyncHandlingActive->GoActive(); - } + iAsyncHandlingActive->iStatus = KRequestPending; + TRequestStatus* sta = &(iAsyncHandlingActive->iStatus); + User::RequestComplete(sta, KErrNone); + iAsyncHandlingActive->GoActive(); } } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstate.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstate.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstate.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -27,7 +27,6 @@ CBasrvAccState::~CBasrvAccState() { - CompleteStateRequest(KErrAbort); } CBasrvAccState* CBasrvAccState::ErrorOnEntry(TInt /*aReason*/) @@ -102,8 +101,8 @@ TRACE_FUNC } -CBasrvAccState::CBasrvAccState(CBasrvAcc& aParent, TRequestStatus* aRequest) - : iParent(aParent), iRequest(aRequest) +CBasrvAccState::CBasrvAccState(CBasrvAcc& aParent) + : iParent(aParent) { } @@ -112,25 +111,6 @@ return iParent; } -void CBasrvAccState::CompleteStateRequest(TInt aErr) - { - if (iRequest) - { - User::RequestComplete(iRequest, aErr); - TRACE_INFO((_L("Request 0x%08X completed with %d"), iRequest, aErr)) - iRequest = NULL; - } - } - -void CBasrvAccState::CompleteRequest(TRequestStatus* aStatus, TInt aErr) - { - if (aStatus) - { - User::RequestComplete(aStatus, aErr); - TRACE_INFO((_L("Request 0x%08X completed with %d"), aStatus, aErr)) - } - } - void CBasrvAccState::StatePrint(const TDesC& aStateName) { TRACE_INFO_SEG( diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstateattach.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -126,7 +126,7 @@ } CBasrvAccStateAttach::CBasrvAccStateAttach(CBasrvAcc& aParent, TBool aConnecting) - : CBasrvAccState(aParent, NULL), iConnecting(aConnecting) + : CBasrvAccState(aParent), iConnecting(aConnecting) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstateattached.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstateattached.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstateattached.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -12,7 +12,7 @@ * Contributors: * * Description: Implementation of Connected state. -* Version : %version: 20 % +* Version : %version: 21 % * */ @@ -385,7 +385,7 @@ } CBasrvAccStateAttached::CBasrvAccStateAttached(CBasrvAcc& aParent, TBool aShowNote) - : CBasrvAccState(aParent, NULL), iShowNote(aShowNote) + : CBasrvAccState(aParent), iShowNote(aShowNote) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstateconnect.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -105,7 +105,7 @@ } CBasrvAccStateConnect::CBasrvAccStateConnect(CBasrvAcc& aParent) - : CBasrvAccState(aParent, NULL) + : CBasrvAccState(aParent) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstatedetach.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -112,7 +112,7 @@ } CBasrvAccStateDetach::CBasrvAccStateDetach(CBasrvAcc& aParent) - : CBasrvAccState(aParent, NULL) + : CBasrvAccState(aParent) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstatedisconnect.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -81,7 +81,7 @@ } CBasrvAccStateDisconnect::CBasrvAccStateDisconnect(CBasrvAcc& aParent, TInt aConnErr) - : CBasrvAccState(aParent, NULL), iConnErr(aConnErr) + : CBasrvAccState(aParent), iConnErr(aConnErr) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvaccstatequery.cpp --- a/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvaccstatequery.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -133,7 +133,7 @@ if ( ( AccInfo().iConnProfiles & EHFP ) && AccInfo().iSupportedFeatures[TAccInfo::EHFPIndex] == 0 ) { - CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(EHFP);; + CBTAccPlugin* plugin = Parent().AccMan().PluginMan().Plugin(EHFP); AccInfo().SetSupportedFeature((TUint16)plugin->GetRemoteSupportedFeature(), TAccInfo::EHFPIndex); } @@ -192,7 +192,7 @@ } CBasrvAccStateQuery::CBasrvAccStateQuery(CBasrvAcc& aParent, TBool aConnectingRequest) - : CBasrvAccState(aParent, NULL), iConnecting(aConnectingRequest) + : CBasrvAccState(aParent), iConnecting(aConnectingRequest) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/basrvsdpquery.cpp --- a/bluetoothengine/btaudioman/src/basrvsdpquery.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/basrvsdpquery.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -67,23 +67,23 @@ SF.iAttrValue = 0; SF.iUUID = KAudioSinkUUID; SF.iAttrID = KSdpAttrIdSupportedFeatures; - iServiceAttrs.Append(SF); // Advanced Audio Distribution Profile - BT Stereo Audio + iServiceAttrs.AppendL(SF); // Advanced Audio Distribution Profile - BT Stereo Audio SF.iUUID = 0x111e; // HFP SF.iAttrID = KSdpAttrIdSupportedFeatures; - iServiceAttrs.Append(SF); // BT Handsfree Profile - BT Mono Audio + iServiceAttrs.AppendL(SF); // BT Handsfree Profile - BT Mono Audio SF.iUUID = 0x1108; // HSP SF.iAttrID = 0x0302; // Atti id of remote volume control - iServiceAttrs.Append(SF); // BT Headset Profile - BT Mono Audio + iServiceAttrs.AppendL(SF); // BT Headset Profile - BT Mono Audio SF.iUUID = KAVRemoteControlTargetUUID; SF.iAttrID = KSdpAttrIdSupportedFeatures; - iServiceAttrs.Append(SF); // Audio Video Remote Control Profile + iServiceAttrs.AppendL(SF); // Audio Video Remote Control Profile SF.iUUID = KAVRemoteControlTargetUUID; SF.iAttrID = KSdpAttrIdBluetoothProfileDescriptorList; - iServiceAttrs.Append(SF); // Audio Video Remote Control Profile, to find out avrcp 1.4 support + iServiceAttrs.AppendL(SF); // Audio Video Remote Control Profile, to find out avrcp 1.4 support /***************************************************** @@ -100,7 +100,7 @@ TUUID serviceUuid = TUUID((0x00005555),(0x00001000),(0x80000002),(0xEE000001)); // model number SF.iUUID = serviceUuid; SF.iAttrID = 0x0300; // Attri id of device model number - iServiceAttrs.Append(SF); + iServiceAttrs.AppendL(SF); iCursor = 0; iTolerateSdpError = aTolerateSdpError; iSdpAgent = CSdpAgent::NewL(*this, iAddr); @@ -134,13 +134,19 @@ { case ECreateView: { + // if we're called with iResponse != NULL we're leaking memory. + __ASSERT_ALWAYS(!iResponse, User::Invariant()); + iResponse = NULL; if (aActive.iStatus > KErrNone) { - iResponse = CBTRegistryResponse::NewL(iReg); - aActive.SetRequestId(EGetResponse); - iResponse->Start(aActive.iStatus); - aActive.GoActive(); + TRAP_IGNORE( iResponse = CBTRegistryResponse::NewL(iReg) ); + if (iResponse) + { + aActive.SetRequestId(EGetResponse); + iResponse->Start(aActive.iStatus); + aActive.GoActive(); + } } else { @@ -172,15 +178,21 @@ void CBasrvSdpQuery::QueryCompleteL(TInt aErr) { iSdpAgent->Cancel(); + delete iSdpAgent; iSdpAgent = NULL; + delete iSdpSearchPattern; iSdpSearchPattern = NULL; + TBTDeviceClass cod = TBTDeviceClass(); if ( iResponse && iResponse->Results().Count() > 0 ) { cod = (iResponse->Results())[0]->DeviceClass(); } + delete iResponse; + iResponse = NULL; + if (!aErr) { TAccInfo info; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btaudioman/src/btaudiomanplugin.cpp --- a/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btaudioman/src/btaudiomanplugin.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 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" @@ -70,23 +70,27 @@ TInt CBtAudioManPlugin::Connect( const TBTDevAddr& aAddr ) { TRACE_FUNC - return HandleAsyncRequest(aAddr, ERequestConnect); + TInt err = PrepareAsyncRequest(aAddr, ERequestConnect); + if(!err) + { + iDiagnostic.Zero(); + iClient.ConnectToAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic); + iActive4ClientReq->GoActive(); + } + return err; } void CBtAudioManPlugin::CancelConnect( const TBTDevAddr& aAddr ) { if (iBTDevAddrPckgBuf() == aAddr && - iActive4ClientReq && iActive4ClientReq->IsActive() && iActive4ClientReq->RequestId() == ERequestConnect ) { TRACE_INFO(_L("CBtAudioManPlugin::CancelConnect KErrCancel")) - delete iActive4ClientReq; - iActive4ClientReq = NULL; + iActive4ClientReq->Cancel(); if (iObserver) { - iObserver->ConnectComplete(iBTDevAddrPckgBuf(), - EBTProfileHFP, KErrCancel); + iObserver->ConnectComplete(aAddr, EBTProfileHFP, KErrCancel); } } else @@ -94,8 +98,7 @@ TRACE_INFO(_L("CBtAudioManPlugin::CancelConnect KErrNotFound")) if (iObserver) { - iObserver->ConnectComplete(aAddr , - EBTProfileHFP, KErrNotFound); + iObserver->ConnectComplete(aAddr, EBTProfileHFP, KErrNotFound); } } @@ -107,12 +110,26 @@ if (aAddr == TBTDevAddr()) { req = ERequestDisconnectAll; - } - return HandleAsyncRequest(aAddr, req); + } + TInt err = PrepareAsyncRequest(aAddr, req); + if (!err) + { + if (req == ERequestDisconnect) + { + iClient.DisconnectAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic); + } + else // if (req == ERequestDisconnectAll) + { + iClient.DisconnectAllGracefully(iActive4ClientReq->iStatus); + } + iActive4ClientReq->GoActive(); + } + return err; } void CBtAudioManPlugin::GetConnections( RBTDevAddrArray& aAddrArray, TBTProfile aConnectedProfile ) { + TRACE_FUNC aAddrArray.Reset(); TProfiles profile = EUnknownProfile; @@ -133,7 +150,6 @@ TInt numAddresses = 2; TInt count = numAddresses; RBuf8 addrbuf; - TPtrC8 ptr(addrbuf); do { @@ -171,6 +187,8 @@ //maybe another connection was established while this was taking place while (count > numAddresses); + TPtrC8 ptr(addrbuf); + //iterate through the addresses buffer while (ptr.Length() >= KBTDevAddrSize) { @@ -207,22 +225,45 @@ void CBtAudioManPlugin::RequestCompletedL(CBasrvActive& aActive) { TRACE_FUNC + TInt result = aActive.iStatus.Int(); switch (aActive.RequestId()) { case ENotifyProfileStatusChange: { - if (aActive.iStatus == KErrNone && iObserver) + // Notify any observer if one is present, and we got valid data (i.e. no error) + if (result == KErrNone && iObserver) + { + ReportProfileConnectionEvents(iProfileStatus.iAddr, iProfileStatus.iProfiles, iProfileStatus.iConnected); + } + // Handle resubscribing for future notifications + static const TInt KMaxFailedNotifyConnectionStatusAttempts = 3; + if (result == KErrNone) + { + iNotifyConnectionStatusFailure = 0; // reset failure count + NotifyConnectionStatus(); + } + else if (result != KErrServerTerminated && iNotifyConnectionStatusFailure < KMaxFailedNotifyConnectionStatusAttempts) { - ReportProfileConnectionEvents(iProfileStatus.iAddr, iProfileStatus.iProfiles, - iProfileStatus.iConnected); - iClient.NotifyConnectionStatus(iProfileStatusPckg, aActive.iStatus); - aActive.GoActive(); + TRACE_ERROR((_L8("Connection Status Notification failed (transiently): %d"), result)) + ++iNotifyConnectionStatusFailure; + NotifyConnectionStatus(); + } + else + { + // The server has died unexpectedly, or we've failed a number of times in succession so we cannot re-subscribe. + // The lack of state here makes it diffcult to know how to report (handle?) this. However, we are in + // no worse situation than before, plus the issue is now logged. + TRACE_ERROR((_L8("Connection Status Notification failed (terminally): %d"), result)) + iClient.Close(); // clean the handle, this might kill outstanding disconnect/connect requests + // but it looks like the server is hosed anyway... + // In keeping with the existing logic we don't attempt to re-start the server. That will only happen when an + // active request is made. } break; } case ERequestConnect: { - if (iActive4ClientReq->iStatus.Int() != KErrNone) // might have conflicts, decode iDiagnostic + if (result != KErrNone) // might have conflicts, decode iDiagnostic { if (iDiagnostic.Length() >= KBTDevAddrSize) { @@ -238,14 +279,12 @@ TRACE_INFO((_L8("conflict <%S>"), &myPtr)) ptr.Set(ptr.Mid(KBTDevAddrSize)); } - iObserver->ConnectComplete(iBTDevAddrPckgBuf(), - EBTProfileHFP, iActive4ClientReq->iStatus.Int(), &array); + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result, &array); CleanupStack::PopAndDestroy(&array); } else { - iObserver->ConnectComplete(iBTDevAddrPckgBuf(), - EBTProfileHFP, iActive4ClientReq->iStatus.Int()); + iObserver->ConnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result); } } else @@ -258,16 +297,13 @@ } ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), profile, ETrue); } - delete iActive4ClientReq; - iActive4ClientReq = NULL; break; } case ERequestDisconnect: { - if (iActive4ClientReq->iStatus.Int() != KErrNone) + if (result != KErrNone) { - iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), - EBTProfileHFP, iActive4ClientReq->iStatus.Int()); + iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result); } else { @@ -278,27 +314,24 @@ pckg.Copy(iDiagnostic.Mid(0, sizeof(TInt))); } ReportProfileConnectionEvents(iBTDevAddrPckgBuf(), profile, EFalse); - } - delete iActive4ClientReq; - iActive4ClientReq = NULL; + } break; } case ERequestDisconnectAll: { - iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), - EBTProfileHFP, iActive4ClientReq->iStatus.Int()); - break; + iObserver->DisconnectComplete(iBTDevAddrPckgBuf(), EBTProfileHFP, result); + break; } } } void CBtAudioManPlugin::CancelRequest(CBasrvActive& aActive) { - if (aActive.RequestId() == ENotifyProfileStatusChange ) + if (aActive.RequestId() == ENotifyProfileStatusChange) { iClient.CancelNotifyConnectionStatus(); } - else if (aActive.RequestId() == ERequestConnect ) + else if (aActive.RequestId() == ERequestConnect) { iClient.CancelConnectToAccessory(); } @@ -312,51 +345,49 @@ void CBtAudioManPlugin::ConstructL() { LEAVE_IF_ERROR(iClient.Connect()); + // Create the handler for profile notifications iActive4ProfileStatus = CBasrvActive::NewL(*this, CActive::EPriorityStandard, ENotifyProfileStatusChange); + NotifyConnectionStatus(); + // Create the handler for active requests (connect, disconnect, etc.) + iActive4ClientReq = CBasrvActive::New(*this, CActive::EPriorityStandard, ERequestConnect); + } + +void CBtAudioManPlugin::NotifyConnectionStatus() + { iClient.NotifyConnectionStatus(iProfileStatusPckg, iActive4ProfileStatus->iStatus); iActive4ProfileStatus->GoActive(); } -TInt CBtAudioManPlugin::HandleAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId) +TInt CBtAudioManPlugin::ReconnectIfNeccessary() { TInt err = KErrNone; - if (! iClient.Handle() ) + if (iClient.Handle() == KNullHandle) { + TRACE_INFO((_L8("Handle to Audio Man Server is not valid, connecting again..."))) err = iClient.Connect(); + TRACE_INFO((_L8("... reconnection result = %d"), err)) + if(!err) + { + // Now reconnected, we should start status notifications again... + NotifyConnectionStatus(); + } } - if ( err ) + return err; + } + +TInt CBtAudioManPlugin::PrepareAsyncRequest(const TBTDevAddr& aAddr, TInt aRequestId) + { + TInt err = KErrNone; + err = ReconnectIfNeccessary(); + if (!err && iActive4ClientReq->IsActive()) { - return err; - } - if ( iActive4ClientReq ) - { + // I would normally expect KErrInUse, so as to distinguish this failure from running out of message slots err = KErrServerBusy; } if (!err) { - iActive4ClientReq = CBasrvActive::New(*this, CActive::EPriorityStandard, aRequestId); - if (iActive4ClientReq) - { - iBTDevAddrPckgBuf() = aAddr; - if (aRequestId == ERequestConnect) - { - iDiagnostic.Zero(); - iClient.ConnectToAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic); - } - else if (aRequestId == ERequestDisconnect) - { - iClient.DisconnectAccessory(iActive4ClientReq->iStatus, iBTDevAddrPckgBuf, iDiagnostic); - } - else // if (aRequestId == ERequestDisconnectAll) - { - iClient.DisconnectAllGracefully(iActive4ClientReq->iStatus); - } - iActive4ClientReq->GoActive(); - } - else - { - err = KErrNoMemory; - } + iBTDevAddrPckgBuf() = aAddr; + iActive4ClientReq->SetRequestId(aRequestId); } return err; } @@ -365,7 +396,7 @@ { TRACE_FUNC TRACE_INFO((_L("status %d profiles 0x%04X"), aConnected, aProfiles)) - TBTEngConnectionStatus status = IsConnected(aAddr); + TBTEngConnectionStatus status = IsConnected(aAddr); if (iObserver) { if (aConnected) @@ -385,21 +416,21 @@ } else { - if( status != EBTEngConnected ) - { - if (aProfiles & EHFP) - { - iObserver->DisconnectComplete(aAddr, EBTProfileHFP, KErrNone); - } - if (aProfiles & EHSP) - { - iObserver->DisconnectComplete(aAddr, EBTProfileHSP, KErrNone); - } - if (aProfiles & EStereo) - { - iObserver->DisconnectComplete(aAddr, EBTProfileA2DP, KErrNone); - } - } + if (status != EBTEngConnected) + { + if (aProfiles & EHFP) + { + iObserver->DisconnectComplete(aAddr, EBTProfileHFP, KErrNone); + } + if (aProfiles & EHSP) + { + iObserver->DisconnectComplete(aAddr, EBTProfileHSP, KErrNone); + } + if (aProfiles & EStereo) + { + iObserver->DisconnectComplete(aAddr, EBTProfileA2DP, KErrNone); + } + } } } } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/btfeatures/btfeatures.cpp --- a/bluetoothengine/bteng/btfeatures/btfeatures.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/btfeatures/btfeatures.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -16,19 +16,11 @@ */ -#include -#include -#include +#include -/** - Device supports bluetooth data profiles disabled. -*/ -const TInt KFeatureIdTempFfBluetoothDataProfilesDisabled = 0x1000001; - -/** - Device supports bluetooth disabled. -*/ -const TInt KFeatureIdTempFfBluetoothDisabled = 0x1000002; +#include + +#include "btengprivatecrkeys.h" EXPORT_C void BluetoothFeatures::SetEnterpriseEnablementL(BluetoothFeatures::TEnterpriseEnablementMode aMode) @@ -40,54 +32,72 @@ if ( proc.SecureId() != KDcmoServerSecureUid ) { User::Leave(KErrPermissionDenied); - } - - const TUid KBtDisabledUid = {KFeatureIdTempFfBluetoothDisabled}; - const TUid KBtDataProfilesDisabledUid = {KFeatureIdTempFfBluetoothDataProfilesDisabled}; - - RFeatureControl featureControl; - User::LeaveIfError(featureControl.Connect()); - CleanupClosePushL(featureControl); - switch ( aMode ) + } + + // get ready to use the central repository. + CRepository* cenRep = CRepository::NewL(KCRUidBTEngPrivateSettings); + CleanupStack::PushL(cenRep); + + switch(aMode) { case EDisabled: - User::LeaveIfError(featureControl.EnableFeature(KBtDisabledUid)); - User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid)); + User::LeaveIfError(cenRep->Set(KBluetoothEnterpriseState, EBluetoothEnterpriseDisabled)); break; case EDataProfilesDisabled: - User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid)); - User::LeaveIfError(featureControl.EnableFeature(KBtDataProfilesDisabledUid)); + User::LeaveIfError(cenRep->Set(KBluetoothEnterpriseState, EBluetoothEnterpriseDataProfilesDisabled)); break; case EEnabled: - User::LeaveIfError(featureControl.DisableFeature(KBtDisabledUid)); - User::LeaveIfError(featureControl.DisableFeature(KBtDataProfilesDisabledUid)); + User::LeaveIfError(cenRep->Set(KBluetoothEnterpriseState, EBluetoothEnterpriseEnabled)); break; default: User::Leave(KErrArgument); break; } - CleanupStack::PopAndDestroy(&featureControl); + + CleanupStack::PopAndDestroy(cenRep); } EXPORT_C BluetoothFeatures::TEnterpriseEnablementMode BluetoothFeatures::EnterpriseEnablementL() { - TEnterpriseEnablementMode mode = EDisabled; + TEnterpriseEnablementMode mode = EEnabled; + TInt setting = EBluetoothEnterpriseEnabled; + + // get the value out of the repository. + CRepository* cenRep = CRepository::NewL(KCRUidBTEngPrivateSettings); + CleanupStack::PushL(cenRep); - FeatureManager::InitializeLibL(); - const TBool bluetoothDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDisabled); - if ( !bluetoothDisabled ) + TInt err = cenRep->Get(KBluetoothEnterpriseState, setting); + if(err == KErrNotFound) { - const TBool dataProfilesDisabled = FeatureManager::FeatureSupported(KFeatureIdTempFfBluetoothDataProfilesDisabled); - if ( dataProfilesDisabled ) + // not found in repository, so assume enabled by default + mode = EEnabled; + } + else if(err == KErrNone) + { + // Got a value from repository, convert it as appropriate. + switch(setting) { + case EBluetoothEnterpriseDisabled: + mode = EDisabled; + break; + case EBluetoothEnterpriseDataProfilesDisabled: mode = EDataProfilesDisabled; - } - else - { + break; + case EBluetoothEnterpriseEnabled: mode = EEnabled; - } + break; + default: + User::Leave(KErrUnknown); + break; + } } - FeatureManager::UnInitializeLib(); - + else + { + // Some other error accessing the central repository. + User::Leave(err); + } + + CleanupStack::PopAndDestroy(cenRep); + return mode; } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/btfeatures/btfeatures.mmp --- a/bluetoothengine/bteng/btfeatures/btfeatures.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/btfeatures/btfeatures.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -28,9 +28,10 @@ SOURCEPATH . SOURCE btfeatures.cpp +USERINCLUDE ../../inc MW_LAYER_SYSTEMINCLUDE LIBRARY euser.lib -LIBRARY featmgr.lib +LIBRARY centralrepository.lib deffile ~/btfeatures.def diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/bttoggle/inc/bttoggle.h --- a/bluetoothengine/bteng/bttoggle/inc/bttoggle.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/bttoggle/inc/bttoggle.h Fri Apr 16 15:08:36 2010 +0300 @@ -143,10 +143,10 @@ enum TToggleActiveNotifier { - ENoneQuery = 0, + ENoneQuery = 0, EPowerModeQuery, ECloseConnectionQuery, - EFakeNotif + EPowerModeChangeNote }; private: //Data diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/bttoggle/src/bttoggle.cpp --- a/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/bttoggle/src/bttoggle.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -177,21 +177,21 @@ //BT Connected or error obtaining link count (in the case of error, we are cautious and assume BT is connected) if (errLinkCount || linkCount > 0) { - TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") )) + TRACE_INFO((_L("[BTENG][BTTOGGLE]Ongoing BT connection") )) __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateCloseConnectionQuery)); - iActiveNotifier = ECloseConnectionQuery; + iActiveNotifier = ECloseConnectionQuery; iPckgGenericQuery().iMessageType = EBTSwitchOffAnyway; iPckgGenericQuery().iNameExists = EFalse; - iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery ); - SetActive(); - } + iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericQueryNotifierUid, iPckgGenericQuery, iConnQuery ); + SetActive(); + } //No open connections else { TRACE_INFO((_L("[BTENG][BTTOGGLE] No BT connections") )) ChangeBtPowerMode(EBTPowerOff); - } + } } TRACE_FUNC_EXIT } @@ -241,20 +241,17 @@ TRACE_FUNC_ENTRY __ASSERT_DEBUG(iActiveNotifier == ENoneQuery, Panic(EBTToggleInvalidStateChangeBtPowerMode)); - TRequestStatus *stat = &iStatus; - TInt errPower = iSettings->SetPowerState(aNewPowerState); - + TInt errPower = iSettings->SetPowerState(aNewPowerState); if (KErrNone == errPower) { ShowNotification( static_cast(aNewPowerState) ); + iActiveNotifier = EPowerModeChangeNote; + iStatus = KRequestPending; + SetActive(); } - iActiveNotifier = EFakeNotif; - iStatus = KRequestPending; - User::RequestComplete(stat, KErrNone); - SetActive(); TRACE_FUNC_EXIT - return errPower; + return errPower; } // ========================================================== @@ -284,7 +281,7 @@ Cancel(); //Start new notification - iNotifier.StartNotifier(KBTGenericInfoNotifierUid, pckgGenericInfo, result); + iNotifier.StartNotifierAndGetResponse(iStatus, KBTGenericInfoNotifierUid, pckgGenericInfo, result); TRACE_FUNC_EXIT } @@ -304,7 +301,11 @@ else if ( ECloseConnectionQuery == iActiveNotifier ) { iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); - } + } + else if ( EPowerModeChangeNote == iActiveNotifier ) + { + iNotifier.CancelNotifier(KBTGenericQueryNotifierUid); + } // For all cancels, we must reset iActiveNotifier back to ENoneQuery // to permit another request to be made. @@ -328,10 +329,10 @@ // to permit another request to be made. switch (iActiveNotifier) { - case EPowerModeQuery: + case EPowerModeQuery: iActiveNotifier = ENoneQuery; - ShowNotification(ETrue); - CActiveScheduler::Stop(); + ShowNotification(ETrue); + SetActive(); break; case ECloseConnectionQuery: iActiveNotifier = ENoneQuery; @@ -343,8 +344,8 @@ { CActiveScheduler::Stop(); } - break; - default: //ENoneQuery or EFakeNotif + break; + default: //ENoneQuery or EPowerModeChangeNote iActiveNotifier = ENoneQuery; CActiveScheduler::Stop(); } @@ -358,8 +359,9 @@ // ========================================================== // TInt CBTToggle::RunError(TInt aError) - { - TRACE_INFO((_L("[BTENG][BTTOGGLE]RunL error %d"), aError )) - CActiveScheduler::Stop(); - return KErrNone; - } + { + TRACE_INFO((_L("[BTENG][BTTOGGLE] RunError %d"), aError )) + iActiveNotifier = ENoneQuery; + CActiveScheduler::Stop(); + return KErrNone; + } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/cenrep/keys_bteng.xls Binary file bluetoothengine/bteng/cenrep/keys_bteng.xls has changed diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/conf/bteng.confml Binary file bluetoothengine/bteng/conf/bteng.confml has changed diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/conf/bteng_10204DAC.crml Binary file bluetoothengine/bteng/conf/bteng_10204DAC.crml has changed diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/data/btengsdp.rss --- a/bluetoothengine/bteng/data/btengsdp.rss Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/data/btengsdp.rss Fri Apr 16 15:08:36 2010 +0300 @@ -879,7 +879,7 @@ elements = { ELEMENT_UUID { uuid = SERVICE_CLASS_ID_HEADSET; }, - ELEMENT_WORD { value = 0x0100; } + ELEMENT_WORD { value = 0x0102; } }; } }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/data/btrfs.txt Binary file bluetoothengine/bteng/data/btrfs.txt has changed diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/data/bttoggle_reg.rss --- a/bluetoothengine/bteng/data/bttoggle_reg.rss Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/data/bttoggle_reg.rss Fri Apr 16 15:08:36 2010 +0300 @@ -24,7 +24,9 @@ RESOURCE APP_REGISTRATION_INFO { - app_file = "bttoggle"; + app_file = "bttoggle"; + hidden = KAppIsHidden; + launch = KAppLaunchInForeground; } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/group/backup_registration.xml --- a/bluetoothengine/bteng/group/backup_registration.xml Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/group/bld.inf --- a/bluetoothengine/bteng/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 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" @@ -39,11 +39,6 @@ ../conf/bteng_10204DAB.crml MW_LAYER_CRML(bteng_10204DAB.crml) ../conf/bteng_10204DAC.crml MW_LAYER_CRML(bteng_10204DAC.crml) - -// Backup registration file -backup_registration.xml /epoc32/data/z/private/10005950/backup_registration.xml -backup_registration.xml /epoc32/release/winscw/udeb/z/private/10005950/backup_registration.xml -backup_registration.xml /epoc32/release/winscw/urel/z/private/10005950/backup_registration.xml ../data/btrfs.txt /epoc32/data/z/resource/btrfs.txt ../data/btrfs.txt /epoc32/release/winscw/udeb/z/resource/btrfs.txt ../data/btrfs.txt /epoc32/release/winscw/urel/z/resource/btrfs.txt diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/group/bteng.mmp --- a/bluetoothengine/bteng/group/bteng.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/group/bteng.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -35,11 +35,11 @@ SOURCE btengsrvbbconnectionmgr.cpp SOURCE btengsdpdbhandler.cpp SOURCE btengsrvkeywatcher.cpp -SOURCE btengactive.cpp SOURCE btengpairman.cpp SOURCE btengpairbase.cpp SOURCE btengincpair.cpp SOURCE btengotgpair.cpp +SOURCE btengsrvsettingsmgr.cpp START RESOURCE ../data/btengsdp.rss HEADER TARGETPATH RESOURCE_FILES_DIR @@ -64,6 +64,10 @@ LIBRARY aknnotify.lib LIBRARY btfeatures.lib +#ifndef SETLOCALNAME +LIBRARY btengsettings.lib +#endif + LIBRARY btpowercontrol.lib #ifndef __WINS__ LIBRARY dutmode.lib diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/group/btengconnman.mmp --- a/bluetoothengine/bteng/group/btengconnman.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/group/btengconnman.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -31,7 +31,6 @@ SOURCE btengconnhandler.cpp SOURCEPATH ../src SOURCE btengclient.cpp -SOURCE btengactive.cpp USERINCLUDE ../inc USERINCLUDE ../btengconnman/inc diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/group/btengdiscovery.mmp --- a/bluetoothengine/bteng/group/btengdiscovery.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/group/btengdiscovery.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -32,7 +32,6 @@ SOURCE btengsdpattrparser.cpp SOURCE btengdevicesearch.cpp SOURCEPATH ../src -SOURCE btengactive.cpp SOURCE btengsdpdbhandler.cpp USERINCLUDE ../inc diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/group/btengsettings.mmp --- a/bluetoothengine/bteng/group/btengsettings.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/group/btengsettings.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -30,7 +30,6 @@ SOURCE btengsettings.cpp SOURCE btengsettingsnotify.cpp SOURCEPATH ../src -SOURCE btengactive.cpp SOURCE btengclient.cpp USERINCLUDE ../inc diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengactive.h --- a/bluetoothengine/bteng/inc/btengactive.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengactive.h Fri Apr 16 15:08:36 2010 +0300 @@ -86,10 +86,12 @@ * @since S60 v3.2 * @param aObserver Pointer to callback interface that receives notification * that the request has been completed. + * @param aId Identifier for the CBTEngActive instance. + * @param aPriority The priority of the active object. * @return Pointer to the constructed CBTEngActive object. */ - static CBTEngActive* NewL( MBTEngActiveObserver& aObserver, - TInt aId, TInt aPriority ); + static CBTEngActive* NewL( MBTEngActiveObserver& aObserver, TInt aId, + TInt aPriority = CActive::EPriorityStandard ); /** * Destructor diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengactive.inl --- a/bluetoothengine/bteng/inc/btengactive.inl Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengactive.inl Fri Apr 16 15:08:36 2010 +0300 @@ -16,6 +16,66 @@ */ +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +inline CBTEngActive::CBTEngActive( MBTEngActiveObserver& aObserver, TInt aId, + TInt aPriority ) +: CActive( aPriority ), + iRequestId( aId ), + iObserver( aObserver ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// Symbian 2nd-phase constructor +// --------------------------------------------------------------------------- +// +inline void CBTEngActive::ConstructL() + { + } + + +// --------------------------------------------------------------------------- +// NewLC +// --------------------------------------------------------------------------- +// +inline CBTEngActive* CBTEngActive::NewL( MBTEngActiveObserver& aObserver, + TInt aId, TInt aPriority ) + { + CBTEngActive* self = new( ELeave ) CBTEngActive( aObserver, aId, aPriority ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +inline CBTEngActive::~CBTEngActive() + { + Cancel(); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been cancelled. +// --------------------------------------------------------------------------- +// +inline void CBTEngActive::DoCancel() + { + } + + // ----------------------------------------------------------------------------- // Get the identifier of this instance. @@ -65,3 +125,26 @@ { return iStatus; } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when the request has been completed. +// --------------------------------------------------------------------------- +// +inline void CBTEngActive::RunL() + { + iObserver.RequestCompletedL( this, iRequestId, iStatus.Int() ); + } + + +// --------------------------------------------------------------------------- +// From class CActive. +// Called by the active scheduler when an error in RunL has occurred. +// --------------------------------------------------------------------------- +// +inline TInt CBTEngActive::RunError( TInt aError ) + { + iObserver.HandleError( this, iRequestId, aError ); + return KErrNone; + } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengincpair.h --- a/bluetoothengine/bteng/inc/btengincpair.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengincpair.h Fri Apr 16 15:08:36 2010 +0300 @@ -176,6 +176,7 @@ */ RTimer iPairingOkTimer; CBTEngActive* iActivePairingOk; + TBool iUserAwarePairing; }; #endif /*BTENGINCPAIR_H_*/ diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengpairman.h --- a/bluetoothengine/bteng/inc/btengpairman.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengpairman.h Fri Apr 16 15:08:36 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 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" @@ -61,12 +61,6 @@ void ProcessCommandL( const RMessage2& aMessage ); /** - * Cancels an outstanding command. - * @param aOpcode the identifier of the command to be cancelled. - */ - void CancelCommand( TInt aOpCode ); - - /** * Handle a change in BTRegistry remote device table. * * @since S60 v5.1 @@ -103,6 +97,14 @@ void OutgoingPairCompleted( TInt aErr ); /** + * Be informed that a session will be closed. + * + * @since Symbian^3 + * @param aSession the session to be cloased. + */ + void SessionClosed(CSession2* aSession ); + + /** * Unpair a device via registry */ void UnpairDevice( const TBTDevAddr& aAddr ); @@ -165,6 +167,16 @@ void ConstructL(); /** + * Initialiases the paired devices list + */ + void InitPairedDevicesList(); + + /** + * Initialises the paired devices list (second stage) + */ + void DoInitPairedDevicesList(); + + /** * Activate / deactivate a pair observer */ TInt SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate); @@ -313,6 +325,31 @@ * Own. */ CBTEngPairBase* iPairer; + + /** + * Client-server message for power change requests. + */ + RMessage2 iMessage; + + /** + * AO for local address updates. + */ + CBTEngActive* iLocalAddrActive; + + /** + * Provides access to the BT local device address. + */ + RProperty iPropertyLocalAddr; + + /** + * Records whether or not this CBTEngPairMan has ever been involed in a pairing operaton. + */ + TBool iPairingOperationAttempted; + + /** + * Counter of unhandled paired device view initialisation requests. + */ + TInt iNotHandledInitEventCounter; }; #endif /*BTENGPAIRMANAGER_H_*/ diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengprivatecrkeys.h --- a/bluetoothengine/bteng/inc/btengprivatecrkeys.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengprivatecrkeys.h Fri Apr 16 15:08:36 2010 +0300 @@ -79,8 +79,6 @@ */ const TUint32 KBTSapEnabled = 0x00000003; -const TUint32 KBtHidKeyboardLayout = 0x00000004; - /** Enumeration for Bluetooth SAP setting */ enum TBTSapMode { @@ -88,5 +86,16 @@ EBTSapEnabled }; +const TUint32 KBtHidKeyboardLayout = 0x00000004; + +const TUint32 KBluetoothEnterpriseState = 0x00000005; + +enum TBluetoothEnterpriseState + { + EBluetoothEnterpriseDisabled = 0, + EBluetoothEnterpriseDataProfilesDisabled = 1, + EBluetoothEnterpriseEnabled = 2, + }; + #endif // BTENG_PRIVATE_CR_KEYS_H diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengserver.h --- a/bluetoothengine/bteng/inc/btengserver.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengserver.h Fri Apr 16 15:08:36 2010 +0300 @@ -20,13 +20,10 @@ #define BTENGSERVER_H #include -#ifndef __WINS__ -#include -#endif //__WINS__ #include #include -#include -#include "btengdomaincrkeys.h" +#include + #include "btengconstants.h" class CBTEngSrvState; @@ -40,6 +37,7 @@ class TEComResolverParams; class CImplementationInformation; class CDeltaTimer; +class CBTEngSrvSettingsMgr; /** * Main function in which the server is running. @@ -75,7 +73,8 @@ EBTEngPanicArgumentIsNull, EBTEngPanicMemberVarIsNull, EBTEngPanicCorrupt, - EBTEngPanicCorruptSettings + EBTEngPanicCorruptSettings, + EBTEngPanicExpectSetPowerOpcode, }; @@ -90,43 +89,114 @@ NONSHARABLE_CLASS( CBTEngServer ) : public CPolicyServer { - friend class CBTEngSrvSession; - friend class CBTEngSrvState; friend class CBTEngSrvPluginMgr; - friend class CBTEngSrvKeyWatcher; friend class CBTEngPairMan; public: + /** Enumeration of bitmask for keeping track of different timers. */ + enum TTimerQueued + { + ENone = 0x00, + EScanModeTimer = 0x01, + EIdleTimer = 0x02, + EAutoPowerOffTimer = 0x04, + ESspDebugModeTimer = 0x08 + }; + + /** + * Two-phased constructor. + */ static CBTEngServer* NewLC(); + /** + * Destructor. + */ virtual ~CBTEngServer(); /** - * ?description + * Getter for power change state machine instance. + * + * @since Symbian^3 + * @return Pointer to instance of state machine. + */ + inline CBTEngSrvState* StateMachine() const + { return iServerState; } + + /** + * Getter for settings manager instance. + * + * @since Symbian^3 + * @return Pointer to instance of settings manager. + */ + inline CBTEngSrvSettingsMgr* SettingsManager() const + { return iSettingsMgr; } + + /** + * Getter for plug-in manager instance. + * + * @since Symbian^3 + * @return Pointer to instance of plug-in manager. + */ + inline CBTEngSrvPluginMgr* PluginManager() const + { return iPluginMgr; } + + /** + * Getter for baseband connection manager instance. + * + * @since Symbian^3 + * @return Pointer to instance of baseband connection manager. + */ + inline CBTEngSrvBBConnMgr* BasebandConnectionManager() const + { return iBBConnMgr; } + + /** + * Getter for pairing manager. Ownership is not transferred. + * + * @since Symbian^3 + * @return Pointer to instance of baseband connection manager. + */ + inline CBTEngPairMan* PairManager() const + { return iPairMan; } + + /** + * Getter for socket server session. + * This handle can be used for creating subsessions. + * + * @since Symbian^3 + * @return Reference to session with the socket server. + */ + inline RSocketServ& SocketServer() + { return iSocketServ; } + + /** + * Getter for registry server session. + * This handle can be used for creating subsessions. + * + * @since Symbian^3 + * @return Reference to session with the registry server. + */ + inline RBTRegServ& RegistrServer() + { return iBTRegServ; } + + /** + * Set Bluetooth on or off * * @since S60 v3.2 * @param aState The new power state. - * @param aTemp Turn BT off after use (ETrue) or not (EFalse). + * @param aTemporary Turn BT off after use (ETrue) or not (EFalse). */ - void SetPowerStateL( TBTPowerStateValue aState, TBool aTemporary ); + void SetPowerStateL( TBTPowerState aState, TBool aTemporary ); /** - * ?description + * Set Bluetooth on or off upon a client power management request. + * This function is only for power management request from clients of bteng server. * - * @since S60 v3.2 - * @param ?arg1 ?description + * @since Symbian^3 + * @param aMessage The message containing the detail of power management request. */ - void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ); + void SetPowerStateL( const RMessage2 aMessage ); - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void UpdateVisibilityModeL( TInt aStackScanMode ); - /** * ?description * @@ -141,23 +211,7 @@ * @since S60 v3.2 * @param ?arg1 ?description */ - void SetDutMode( TInt aDutMode ); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void ScanModeTimerCompletedL(); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void DisconnectAllCompleted(); + void DisconnectAllCompleted(); /** * ?description @@ -172,86 +226,89 @@ * * @since S60 v3.2 */ - void AddSession(); + void AddSession(); /** * Decrement the session count. * - * @since S60 v3.2 + * @since Symbian^3 + * @param aSession the session to be cloased. * @param aAutoOff Indicator if this session had requested BT temporary on. */ - void RemoveSession( TBool aAutoOff ); - - /** - * ?description + void RemoveSession(CSession2* aSession, TBool aAutoOff ); + + /** + * Queue a new timer. + * + * @since Symbian^3 + * @param aTimer Identifier for the timer to be queued. + * @param aInterval The interval for timer callback. + */ + void QueueTimer( CBTEngServer::TTimerQueued aTimer, TInt64 aInterval ); + + /** + * Remove a queued timer. + * + * @since Symbian^3 + * @param aTimer Identifier for the timer to be removed. + */ + void RemoveTimer( CBTEngServer::TTimerQueued aTimer ); + + /** + * Check if a specific timer is currently queued. + * + * @since Symbian^3 + * @param aTimer Identifier for the timer to check. + */ + inline TBool IsTimerQueued( CBTEngServer::TTimerQueued aTimer ) const + { return ( iTimerQueued & aTimer ); } + + /** + * Returns the service (limited to services managed in bteng scope) + * level connection status of the specified device. + * + * @param aAddr the address of the device + * @return one of TBTEngConnectionStatus enums + */ + TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); + + /** + * Checks if power is off and no session are connected, and + * starts a shutdown timer if so. * * @since S60 v3.2 * @param ?arg1 ?description */ - void SetUiIndicatorsL(); - - /** + void CheckIdle(); + + /** * ?description * * @since S60 v3.2 * @param ?arg1 ?description */ - void SetIndicatorStateL( const TInt aIndicator, const TInt aState ); - - /** - * Check whether BT should be turned off automatically. - * - * @since S60 v5.0 - */ - void CheckAutoPowerOffL(); + void ManageDIServiceL( TBool aState ); /** - * Utility to get HW power state. - * - * @since S60 v5.1 - * @param aState On return, this will contain the current HW power state. - * @return KErrNone if successful, otherwise one of the system-wide error codes. - */ - TInt GetHwPowerState( TBTPowerStateValue& aState ); - - /** - * queue a timer if Simple Pairing debug mode has been enabled. + * Callback function for completion of disconnecting all + * Bluetoooth Baseband links. * * @since S60 v3.2 - * @param aDebugMode State of Simple Pairing debug mode. + * @param aPtr Pointer to ourselves. + * @return Result */ - void CheckSspDebugModeL( TBool aDebugMode ); - - /** - * Gets the access to pairing manager. Ownership is not transferred. - * @return the pairing manager - */ - CBTEngPairMan& PairManager(); - - /** - * Be informed when registry remote device table is changed - */ - void RemoteRegistryChangeDetected(); + static TInt DisconnectAllCallBack( TAny* aPtr ); - /** - * gets the reference of socket server session - */ - RSocketServ& SocketServ(); - - /** - * gets the reference of registry session. - */ - RBTRegServ& BTRegServ(); - - /** - * Returns the service (limited to services managed in bteng scope) - * level connection status of the specified device. - * - * @param aAddr the address of the device - * @return one of TBTEngConnectionStatus enums - */ - TBTEngConnectionStatus IsDeviceConnected( const TBTDevAddr& aAddr ); - + /** + * Callback function for turning BT off automatically after all + * connections are gone. + * + * @since S60 v5.0 + * @param aPtr Pointer to ourselves. + * @return Result + */ + static TInt AutoPowerOffCallBack( TAny* aPtr ); + // from base class CPolicyServer /** @@ -264,10 +321,6 @@ virtual CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const; -// from base class MBTPowerManagerObserver - - BluetoothFeatures::TEnterpriseEnablementMode EnterpriseEnablementMode() const; - private: CBTEngServer(); @@ -275,81 +328,6 @@ void ConstructL(); /** - * Checks if power is off and no session are connected, and - * starts a shutdown timer if so. - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void CheckIdle(); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - TInt SetPowerState( TBool aState ); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - TInt SetLocalNameL(); - - TInt GetLocalNameFromRegistryL(TDes& aName); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void SetClassOfDeviceL(); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void InitBTStackL(); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void StopBTStackL(); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void UpdateCenRepPowerKeyL( TBTPowerStateValue aValue ); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void LoadBTPowerManagerL(); - - /** - * ?description - * - * @since S60 v3.2 - * @param ?arg1 ?description - */ - void ManageDIServiceL( TBool aState ); - - /** * Reads the product-specific IDs for this phone from central repository. * These values are used in the BT Device Information profile. * @@ -358,19 +336,6 @@ * @param aProductId On return, holds the product ID for this phone. */ void GetProductIdsL( TInt& aVendorId, TInt& aProductId ); - - /** - * Checks if a client requests temporary power on/off, and keeps track - * of the number of clients requesting that. - * - * @since S60 v5.0 - * @param aCurrentState On return, will contain the current power state. - * @param aNewState The requested power state. - * @param aTemporary Indicates if this is about a tempororary state change. - */ - void CheckTemporaryPowerStateL( TBTPowerStateValue& aCurrentState, - TBTPowerStateValue aNewState, - TBool aTemporary ); /** * Callback function for expiry of CDeltaTimer timer of temporary @@ -383,16 +348,6 @@ static TInt ScanModeTimerCallBack( TAny* aPtr ); /** - * Callback function for completion of disconnecting all - * Bluetoooth Baseband links. - * - * @since S60 v3.2 - * @param aPtr Pointer to ourselves. - * @return Result - */ - static TInt DisconnectAllCallBack( TAny* aPtr ); - - /** * Callback function for expiriy CDeltaTimer timer of server idle timeout. * * @since S60 v3.2 @@ -410,17 +365,7 @@ * @return Result */ static TInt DebugModeTimerCallBack( TAny* aPtr ); - - /** - * Callback function for turning BT off automatically after all - * connections are gone. - * - * @since S60 v5.0 - * @param aPtr Pointer to ourselves. - * @return Result - */ - static TInt AutoPowerOffCallBack( TAny* aPtr ); - + private: // data /** @@ -436,28 +381,6 @@ TUint32 iDiSdpRecHandle; /** - * Flag indicating if BT is going to be switched off automatically. - */ - TBool iAutoSwitchOff; - - /** - * Number of clients that are using BT temporarily. - * Note that this is equal or less than the active number of links. - */ - TInt iAutoOffClients; - - /** - * Flag indicating hidden mode has been set for temporary power on. - */ - TBool iRestoreVisibility; - - /** - * To decide wether DUT mode should be enabled in power mode - * change callback. - */ - TBool iEnableDutMode; - - /** * Remember which timer has been queued. (CDeltaTimer does not * provide this information). */ @@ -477,24 +400,13 @@ * Callback for expiry of idle timer. */ TDeltaTimerEntry iIdleCallBack; + /** * Callback for expiry of Simple Pairing debug mode. */ TDeltaTimerEntry iDebugModeCallBack; /** - * Handle to BT Power Manager library; this handle must exist - * for the lifetime of the loaded library. - */ - RLibrary iPowerMgrLib; -#ifndef __WINS__ - /** - * Handle for DUT mode API - */ - RBluetoothDutMode iDutMode; -#endif //__WINS__ - - /** * Pairing manager. */ CBTEngPairMan* iPairMan; @@ -503,20 +415,25 @@ * Socket Server instance for this and other classes to access Bluetooth socket APIs. */ RSocketServ iSocketServ; - - + /** * Registry Server instance for bteng to access Bluetooth registry APIs. */ RBTRegServ iBTRegServ; - + /** - * BT Power Manager. + * Our state machine for handling power on/off. * Own. */ CBTEngSrvState* iServerState; /** + * Hardware and stack settings manager. + * Own. + */ + CBTEngSrvSettingsMgr* iSettingsMgr; + + /** * ECOM plugin manager. * Own. */ @@ -535,18 +452,6 @@ CBTEngSrvKeyWatcher* iWatcher; /** - * BT Power Manager (HCIv2 version). - */ - RBTPowerControl iPowerMgr; - -#ifdef __WINS__ - /** - * Current BT power state (power manager is not used in emulator). - */ - TBTPowerState iPowerState; -#endif //__WINS__ - - /** * SDP database handler. * Own. */ @@ -558,7 +463,6 @@ */ CDeltaTimer* iTimer; - BluetoothFeatures::TEnterpriseEnablementMode iEnterpriseEnablementMode; }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengsrvsession.h --- a/bluetoothengine/bteng/inc/btengsrvsession.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengsrvsession.h Fri Apr 16 15:08:36 2010 +0300 @@ -73,12 +73,6 @@ TBTEngConnectionStatus aConnStatus, RBTDevAddrArray* aArray, TInt aErr ); - /** - * Completes client's pairing request. - * @param aResult the resultof pairing the client will receive. - */ - TInt CompletePairRequest( TInt aResult ); - private: // from base class CSession2 /** @@ -131,22 +125,22 @@ void DispatchMessageL( const RMessage2& aMessage ); /** - * Cancels outstanding pairing request. + * Cancels outstanding request. */ - void CancelPairRequest(); - + void CancelRequest(); + + /** + * Checks if power is on, and leaves with error KErrNotReady if not. + */ + void CheckPowerOnL(); + private: // data + /** * Client-server message containing the thread handle of the client. * For connection notifications. */ RMessage2 iNotifyConnMessage; - - /** - * For connection notifications. - * For outgoing pairing request. - */ - RMessage2 iPairMessage; /** * Flag indicating if this client requested BT to be switched on temporarily. diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengsrvsettingsmgr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/inc/btengsrvsettingsmgr.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,312 @@ +/* +* 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: Class to manage Bluetooth hardware and stack settings. +* +*/ + +#ifndef BTENGSRVSETTINGSMGR_H +#define BTENGSRVSETTINGSMGR_H + +#include +#include +#ifndef __WINS__ +#include +#endif //__WINS__ + +#include "btengprivatecrkeys.h" +#include "btengconstants.h" +#include "btengactive.h" + +class CBTEngServer; + + +/** + * ?one_line_short_description + * ?more_complete_description + * + * @code + * ?good_class_usage_example(s) + * @endcode + * + * @lib ?library + * @since S60 ?S60_version *** for example, S60 v3.0 + */ +NONSHARABLE_CLASS( CBTEngSrvSettingsMgr ) : public CBase, + public MBTEngActiveObserver + { + +public: + + /** + * Two-phased constructor. + * @param aServer Pointer to server instance. + */ + static CBTEngSrvSettingsMgr* NewL( CBTEngServer* aServer ); + + /** + * Destructor. + */ + virtual ~CBTEngSrvSettingsMgr(); + + /** + * Utility to get the Bluetooth hardware power state. + * + * @since Symbian^3 + * @param aState On return, this will contain the current HW power state. + * @return KErrNone if successful, otherwise one of the system-wide error codes. + */ + TInt GetHwPowerState( TBTPowerState& aState ); + + /** + * Set the Bluetooth hardware power state. + * + * @since Symbian^3 + * @param aState The new power state. + */ + TInt SetHwPowerState( TBTPowerState aState ); + + /** + * Set Bluetooth on or off. This function is for internal classes of bteng server + * for power management. + * + * @since Symbian^3 + * @param aState The new power state. + * @param aTemporary Turn BT off after use (ETrue) or not (EFalse). + */ + void SetPowerStateL( TBTPowerState aState, TBool aTemporary ); + + /** + * Set Bluetooth on or off upon a client power management request. + * This function is only for power management request from clients of bteng server. + * + * @since Symbian^3 + * @param aState The new power state. + * @param aTemporary Turn BT off after use (ETrue) or not (EFalse). + */ + void SetPowerStateL( const RMessage2 aMessage ); + + /** + * Initialize Bluetooth stack settings. + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void InitBTStackL(); + + /** + * Reset settings and disconnect all links. + * + * @since Symbian^3 + */ + void StopBTStackL(); + + /** + * Update the central repository key for Bluetooth power state. + * + * @since Symbian^3 + * @param aValue The new Bluetooth power state. + */ + void UpdateCenRepPowerKeyL( TBTPowerState aValue ); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetUiIndicatorsL(); + + /** + * ?description + * + * @since S60 v3.2 + * @param ?arg1 ?description + */ + void SetIndicatorStateL( const TInt aIndicator, const TInt aState ); + + /** + * Update the Bluetooth visibility mode. + * + * @since Symbian^3 + * @param ?arg1 ?description + */ + void SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ); + + /** + * Update the Bluetooth visibility mode. + * + * @since Symbian^3 + * @param ?arg1 ?description + */ + void UpdateVisibilityModeL( TInt aStackScanMode ); + + /** + * Set Device Under Test mode. + * + * @since Symbian^3 + * @param aDutMode The mode to be set (DUT mode on or off). + */ + void SetDutMode( TInt aDutMode ); + + /** + * Timed visible mode has expired. + * + * @since Symbian^3 + */ + void ScanModeTimerCompletedL(); + + /** + * Check whether BT should be turned off automatically. + * + * @since Symbian^3 + */ + void CheckAutoPowerOffL(); + + /** + * Queue a timer if secure simple pairing debug mode has been enabled. + * + * @since Symbian^3 + * @param aDebugMode State of Simple Pairing debug mode. + */ + void CheckSspDebugModeL( TBool aDebugMode ); + + /** + * Be informed that a session will be closed. + * + * @since Symbian^3 + * @param aSession the session to be cloased. + */ + void SessionClosed(CSession2* aSession ); + +private: + +// from base class MBTEngActiveObserver + + /** + * From MBTEngActiveObserver. + * Callback to notify that an outstanding request has completed. + * + * @since Symbian^3 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ); + + /** + * From MBTEngActiveObserver. + * Callback to notify that an error has occurred in RunL. + * + * @since Symbian^3 + * @param aActive Pointer to the active object that completed. + * @param aId The ID that identifies the outstanding request. + * @param aStatus The status of the completed request. + */ + virtual void HandleError( CBTEngActive* aActive, TInt aId, TInt aError ); + +private: + + /** + * C++ default constructor. + */ + CBTEngSrvSettingsMgr( CBTEngServer* aServer ); + + /** + * Symbian second-phase constructor. + */ + void ConstructL(); + + /** + * Open a handle to the Bluetooth power manager, and + * initialize the power to off. + * + * @since Symbian^3 + */ + void LoadBTPowerManagerL(); + + /** + * Checks if a client requests temporary power on/off, and keeps track + * of the number of clients requesting that. + * + * @since Symbian^3 + * @param aCurrentState On return, will contain the current power state. + * @param aNewState The requested power state. + * @param aTemporary Indicates if this is about a tempororary state change. + */ + void CheckTemporaryPowerStateL( TBTPowerState& aCurrentState, + TBTPowerState aNewState, TBool aTemporary ); + + /** + * Set the Class of Device. + * + * @since Symbian^3 + */ + void SetClassOfDeviceL(); + +private: // data + +#ifdef __WINS__ + /** + * Current BT power state (power manager is not used in emulator). + */ + TBTPowerState iPowerState; +#endif //__WINS__ + + /** + * Flag indicating if BT is allowed to be turned on. + */ + BluetoothFeatures::TEnterpriseEnablementMode iEnterpriseEnablementMode; + + /** + * Flag indicating if BT is going to be switched off automatically. + */ + TBool iAutoSwitchOff; + + /** + * Number of clients that are using BT temporarily. + * Note that this is equal or less than the active number of links. + */ + TInt iAutoOffClients; + + /** + * Flag indicating hidden mode has been set for temporary power on. + */ + TBool iRestoreVisibility; + + /** + * BT power control. + */ + RBTPowerControl iPowerMgr; + + /** + * Active object helper. + * Own. + */ + CBTEngActive* iActive; + + /** + * The server instance. + * Not own. + */ + CBTEngServer* iServer; + + /** + * Client-server message for power change requests. + */ + RMessage2 iMessage; + + }; + + +#endif // BTENGSRVSETTINGS_H diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/inc/btengsrvstate.h --- a/bluetoothengine/bteng/inc/btengsrvstate.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/inc/btengsrvstate.h Fri Apr 16 15:08:36 2010 +0300 @@ -20,18 +20,13 @@ #ifndef BTENGSRVSTATE_H #define BTENGSRVSTATE_H - -//#include +#include #include "btengactive.h" -#include "btserversdkcrkeys.h" class MBTEngActiveObserver; class CBTEngServer; -/** ?description */ -//const ?type ?constant_var = ?constant; - /** * Class CBTEngSrvState @@ -93,32 +88,26 @@ virtual ~CBTEngSrvState(); /** - * ?description + * Getter for the current operation. * * @since S60 v3.2 - * @param ?arg1 ?description - * @param ?arg2 ?description - * @return ?description + * @return The current operation. */ CBTEngSrvState::TBTEngSrvOperation CurrentOperation(); /** - * ?description + * Start the state machine. If the state machine was already running, + * it is simply restarted. * * @since S60 v3.2 * @param ?arg1 ?description - * @param ?arg2 ?description - * @return ?description */ - void StartStateMachineL( TBool aState ); + void StartStateMachineL( TBTPowerState aState ); /** - * ?description + * Schedule the next state operation. * * @since S60 v3.2 - * @param ?arg1 ?description - * @param ?arg2 ?description - * @return ?description */ void ChangeState(); @@ -133,11 +122,20 @@ * Symbian 2nd-phase constructor */ void ConstructL(); - + + /** + * Callback function for asynchronous cycle. + */ static TInt ChangeStateCb(TAny* aThis); - + + /** + * Execute the next state operation. + */ void RequestCompletedL(); - + + /** + * Handle an error that occurred during a state operation. + */ void HandleError(TInt aError); private: // data diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/rom/bteng.iby --- a/bluetoothengine/bteng/rom/bteng.iby Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/rom/bteng.iby Fri Apr 16 15:08:36 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2003-2010 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" @@ -29,9 +29,7 @@ file=ABI_DIR\BUILD_DIR\btengdiscovery.dll SHARED_LIB_DIR\btengdiscovery.dll file=ABI_DIR\BUILD_DIR\btfeatures.dll SHARED_LIB_DIR\btfeatures.dll file=ABI_DIR\BUILD_DIR\btengsettings.dll SHARED_LIB_DIR\btengsettings.dll -data=ZPRIVATE\10005950\backup_registration.xml private\10005950\backup_registration.xml -data=ZPRIVATE\10003A3F\APPS\bttoggle_reg.rsc Private\10003a3f\apps\bttoggle_reg.rsc - +data=ZPRIVATE\10003A3F\APPS\bttoggle_reg.rsc Private\10003a3f\apps\bttoggle_reg.rsc data=DATAZ_\RESOURCE_FILES_DIR\btengsdp.rsc RESOURCE_FILES_DIR\btengsdp.rsc data=DATAZ_\RESOURCE_FILES_DIR\btrfs.txt RESOURCE_FILES_DIR\btrfs.txt diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengactive.cpp --- a/bluetoothengine/bteng/src/btengactive.cpp Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* -* Copyright (c) 2006 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: Active object helper class. -* -*/ - - - -#include - -#include "btengactive.h" - - -// ======== MEMBER FUNCTIONS ======== - -// --------------------------------------------------------------------------- -// C++ default constructor -// --------------------------------------------------------------------------- -// -CBTEngActive::CBTEngActive( MBTEngActiveObserver& aObserver, TInt aId, - TInt aPriority ) -: CActive( aPriority ), - iRequestId( aId ), - iObserver( aObserver ) - { - CActiveScheduler::Add( this ); - } - - -// --------------------------------------------------------------------------- -// Symbian 2nd-phase constructor -// --------------------------------------------------------------------------- -// -void CBTEngActive::ConstructL() - { - } - - -// --------------------------------------------------------------------------- -// NewLC -// --------------------------------------------------------------------------- -// -CBTEngActive* CBTEngActive::NewL( MBTEngActiveObserver& aObserver, - TInt aId, TInt aPriority ) - { - CBTEngActive* self = new( ELeave ) CBTEngActive( aObserver, aId, aPriority ); - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop( self ); - return self; - } - - -// --------------------------------------------------------------------------- -// Destructor -// --------------------------------------------------------------------------- -// -CBTEngActive::~CBTEngActive() - { - Cancel(); - } - - -// --------------------------------------------------------------------------- -// From class CActive. -// Called by the active scheduler when the request has been cancelled. -// --------------------------------------------------------------------------- -// -void CBTEngActive::DoCancel() - { - } - - -// --------------------------------------------------------------------------- -// From class CActive. -// Called by the active scheduler when the request has been completed. -// --------------------------------------------------------------------------- -// -void CBTEngActive::RunL() - { - iObserver.RequestCompletedL( this, iRequestId, iStatus.Int() ); - } - - -// --------------------------------------------------------------------------- -// From class CActive. -// Called by the active scheduler when an error in RunL has occurred. -// --------------------------------------------------------------------------- -// -TInt CBTEngActive::RunError( TInt aError ) - { - iObserver.HandleError( this, iRequestId, aError ); - return KErrNone; - } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengincpair.cpp --- a/bluetoothengine/bteng/src/btengincpair.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengincpair.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -99,6 +99,8 @@ if ( iAddr == aAddr ) { err = KErrNone; + iUserAwarePairing = ETrue; // This function is called by a notifier, which means the UI has been involved + // Therefore we can display it in the paired devices list if ( !iActive->IsActive() && !OpenPhysicalLinkAdaptor() ) { // If we are observing physical link, or showing user a note, @@ -171,46 +173,46 @@ iActivePairingOk->CancelRequest(); UnSetPairResult(); // we might have set it before (if the link went down) so we want to reset it. } - switch ( aDev.LinkKeyType() ) - { - case ELinkKeyUnauthenticatedNonUpgradable: - { - // If an application uses btengconnman API to connect a service of - // this device and JW pairing occurred as part of security enforcement, - // it shall be a user aware pairing, and we shall add this device in paired - // view. In this way, user is able to disconnect the device from our UI. - // Otherwise the link key has been created by a device without IO requesting - // a service connection with phone. We won't take any action (e.g. remove - // link key) in this case. As the result, this device can't be seen in our UI, - // however other applications are still freely to use its services. - TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with no IO device" ) ) - TBTEngConnectionStatus status = iParent.IsDeviceConnected( aDev.Address() ); - if ( status == EBTEngConnecting || status == EBTEngConnected ) - { - // the return error is ingore as we can not have other proper - // exception handling option: - (void) iParent.AddUiCookieJustWorksPaired( aDev ); - } - iParent.RenewPairer( NULL ); - break; - } - case ELinkKeyUnauthenticatedUpgradable: - { - // The linkkey has been created by an incoming OBEX service request - // which resulted a pairing event received from pair server. - TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with IO device" ) ) - iParent.RenewPairer( NULL ); - break; - } - default: - { - // Other pairing model than Just Works: - CancelPlaNotification(); - SetPairResult( KErrNone ); - ShowPairingNoteAndAuthorizeQuery(); - break; - } - } + if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable && !iUserAwarePairing) + { + // If an application uses btengconnman API to connect a service of + // this device and JW pairing occurred as part of security enforcement, + // it shall be a user aware pairing, and we shall add this device in paired + // view. In this way, user is able to disconnect the device from our UI. + // Otherwise the link key has been created by a device without IO requesting + // a service connection with phone. We won't take any action (e.g. remove + // link key) in this case. As the result, this device can't be seen in our UI, + // however other applications are still freely to use its services. + TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with no IO device" ) ) + TBTEngConnectionStatus status = iParent.IsDeviceConnected( aDev.Address() ); + if ( status == EBTEngConnecting || status == EBTEngConnected ) + { + // the return error is ingore as we can not have other proper + // exception handling option: + (void) iParent.AddUiCookieJustWorksPaired( aDev ); + } + iParent.RenewPairer( NULL ); + } + else if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedUpgradable && !iUserAwarePairing) + { + // The linkkey has been created by an incoming OBEX service request + // which resulted a pairing event received from pair server. + TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with IO device" ) ) + iParent.RenewPairer( NULL ); + } + else + { + if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable || aDev.LinkKeyType() == ELinkKeyUnauthenticatedUpgradable) + { + // The user was involved in the pairing, so display in the paired devices list + (void) iParent.AddUiCookieJustWorksPaired(aDev); + } + TRACE_INFO(_L("[BTEng]: CBTEngIncPair: Non-JW pairing")) + // Other pairing model than Just Works: + CancelPlaNotification(); + SetPairResult( KErrNone ); + ShowPairingNoteAndAuthorizeQuery(); + } TRACE_FUNC_EXIT } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengpairman.cpp --- a/bluetoothengine/bteng/src/btengpairman.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengpairman.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 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" @@ -33,6 +33,7 @@ ERegistryPairedDevicesNewView, ERegistryInitiatePairedDevicesList, ERegistryGetPairedDevices, + ERegistryGetLocalAddress, }; /** The message argument which holds the Bluetooth address. */ @@ -81,16 +82,20 @@ User::LeaveIfError( iAuthenResult.Open( *iPairingServ ) ); iSSPResultActive = CBTEngActive::NewL( *this, ESimplePairingResult, CActive::EPriorityStandard ); iAuthenResultActive = CBTEngActive::NewL( *this, EAuthenticationResult, CActive::EPriorityStandard ); - SubscribeSspPairingResult(); - SubscribeAuthenticateResult(); } + // RProperty for accessing the local device address + User::LeaveIfError( iPropertyLocalAddr.Attach(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetLocalDeviceAddress) ); + // connect to registry User::LeaveIfError( iBTRegistry.Open( BTRegServ() ) ); iRegistryActive = CBTEngActive::NewL( *this, ERegistryInitiatePairedDevicesView, CActive::EPriorityStandard ); - // Start to get the list of all paired devices. - CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); - iPairedDevices = new (ELeave) RArray; + iPairedDevices = new (ELeave) RArray; + + // Initialise paired devices list + iLocalAddrActive = CBTEngActive::NewL( *this, ERegistryGetLocalAddress, CActive::EPriorityStandard ); + InitPairedDevicesList(); + TRACE_FUNC_EXIT } @@ -134,6 +139,89 @@ iPairingServ->Close(); delete iPairingServ; } + if ( !iMessage.IsNull() ) + { + iMessage.Complete( KErrCancel ); + } + iPropertyLocalAddr.Cancel(); + iPropertyLocalAddr.Close(); + delete iLocalAddrActive; + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initialises the paired devices list. +// If the local address is not available from the P&S key +// KPropertyKeyBluetoothGetLocalDeviceAddress, then the list may need to be +// updated once the H/W is switched on. This is so that any registry update +// from a restore operation can be included in the list, without mistaking the +// new devices for new pairings. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::InitPairedDevicesList() + { + TRACE_FUNC_ENTRY + + // Check that we have the Bluetooth local address. If we don't then initialise anyway, but subscribe for an update. + // This allows us to refresh our paired devices list to include updates made to the remote devices table of the + // Bluetooth registry from a restore operation. We need to include these devices without mistaking them for new + // pairings. We look solely at the P&S key for the address to avoid the condition whereby the address has been + // entered into the reigstry but the Bluetooth Manager server has not begun the restore process yet. The signalling + // of the P&S key will cause Bluetooth Manager to update the registry with any restored devices before fulfilling + // any further requests. + + // Subscribe to local address property in case we need an update. + iPropertyLocalAddr.Subscribe( iLocalAddrActive->iStatus ); + iLocalAddrActive->SetRequestId( ERegistryGetLocalAddress ); + iLocalAddrActive->GoActive(); + + // Attempt to read address from P&S key. + TBuf8 btAddrDes; + TInt err = iPropertyLocalAddr.Get( btAddrDes ); + + // Is the P&S key defined yet? (if not, stack not up yet) + if ( err == KErrNone ) + { + // P&S key defined, is local address set? (if not, H/W not initialised yet) + if ( btAddrDes.Length() == KBTDevAddrSize ) + { + TBTDevAddr btAddr = btAddrDes; + + if ( btAddr != TBTDevAddr() ) + { + // Non-zero local address is available. + iPropertyLocalAddr.Cancel(); + iLocalAddrActive->CancelRequest(); + } + } + } + + // Perform initialisation of the paired devices list. + DoInitPairedDevicesList(); + + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initialises the paired devices list (second stage) +// This method performs the actual initialisation, now that the local BT H/W +// address had been made available. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::DoInitPairedDevicesList() + { + TRACE_FUNC_ENTRY + + if ( !iRegistryActive->IsActive() ) + { + // Start to get the list of all paired devices. + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + else + { + iNotHandledInitEventCounter++; + } + TRACE_FUNC_EXIT } @@ -156,14 +244,24 @@ } case EBTEngPairDevice: { + if ( !iMessage.IsNull() ) + { + User::Leave( KErrServerBusy ); + } TBTDevAddrPckgBuf addrPkg; aMessage.ReadL( KBTEngAddrSlot, addrPkg ); PairDeviceL( addrPkg(), aMessage.Int1() ); + iMessage = RMessage2( aMessage ); break; } case EBTEngCancelPairDevice: { - CancelCommand( opcode ); + // Only the client who requested pairing can cancel it: + if ( !iMessage.IsNull() && aMessage.Session() == iMessage.Session() ) + { + iPairer->CancelOutgoingPair(); + iMessage.Complete( KErrCancel ); + } break; } default: @@ -177,27 +275,6 @@ } // --------------------------------------------------------------------------- -// Cancels outgoing pairing requests -// --------------------------------------------------------------------------- -// -void CBTEngPairMan::CancelCommand( TInt aOpCode ) - { - switch( aOpCode ) - { - case EBTEngPairDevice: - { - TRACE_FUNC_ENTRY - if ( iPairer ) - { - iPairer->CancelOutgoingPair(); - } - TRACE_FUNC_EXIT - break; - } - } - } - -// --------------------------------------------------------------------------- // Handle a change in BTRegistry remote devices table. // --------------------------------------------------------------------------- // @@ -228,7 +305,7 @@ // RSocketServ& CBTEngPairMan::SocketServ() { - return iServer.SocketServ(); + return iServer.SocketServer(); } // --------------------------------------------------------------------------- @@ -237,7 +314,7 @@ // RBTRegServ& CBTEngPairMan::BTRegServ() { - return iServer.BTRegServ(); + return iServer.RegistrServer(); } // --------------------------------------------------------------------------- @@ -265,13 +342,23 @@ aErr = KErrNone; } // we must complete client's pairing request: - iServer.iSessionIter.SetToLast(); - CBTEngSrvSession* session = (CBTEngSrvSession*) iServer.iSessionIter--; - TInt ret( KErrNotFound ); - while( session && ret ) + if ( !iMessage.IsNull() ) { - ret = session->CompletePairRequest( aErr ); - session = (CBTEngSrvSession*) iServer.iSessionIter--; + iMessage.Complete( aErr ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// A session will be ended, completes the pending request for this session. +// --------------------------------------------------------------------------- +// +void CBTEngPairMan::SessionClosed( CSession2* aSession ) + { + TRACE_FUNC_ARG( ( _L( " session %x"), aSession ) ) + if ( !iMessage.IsNull() && iMessage.Session() == aSession ) + { + iMessage.Complete( KErrCancel ); } TRACE_FUNC_EXIT } @@ -291,30 +378,41 @@ if ( index > KErrNotFound ) { dev = (*iPairedDevices)[index]; - TBTDeviceSecurity security = dev.GlobalSecurity(); - // Clear trust setting so that correct icon will be shown in ui applications. - security.SetNoAuthenticate(EFalse ); - security.SetNoAuthorise(EFalse ); - dev.SetGlobalSecurity(security); - dev.DeleteLinkKey(); - if ( dev.IsValidUiCookie() && - ( dev.UiCookie() & EBTUiCookieJustWorksPaired ) ) + + TRequestStatus status( KRequestPending ); + // Unpair the device in registry (synchronously) + iBTRegistry.UnpairDevice( dev.Address(), status ); + User::WaitForRequest( status ); + TRACE_INFO( ( _L( "Delete link key, res %d"), status.Int() ) ) + + if ( status == KErrNone ) { - // Remove the UI cookie bit for Just Works pairing. - TInt32 cookie = dev.UiCookie() & ~EBTUiCookieJustWorksPaired; - dev.SetUiCookie( cookie ); - TRACE_INFO( ( _L( "UI cookie %x cleared"), EBTUiCookieJustWorksPaired ) ); + TBTDeviceSecurity security = dev.GlobalSecurity(); + // Clear trust setting so that correct icon will be shown in ui applications. + security.SetNoAuthenticate(EFalse ); + security.SetNoAuthorise(EFalse ); + dev.SetGlobalSecurity(security); + dev.DeleteLinkKey(); + if ( dev.IsValidUiCookie() && + ( dev.UiCookie() & EBTUiCookieJustWorksPaired ) ) + { + // Remove the UI cookie bit for Just Works pairing. + TInt32 cookie = dev.UiCookie() & ~EBTUiCookieJustWorksPaired; + dev.SetUiCookie( cookie ); + TRACE_INFO( ( _L( "UI cookie %x cleared"), EBTUiCookieJustWorksPaired ) ); + } + // modify the device in registry synchronously + // status.Int() could be -1 if the device is not in registry + // which is totally fine for us. + (void) UpdateRegDevice( dev ); } - // modify the device in registry synchronously - // status.Int() could be -1 if the device is not in registry - // which is totally fine for us. - (void) UpdateRegDevice( dev ); } TRACE_FUNC_EXIT } TInt CBTEngPairMan::AddUiCookieJustWorksPaired( const TBTNamelessDevice& aDev ) { + TRACE_FUNC_ENTRY TInt err( KErrNone ); // There might be UI cookies used by other applications, // we should not overwrite them. @@ -329,6 +427,7 @@ err = UpdateRegDevice( dev ); TRACE_INFO( ( _L( "[BTENG] CBTEngOtgPair write Ui cookie ret %d"), err ) ); } + TRACE_FUNC_EXIT return err; } @@ -393,11 +492,26 @@ break; } case ERegistryInitiatePairedDevicesList: + { + if (iSSPResultActive && iAuthenResultActive) + { + SubscribeSspPairingResult(); + SubscribeAuthenticateResult(); + } + HandleGetPairedDevicesCompletedL( aStatus, aId ); + break; + } case ERegistryGetPairedDevices: { HandleGetPairedDevicesCompletedL( aStatus, aId ); break; } + case ERegistryGetLocalAddress: + { + // Refresh paired devices list to include any restored devices. + DoInitPairedDevicesList(); + break; + } default: // Should not be possible, but no need for handling. TRACE_INFO( (_L("[BTEng]: CBTEngPairMan::RequestCompletedL unhandled event!!") ) ) @@ -431,6 +545,7 @@ { TRACE_FUNC_ARG( ( _L( "%d" ), aActivate ) ) TRACE_BDADDR( aAddr ) + iPairingOperationAttempted = ETrue; TInt err( KErrNone ); if ( !aActivate ) { @@ -463,6 +578,7 @@ // void CBTEngPairMan::PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod ) { + iPairingOperationAttempted = ETrue; if ( !iPairer) { // no existing pair handling, create one: @@ -496,27 +612,35 @@ } // --------------------------------------------------------------------------- -// Subscribes to simple pairing result from Pairing Server +// Subscribes to simple pairing result from Pairing Server (if not already +// subscribed). // --------------------------------------------------------------------------- // void CBTEngPairMan::SubscribeSspPairingResult() { TRACE_FUNC_ENTRY - iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() ); - iSSPResultActive->GoActive(); + if ( !iSSPResultActive->IsActive() ) + { + iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() ); + iSSPResultActive->GoActive(); + } TRACE_FUNC_EXIT } // --------------------------------------------------------------------------- -// Subscribes to authentication result from Pairing Server +// Subscribes to authentication result from Pairing Server (if not already +// subscribed). // --------------------------------------------------------------------------- // void CBTEngPairMan::SubscribeAuthenticateResult() { TRACE_FUNC_ENTRY - // Subscribe authentication result (which requires pairing for unpaired devices) - iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() ); - iAuthenResultActive->GoActive(); + if ( !iAuthenResultActive->IsActive() ) + { + // Subscribe authentication result (which requires pairing for unpaired devices) + iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() ); + iAuthenResultActive->GoActive(); + } TRACE_FUNC_EXIT } @@ -567,7 +691,14 @@ void CBTEngPairMan::CreatePairedDevicesView( TInt aReqId ) { TRACE_FUNC_ENTRY - iNotHandledRegEventCounter = 0; + if ( aReqId == ERegistryInitiatePairedDevicesView ) + { + iNotHandledInitEventCounter = 0; + } + else + { + iNotHandledRegEventCounter = 0; + } TBTRegistrySearch searchPattern; searchPattern.FindBonded(); iRegistryActive->SetRequestId( aReqId ); @@ -605,8 +736,14 @@ TRACE_FUNC_ENTRY if ( aReqId == ERegistryInitiatePairedDevicesView ) - {// Initialization phase, list paired devices if there are. - if ( aStatus > KErrNone ) + {// Initialization phase, list paired devices if there are any. + if ( iNotHandledInitEventCounter ) + { + // Reinitialisaton detected, create paired device view again: + (void) iBTRegistry.CloseView(); + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + else if ( aStatus > KErrNone ) { GetPairedDevices( ERegistryInitiatePairedDevicesList ); } @@ -617,7 +754,25 @@ } else { - if (iNotHandledRegEventCounter) + if ( iNotHandledInitEventCounter ) + { + // We need to reinitialise but we may be pairing. + // This situation is not expected to arise, as reinitialisation means + // that the H/W was only just switched on. + // If we have ever started to take part in a pairing, then prioritise that + // pairing. + (void) iBTRegistry.CloseView(); + if ( iPairingOperationAttempted ) + { + iNotHandledInitEventCounter = 0; + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else + { + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + } + else if (iNotHandledRegEventCounter) { // more registry change detected, create paired device view again: (void) iBTRegistry.CloseView(); CreatePairedDevicesView( ERegistryPairedDevicesNewView ); @@ -647,19 +802,46 @@ (void) iBTRegistry.CloseView(); if ( aReqId == ERegistryInitiatePairedDevicesList ) { - // We completed the initialization of paired device list, - // move all paired devices to the array: - UpdatePairedDeviceListL(); + if ( iNotHandledInitEventCounter ) + { + // Reinitialisation required, create paired device view again: + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + else + { + // We completed the initialisation of paired device list, + // move all paired devices to the array: + UpdatePairedDeviceListL(); + } } - - if (iNotHandledRegEventCounter) - { // more registry change detected, create paired device view again: - CreatePairedDevicesView( ERegistryPairedDevicesNewView ); - } - else if ( aReqId == ERegistryGetPairedDevices) + else { - // no more registry change detected, find new pairings: - CheckPairEventL(); + if (iNotHandledInitEventCounter) + { + // We need to reinitialise but we may be pairing. + // This situation is not expected to arise, as reinitialisation means + // that the H/W was only just switched on. + // If we have ever started to take part in a pairing, then prioritise that + // pairing. + if ( iPairingOperationAttempted ) + { + iNotHandledInitEventCounter = 0; + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else + { + CreatePairedDevicesView( ERegistryInitiatePairedDevicesView ); + } + } + else if (iNotHandledRegEventCounter) + { // more registry change detected, create paired device view again: + CreatePairedDevicesView( ERegistryPairedDevicesNewView ); + } + else if ( aReqId == ERegistryGetPairedDevices) + { + // no more registry change detected, find new pairings: + CheckPairEventL(); + } } TRACE_FUNC_EXIT @@ -718,9 +900,10 @@ TRACE_BDADDR( dev.Address() ); if ( newPaired && !iPairer) { + iPairingOperationAttempted = ETrue; iPairer = CBTEngIncPair::NewL( *this, dev.Address() ); } - if ( iPairer ) + if ( newPaired && iPairer ) { // Ask pair handler to decide what to do: iPairer->HandleRegistryNewPairedEvent( dev ); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengserver.cpp --- a/bluetoothengine/bteng/src/btengserver.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengserver.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -16,12 +16,6 @@ */ - -#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS -#include -#include -#endif - #include #include #include @@ -29,20 +23,18 @@ #include #include #include -#include -#include -#include +#include #include #include "btengserver.h" #include "btengsrvstate.h" #include "btengsrvsession.h" #include "btengsrvpluginmgr.h" #include "btengsrvbbconnectionmgr.h" +#include "btengsrvsettingsmgr.h" #include "btengsrvkeywatcher.h" #include "btengsdpdbhandler.h" #include "btengclientserver.h" #include "btengsecpolicy.h" -#include "btengprivatecrkeys.h" #include "btengprivatepskeys.h" #include "btengplugin.h" #include "btengpairman.h" @@ -50,43 +42,12 @@ /** Bluetooth Engine server thread name */ _LIT( KBTEngThreadName, "BTEngine" ); - -/** Constant for converting minutes to microseconds */ -const TInt64 KMinutesInMicroSecs = MAKE_TINT64( 0, 60000000 ); - -/** Idle timeout for shutting down the server (when power is off, - * and no clients are connected). The value is 3 seconds. - */ +/** Timeout (3 sec) for shutting down the server (when power is off and no clients connected). */ const TInt KBTEngSrvIdleTimeout = 3000000; - -/** Timeout for disabling Simple Pairing debug mode. The value is 30 minutes. */ -const TInt KBTEngSspDebugModeTimeout = 1800000000; - -/** Timeout for determining that BT is not turned off automatically. - * The value is 10.5 seconds. - */ -const TInt KBTEngBtAutoOffTimeout = 10500000; +/** PubSub key read and write policies */ +_LIT_SECURITY_POLICY_C2( KBTEngPSKeyReadPolicy, ECapabilityLocalServices, ECapabilityReadDeviceData ); +_LIT_SECURITY_POLICY_C2( KBTEngPSKeyWritePolicy, ECapabilityLocalServices, ECapabilityWriteDeviceData ); -/** Enumeration of bitmask for keeping track of different timers. */ -enum TTimerQueued - { - ENone = 0x00, - EScanModeTimer = 0x01, - EIdleTimer = 0x02, - EAutoPowerOffTimer = 0x04, - ESspDebugModeTimer = 0x08 - }; - -/** PubSub key read and write policies */ -_LIT_SECURITY_POLICY_C2( KBTEngPSKeyReadPolicy, - ECapabilityLocalServices, ECapabilityReadDeviceData ); -_LIT_SECURITY_POLICY_C2( KBTEngPSKeyWritePolicy, - ECapabilityLocalServices, ECapabilityWriteDeviceData ); - -// Default values for Major and Minor Device Class -const TUint16 KCoDDefaultServiceClass = EMajorServiceTelephony | EMajorServiceObjectTransfer | EMajorServiceNetworking; -const TUint8 KCoDDefaultMajorDeviceClass = EMajorDevicePhone; -const TUint8 KCoDDefaultMinorDeviceClass = EMinorDevicePhoneSmartPhone; // ======== LOCAL FUNCTIONS ======== @@ -149,7 +110,6 @@ CBTEngServer::CBTEngServer() : CPolicyServer( EPriorityHigh, KBTEngServerPolicy ) { - iEnableDutMode = EFalse; } @@ -190,7 +150,6 @@ RProperty::EInt, KBTEngPSKeyReadPolicy, KBTEngPSKeyWritePolicy) ); - User::LeaveIfError( RProperty::Define( KPSUidBluetoothEnginePrivateCategory, KBTNotifierLocks, RProperty::EByteArray, @@ -198,18 +157,19 @@ KBTEngPSKeyWritePolicy) ); User::LeaveIfError( iSocketServ.Connect() ); - LoadBTPowerManagerL(); + // The server is only started by its client, so leave the state // machine in Init state. A request to turn power on will follow // usually immediately. iServerState = CBTEngSrvState::NewL( this ); iWatcher = CBTEngSrvKeyWatcher::NewL( this ); + iSettingsMgr = CBTEngSrvSettingsMgr::NewL( this ); iPluginMgr = CBTEngSrvPluginMgr::NewL( this ); iBBConnMgr = CBTEngSrvBBConnMgr::NewL( iSocketServ ); - + User::LeaveIfError( iBTRegServ.Connect() ); iPairMan = CBTEngPairMan::NewL( *this ); - + TCallBack idleCb( IdleTimerCallBack, this ); iIdleCallBack.Set( idleCb ); TCallBack sspCb( DebugModeTimerCallBack, this ); @@ -219,14 +179,6 @@ TCallBack powerOffCb( AutoPowerOffCallBack, this ); iPowerOffCallBack.Set( powerOffCb ); iTimer = CDeltaTimer::NewL(CActive::EPriorityLow); - - iEnterpriseEnablementMode = BluetoothFeatures::EnterpriseEnablementL(); - TRACE_INFO( ( _L( "iEnterpriseEnablementMode = %d" ), iEnterpriseEnablementMode) ) - if ( iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) - { - SetVisibilityModeL( EBTVisibilityModeNoScans, 0 ); - } - TRACE_FUNC_EXIT } @@ -256,7 +208,7 @@ iTimerQueued = ENone; iTimer->Remove( iScanModeCallBack ); iTimer->Remove( iPowerOffCallBack ); - iTimer->Remove( iIdleCallBack); + iTimer->Remove( iIdleCallBack ); iTimer->Remove( iDebugModeCallBack ); } RProperty::Delete( KPSUidBluetoothTestingMode, KBTDutEnabled ); @@ -269,171 +221,34 @@ delete iTimer; delete iSdpDbHandler; delete iWatcher; + delete iSettingsMgr; delete iPluginMgr; delete iBBConnMgr; delete iServerState; delete iPairMan; - iPowerMgr.Close(); iSocketServ.Close(); iBTRegServ.Close(); } - // --------------------------------------------------------------------------- // Turn BT on or off. // --------------------------------------------------------------------------- // -void CBTEngServer::SetPowerStateL( TBTPowerStateValue aState, TBool aTemporary ) +void CBTEngServer::SetPowerStateL( TBTPowerState aState, TBool aTemporary ) { - TRACE_FUNC_ARG( ( _L( "setting power state %d" ), (TInt) aState ) ) - if ( aState == EBTPowerOn && iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) - { - TRACE_INFO( ( _L( "\tno we're not... Bluetooth is enterprise-IT-disabled" ) ) ) - User::Leave(KErrNotSupported); - } - - TBTPowerStateValue currentState = EBTPowerOff; - CheckTemporaryPowerStateL( currentState, aState, aTemporary ); - - if( ( currentState == aState || ( aTemporary && aState == EBTPowerOff ) ) && iServerState->CurrentOperation() == CBTEngSrvState::ESrvOpIdle ) - { - // The requested power state is already active, ignore silently. - // We don't return an error here, as there is no error situation. - TRACE_INFO( ( _L( "SetPowerStateL: nothing to do" ) ) ) - if(currentState == aState) - { - // Make sure that the CenRep key is in sync. - // During boot-up, the pwoer is set from the CenRep key, so we could - // end up out-of-sync. - TRACE_INFO( ( _L( "SetPowerStateL: currentState == aState" ) ) ) - UpdateCenRepPowerKeyL( aState ); - } - return; - } - if( aState ) - { - // Hardware power on is the first step. - User::LeaveIfError( SetPowerState( aState ) ); - } - else - { - //Prevent BT visibility in the situation when we turn OFF BT Engine - //but FM Radio is still alive - SetVisibilityModeL( EBTVisibilityModeNoScans, 0 ); - // Hardware power off is the last step. - // First disconnect all plug-ins. - iPluginMgr->DisconnectAllPlugins(); - } - // We only signal that BT is on after everything has completed (through - // the CenRep power state key), so that all services are initialized. - // We signal that BT is off immediately though, so that our clients will - // not try to use BT during power down. - iServerState->StartStateMachineL( (TBool) aState ); + TRACE_FUNC_ARG( ( _L( "setting power state %d (temporary=%d" ), (TInt) aState, aTemporary ) ) + iSettingsMgr->SetPowerStateL( aState, aTemporary ); TRACE_FUNC_EXIT } - // --------------------------------------------------------------------------- -// ?implementation_description +// Turn BT on or off. // --------------------------------------------------------------------------- // -void CBTEngServer::SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ) +void CBTEngServer::SetPowerStateL(const RMessage2 aMessage ) { TRACE_FUNC_ENTRY - - if ( aMode != EBTVisibilityModeNoScans && iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) - { - TRACE_INFO( ( _L( "\tnot changing anything... Bluetooth is enterprise-IT-disabled" ) ) ) - User::Leave(KErrNotSupported); - } - - TInt err = KErrNone; - iTimerQueued &= ~EScanModeTimer; - iTimer->Remove( iScanModeCallBack ); - if( aMode != EBTVisibilityModeNoScans ) - { - CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); - err = cenRep->Set( KBTDiscoverable, aMode ); - delete cenRep; - } - if( !err && aMode == EBTVisibilityModeTemporary ) - { - // We need TInt64 here, as the max. time in microseconds for the - // max. value (1 hour) is larger than KMaxTInt32. - TInt64 timeMicroSec = MAKE_TINT64( 0, aTime ); - timeMicroSec = timeMicroSec * KMinutesInMicroSecs; - TTimeIntervalMicroSeconds interval( timeMicroSec ); - // Queue callback to set the visibility back to hidden. - err = iTimer->QueueLong( interval, iScanModeCallBack ); - iTimerQueued |= EScanModeTimer; - aMode = EBTVisibilityModeGeneral; - } - else if( !err && iRestoreVisibility ) - { - // The user overrides, do not restore visibility mode anymore. - iRestoreVisibility = EFalse; - } - if( !err ) - { - err = RProperty::Set( KUidSystemCategory, - KPropertyKeyBluetoothSetScanningStatus, aMode ); - } - TBool hiddenMode = ( aMode == EBTVisibilityModeHidden ); - if( !err && aMode != EBTVisibilityModeNoScans ) - { - // In hidden mode, we only accept connections from paired devices. - err = RProperty::Set( KUidSystemCategory, - KPropertyKeyBluetoothSetAcceptPairedOnlyMode, - hiddenMode ); - } - - User::LeaveIfError( err ); // To communicate the result to the client. - TRACE_FUNC_EXIT - } - -// --------------------------------------------------------------------------- -// The method is called when BT stack scanning mode P&S key is changed -// --------------------------------------------------------------------------- -// -void CBTEngServer::UpdateVisibilityModeL( TInt aStackScanMode ) - { - TRACE_FUNC_ENTRY - TRACE_INFO( ( _L( "[BTEng]\t aStackScanMode: %d" ), aStackScanMode ) ) - TBTVisibilityMode currentMode; - - CRepository* cenRep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); - User::LeaveIfError( cenRep->Get( KBTDiscoverable, (TInt&) currentMode ) ); - - // In case we are in temp visibility mode, we cannot always know whether the BT stack - // scan mode key was set by some external party or by us in SetVisibilityModeL above. - // Therefore we cannot stop the timer in case aMode is EBTVisibilityModeGeneral and - // currentmode is EBTVisibilityModeTemporary - if( !( currentMode == EBTVisibilityModeTemporary && aStackScanMode == EBTVisibilityModeGeneral ) ) - { - // Cancel the timer and queue it again if needed. - iTimerQueued &= ~EScanModeTimer; - iTimer->Remove( iScanModeCallBack ); - if( currentMode != aStackScanMode ) - { - if( aStackScanMode == EPageScanOnly || aStackScanMode == EInquiryAndPageScan ) - { - User::LeaveIfError( cenRep->Set( KBTDiscoverable, aStackScanMode ) ); - } - else if( aStackScanMode == EInquiryScanOnly ) - { - // We don't support ENoScansEnabled nor EInquiryScanOnly mode - // -> Consider these as same as Hidden - User::LeaveIfError( cenRep->Set( KBTDiscoverable, EBTVisibilityModeHidden ) ); - } - else if( aStackScanMode == ENoScansEnabled ) - { - //We don't change KBTDiscoverable here, because ENoScansEnabled - //indicates BT/SYSTEM shutdown is happening - } - } - } - SetUiIndicatorsL(); - CleanupStack::PopAndDestroy( cenRep ); + iSettingsMgr->SetPowerStateL( aMessage ); TRACE_FUNC_EXIT } @@ -454,90 +269,13 @@ // ?implementation_description // --------------------------------------------------------------------------- // -void CBTEngServer::SetDutMode( TInt aDutMode ) - { - TRACE_FUNC_ARG( ( _L( "DUT mode %d" ), aDutMode ) ) - - if (aDutMode == EBTDutOff) - { - return; - } - - TInt powerState = EBTPowerOff; - CRepository* cenrep = NULL; - - TRAPD(err, cenrep = CRepository::NewL(KCRUidBluetoothPowerState)); - - if (!err && cenrep) - { - cenrep->Get(KBTPowerState, powerState); - delete cenrep; - cenrep = NULL; - } - else - { - return; - } - - if (powerState == EBTPowerOn) - { - -#ifndef __WINS__ - - TInt err = iDutMode.Open(); - TRACE_FUNC_ARG( ( _L( "Open DUT mode handle err %d" ), err) ) - if(!err) - { - iDutMode.ActivateDutMode(); - iDutMode.Close(); - } -#endif //__WINS__ - } - iEnableDutMode = EFalse; - } - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::ScanModeTimerCompletedL() - { - TRACE_FUNC_ENTRY - // The timer has completed, so remove our reference as well. - iTimerQueued &= ~EScanModeTimer; - iTimer->Remove( iScanModeCallBack ); - SetVisibilityModeL( EBTVisibilityModeHidden, 0 ); - TBTPowerStateValue power = EBTPowerOff; - TInt err = GetHwPowerState( (TBTPowerStateValue&) power ); - if( !err && power ) - { - // Show a notification to the user - TBTGenericInfoNotiferParamsPckg pckg; - pckg().iMessageType = EBTVisibilityTimeout; - - RNotifier notifier; - TInt err = notifier.Connect(); - if( !err ) - { - err = notifier.StartNotifier( KBTGenericInfoNotifierUid, pckg ); - notifier.Close(); - } - } - TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) - } - - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// void CBTEngServer::DisconnectAllCompleted() { // Check if we are powering off. Otherwise we have just been // requested to disconnect all, e.g. for system shutdown. if( iServerState->CurrentOperation() == CBTEngSrvState::EPowerOff ) { - (void) SetPowerState( EFalse ); + (void) iSettingsMgr->SetHwPowerState( EBTOff ); // Put the state machine into idle state. iServerState->ChangeState(); } @@ -568,18 +306,20 @@ // --------------------------------------------------------------------------- -// A session has been ended, update the session count. +// A session has been ended, update the session count and inform others. // --------------------------------------------------------------------------- // -void CBTEngServer::RemoveSession( TBool aAutoOff ) +void CBTEngServer::RemoveSession( CSession2* aSession, TBool aAutoOff ) { TRACE_FUNC_ENTRY TRACE_INFO( ( _L( "[CBTEngServer]\t aAutoOff %d"), aAutoOff )) TRACE_INFO( ( _L( "[CBTEngServer]\t iSessionCount %d"), iSessionCount )) iSessionCount--; + iSettingsMgr->SessionClosed( aSession ); + iPairMan->SessionClosed( aSession ); if( aAutoOff ) { - TRAP_IGNORE( SetPowerStateL( EBTPowerOff, ETrue ) ); + TRAP_IGNORE( SetPowerStateL( EBTOff, ETrue ) ); } else { @@ -588,6 +328,69 @@ TRACE_FUNC_EXIT } +// --------------------------------------------------------------------------- +// Queue a new timer. +// --------------------------------------------------------------------------- +// +void CBTEngServer::QueueTimer( CBTEngServer::TTimerQueued aTimer, TInt64 aInterval ) + { + TRACE_FUNC_ARG( ( _L( "queueing timer %d" ), (TInt) aTimer ) ) + __ASSERT_DEBUG( iTimer, PanicServer( EBTEngPanicMemberVarIsNull ) ); + iTimerQueued |= aTimer; + TTimeIntervalMicroSeconds interval( aInterval ); + switch( aTimer ) + { + case EScanModeTimer: + (void) iTimer->QueueLong( interval, iScanModeCallBack ); + break; + case EIdleTimer: + iTimer->QueueLong( aInterval, iIdleCallBack ); + break; + case EAutoPowerOffTimer: + iTimer->QueueLong( aInterval, iPowerOffCallBack ); + break; + case ESspDebugModeTimer: + iTimer->QueueLong( aInterval, iDebugModeCallBack ); + break; + default: + PanicServer( EBTEngPanicCorrupt ); + } + } + + +// --------------------------------------------------------------------------- +// Remove a queued timer. +// --------------------------------------------------------------------------- +// +void CBTEngServer::RemoveTimer( CBTEngServer::TTimerQueued aTimer ) + { + TRACE_FUNC_ARG( ( _L( "removing timer %d" ), (TInt) aTimer ) ) + if(!iTimer) + { + return; // not fully constructed yet, don't do anything + } + iTimerQueued &= ~aTimer; + // Timers can be removed without being queued, no need to check. + switch( aTimer ) + { + case EScanModeTimer: + iTimer->Remove( iScanModeCallBack ); + break; + case EIdleTimer: + iTimer->Remove( iIdleCallBack ); + break; + case EAutoPowerOffTimer: + iTimer->Remove( iPowerOffCallBack ); + break; + case ESspDebugModeTimer: + iTimer->Remove( iDebugModeCallBack ); + break; + default: + PanicServer( EBTEngPanicCorrupt ); + } + TRACE_FUNC_EXIT + } + // --------------------------------------------------------------------------- // From class CPolicyServer. @@ -628,10 +431,10 @@ if( iSessionCount <= 0 ) { // No more sessions, check the power state. - TBTPowerStateValue pwr = EBTPowerOff; - TInt err = GetHwPowerState( pwr ); - TRACE_INFO( ( _L( "[BTEng]\t No sessions; power state: %d" ), pwr ) ) - if( !err &&!pwr + TBTPowerState power = EBTOff; + TInt err = iSettingsMgr->GetHwPowerState( power ); + TRACE_INFO( ( _L( "[BTEng]\t No sessions; power state: %d" ), power ) ) + if( !err && power == EBTOff && iServerState->CurrentOperation() == CBTEngSrvState::ESrvOpIdle ) { TRACE_INFO( ( _L( "[BTEng]\t Power off; starting shutdown timer" ) ) ) @@ -648,259 +451,6 @@ // ?implementation_description // --------------------------------------------------------------------------- // -TInt CBTEngServer::SetPowerState( TBool aState ) - { - TRACE_FUNC_ENTRY - TInt err = KErrNone; - // HCIv2 power state type is inverted from BTPM-defined type... - TBTPowerState powerState = (TBTPowerState) !aState; - TRequestStatus status; - -#ifndef __WINS__ - iPowerMgr.SetPower( powerState, NULL, status ); - User::WaitForRequest( status ); - err = status.Int(); -#else //__WINS__ - iPowerState = powerState; - err = KErrNone; -#endif //__WINS__ - - if( !err && aState ) - { - TInt dutMode; - err = RProperty::Get( KPSUidBluetoothTestingMode, KBTDutEnabled, dutMode ); - if( !err && dutMode == EBTDutOn ) - { - // Set the DUT mode key to OFF since DUT mode is disabled at this point - err = RProperty::Set( KPSUidBluetoothTestingMode, KBTDutEnabled, EBTDutOff ); - } - // Set the local name straight away, so that an error - // in the loading of the BT stack will be detected here. - // Note that the HCIv2 power manager already loads the BT stack, - // so we do not need to do that here. - TRAP(err,SetLocalNameL()); - } - if( err ) - { - // Power off if an error occurred during power on sequence. -#ifndef __WINS__ - // This cannot happen in emulator environment. - iPowerMgr.SetPower( EBTOff, NULL, status ); - User::WaitForRequest( status ); -#endif //__WINS__ - } - TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) - return err; - } - - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -TInt CBTEngServer::SetLocalNameL() - { - TRACE_FUNC_ENTRY - RHostResolver hostResolver; - TBuf name; - name.Zero(); - TBuf tmpName; - - TInt err = RProperty::Get(KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothGetDeviceName, name); - if(err == KErrNone) - { - err = RProperty::Get(KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothSetDeviceName, tmpName); - if (tmpName.Compare(name)) - { - // The name has not yet been updated. Use the new one. - name.Copy(tmpName); - } - } - // if name hasn't been set, check whats in the registry - if (err || !name.Length()) - { - GetLocalNameFromRegistryL(name); - } - - TRACE_INFO( ( _L( "[CBTEngServer]\t localDev.DeviceName(): '%S'" ), &name)) - - CleanupClosePushL(hostResolver); - User::LeaveIfError(hostResolver.Open(iSocketServ, KBTAddrFamily, KBTLinkManager)); - User::LeaveIfError(hostResolver.SetHostName(name)); - CleanupStack::PopAndDestroy(&hostResolver); - - return KErrNone; - } - - -// --------------------------------------------------------------------------- -// Checks whats written in the registry in order to set host name -// --------------------------------------------------------------------------- -// -TInt CBTEngServer::GetLocalNameFromRegistryL(TDes& aName) - { - TRACE_FUNC_ENTRY - RBTRegServ btRegServ; - RBTLocalDevice btReg; - TBTLocalDevice localDev; - - CleanupClosePushL(btRegServ); - CleanupClosePushL(btReg); - - // In case of error, read local name from registry - aName.Zero(); - User::LeaveIfError(btRegServ.Connect()); - User::LeaveIfError(btReg.Open(btRegServ)); - - // Read the BT local name from BT Registry. - User::LeaveIfError(btReg.Get(localDev)); - - CleanupStack::PopAndDestroy(2,&btRegServ); - - // BT registry keeps the device name in UTF-8 format, convert to unicode. - // The error can be > 0 if there are unconverted characters. - TInt err = CnvUtfConverter::ConvertToUnicodeFromUtf8(aName, localDev.DeviceName()); - if (err != KErrNone) - User::Leave(err); - return KErrNone; - } - - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::SetClassOfDeviceL() - { - TRACE_FUNC_ENTRY - TUint16 serviceClass = KCoDDefaultServiceClass; - // Check from feature manager if stereo audio is enabled. - FeatureManager::InitializeLibL(); - TBool supported = FeatureManager::FeatureSupported( KFeatureIdBtStereoAudio ); - FeatureManager::UnInitializeLib(); - if( supported ) - { - // A2DP spec says we should set this bit as we are a SRC - serviceClass |= EMajorServiceCapturing; - } - // These values may nayway be overridden by HCI - TBTDeviceClass cod( serviceClass, KCoDDefaultMajorDeviceClass, - KCoDDefaultMinorDeviceClass ); - // Ignore error, it is non-critical - (void) RProperty::Set( KPropertyUidBluetoothControlCategory, - KPropertyKeyBluetoothSetDeviceClass, cod.DeviceClass() ); - TRACE_FUNC_EXIT - } - - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::InitBTStackL() - { - TRACE_FUNC_ENTRY - iBBConnMgr->Subscribe(); - TBTVisibilityMode visibility = EBTVisibilityModeHidden; - CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); - TInt err = cenRep->Get( KBTDiscoverable, (TInt&) visibility ); - delete cenRep; - if (iRestoreVisibility == EFalse) - { - if( err || visibility == EBTVisibilityModeTemporary && !( iTimerQueued & EScanModeTimer ) ) - { - visibility = EBTVisibilityModeHidden; - } - SetVisibilityModeL( visibility, 0 ); - } - SetClassOfDeviceL(); - TBool sspDebugMode = EFalse; - (void) RProperty::Get( KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothGetSimplePairingDebugMode, - (TInt&) sspDebugMode ); - // Only set debug mode to off if it is on, to prevent a loop notifications. - if( sspDebugMode ) - { - sspDebugMode = EFalse; - // Add LeaveIfError if unsuccessful - (void) RProperty::Set(KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothSetSimplePairingDebugMode, - (TInt) sspDebugMode ); - } - TRACE_FUNC_EXIT - } - - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::StopBTStackL() - { - TRACE_FUNC_ENTRY - TBTVisibilityMode visibility = EBTVisibilityModeHidden; - CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); - // Ignore error here; if we can't read it, likely we can't set it either. - (void) cenRep->Get( KBTDiscoverable, (TInt&) visibility ); - delete cenRep; - if( visibility == EBTVisibilityModeTemporary ) - { - visibility = EBTVisibilityModeHidden; - SetVisibilityModeL( visibility, 0 ); // Also cancels scan mode timer. - } - - // Stop listening to events - iBBConnMgr->Unsubscribe(); - // Disconnect all links - TCallBack cb( DisconnectAllCallBack, this ); - iBBConnMgr->DisconnectAllLinksL( cb ); - // Results in a callback (which is called directly when there are no links). - TRACE_FUNC_EXIT - } - - -// --------------------------------------------------------------------------- -// Update the power state CenRep key. -// --------------------------------------------------------------------------- -// -void CBTEngServer::UpdateCenRepPowerKeyL( TBTPowerStateValue aState ) - { - TRACE_FUNC_ENTRY - CRepository* cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); - User::LeaveIfError( cenrep->Set( KBTPowerState, (TInt) aState ) ); - CleanupStack::PopAndDestroy( cenrep ); - TRACE_FUNC_EXIT - } - - -// --------------------------------------------------------------------------- -// Loads the BT Power Manager; leaves if it cannot be loaded. -// --------------------------------------------------------------------------- -// -void CBTEngServer::LoadBTPowerManagerL() - { - TRACE_FUNC_ENTRY - TRACE_INFO( ( _L( "[CBTEngServer]\t Using HCI API v2 power manager" ) ) ) - User::LeaveIfError( iPowerMgr.Open() ); -#ifndef __WINS__ - TRequestStatus status( KRequestPending ); - iPowerMgr.SetPower( EBTOff, NULL, status ); - User::WaitForRequest( status ); - status = ( status.Int() == KErrAlreadyExists ? KErrNone : status.Int() ); - User::LeaveIfError( status.Int() ); -#else //__WINS__ - iPowerState = EBTOff; -#endif //__WINS__ - TRACE_FUNC_EXIT - } - - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// void CBTEngServer::ManageDIServiceL( TBool aState ) { TRACE_FUNC_ENTRY @@ -959,353 +509,6 @@ CleanupStack::PopAndDestroy( cenRep ); //cenRep } -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::SetUiIndicatorsL() - { - TRACE_FUNC_ENTRY - TInt powerState = EBTPowerOff; - TBTVisibilityMode visibilityMode = EBTVisibilityModeHidden; - CRepository* cenrep = NULL; - TInt phys = 0; - TInt connecting = 0; - - cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); - User::LeaveIfError( cenrep->Get( KBTPowerState, powerState ) ); - CleanupStack::PopAndDestroy( cenrep ); - - if( powerState == EBTPowerOff ) - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); - } - else if( powerState == EBTPowerOn ) - { - RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, phys ); - RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); - - cenrep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); - User::LeaveIfError( cenrep->Get( KBTDiscoverable, (TInt&) visibilityMode ) ); - CleanupStack::PopAndDestroy( cenrep ); - - if( visibilityMode == EBTVisibilityModeHidden ) - { - if ( connecting ) // BT connecting and hidden - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateAnimate ); - } - else if ( phys > 0 ) // BT connection active and hidden - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOn ); - } - else // BT connection not active and hidden - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOn ); - SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); - } - SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); - } - else if( visibilityMode == EBTVisibilityModeGeneral || visibilityMode == EBTVisibilityModeTemporary ) - { - if ( connecting ) // BT connecting and visible - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateAnimate ); - } - else if ( phys > 0 ) // BT connection active and visible - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOn ); - } - else // BT connection not active and visible - { - SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOn ); - SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); - } - SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); - SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); - } - } - TRACE_FUNC_EXIT - } - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) - { - CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) ); - indicator->SetIndicatorStateL( aState ); - CleanupStack::PopAndDestroy( indicator ); //indicator - } - -// --------------------------------------------------------------------------- -// Gets the current HW power state. -// For now this is a separate method to isolate the different variations. -// --------------------------------------------------------------------------- -// -TInt CBTEngServer::GetHwPowerState( TBTPowerStateValue& aState ) - { - TRACE_FUNC_ENTRY - TInt err = KErrNone; - -#ifndef __WINS__ - err = iPowerMgr.GetPower( (TBTPowerState&) aState, NULL ); -#else //__WINS__ - aState = (TBTPowerStateValue) iPowerState; -#endif //__WINS__ - - // HCIv2 power state type is inverted from BTPM-defined type... - aState = (TBTPowerStateValue) !aState; - TRACE_FUNC_ARG( ( _L( "Power state is %d, result %d" ), (TInt) aState, err ) ) - return err; - } - -// --------------------------------------------------------------------------- -// Check the power state and if BT gets turned off automatically. -// --------------------------------------------------------------------------- -// -void CBTEngServer::CheckTemporaryPowerStateL( TBTPowerStateValue& aCurrentState, - TBTPowerStateValue aNewState, TBool aTemporary ) - { - TRACE_FUNC_ENTRY - User::LeaveIfError( GetHwPowerState( aCurrentState ) ); - if( !aTemporary ) - { - // Force the new power state, so clear all auto switch off flags. - // If power is off, this will anyway be ignored. - iAutoOffClients = 0; - iAutoSwitchOff = EFalse; - TCallBack cb; - iBBConnMgr->SetAutoSwitchOff( EFalse, cb ); - if( iRestoreVisibility && aCurrentState == EBTPowerOn ) - { - // Set visibility mode back to the value selected by the user. - SetVisibilityModeL( EBTVisibilityModeGeneral, 0 ); - iRestoreVisibility = EFalse; - } - } - else - { - if( aCurrentState == aNewState ) - { - if( iAutoSwitchOff && aNewState == EBTPowerOn ) - { - iAutoOffClients++; - if( iTimerQueued & EAutoPowerOffTimer ) - { - iTimer->Remove( iPowerOffCallBack ); - iTimerQueued &= ~EAutoPowerOffTimer; - } - } - } - else if( iAutoSwitchOff || aNewState == EBTPowerOn ) - { - aNewState == EBTPowerOff ? iAutoOffClients-- : iAutoOffClients++; - iAutoSwitchOff = ETrue; - if( aNewState == EBTPowerOff && iAutoOffClients <= 0 ) - { - TCallBack powerOffCb( AutoPowerOffCallBack, this ); - iBBConnMgr->SetAutoSwitchOff( ETrue, powerOffCb ); - iTimer->Queue( KBTEngBtAutoOffTimeout, iPowerOffCallBack ); - iTimerQueued |= EAutoPowerOffTimer; - } - else if( aNewState == EBTPowerOn ) - { - CRepository* cenRep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); - TBTVisibilityMode visibility = EBTVisibilityModeGeneral; - TInt err = cenRep->Get( KBTDiscoverable, (TInt&) visibility ); - CleanupStack::PopAndDestroy( cenRep ); - if( !err && visibility == EBTVisibilityModeGeneral ) - { - SetVisibilityModeL( EBTVisibilityModeHidden, 0 ); - iRestoreVisibility = ETrue; - } - if( iTimerQueued & EAutoPowerOffTimer ) - { - iTimer->Remove( iPowerOffCallBack ); - iTimerQueued &= ~EAutoPowerOffTimer; - } - } - } - } - if( iAutoOffClients < 0 ) - { - iAutoOffClients = 0; - } - TRACE_FUNC_EXIT - } - -// --------------------------------------------------------------------------- -// Check the power state and if BT gets turned off automatically. -// This method is invoked either when the timer has expired, or -// if there are no more connections while the timer was running. -// --------------------------------------------------------------------------- -// -void CBTEngServer::CheckAutoPowerOffL() - { - TRACE_FUNC_ENTRY - if ( iAutoOffClients > 0 ) - { - TRACE_INFO( ( _L( "[CBTEngServer]\t iAutoOffClients %d"), iAutoOffClients )) - return; - } - TInt linkCount = 0; - TInt err = RProperty::Get( KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothGetPHYCount, linkCount ); - if( !err && !linkCount ) - { - TRACE_INFO( ( _L( "[CBTEngServer]\t SetPowerStateL( EBTPowerOff, EFalse );"))) - SetPowerStateL( EBTPowerOff, EFalse ); - } - else - { - if( iRestoreVisibility ) - { - // Set visibility mode back to the value selected by the user. - SetVisibilityModeL( EBTVisibilityModeGeneral, 0 ); - iRestoreVisibility = EFalse; - } - // show note if non-audio connection exists - if ( !iPluginMgr->CheckAudioConnectionsL() ) - { - RNotifier notifier; - TInt err = notifier.Connect(); - if( !err ) - { - TRequestStatus status; - TBTGenericInfoNotiferParamsPckg pckg; - pckg().iMessageType = EBTStayPowerOn; - TBuf8 result; - //notifier.StartNotifier( KBTGenericInfoNotifierUid, pckg, result ); - notifier.StartNotifierAndGetResponse( status, - KBTGenericInfoNotifierUid, - pckg, result ); // Reply buffer not used. - User::WaitForRequest( status ); - notifier.Close(); - } - } - iAutoOffClients = 0; - iAutoSwitchOff = EFalse; - TCallBack cb; - iBBConnMgr->SetAutoSwitchOff( EFalse, cb ); - } - TRACE_FUNC_EXIT - } - -// --------------------------------------------------------------------------- -// ?implementation_description -// --------------------------------------------------------------------------- -// -void CBTEngServer::CheckSspDebugModeL( TBool aDebugMode ) - { - TRACE_FUNC_ARG( ( _L( "SSP debug mode state %d" ), (TInt) aDebugMode ) ) - TBTPowerState pwr = EBTOff; - TBool currentMode = EFalse; - TInt err = RProperty::Get( KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothGetSimplePairingDebugMode, - (TInt&) currentMode ); -#ifndef __WINS__ - err = iPowerMgr.GetPower( pwr, NULL ); // Treat error as power off. -#else //__WINS__ - pwr = iPowerState; -#endif //__WINS__ - if( err || pwr == EBTOff ) - { - iTimerQueued &= ~ESspDebugModeTimer; - iTimer->Remove( iDebugModeCallBack ); - // Only set debug mode to off if it is on, to prevent a loop notifications. - if( currentMode ) - { - (void) RProperty::Set( KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothSetSimplePairingDebugMode, - (TInt) aDebugMode ); - } - // In case of an error in getting the power state, turn BT off. - // If BT is already off, this call will be ignored. - SetPowerStateL( EBTPowerOff, EFalse ); - } - else if( aDebugMode ) - { - // Ignore if there already is a timer queued. - if( !( iTimerQueued & ESspDebugModeTimer ) ) - { - iTimer->Queue( TTimeIntervalMicroSeconds32( KBTEngSspDebugModeTimeout ), - iDebugModeCallBack ); - iTimerQueued &= ESspDebugModeTimer; - err = RProperty::Set(KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothSetSimplePairingDebugMode, - (TInt) aDebugMode ); - } - } - else - { - // Power is on, and debug mode is set to off. - TInt linkCount = 0; - err = RProperty::Get( KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothGetPHYCount, linkCount ); - if( err || !linkCount ) - { - (void) RProperty::Set(KPropertyUidBluetoothCategory, - KPropertyKeyBluetoothSetSimplePairingDebugMode, - (TInt) aDebugMode ); - SetPowerStateL( EBTPowerOff, EFalse ); - } - else - { - // There are still existing connections, queue the - // timer again for half the period. - iTimer->Queue( TTimeIntervalMicroSeconds32( KBTEngSspDebugModeTimeout / 2 ), - iDebugModeCallBack ); - iTimerQueued &= ESspDebugModeTimer; - } - } - TRACE_FUNC_EXIT - } - -// --------------------------------------------------------------------------- -// returns the reference of pairing manager -// --------------------------------------------------------------------------- -// -CBTEngPairMan& CBTEngServer::PairManager() - { - return *iPairMan; - } - -// --------------------------------------------------------------------------- -// Delegate the information to pairing manager -// --------------------------------------------------------------------------- -// -void CBTEngServer::RemoteRegistryChangeDetected() - { - iPairMan->RemoteRegistryChangeDetected(); - } - -// --------------------------------------------------------------------------- -// Access the reference of RSockServ -// --------------------------------------------------------------------------- -// -RSocketServ& CBTEngServer::SocketServ() - { - return iSocketServ; - } - -// --------------------------------------------------------------------------- -// Access the reference of RBTRegSrv -// --------------------------------------------------------------------------- -// -RBTRegServ& CBTEngServer::BTRegServ() - { - return iBTRegServ; - } // --------------------------------------------------------------------------- // Ask plugin manager the connection status of the specified device @@ -1321,6 +524,7 @@ return status; } + // --------------------------------------------------------------------------- // Static callback for temporary visibility mode. // --------------------------------------------------------------------------- @@ -1328,10 +532,14 @@ TInt CBTEngServer::ScanModeTimerCallBack( TAny* aPtr ) { __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); - TRAPD( err, ( (CBTEngServer*) aPtr )->ScanModeTimerCompletedL() ); + // The timer has completed, so remove our reference as well. + CBTEngServer* server = (CBTEngServer*) aPtr; + server->RemoveTimer( EScanModeTimer ); + TRAPD( err, server->SettingsManager()->ScanModeTimerCompletedL() ); return err; } + // --------------------------------------------------------------------------- // Static callback for disconnecting all Baseband connections. // --------------------------------------------------------------------------- @@ -1355,6 +563,7 @@ return KErrNone; } + // --------------------------------------------------------------------------- // Static callback for idle timer timeout. Turn off BT to get it out of // debug mode. If there are existing connections, queue the timer again. @@ -1362,35 +571,29 @@ // TInt CBTEngServer::DebugModeTimerCallBack( TAny* aPtr ) { + __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); // Set our internal debug mode key to off. Ignore error, not critical here. (void) RProperty::Set( KPSUidBluetoothTestingMode, KBTSspDebugmode, EFalse ); - - __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); - - TRAP_IGNORE( ( (CBTEngServer*) aPtr )->CheckSspDebugModeL( EFalse ) ); + CBTEngServer* server = (CBTEngServer*) aPtr; + TRAP_IGNORE( server->SettingsManager()->CheckSspDebugModeL( EFalse ) ); return KErrNone; } + // --------------------------------------------------------------------------- // Static callback for auto power off. // --------------------------------------------------------------------------- // TInt CBTEngServer::AutoPowerOffCallBack( TAny* aPtr ) { - TRACE_FUNC_ENTRY - - __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); - + __ASSERT_ALWAYS(aPtr, PanicServer(EBTEngPanicArgumentIsNull) ); + // The timer has completed, so remove our reference as well. CBTEngServer* server = (CBTEngServer*) aPtr; - server->iTimerQueued &= ~EAutoPowerOffTimer; - TRAPD( err, server->CheckAutoPowerOffL() ); + server->RemoveTimer( EAutoPowerOffTimer ); + TRAPD( err, server->SettingsManager()->CheckAutoPowerOffL() ); return err; } -BluetoothFeatures::TEnterpriseEnablementMode CBTEngServer::EnterpriseEnablementMode() const - { - return iEnterpriseEnablementMode; - } // ======== GLOBAL FUNCTIONS ======== diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengsrvkeywatcher.cpp --- a/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -26,6 +26,8 @@ #include "btengsrvkeywatcher.h" #include "btengserver.h" #include "btengsrvpluginmgr.h" +#include "btengsrvsettingsmgr.h" +#include "btengpairman.h" #include "btengprivatepskeys.h" #include "btengprivatecrkeys.h" #include "debug.h" @@ -302,7 +304,7 @@ aActive->GoActive(); if( !aStatus && !iDutModeKey.Get( val ) ) { - iServer->SetDutMode( val ); + iServer->SettingsManager()->SetDutMode( val ); } } break; @@ -316,7 +318,7 @@ remoteLockVal = ERemoteLocked; if( !aStatus && !iPhoneLockKey.Get( val ) && val == remoteLockVal ) { - iServer->SetPowerStateL( EBTPowerOff, EFalse ); + iServer->SetPowerStateL( EBTOff, EFalse ); } #endif //RD_REMOTELOCK } @@ -329,7 +331,7 @@ if( !aStatus && !iSystemStateKey.Get( val ) && val == ESwStateShuttingDown ) { - iServer->SetVisibilityModeL( EBTVisibilityModeNoScans , 0 ); + iServer->SettingsManager()->SetVisibilityModeL( EBTVisibilityModeNoScans , 0 ); iServer->DisconnectAllL(); } } @@ -339,7 +341,7 @@ TRACE_INFO( ( _L( "PHY count key changed" ) ) ) iPHYCountKey.Subscribe( aActive->RequestStatus() ); aActive->GoActive(); - iServer->SetUiIndicatorsL(); + iServer->SettingsManager()->SetUiIndicatorsL(); } break; case KBTEngBtConnectionWatcher: @@ -347,7 +349,7 @@ TRACE_INFO( ( _L( "BT connection key changed" ) ) ) iBtConnectionKey.Subscribe( aActive->RequestStatus() ); aActive->GoActive(); - iServer->SetUiIndicatorsL(); + iServer->SettingsManager()->SetUiIndicatorsL(); } break; case KBTEngScanningWatcher: @@ -357,7 +359,7 @@ aActive->GoActive(); if ( !iBtScanningKey.Get( val ) ) { - iServer->UpdateVisibilityModeL( val ); + iServer->SettingsManager()->UpdateVisibilityModeL( val ); } } break; @@ -369,7 +371,7 @@ if( !aStatus && !iEmergencyCallKey.Get( val ) && val ) { // An emergency call initiated -> Close SAP connection if it's active - iServer->iPluginMgr->DisconnectProfile( EBTProfileSAP ); + iServer->PluginManager()->DisconnectProfile( EBTProfileSAP ); } } break; @@ -380,7 +382,7 @@ aActive->GoActive(); if( !aStatus && !iSspDebugModeKey.Get( val ) ) { - iServer->CheckSspDebugModeL( (TBool) val ); + iServer->SettingsManager()->CheckSspDebugModeL( (TBool) val ); } break; } @@ -396,7 +398,7 @@ if( !err && myChangedTable == KRegistryChangeRemoteTable ) { TRACE_INFO( ( _L("BT Remote registry key changed") ) ) - iServer->RemoteRegistryChangeDetected(); + iServer->PairManager()->RemoteRegistryChangeDetected(); } break; } @@ -407,18 +409,18 @@ aActive->GoActive(); iSapKeyCenRep->Get( KBTSapEnabled, val ); - TBTPowerStateValue powerState = EBTPowerOff; - User::LeaveIfError( iServer->GetHwPowerState( (TBTPowerStateValue&) powerState ) ); - if( aStatus >= 0 && powerState ) + TBTPowerState powerState = EBTOff; + User::LeaveIfError( iServer->SettingsManager()->GetHwPowerState( powerState ) ); + if( aStatus >= 0 && powerState == EBTOn ) { // Relevant only if BT is on if( val == EBTSapEnabled ) { - iServer->iPluginMgr->LoadBTSapPluginL(); + iServer->PluginManager()->LoadBTSapPluginL(); } else { - iServer->iPluginMgr->UnloadBTSapPlugin(); + iServer->PluginManager()->UnloadBTSapPlugin(); } } } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengsrvpluginmgr.cpp --- a/bluetoothengine/bteng/src/btengsrvpluginmgr.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengsrvpluginmgr.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -229,7 +229,7 @@ { TRACE_FUNC_ENTRY TBool want = EFalse; - switch ( iServer->EnterpriseEnablementMode() ) + switch ( BluetoothFeatures::EnterpriseEnablementL() ) { case BluetoothFeatures::EDisabled: // In Disabled mode all plugins are filtered out. @@ -322,7 +322,7 @@ TRACE_FUNC_ENTRY // SAP is supported in neither Data Profiles Disabled nor Disabled mode. - if ( iServer->EnterpriseEnablementMode() != BluetoothFeatures::EEnabled ) + if ( BluetoothFeatures::EnterpriseEnablementL() != BluetoothFeatures::EEnabled ) { TRACE_INFO( ( _L( "\tno we're not... Bluetooth is enterprise-IT-disabled" ) ) ) User::Leave(KErrNotSupported); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengsrvsession.cpp --- a/bluetoothengine/bteng/src/btengsrvsession.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengsrvsession.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -22,6 +22,7 @@ #include "btengserver.h" #include "btengsrvbbconnectionmgr.h" #include "btengpairman.h" +#include "btengsrvsettingsmgr.h" #include "btengclientserver.h" #include "debug.h" @@ -79,14 +80,11 @@ { iNotifyConnMessage.Complete( KErrCancel ); } - CancelPairRequest(); if( Server() ) { - Server()->RemoveSession( iAutoSwitchOff ); + Server()->RemoveSession(this, iAutoSwitchOff ); } - delete iConnectionEventQueue; - TRACE_FUNC_EXIT } @@ -150,20 +148,6 @@ } // --------------------------------------------------------------------------- -// Comfirm the caller if pairing request is completed in this invoke. -// --------------------------------------------------------------------------- -// -TInt CBTEngSrvSession::CompletePairRequest( TInt aResult ) - { - if ( !iPairMessage.IsNull()) - { - iPairMessage.Complete( aResult ); - return KErrNone; - } - return KErrNotFound; - } - -// --------------------------------------------------------------------------- // From class CSession2 // Handles servicing of a client request that has been passed to the server. // --------------------------------------------------------------------------- @@ -171,11 +155,11 @@ void CBTEngSrvSession::ServiceL( const RMessage2& aMessage ) { TRAPD( err, DispatchMessageL( aMessage ) ); - if( !aMessage.IsNull() && ( err || ( aMessage.Function() != EBTEngNotifyConnectionEvents && - aMessage.Function() != EBTEngPairDevice ) ) ) + aMessage.Function() != EBTEngPairDevice && + aMessage.Function() != EBTEngSetPowerState ) ) ) { // Return the error code to the client. aMessage.Complete( err ); @@ -206,15 +190,13 @@ { case EBTEngSetPowerState: { - iAutoSwitchOff = (TBool) aMessage.Int1(); - Server()->SetPowerStateL( (TBTPowerStateValue) aMessage.Int0(), - iAutoSwitchOff ); + Server()->SetPowerStateL( aMessage ); } break; case EBTEngSetVisibilityMode: { - Server()->SetVisibilityModeL( (TBTVisibilityMode) aMessage.Int0(), - aMessage.Int1() ); + Server()->SettingsManager()->SetVisibilityModeL( + (TBTVisibilityMode) aMessage.Int0(),aMessage.Int1() ); } break; case EBTEngNotifyConnectionEvents: @@ -229,7 +211,6 @@ { User::Leave(KErrInUse); } - //save the client message iNotifyConnMessage = RMessage2(aMessage); @@ -261,17 +242,9 @@ case EBTEngIsDeviceConnected: case EBTEngGetConnectedAddresses: { - TBTPowerStateValue pwr = EBTPowerOff; - Server()->GetHwPowerState( pwr ); - if( pwr ) - { - // Simply forward it to the plug-in manager - Server()->DispatchPluginMessageL( aMessage ); - } - else - { - User::Leave( KErrNotReady ); - } + CheckPowerOnL(); + // Simply forward it to the plug-in manager + Server()->DispatchPluginMessageL( aMessage ); } break; case EBTEngIsDeviceConnectable: @@ -282,38 +255,31 @@ case EBTEngPrepareDiscovery: { aMessage.Complete( KErrNone ); // Client does not have to wait. - Server()->iBBConnMgr->ManageTopology( ETrue ); + Server()->BasebandConnectionManager()->ManageTopology( ETrue ); } break; case EBTEngSetPairingObserver: + { + CheckPowerOnL(); + // Simply forward it to the pairing manager + Server()->PairManager()->ProcessCommandL( aMessage ); + break; + } case EBTEngPairDevice: { - TBTPowerStateValue pwr = EBTPowerOff; - (void) Server()->GetHwPowerState( pwr ); - if( pwr ) - { - // Simply forward it to the pairing manager - Server()->PairManager().ProcessCommandL( aMessage ); - if ( opcode == EBTEngPairDevice ) - { - iPairMessage = RMessage2( aMessage ); - } - } - else - { - User::Leave( KErrNotReady ); - } + CheckPowerOnL(); + // Simply forward it to the pairing manager + Server()->PairManager()->ProcessCommandL( aMessage ); break; } case EBTEngCancelPairDevice: { - CancelPairRequest(); + Server()->PairManager()->ProcessCommandL( aMessage ); break; } default: { - TRACE_INFO( ( _L( "[BTENG]\t DispatchMessageL: bad request (%d)" ), - aMessage.Function() ) ) + TRACE_INFO( ( _L( "[BTENG]\t DispatchMessageL: bad request (%d)" ), aMessage.Function() ) ) User::Leave( KErrArgument ); } break; @@ -322,14 +288,15 @@ } // --------------------------------------------------------------------------- -// Only the originator of pairing can cancel the pairing request. +// Check if power is on, and leave if it is not. // --------------------------------------------------------------------------- // -void CBTEngSrvSession::CancelPairRequest() +void CBTEngSrvSession::CheckPowerOnL() { - if ( !iPairMessage.IsNull() ) + TBTPowerState power = EBTOff; + (void) Server()->SettingsManager()->GetHwPowerState( power ); + if ( power == EBTOff ) { - Server()->PairManager().CancelCommand( iPairMessage.Function() ); - iPairMessage.Complete( KErrCancel ); + User::Leave( KErrNotReady ); } } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,943 @@ +/* +* Copyright (c) 2009-2010 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: Class to manage Bluetooth hardware and stack settings. +* +*/ + +#include "btengsrvsettingsmgr.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "btengserver.h" +#include "btengsrvpluginmgr.h" +#include "btengsrvbbconnectionmgr.h" +#include "btengsrvstate.h" +#include "debug.h" + +#ifndef SETLOCALNAME +#include +#endif + +/** ID of active object helper */ +const TInt KBTEngSettingsActive = 30; +/** Constant for converting minutes to microseconds */ +//const TInt64 KMinutesInMicroSecs = 60000000; +const TInt64 KMinutesInMicroSecs = MAKE_TINT64( 0, 60000000 ); +/** Timeout for disabling Simple Pairing debug mode. The value is 30 minutes. */ +//const TInt KBTEngSspDebugModeTimeout = 1800000000; +const TInt64 KBTEngSspDebugModeTimeout = MAKE_TINT64( 0, 1800000000 ); +/** Timeout for turning BT off automatically. The value is 10.5 seconds. */ +const TInt KBTEngBtAutoOffTimeout = 10500000; +/** Default values for Major Service Class */ +const TUint16 KCoDDefaultServiceClass = EMajorServiceTelephony | EMajorServiceObjectTransfer | EMajorServiceNetworking; +/** Default values for Major Device Class */ +const TUint8 KCoDDefaultMajorDeviceClass = EMajorDevicePhone; +/** Default values for Minor Device Class */ +const TUint8 KCoDDefaultMinorDeviceClass = EMinorDevicePhoneSmartPhone; + + +// ======== MEMBER FUNCTIONS ======== + +// --------------------------------------------------------------------------- +// C++ default constructor +// --------------------------------------------------------------------------- +// +CBTEngSrvSettingsMgr::CBTEngSrvSettingsMgr( CBTEngServer* aServer ) +: iServer( aServer ) + { + } + + +// --------------------------------------------------------------------------- +// Symbian second-phase constructor +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::ConstructL() + { + TRACE_FUNC_ENTRY + iActive = CBTEngActive::NewL( *this, KBTEngSettingsActive ); + LoadBTPowerManagerL(); + iEnterpriseEnablementMode = BluetoothFeatures::EnterpriseEnablementL(); + TRACE_INFO( ( _L( "iEnterpriseEnablementMode = %d" ), iEnterpriseEnablementMode) ) + if ( iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) + { + SetVisibilityModeL( EBTVisibilityModeNoScans, 0 ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// NewL +// --------------------------------------------------------------------------- +// +CBTEngSrvSettingsMgr* CBTEngSrvSettingsMgr::NewL( CBTEngServer* aServer ) + { + CBTEngSrvSettingsMgr* self = new( ELeave ) CBTEngSrvSettingsMgr( aServer ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CBTEngSrvSettingsMgr::~CBTEngSrvSettingsMgr() + { + if( iActive && iActive->IsActive() ) + { + // Cancel the outstanding request. + iPowerMgr.Cancel(); + } + delete iActive; + iPowerMgr.Close(); + } + + +// --------------------------------------------------------------------------- +// Power Bluetooth hardware on or off. +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvSettingsMgr::SetHwPowerState( TBTPowerState aState ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; +#ifndef __WINS__ + if( iActive->IsActive() ) + { + // Cancel the outstanding request. + iPowerMgr.Cancel(); + iActive->Cancel(); + } + iPowerMgr.SetPower( aState, NULL, iActive->RequestStatus() ); + iActive->GoActive(); +#else //__WINS__ + iPowerState = aState; +#endif //__WINS__ + + if( !err && aState == EBTOn ) + { + TInt dutMode = EBTDutOff; + err = RProperty::Get( KPSUidBluetoothTestingMode, KBTDutEnabled, dutMode ); + if( !err && dutMode == EBTDutOn ) + { + // Set the DUT mode key to OFF since DUT mode is disabled at this point + err = RProperty::Set( KPSUidBluetoothTestingMode, KBTDutEnabled, EBTDutOff ); + } + } + if( err ) + { + // Power off if an error occurred during power on sequence. +#ifndef __WINS__ + // This cannot happen in emulator environment. + iPowerMgr.Cancel(); + iActive->Cancel(); + iPowerMgr.SetPower( EBTOff, NULL, iActive->RequestStatus() ); + User::WaitForRequest( iActive->RequestStatus() ); + // Result will be communicated through the caller of this function (by leaving). +#else //__WINS__ + iPowerState = EBTOff; +#endif //__WINS__ + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + return err; + } + + +// --------------------------------------------------------------------------- +// Turn BT on or off. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetPowerStateL( TBTPowerState aState, TBool aTemporary ) + { + TRACE_FUNC_ARG( ( _L( "%d (temporary=%d" ), aState, aTemporary ) ) + if ( aState == EBTOn && iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) + { + TRACE_INFO( ( _L( "no we're not... Bluetooth is enterprise-IT-disabled" ) ) ) + User::Leave(KErrNotSupported); + } + TBool idle = ( iServer->StateMachine()->CurrentOperation() == CBTEngSrvState::ESrvOpIdle ); + TBTPowerState currentState = EBTOff; + CheckTemporaryPowerStateL( currentState, aState, aTemporary ); + + if ( ( currentState == aState || ( aTemporary && aState == EBTOff ) ) && idle ) + { + // The requested power state is already active, ignore silently. + // We don't return an error here, as there is no error situation. + TRACE_INFO( ( _L( "SetPowerStateL: nothing to do" ) ) ) + if ( currentState == aState ) + { + // Make sure that the CenRep key is in sync. + // During boot-up, the pwoer is set from the CenRep key, so we could + // end up out-of-sync. + TRACE_INFO( ( _L( "SetPowerStateL: currentState == aState" ) ) ) + UpdateCenRepPowerKeyL( aState ); + } + return; + } + if ( aState == EBTOn ) + { + // Hardware power on is the first step. + User::LeaveIfError( SetHwPowerState( aState ) ); + } + else + { + //Prevent BT visibility in the situation when we turn OFF BT Engine + //but FM Radio is still alive + SetVisibilityModeL( EBTVisibilityModeNoScans, 0 ); + // Hardware power off is the last step. + // First disconnect all plug-ins. + iServer->PluginManager()->DisconnectAllPlugins(); + } + // We only signal that BT is on after everything has completed (through + // the CenRep power state key), so that all services are initialized. + // We signal that BT is off immediately though, so that our clients will + // not try to use BT during power down. + iServer->StateMachine()->StartStateMachineL( aState ); + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Turn BT on or off. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetPowerStateL(const RMessage2 aMessage ) + { + TRACE_FUNC_ENTRY + __ASSERT_ALWAYS( aMessage.Function() == EBTEngSetPowerState, + PanicServer( EBTEngPanicExpectSetPowerOpcode ) ); + if ( !iMessage.IsNull() ) + { + // A power management request from a client is outstanding. + User::Leave( KErrAlreadyExists ); + } + + TBTPowerStateValue arg = (TBTPowerStateValue) aMessage.Int0(); + // TBTPowerState power state type is inverted from TBTPowerStateValue, + // which is used by the client to pass the parameter... + TBTPowerState reqedPowerState( EBTOff ); + if ( arg == EBTPowerOn ) + { + reqedPowerState = EBTOn; + } + TBool tempPowerOn = (TBool) aMessage.Int1(); + + SetPowerStateL( reqedPowerState, tempPowerOn ); + if ( iServer->StateMachine()->CurrentOperation() == CBTEngSrvState::ESrvOpIdle ) + { + // The request is accepted but the state machine is not running. This means the + // requested power state is already active. Request is done. + aMessage.Complete( KErrNone ); + } + else + { + iMessage = RMessage2( aMessage ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Initialize Bluetooth stack settings. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::InitBTStackL() + { + TRACE_FUNC_ENTRY + iServer->BasebandConnectionManager()->Subscribe(); + TBTVisibilityMode visibility = EBTVisibilityModeHidden; + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + TInt err = cenRep->Get( KBTDiscoverable, (TInt&) visibility ); + delete cenRep; + if (iRestoreVisibility == EFalse) + { + if( err || visibility == EBTVisibilityModeTemporary && + !( iServer->IsTimerQueued( CBTEngServer::EScanModeTimer ) ) ) + { + visibility = EBTVisibilityModeHidden; + } + SetVisibilityModeL( visibility, 0 ); + } + + TBool sspDebugMode = EFalse; + (void) RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetSimplePairingDebugMode, (TInt&) sspDebugMode ); + // Only set debug mode to off if it is on, to prevent a loop notifications. + if( sspDebugMode ) + { + sspDebugMode = EFalse; + // Add LeaveIfError if unsuccessful + (void) RProperty::Set(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, (TInt) sspDebugMode ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Reset settings and disconnect all links. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::StopBTStackL() + { + TRACE_FUNC_ENTRY + TBTVisibilityMode visibility = EBTVisibilityModeHidden; + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + // Ignore error here; if we can't read it, likely we can't set it either. + (void) cenRep->Get( KBTDiscoverable, (TInt&) visibility ); + delete cenRep; + if( visibility == EBTVisibilityModeTemporary ) + { + visibility = EBTVisibilityModeHidden; + SetVisibilityModeL( visibility, 0 ); // Also cancels scan mode timer. + } + + // Stop listening to events + iServer->BasebandConnectionManager()->Unsubscribe(); + // Disconnect all links + TCallBack cb( CBTEngServer::DisconnectAllCallBack, iServer ); + iServer->BasebandConnectionManager()->DisconnectAllLinksL( cb ); + // Results in a callback (which is called directly when there are no links). + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Update the power state CenRep key. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::UpdateCenRepPowerKeyL( TBTPowerState aState ) + { + TRACE_FUNC_ENTRY + CRepository* cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); + // TBTPowerState power state type is inverted from TBTPowerStateValue... + TBTPowerStateValue power = (TBTPowerStateValue) !aState; + User::LeaveIfError( cenrep->Set( KBTPowerState, (TInt) power ) ); + CleanupStack::PopAndDestroy( cenrep ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetVisibilityModeL( TBTVisibilityMode aMode, TInt aTime ) + { + TRACE_FUNC_ARG( ( _L( "[aMode: %d" ), aMode ) ) + if ( aMode != EBTVisibilityModeNoScans && iEnterpriseEnablementMode == BluetoothFeatures::EDisabled ) + { + TRACE_INFO( ( _L( "\tnot changing anything... Bluetooth is enterprise-IT-disabled" ) ) ) + User::Leave( KErrNotSupported ); + } + + TInt err = KErrNone; + iServer->RemoveTimer( CBTEngServer::EScanModeTimer ); + if( aMode != EBTVisibilityModeNoScans ) + { + CRepository* cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings ); + err = cenRep->Set( KBTDiscoverable, aMode ); + delete cenRep; + } + if( !err && aMode == EBTVisibilityModeTemporary ) + { + // We need TInt64 here, as the max. time in microseconds for the + // max. value (1 hour) is larger than KMaxTInt32. + TInt64 timeMicroSec = MAKE_TINT64( 0, aTime ); + timeMicroSec = timeMicroSec * KMinutesInMicroSecs; + // Queue callback to set the visibility back to hidden. + iServer->QueueTimer( CBTEngServer::EScanModeTimer, (TInt64) timeMicroSec ); + aMode = EBTVisibilityModeGeneral; + } + else if( !err && iRestoreVisibility ) + { + // The user overrides, do not restore visibility mode anymore. + iRestoreVisibility = EFalse; + } + if( !err ) + { + err = RProperty::Set( KUidSystemCategory, + KPropertyKeyBluetoothSetScanningStatus, aMode ); + } + TBool hiddenMode = ( aMode == EBTVisibilityModeHidden ); + if( !err && aMode != EBTVisibilityModeNoScans ) + { + // In hidden mode, we only accept connections from paired devices. + err = RProperty::Set( KUidSystemCategory, + KPropertyKeyBluetoothSetAcceptPairedOnlyMode, + hiddenMode ); + } + + User::LeaveIfError( err ); // To communicate the result to the client. + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Timed visible mode has expired. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::ScanModeTimerCompletedL() + { + TRACE_FUNC_ENTRY + SetVisibilityModeL( EBTVisibilityModeHidden, 0 ); + TBTPowerState power = EBTOff; + TInt err = GetHwPowerState( power ); + // See p2.1.2.1.2 of the UI spec + // NB: Please distinguish between TBTPowerState::EBTOff (defined in hcitypes.h) + // and TBTPowerStateValue::EBTPowerOff (defined in btserversdkcrkeys.h) + // because they have the opposite values + if( !err && (power != EBTOff)) + { + // Show a notification to the user + TBTGenericInfoNotiferParamsPckg pckg; + pckg().iMessageType = EBTVisibilityTimeout; + + RNotifier notifier; + TInt err = notifier.Connect(); + if( !err ) + { + err = notifier.StartNotifier( KBTGenericInfoNotifierUid, pckg ); + notifier.Close(); + } + } + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) + } + + +// --------------------------------------------------------------------------- +// Check the secure simple pairing debug mode and turn it off if needed. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::CheckSspDebugModeL( TBool aDebugMode ) + { + TRACE_FUNC_ARG( ( _L( "SSP debug mode state %d" ), (TInt) aDebugMode ) ) + TBTPowerState pwr = EBTOff; + TBool currentMode = EFalse; + TInt err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetSimplePairingDebugMode, + (TInt&) currentMode ); +#ifndef __WINS__ + err = iPowerMgr.GetPower( pwr, NULL ); // Treat error as power off. +#else //__WINS__ + pwr = iPowerState; +#endif //__WINS__ + if( err || pwr == EBTOff ) + { + iServer->RemoveTimer( CBTEngServer::ESspDebugModeTimer ); + // Only set debug mode to off if it is on, to prevent a loop notifications. + if( currentMode ) + { + (void) RProperty::Set( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) aDebugMode ); + } + // In case of an error in getting the power state, turn BT off. + // If BT is already off, this call will be ignored. + SetPowerStateL( EBTOff, EFalse ); + } + else if( aDebugMode ) + { + // Ignore if there already is a timer queued. + if( !( iServer->IsTimerQueued( CBTEngServer::ESspDebugModeTimer ) ) ) + { + iServer->QueueTimer( CBTEngServer::ESspDebugModeTimer, (TInt64) KBTEngSspDebugModeTimeout ); + err = RProperty::Set(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) aDebugMode ); + } + } + else + { + // Power is on, and debug mode is set to off. + TInt linkCount = 0; + err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount, linkCount ); + if( err || !linkCount ) + { + (void) RProperty::Set(KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothSetSimplePairingDebugMode, + (TInt) aDebugMode ); + SetPowerStateL( EBTOff, EFalse ); + } + else + { + // There are still existing connections, queue the + // timer again for half the period. + TInt64 interval = KBTEngSspDebugModeTimeout / 2; + iServer->QueueTimer( CBTEngServer::ESspDebugModeTimer, interval ); + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// A session will be ended, completes the pending request for this session. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SessionClosed( CSession2* aSession ) + { + TRACE_FUNC_ARG( ( _L( " session %x"), aSession ) ) + if ( !iMessage.IsNull() && iMessage.Session() == aSession ) + { + iMessage.Complete( KErrCancel ); + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------------------------- +// Check the power state and if BT gets turned off automatically. +// This method is invoked either when the timer has expired, or +// if there are no more connections while the timer was running. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::CheckAutoPowerOffL() + { + TRACE_FUNC_ENTRY + if ( iAutoOffClients > 0 ) + { + TRACE_INFO( ( _L( "[CBTEngServer]\t iAutoOffClients %d"), iAutoOffClients ) ) + return; + } + TInt linkCount = 0; + TInt err = RProperty::Get( KPropertyUidBluetoothCategory, + KPropertyKeyBluetoothGetPHYCount, linkCount ); + if( !err && !linkCount ) + { + TRACE_INFO( ( _L( "[CBTEngServer]\t SetPowerStateL( EBTOff, EFalse );"))) + SetPowerStateL( EBTOff, EFalse ); + } + else + { + if( iRestoreVisibility ) + { + // Set visibility mode back to the value selected by the user. + SetVisibilityModeL( EBTVisibilityModeGeneral, 0 ); + iRestoreVisibility = EFalse; + } + // show note if non-audio connection exists + if ( !iServer->PluginManager()->CheckAudioConnectionsL() ) + { + RNotifier notifier; + TInt err = notifier.Connect(); + if( !err ) + { + TRequestStatus status; + TBTGenericInfoNotiferParamsPckg pckg; + pckg().iMessageType = EBTStayPowerOn; + TBuf8 result; + //notifier.StartNotifier( KBTGenericInfoNotifierUid, pckg, result ); + notifier.StartNotifierAndGetResponse( status, + KBTGenericInfoNotifierUid, + pckg, result ); // Reply buffer not used. + User::WaitForRequest( status ); + notifier.Close(); + } + } + iAutoOffClients = 0; + iAutoSwitchOff = EFalse; + TCallBack cb; + iServer->BasebandConnectionManager()->SetAutoSwitchOff( EFalse, cb ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// The method is called when BT stack scanning mode P&S key is changed +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::UpdateVisibilityModeL( TInt aStackScanMode ) + { + TRACE_FUNC_ARG( ( _L( "[aStackScanMode: %d" ), aStackScanMode ) ) + TBTVisibilityMode currentMode; + + CRepository* cenRep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); + User::LeaveIfError( cenRep->Get( KBTDiscoverable, (TInt&) currentMode ) ); + + // In case we are in temp visibility mode, we cannot always know whether the BT stack + // scan mode key was set by some external party or by us in SetVisibilityModeL above. + // Therefore we cannot stop the timer in case aMode is EBTVisibilityModeGeneral and + // currentmode is EBTVisibilityModeTemporary + if( !( currentMode == EBTVisibilityModeTemporary && aStackScanMode == EBTVisibilityModeGeneral ) ) + { + // Cancel the timer and queue it again if needed. + iServer->RemoveTimer( CBTEngServer::EScanModeTimer ); + if( currentMode != aStackScanMode ) + { + if( aStackScanMode == EPageScanOnly || aStackScanMode == EInquiryAndPageScan ) + { + User::LeaveIfError( cenRep->Set( KBTDiscoverable, aStackScanMode ) ); + } + else if( aStackScanMode == EInquiryScanOnly ) + { + // We don't support ENoScansEnabled nor EInquiryScanOnly mode + // -> Consider these as same as Hidden + User::LeaveIfError( cenRep->Set( KBTDiscoverable, EBTVisibilityModeHidden ) ); + } + else if( aStackScanMode == ENoScansEnabled ) + { + //We don't change KBTDiscoverable here, because ENoScansEnabled + //indicates BT/SYSTEM shutdown is happening + } + } + } + SetUiIndicatorsL(); + CleanupStack::PopAndDestroy( cenRep ); + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Set Device Under Test mode. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetDutMode( TInt aDutMode ) + { + TRACE_FUNC_ARG( ( _L( "DUT mode %d" ), aDutMode ) ) + + if (aDutMode == EBTDutOff) + { + return; + } + + TInt powerState = EBTOff; + CRepository* cenrep = NULL; + + TRAPD(err, cenrep = CRepository::NewL(KCRUidBluetoothPowerState)); + + if (!err && cenrep) + { + cenrep->Get(KBTPowerState, powerState); + delete cenrep; + cenrep = NULL; + } + else + { + return; + } + + if (powerState == EBTPowerOn) + { + +#ifndef __WINS__ + RBluetoothDutMode dutMode; + TInt err = dutMode.Open(); + TRACE_FUNC_ARG( ( _L( "Open DUT mode handle err %d" ), err) ) + if(!err) + { + dutMode.ActivateDutMode(); + dutMode.Close(); + } +#endif //__WINS__ + } + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Callback to notify that an outstanding request has completed. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::RequestCompletedL( CBTEngActive* aActive, TInt aId, TInt aStatus ) + { + __ASSERT_ALWAYS( aId == KBTEngSettingsActive, PanicServer( EBTEngPanicCorrupt ) ); + TRACE_FUNC_ENTRY + (void) aActive; + if ( aStatus != KErrNone && aStatus != KErrAlreadyExists && aStatus != KErrCancel ) + { + // Something went wrong, so we turn BT off again. + SetPowerStateL( EBTOff, EFalse ); + } + else + { + // Write CoD only when the hardware has fully powered up. + TBTPowerState currState ( EBTOff ); + (void) GetHwPowerState( currState ); + if ( currState == EBTOn ) + { + SetClassOfDeviceL(); +#ifndef SETLOCALNAME + // the macro SETLOCALNAME is used as a workaround to tackle the BT name + // could not be saved to BT chip before chip initialization completed for the first time, + // which is one of the regression after improving the BT boot up time. + // To be removed once the final solution is in place. + CBTEngSettings* settings = CBTEngSettings::NewL(); + TBTDeviceName localName; + localName.Zero(); + TInt err = settings->GetLocalName(localName); + if (err == KErrNone) + { + settings->SetLocalName(localName); + } + delete settings; +#endif + } + } + if ( !iMessage.IsNull()) + { + iMessage.Complete( aStatus ); + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// From class MBTEngActiveObserver. +// Callback to notify that an error has occurred in RunL. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::HandleError( CBTEngActive* aActive, TInt aId, TInt aError ) + { + (void) aActive; + (void) aId; + if ( !iMessage.IsNull()) + { + iMessage.Complete( aError ); + } + } + + +// --------------------------------------------------------------------------- +// Loads the BT Power Manager; leaves if it cannot be loaded. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::LoadBTPowerManagerL() + { + TRACE_FUNC_ENTRY + TRACE_INFO( ( _L( "[CBTEngSrvSettingsMgr]\t Using HCI API v2 power manager" ) ) ) + User::LeaveIfError( iPowerMgr.Open() ); +#ifndef __WINS__ + iPowerMgr.SetPower( EBTOff, NULL, iActive->RequestStatus() ); + User::WaitForRequest( iActive->RequestStatus() ); + TInt status = ( iActive->RequestStatus().Int() == KErrAlreadyExists ? KErrNone : iActive->RequestStatus().Int() ); + User::LeaveIfError( status ); +#else //__WINS__ + iPowerState = EBTOff; +#endif //__WINS__ + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetUiIndicatorsL() + { + TRACE_FUNC_ENTRY + TBTPowerStateValue powerState = EBTPowerOff; + TBTVisibilityMode visibilityMode = EBTVisibilityModeHidden; + CRepository* cenrep = NULL; + TInt phys = 0; + TInt connecting = 0; + + cenrep = CRepository::NewLC( KCRUidBluetoothPowerState ); + User::LeaveIfError( cenrep->Get( KBTPowerState, (TInt&) powerState ) ); + CleanupStack::PopAndDestroy( cenrep ); + + if( powerState == EBTPowerOff ) + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); + } + else + { + // Power is on. + RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, phys ); + RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting, connecting ); + + cenrep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); + User::LeaveIfError( cenrep->Get( KBTDiscoverable, (TInt&) visibilityMode ) ); + CleanupStack::PopAndDestroy( cenrep ); + + if( visibilityMode == EBTVisibilityModeHidden ) + { + if ( connecting ) // BT connecting and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateAnimate ); + } + else if ( phys > 0 ) // BT connection active and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOn ); + } + else // BT connection not active and hidden + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOn ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + } + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); + } + else if( visibilityMode == EBTVisibilityModeGeneral || visibilityMode == EBTVisibilityModeTemporary ) + { + if ( connecting ) // BT connecting and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateAnimate ); + } + else if ( phys > 0 ) // BT connection active and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOn ); + } + else // BT connection not active and visible + { + SetIndicatorStateL( EAknIndicatorBluetoothModuleOnVisible, EAknIndicatorStateOn ); + SetIndicatorStateL( EAknIndicatorBluetoothVisible, EAknIndicatorStateOff ); + } + SetIndicatorStateL( EAknIndicatorBluetoothModuleOn, EAknIndicatorStateOff ); + SetIndicatorStateL( EAknIndicatorBluetooth, EAknIndicatorStateOff ); + } + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// ?implementation_description +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) + { + CAknSmallIndicator* indicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) ); + indicator->SetIndicatorStateL( aState ); + CleanupStack::PopAndDestroy( indicator ); //indicator + } + + +// --------------------------------------------------------------------------- +// Gets the current HW power state. +// For now this is a separate method to isolate the different variations. +// --------------------------------------------------------------------------- +// +TInt CBTEngSrvSettingsMgr::GetHwPowerState( TBTPowerState& aState ) + { + TRACE_FUNC_ENTRY + TInt err = KErrNone; + +#ifndef __WINS__ + err = iPowerMgr.GetPower( aState, NULL ); +#else //__WINS__ + aState = iPowerState; +#endif //__WINS__ + TRACE_FUNC_ARG( ( _L( "Power state is %d, result %d" ), (TInt) aState, err ) ) + return err; + } + +// --------------------------------------------------------------------------- +// Check the power state and if BT gets turned off automatically. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::CheckTemporaryPowerStateL( TBTPowerState& aCurrentState, + TBTPowerState aNewState, TBool aTemporary ) + { + TRACE_FUNC_ENTRY + User::LeaveIfError( GetHwPowerState( aCurrentState ) ); + if( !aTemporary ) + { + // Force the new power state, so clear all auto switch off flags. + // If power is off, this will anyway be ignored. + iAutoOffClients = 0; + iAutoSwitchOff = EFalse; + TCallBack cb; + iServer->BasebandConnectionManager()->SetAutoSwitchOff( EFalse, cb ); + if( iRestoreVisibility && aCurrentState == EBTOn ) + { + // Set visibility mode back to the value selected by the user. + SetVisibilityModeL( EBTVisibilityModeGeneral, 0 ); + iRestoreVisibility = EFalse; + } + } + else + { + if( aCurrentState == aNewState ) + { + if( iAutoSwitchOff && aNewState == EBTOn ) + { + iAutoOffClients++; + iServer->RemoveTimer( CBTEngServer::EAutoPowerOffTimer ); + } + } + else if( iAutoSwitchOff || aNewState == EBTOn ) + { + aNewState == EBTOff ? iAutoOffClients-- : iAutoOffClients++; + iAutoSwitchOff = ETrue; + if( aNewState == EBTOff && iAutoOffClients <= 0 ) + { + TCallBack powerOffCb( CBTEngServer::AutoPowerOffCallBack, iServer ); + iServer->BasebandConnectionManager()->SetAutoSwitchOff( ETrue, powerOffCb ); + TInt64 interval = KBTEngBtAutoOffTimeout; + iServer->QueueTimer( CBTEngServer::EAutoPowerOffTimer, interval ); + } + else if( aNewState == EBTOn ) + { + CRepository* cenRep = CRepository::NewLC( KCRUidBTEngPrivateSettings ); + TBTVisibilityMode visibility = EBTVisibilityModeGeneral; + TInt err = cenRep->Get( KBTDiscoverable, (TInt&) visibility ); + CleanupStack::PopAndDestroy( cenRep ); + if( !err && visibility == EBTVisibilityModeGeneral ) + { + SetVisibilityModeL( EBTVisibilityModeHidden, 0 ); + iRestoreVisibility = ETrue; + } + iServer->RemoveTimer( CBTEngServer::EAutoPowerOffTimer ); + } + } + } + if( iAutoOffClients < 0 ) + { + iAutoOffClients = 0; + } + TRACE_FUNC_EXIT + } + + +// --------------------------------------------------------------------------- +// Set the Class of Device. +// --------------------------------------------------------------------------- +// +void CBTEngSrvSettingsMgr::SetClassOfDeviceL() + { + TRACE_FUNC_ENTRY + TUint16 serviceClass = KCoDDefaultServiceClass; + // Check from feature manager if stereo audio is enabled. + FeatureManager::InitializeLibL(); + TBool supported = FeatureManager::FeatureSupported( KFeatureIdBtStereoAudio ); + FeatureManager::UnInitializeLib(); + if( supported ) + { + // A2DP spec says we should set this bit as we are a SRC + serviceClass |= EMajorServiceCapturing; + } + // These values may nayway be overridden by HCI + TBTDeviceClass cod( serviceClass, KCoDDefaultMajorDeviceClass, + KCoDDefaultMinorDeviceClass ); + // Ignore error, it is non-critical + (void) RProperty::Set( KPropertyUidBluetoothControlCategory, + KPropertyKeyBluetoothSetDeviceClass, cod.DeviceClass() ); + TRACE_FUNC_EXIT + } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bteng/src/btengsrvstate.cpp --- a/bluetoothengine/bteng/src/btengsrvstate.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bteng/src/btengsrvstate.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -22,6 +22,7 @@ #include "btengsrvstate.h" #include "btengserver.h" #include "btengsrvpluginmgr.h" +#include "btengsrvsettingsmgr.h" #include "debug.h" @@ -93,10 +94,10 @@ // ?implementation_description // --------------------------------------------------------------------------- // -void CBTEngSrvState::StartStateMachineL( TBool aState ) +void CBTEngSrvState::StartStateMachineL( TBTPowerState aState ) { TRACE_FUNC_ENTRY - if( aState ) + if( aState == EBTOn ) { // Power on; starting state is initializing the stack iState = EInitBTStack; @@ -107,8 +108,8 @@ // Power off, starting state is to disconnect the plug-ins iState = EDisconnectPlugins; iOperation = EPowerOff; - iServer->UpdateCenRepPowerKeyL( EBTPowerOff ); - iServer->SetUiIndicatorsL(); + iServer->SettingsManager()->UpdateCenRepPowerKeyL( EBTOff ); + iServer->SettingsManager()->SetUiIndicatorsL(); } ChangeState(); } @@ -121,10 +122,7 @@ void CBTEngSrvState::ChangeState() { TRACE_FUNC_ENTRY - if(!iAsyncCallback->IsActive()) - { - iAsyncCallback->CallBack(); - } + iAsyncCallback->CallBack(); } // --------------------------------------------------------------------------- @@ -153,7 +151,7 @@ case EInitBTStack: { iState = ELoadDIService; - iServer->InitBTStackL(); + iServer->SettingsManager()->InitBTStackL(); } break; case ELoadDIService: @@ -166,13 +164,13 @@ { iState = ELoadNextPlugin; TEComResolverParams params; - iServer->iPluginMgr->LoadProfilePluginsL( params ); + iServer->PluginManager()->LoadProfilePluginsL( params ); } break; case ELoadNextPlugin: { // Only change the state when all plug-ins are loaded - if( iServer->iPluginMgr->LoadPluginL() <= 0 ) + if( iServer->PluginManager()->LoadPluginL() <= 0 ) { iState = EIdle; } @@ -181,7 +179,7 @@ case EStopBTStack: { iState = EWaitingForPowerOff; - iServer->StopBTStackL(); + iServer->SettingsManager()->StopBTStackL(); } break; case EUnloadDIService: @@ -193,7 +191,7 @@ case EUnloadPlugins: { iState = EUnloadDIService; - iServer->iPluginMgr->UnloadProfilePlugins(); + iServer->PluginManager()->UnloadProfilePlugins(); } break; case EDisconnectPlugins: @@ -214,8 +212,8 @@ { if( iOperation == EPowerOn ) { - iServer->UpdateCenRepPowerKeyL( EBTPowerOn ); - iServer->SetUiIndicatorsL(); + iServer->SettingsManager()->UpdateCenRepPowerKeyL( EBTOn ); + iServer->SettingsManager()->SetUiIndicatorsL(); } iOperation = ESrvOpIdle; iServer->CheckIdle(); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidclient/eabi/bthidclientu.def --- a/bluetoothengine/bthid/bthidclient/eabi/bthidclientu.def Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidclient/eabi/bthidclientu.def Fri Apr 16 15:08:36 2010 +0300 @@ -8,4 +8,5 @@ _ZN12RBTHidClient7ConnectEv @ 7 NONAME _ZNK12RBTHidClient19CancelConnectDeviceEv @ 8 NONAME _ZNK12RBTHidClient24CancelNotifyStatusChangeEv @ 9 NONAME + _ZNK12RBTHidClient7VersionEv @ 10 NONAME diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidclient/inc/bthidclient.h --- a/bluetoothengine/bthid/bthidclient/inc/bthidclient.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidclient/inc/bthidclient.h Fri Apr 16 15:08:36 2010 +0300 @@ -31,6 +31,7 @@ enum TBTHidConnState { EBTDeviceConnected, /*!< Device connected */ + EBTDeviceConnectedFromRemote, /*!< Device connected from remote HID device */ EBTDeviceLinkLost, /*!< Device link lost */ EBTDeviceLinkRestored, /*!< Device link restored */ EBTDeviceDisconnected, /*!< Device disconnected */ diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidclient/src/bthidclient.cpp --- a/bluetoothengine/bthid/bthidclient/src/bthidclient.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidclient/src/bthidclient.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -57,7 +57,7 @@ // Defines server version number // --------------------------------------------------------- // -TVersion RBTHidClient::Version() const +EXPORT_C TVersion RBTHidClient::Version() const { return (TVersion(KBTHIDServMajorVersionNumber, KBTHIDServMinorVersionNumber, KBTHIDServBuildVersionNumber)); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp --- a/bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidengplugin/src/bthidengplugin.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -137,7 +137,8 @@ THIDStateUpdate& HIDStateUpdate = iHIDStateUpdatePckg(); if (HIDStateUpdate.iState == EBTDeviceConnected - || HIDStateUpdate.iState == EBTDeviceLinkRestored) + || HIDStateUpdate.iState == EBTDeviceLinkRestored + || HIDStateUpdate.iState == EBTDeviceConnectedFromRemote) { retStatus = ETrue; ReportProfileConnectionEvents(HIDStateUpdate.iDeviceAddress, diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h --- a/bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidserver/inc/btconnectionobserver.h Fri Apr 16 15:08:36 2010 +0300 @@ -56,6 +56,19 @@ @param aStatus KErrNone, or system error code. */ virtual void FirstTimeConnectionComplete(TInt aConnID, TInt aStatus) = 0; + + /*! + Report a change in the connection status + @param aConnID connection id + @param aStatus KErrNone, or system error code. + */ + virtual void FirstTimeConnectionCompleteFromRemote(TInt aConnID, TInt aStatus) = 0; + + /*! + Start SDP on remote HID device + @param aConnID connection id + */ + virtual void StartSDPSearch(TInt aConnID) = 0; /*! Reports that a connection has entered the link loss state diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidserver/inc/bthidconnection.h --- a/bluetoothengine/bthid/bthidserver/inc/bthidconnection.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidconnection.h Fri Apr 16 15:08:36 2010 +0300 @@ -57,7 +57,8 @@ EHostReconnecting, /*!< Host is reconnecting to the device */ EHIDReconnecting, /*!< The device is reconnection to the host */ EDisconnecting, /*!< The connection is being closed */ - EConnecting + EConnecting, /*!< The connection is being set up from phone side */ + EHIDInitConnecting /*!< The connection is being set up from remote HID */ }; /*! diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidserver/inc/bthidserver.h --- a/bluetoothengine/bthid/bthidserver/inc/bthidserver.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidserver/inc/bthidserver.h Fri Apr 16 15:08:36 2010 +0300 @@ -37,12 +37,15 @@ #include "genericserver.h" #include "hidlayoutids.h" #include "genericactive.h" +#include "hidsdpobserver.h" +#include "bthidconnection.h" class CBTConnection; class CSocketListener; class CBTHidConnection; class CBTHidDevice; class CGenericHid; +class CHidSdpClient; class CBTHidNotifierHelper; /** @@ -53,7 +56,8 @@ class CBTHidServer : public CGenericServer, public MBTConnectionObserver, public MListenerObserver, - public MTransportLayer + public MTransportLayer, + public MHidSdpObserver { public: @@ -117,7 +121,7 @@ Asks the server to create a new connection object. @result ID for the connection */ - TInt NewConnectionL(); + TInt NewConnectionL(TBTConnectionState aConnectionState); /*! Asks the server to do a first-time connection to a device. @@ -151,7 +155,15 @@ @result TBTEngConnectionStatus */ TBTEngConnectionStatus ConnectStatus(const TBTDevAddr& aAddress); - + + /*! + Finds out the connection status for a given Bluetooth address connected with HID profile + @param aBDAddr reference to TBTAddr that is checked from Bluetooth registry + @result ETrue device is found from Container + EFalse device is not found from Container + */ + TBool DeviceExistInContainer(const TBTDevAddr& aAddress); + /*! Panic the server. @param aPanic panic code @@ -177,6 +189,8 @@ void HandleInterruptData(TInt aConnID, const TDesC8& aBuffer); void FirstTimeConnectionComplete(TInt aConnID, TInt aStatus); + + void FirstTimeConnectionCompleteFromRemote(TInt aConnID, TInt aStatus); void LinkLost(TInt aConnID); @@ -185,10 +199,17 @@ void Disconnected(TInt aConnID); void Unplugged(TInt aConnID); + + void StartSDPSearch(TInt aConnID); public: //from MListenerObserver void SocketAccepted(TUint aPort, TInt aErrorCode); + +public: + // from MHidSdpObserver + + void HidSdpSearchComplete(TInt aResult); public: //from MTransportLayer @@ -363,7 +384,12 @@ RNotifier iNotifier; RPointerArray iReqs; - + + /*! The ID given to this connection */ + TInt iConnID; + + /*! A hid sdp client */ + CHidSdpClient* iHidSdpClient; }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp --- a/bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidserver/src/bthidconnection.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -103,7 +103,9 @@ { // We shouldn't be trying to set the id for this connection // after it is connected. - __ASSERT_DEBUG(iConnectionState == ENotConnected || iConnectionState == EConnecting, + __ASSERT_DEBUG(iConnectionState == ENotConnected || + iConnectionState == EConnecting || + iConnectionState == EHIDInitConnecting , User::Panic(KPanicBTConnection, ESocketsBadState)); iConnID = aConnID; @@ -214,7 +216,7 @@ (_L("[BTHID]\tCBTHidConnection::OfferControlSocket")); if (aAddress == iDevice->iAddress) { - __ASSERT_DEBUG((iConnectionState == ELinkLost) || + __ASSERT_DEBUG((iConnectionState == ELinkLost) || (iConnectionState == EHIDInitConnecting) || (iConnectionState == EHIDReconnecting), User::Panic(KPanicBTConnection, ESocketsBadState)); @@ -223,8 +225,11 @@ iControlSocket = aSocket; aSocket = 0; - // Mark that the HID Device is reconnecting to us. - ChangeState(EHIDReconnecting); + // Mark that the HID Device is reconnecting to us. Skip the state change if an initial connection from HID device. + if (iConnectionState != EHIDInitConnecting) + { + ChangeState(EHIDReconnecting); + } } } @@ -236,7 +241,7 @@ if (aAddress == iDevice->iAddress) { - __ASSERT_DEBUG((iConnectionState == EHIDReconnecting), //||(iConnectionState == ELinkLost) , + __ASSERT_DEBUG((iConnectionState == EHIDReconnecting) ||(iConnectionState == EHIDInitConnecting) , User::Panic(KPanicBTConnection, ESocketsBadState)); // Take ownership of this socket @@ -248,18 +253,35 @@ if (KErrNone == error) { // Mark that we are now reconnected. - + TBTConnectionState prevState = iConnectionState; ChangeState(EConnected); - // Inform the observer that the connection has been restored. - iObserver.LinkRestored(iConnID); - + if (prevState == EHIDInitConnecting) + { + // If this was an remote HID initial connection, start the SDP Search. + iObserver.StartSDPSearch(iConnID); + } + else + { + // Inform the observer that the connection has been restored. + iObserver.LinkRestored(iConnID); + } } else { // Close the sockets as they can't be used CloseChannels(); - ChangeState(ELinkLost); + + if (iConnectionState == EHIDInitConnecting) + { + ChangeState(ENotConnected); + // If this was an remote HID initial connection inform the observer + iObserver.FirstTimeConnectionCompleteFromRemote(iConnID, error); + } + else + { + ChangeState(ELinkLost); + } } } } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidserver/src/bthidserver.cpp --- a/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidserver/src/bthidserver.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -38,6 +38,7 @@ #include "hidgeneric.h" #include "hidlayoutids.h" #include "bthidPsKey.h" +#include "hidsdpclient.h" #ifndef DBG @@ -98,6 +99,8 @@ delete iGenHID; + delete iHidSdpClient; + RProperty::Delete( KPSUidBthidSrv, KBTMouseCursorState ); } @@ -241,8 +244,11 @@ const CBTHidDevice& aDeviceDetails, TBTHidConnState aState) { TRACE_INFO( (_L("[BTHID]\tCBTHidServer::InformClientsOfStatusChange, state=%d"),aState) ); - if (aState == EBTDeviceConnected || aState == EBTDeviceLinkRestored - || aState == EBTDeviceLinkLost || aState == EBTDeviceDisconnected) + if (aState == EBTDeviceConnected || + aState == EBTDeviceLinkRestored || + aState == EBTDeviceLinkLost || + aState == EBTDeviceDisconnected || + aState == EBTDeviceConnectedFromRemote) { iLastUsedAddr = aDeviceDetails.iAddress; iActiveState = ETrue; @@ -286,6 +292,7 @@ switch (aState) { case EBTDeviceLinkRestored: + case EBTDeviceConnectedFromRemote: { HandleAsyncRequest(aDeviceAddr, EBTConnected); break; @@ -484,10 +491,11 @@ foundItem = ETrue; TBTConnectionState HidConnectionStatus = connection->ConnectStatus(); - if (EFirstConnection == HidConnectionStatus || EConnecting - == HidConnectionStatus || EHIDReconnecting - == HidConnectionStatus || EHostReconnecting - == HidConnectionStatus) + if ( (EFirstConnection == HidConnectionStatus) || + (EConnecting == HidConnectionStatus) || + (EHIDReconnecting == HidConnectionStatus) || + (EHostReconnecting == HidConnectionStatus) || + (EHIDInitConnecting == HidConnectionStatus) ) { retVal = EBTEngConnecting; } @@ -504,6 +512,33 @@ return retVal; } +TBool CBTHidServer::DeviceExistInContainer(const TBTDevAddr& aAddress) + { + TInt i = 0; + TBool foundItem = EFalse; + TInt BTConnectionObjCount = iBTConnContainer->Count(); + + TRACE_INFO(_L("[BTHID]\tCBTHidServer::DeviceExistInContainer()")); + while ((i < BTConnectionObjCount) && (!foundItem)) + { + CBTHidConnection *connection = + static_cast ((*iBTConnContainer)[i]); + + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + if (devDetails.iAddress == aAddress) + { + foundItem = ETrue; + } + } + i++; + } + + return foundItem; + } + TBool CBTHidServer::GetConnectionAddress(TDes8& aAddressBuf) { TInt i = 0; @@ -549,8 +584,9 @@ CBTHidDevice& devDetails = connection->DeviceDetails(); TBTConnectionState HidConnectionStatus = connection->ConnectStatus(); - if (connection->IsConnected() || HidConnectionStatus - == EHIDReconnecting) + if (connection->IsConnected() || + HidConnectionStatus == EHIDReconnecting || + HidConnectionStatus == EHIDInitConnecting) { if ((IsKeyboard(aDeviceSubClass) && IsKeyboard( devDetails.iDeviceSubClass)) || (IsPointer( @@ -597,7 +633,7 @@ TInt BTConnectionObjCount = iBTConnContainer->Count(); TUint deviceSubClass = GetDeviceSubClass(aDevAddr); - TRACE_INFO(_L("[BTHID]\tCBTHidServer::IsAllowToConnectFromClientSide()")); + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::IsAllowToConnectFromClientSide() BTConnectionObjCount = %d"), BTConnectionObjCount) ); while ((i < BTConnectionObjCount) && retVal) { CBTHidConnection *connection = @@ -608,16 +644,18 @@ CBTHidDevice& devDetails = connection->DeviceDetails(); TBTConnectionState HidConnectionStatus = connection->ConnectStatus(); - if (connection->IsConnected() || HidConnectionStatus - == EConnecting) + if (connection->IsConnected() || + HidConnectionStatus == EConnecting || + HidConnectionStatus == EHIDInitConnecting) { if (devDetails.iAddress != aDevAddr) - { + { if ((IsKeyboard(deviceSubClass) && IsKeyboard( devDetails.iDeviceSubClass)) || (IsPointer( deviceSubClass) && IsPointer( devDetails.iDeviceSubClass))) { + TRACE_INFO(_L("[BTHID]\tCBTHidServer::() NO connection allowed, connection exist already!")); retVal = EFalse; iConflictAddr = devDetails.iAddress; } @@ -699,11 +737,14 @@ return; } -TInt CBTHidServer::NewConnectionL() +TInt CBTHidServer::NewConnectionL(TBTConnectionState aConnectionStatus) { TRACE_INFO(_L("[BTHID]\tCBTHidServer::NewConnectionL")); + __ASSERT_DEBUG( aConnectionStatus == EConnecting || aConnectionStatus == EHIDInitConnecting , + CBTHidServer::PanicServer(EBadState)); + CBTHidConnection *connection = CBTHidConnection::NewLC(iSocketServ, - *this, EConnecting); + *this, aConnectionStatus); // Add to the connection container object. iBTConnContainer->AddL(connection); CleanupStack::Pop(); // connection @@ -1012,6 +1053,132 @@ } } +void CBTHidServer::FirstTimeConnectionCompleteFromRemote(TInt aConnID, TInt aStatus) + { + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::FirstTimeConnectionCompleteFromRemote(%d)"), aStatus)); + TInt error = aStatus; + + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(aConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + if (error == KErrNone) + { + TBool genHidConnected = EFalse; + + TRAP( error, + // Inform the Generic HID of the Connection + GenericHIDConnectL(connection, ETrue); + + // Record that we got as far as informing the Generic HID. + genHidConnected = ETrue; + + // Try to start monitoring the channels. + connection->StartMonitoringChannelsL(); + ) + + if (error != KErrNone) + { + // If we informed the Generic HID of the connection, then + // we must also disconnect. + if (genHidConnected) + { + iGenHID->Disconnected(aConnID); + } + + // Delete the connection object. + //Quietly refuse the remote initialized connection in case of error. + //No need to bother user. + iBTConnIndex->Remove(aConnID); + } + else + { + // Update the stored devices, as we could have power off + // and no clean shutdown. + // Use the non-leaving version. + CleanOldConnection(aConnID); + StoreVirtuallyCabledDevices(KFileStore); + InformClientsOfStatusChange(connection->DeviceDetails(), + EBTDeviceConnectedFromRemote); + } + } + else + { + //Quietly refuse the remote initialized connection in case of error. + //No need to bother user. + iBTConnIndex->Remove(aConnID); + } + } + +void CBTHidServer::StartSDPSearch(TInt aConnID) + { + iConnID = aConnID; + TRACE_INFO( (_L("[BTHID]\tCBTHidServer::StartSDPSearch aConnID= (%d)"), aConnID)); + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(iConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + + TRAPD( res, + // Retrieve the hid device object for this new connection + CBTHidDevice &devDetails = + ConnectionDetailsL(iConnID); + + // Create a new HID Sdp Client + // Its only used here so it doesn't matter if we leave. + delete iHidSdpClient; + iHidSdpClient = 0; + //Create a new hid sdp client using the hid device object. + iHidSdpClient = CHidSdpClient::NewL(devDetails, *this); + + // Start the hid sdp client + iHidSdpClient->StartL(); + ) + + if (res != KErrNone) + { + // Get the server to delete the new connection object + DeleteNewConnection(iConnID); + } + } + +void CBTHidServer::HidSdpSearchComplete(TInt aResult) + { + TRACE_FUNC(_L("[BTHID]\tCBTHidServer::HidSdpSearchComplete")); + // This is a callback from the Hid SDP client so we can't delete it here + // Get it to destroy itself when its convenient. + iHidSdpClient->Kill(); + // Deleted outside destructor. + iHidSdpClient = 0; + + // If the SDP search was a success + if (aResult == KErrNone) + { + // Try to connect to the device as a HID + CBTHidConnection* connection = + static_cast (iBTConnIndex->At(iConnID)); + __ASSERT_ALWAYS(connection, PanicServer(EInvalidHandle)); + if (connection) + { + CBTHidDevice& devDetails = connection->DeviceDetails(); + + //Only after SDP search complete, do we know the CoD which is needed + //to tell if the incoming connection is allowed or not. + //ETrue , establish the connection. + //EFalse, refuse the remote connecion sliently + if (IsAllowToConnectFromClientSide(devDetails.iAddress)) + { + FirstTimeConnectionCompleteFromRemote(iConnID, aResult); + } + else + { + FirstTimeConnectionCompleteFromRemote(iConnID, KErrAlreadyExists); + } + } + + } + } + + void CBTHidServer::LinkLost(TInt aConnID) { TRACE_INFO( (_L("[BTHID]\tCBTHidServer::LinkLost(%d)"), aConnID)); @@ -1126,9 +1293,10 @@ else { TInt i = 0; - TInt count = iBTConnContainer->Count(); + TInt err = KErrNone; + TInt connectingID = 0; // Check which port has accepted a connection switch (aPort) { @@ -1137,8 +1305,32 @@ // Get the BT address of the device that has connected iTempControl->RemoteName(sockAddr); devAddr = sockAddr.BTAddr(); + // incoming HID connection is allowed + if (!DeviceExistInContainer(devAddr)) + { + TRAPD( res, + // to be created as New if device not yet listed in container + connectingID = NewConnectionL(EHIDInitConnecting); + + // Retrieve the hid device object for this new connection + CBTHidDevice &devDetails = + ConnectionDetailsL(connectingID); + + // Fill in the information we got from the client + devDetails.iAddress = devAddr; + devDetails.iUseSecurity = ETrue; + ) + + if (res != KErrNone && connectingID != 0) + { + // Get the server to delete the new connection object + DeleteNewConnection(connectingID); + } + } + if (IsAllowToConnectFromClientSide(devAddr)) { + TInt count = iBTConnContainer->Count(); while ((i < count) && (iTempControl)) { CBTHidConnection @@ -1184,7 +1376,7 @@ TRACE_INFO(_L("[BTHID]\tCBTHidServer::SocketAccepted, control channel failed, shutdown listener")); ShutdownListeners(err); } - + break; // The HID Interrupt Channel @@ -1194,6 +1386,7 @@ devAddr = sockAddr.BTAddr(); if (IsAllowToConnectFromClientSide(devAddr)) { + TInt count = iBTConnContainer->Count(); while ((i < count) && (iTempInterrupt)) { CBTHidConnection diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/bthidserver/src/bthidsession.cpp --- a/bluetoothengine/bthid/bthidserver/src/bthidsession.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/bthidserver/src/bthidsession.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -19,6 +19,7 @@ #include #include #include "bthidsession.h" +#include "bthidconnection.h" #include "bthidserver.h" #include "bthidclientsrv.h" #include "hidsdpclient.h" @@ -193,10 +194,10 @@ TPckg addrPack(addr); iConnectionMessage.ReadL(0, addrPack); + // Ask the server to create a new connection object - - - iConnectingID = iServer.NewConnectionL(); + iConnectingID = iServer.NewConnectionL(EConnecting); + TRAPD( res, // Retrieve the hid device object for this new connection CBTHidDevice &devDetails = diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor_reg.rss --- a/bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor_reg.rss Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/data/paintcursor_reg.rss Fri Apr 16 15:08:36 2010 +0300 @@ -25,9 +25,8 @@ RESOURCE APP_REGISTRATION_INFO { app_file = "paintcursor"; - localisable_resource_file = APP_RESOURCE_DIR"\\paintcursor"; - localisable_resource_id = R_PAINTCURSOR_LOCALISABLE_APP_INFO; -// hidden = KAppIsHidden; + hidden = KAppIsHidden; + launch = KAppLaunchInForeground; } // End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappui.h --- a/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappui.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappui.h Fri Apr 16 15:08:36 2010 +0300 @@ -77,6 +77,8 @@ void SendToBackground(); void EndTask(); + + void HandleForegroundEventL(TBool aForeground); private: CPaintCursorAppView* iAppView; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h --- a/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Fri Apr 16 15:08:36 2010 +0300 @@ -33,7 +33,8 @@ /*! An instance of the CPaintCursorAppView View object for PaintCursor application */ -class CPaintCursorAppView : public CCoeControl +class CPaintCursorAppView : public CCoeControl, public MCoeControlObserver + { public: @@ -55,17 +56,28 @@ Destroy the object and release all memory objects */ ~CPaintCursorAppView(); + + void HideCursor(); + void ShowCursor(); + public: // from CCoeControl void SizeChanged(); void Draw(const TRect& aRect) const; + +public: + /** + * From MCoeControlObserver, HandleControlEventL. + */ + // event handling section + // e.g Listbox events + void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ); - void HideCursor(); + void HandleResourceChange( TInt aType ); - void ShowCursor(); private: /*! diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursordocument.h --- a/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursordocument.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursordocument.h Fri Apr 16 15:08:36 2010 +0300 @@ -20,6 +20,7 @@ #define PaintCursorDOCUMENT_H #include +#include class CEikAppUi; @@ -54,6 +55,8 @@ * From CEikDocument, create CPaintCursorAppUi "App UI" object. */ CEikAppUi* CreateAppUiL(); + + void UpdateTaskNameL(CApaWindowGroupName* aWgName); }; #endif diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp --- a/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -20,6 +20,7 @@ #include #include #include +#include #include "paintcursorapp.h" #include "paintcursorappui.h" @@ -131,6 +132,7 @@ case ECursorHide: { iAppView->HideCursor(); + EndTask(); break; } case ECursorNotInitialized: @@ -159,3 +161,26 @@ task.EndTask(); } +void CPaintCursorAppUi::HandleForegroundEventL(TBool aForeground) + { + if(aForeground) + { + TInt wgId = iEikonEnv->RootWin().Identifier(); + + TApaTask self( iCoeEnv->WsSession() ); + + self.SetWgId( wgId ); + self.SendToBackground(); + + RWsSession session = iEikonEnv->WsSession(); + + CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(session, wgId); + + wgName->SetHidden(ETrue); + + wgName->SetWindowGroupName(iEikonEnv->RootWin()); + + CleanupStack::PopAndDestroy(); // wgName + } + } + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp --- a/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -15,7 +15,7 @@ * */ - +#include #include "paintcursorappview.h" #include "pointmsgqueue.h" #include "debug.h" @@ -155,3 +155,25 @@ iMouseInitialized = ETrue; } +void CPaintCursorAppView::HandleResourceChange( TInt aType ) + { + CCoeControl::HandleResourceChange( aType ); + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); + SetRect( mainPaneRect ); + DrawNow(); + if (iMouseInitialized) + { + iClientCommander.ImageCommand( KRedrawBTCursorAnim ); + } + } + } + +void CPaintCursorAppView::HandleControlEventL( + CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/ ) + { + } + + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/PaintCursor/src/paintcursordocument.cpp --- a/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursordocument.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursordocument.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -15,7 +15,7 @@ * */ - +#include #include "paintcursordocument.h" #include "paintcursorappui.h" @@ -45,3 +45,9 @@ return new (ELeave) CPaintCursorAppUi; } +void CPaintCursorDocument::UpdateTaskNameL(CApaWindowGroupName* aWgName) + { + aWgName->SetHidden(ETrue); + } + + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_client/data/Thumbs.db Binary file bluetoothengine/bthid/mouse/Sesame_client/data/Thumbs.db has changed diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp Binary file bluetoothengine/bthid/mouse/Sesame_client/data/cursormask.bmp has changed diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h --- a/bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h Fri Apr 16 15:08:36 2010 +0300 @@ -39,7 +39,8 @@ KStartBTCursorAnim = 1, KStopBTCursorAnim = 2, KChangeCursor = 3, - KSendRawEvent = 4 + KSendRawEvent = 4, + KRedrawBTCursorAnim = 5 }; class TPointBuffer diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp --- a/bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -175,6 +175,11 @@ { // Could optionally decode the commands here DBG(RDebug::Print(_L("RImageCommander::ImageCommand %d"), aCommand)); + if ( aCommand == KRedrawBTCursorAnim ) + { + //reset the current location to avoid sudden jumping + iCurrentPoint.SetXY(0,0); + } RAnim::Command( aCommand ); @@ -230,7 +235,6 @@ return KErrNone; } - TBool RImageCommander::RestrictPos() { TBool notInScreen(EFalse); @@ -242,6 +246,12 @@ TInt mode(screen->CurrentScreenMode()); screen->GetScreenModeSizeAndRotation(mode, sizeAndRotation); } + + DBG( + RDebug::Print(_L("RImageCommander::RestrictPos sizeAndRotation.iPixelSize (%d,%d)"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight); + RDebug::Print(_L("RImageCommander::RestrictPos sizeAndRotation.iRotation (%d)"), sizeAndRotation.iRotation); + ) + TRect validRect(sizeAndRotation.iPixelSize); if (! validRect.Contains(iCurrentPoint)) { @@ -268,7 +278,11 @@ DBG( if (outSide) { - RDebug::Print(_L("RImageCommander::CheckCurrentPoint not in screen (%d,%d)"), pos.iX, pos.iY); + RDebug::Print(_L("RImageCommander::CheckCurrentPoint NOT in screen (%d,%d)"), pos.iX, pos.iY); + } + else + { + RDebug::Print(_L("RImageCommander::CheckCurrentPoint DOES in screen (%d,%d)"), pos.iX, pos.iY); } ) return outSide; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_server/bwins/btcursor_serveru.def --- a/bluetoothengine/bthid/mouse/Sesame_server/bwins/btcursor_serveru.def Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -EXPORTS - ?CreateCAnimDllL@@YAPAVCAnimDll@@XZ @ 1 NONAME ; class CAnimDll * CreateCAnimDllL(void) - ?CreateInstanceL@CMouseCursorSrv@@UAEPAVCAnim@@H@Z @ 2 NONAME ; class CAnim * CMouseCursorSrv::CreateInstanceL(int) - diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_server/eabi/btcursor_serveru.def --- a/bluetoothengine/bthid/mouse/Sesame_server/eabi/btcursor_serveru.def Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -EXPORTS - _Z15CreateCAnimDllLv @ 1 NONAME - _ZTI15CMouseCursorSrv @ 2 NONAME ; ## - _ZTI6CImage @ 3 NONAME ; ## - _ZTV15CMouseCursorSrv @ 4 NONAME ; ## - _ZTV6CImage @ 5 NONAME ; ## - diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp --- a/bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/Sesame_server/group/animation_server.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -21,13 +21,11 @@ TARGETTYPE ani // The second one is the UID of the server, different than main program's UID -UID 0x10003b22 0x2001FE5A +UID 0x10003B22 0x2001FE5A CAPABILITY CAP_CLIENT_DLL VENDORID VID_DEFAULT -DEFFILE btcursor_server.def - SECUREID 0xA000022E EPOCSTACKSIZE 0x5000 diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorsrv.h --- a/bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorsrv.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorsrv.h Fri Apr 16 15:08:36 2010 +0300 @@ -49,9 +49,15 @@ * Create an instance of the Animation Server image aType. * @param aType KAnimationSquare implies "construct a bouncing square" */ - IMPORT_C CAnim* CreateInstanceL(TInt aType); + CAnim* CreateInstanceL(TInt aType); }; +/** + * Entry point function to Create the animation plugin + * Returns the object of the CMouseCursorSrv class + */ +IMPORT_C CAnimDll* CreateCAnimDllL(); + #endif // __MOUSECURSORSRV_H__ // End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp --- a/bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -189,6 +189,18 @@ iSpriteFunctions->Activate(EFalse); } break; + + case KRedrawBTCursorAnim: + { + iSpriteFunctions->Activate(EFalse); + iSpriteGc->Reset(); + iSpriteFunctions->SetPosition(TPoint()); + iSpriteFunctions->SizeChangedL(); + iSpriteFunctions->Activate(ETrue); + DrawCursor(); + } + break; + case KChangeCursor: { TPoint pos = *(TPoint *)aArgs; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF --- a/bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/BWINS/BTMonoCmdHandlerU.DEF Fri Apr 16 15:08:36 2010 +0300 @@ -1,10 +1,10 @@ EXPORTS - ??1CBtmcHandlerApi@@UAE@XZ @ 1 NONAME ; CBtmcHandlerApi::~CBtmcHandlerApi(void) + ?NewL@CBtmcHandlerApi@@SAPAV1@AAVMBtmcObserver@@W4TBtmcProfileId@@ABVTDesC8@@H@Z @ 1 NONAME ; class CBtmcHandlerApi * CBtmcHandlerApi::NewL(class MBtmcObserver &, enum TBtmcProfileId, class TDesC8 const &, int) ?HandleNrecCompletedL@CBtmcHandlerApi@@QAEXH@Z @ 2 NONAME ; void CBtmcHandlerApi::HandleNrecCompletedL(int) - ?HandleProtocolDataL@CBtmcHandlerApi@@QAEXABVTDesC8@@@Z @ 3 NONAME ; void CBtmcHandlerApi::HandleProtocolDataL(class TDesC8 const &) - ?NewL@CBtmcHandlerApi@@SAPAV1@AAVMBtmcObserver@@W4TBtmcProfileId@@ABVTDesC8@@H@Z @ 4 NONAME ; class CBtmcHandlerApi * CBtmcHandlerApi::NewL(class MBtmcObserver &, enum TBtmcProfileId, class TDesC8 const &, int) - ?ActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 5 NONAME ; void CBtmcHandlerApi::ActivateRemoteVolumeControl(void) - ?DeActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 6 NONAME ; void CBtmcHandlerApi::DeActivateRemoteVolumeControl(void) - ?GetRemoteSupportedFeature@CBtmcHandlerApi@@QAEHXZ @ 7 NONAME ; int CBtmcHandlerApi::GetRemoteSupportedFeature(void) - ?SetHspRvcSupported@CBtmcHandlerApi@@QAEXH@Z @ 8 NONAME ; void CBtmcHandlerApi::SetHspRvcSupported(int) + ?ActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 3 NONAME ; void CBtmcHandlerApi::ActivateRemoteVolumeControl(void) + ?GetRemoteSupportedFeature@CBtmcHandlerApi@@QAEHXZ @ 4 NONAME ; int CBtmcHandlerApi::GetRemoteSupportedFeature(void) + ?SetHspRvcSupported@CBtmcHandlerApi@@QAEXH@Z @ 5 NONAME ; void CBtmcHandlerApi::SetHspRvcSupported(int) + ?HandleProtocolDataL@CBtmcHandlerApi@@QAEXABVTDesC8@@@Z @ 6 NONAME ; void CBtmcHandlerApi::HandleProtocolDataL(class TDesC8 const &) + ?DeActivateRemoteVolumeControl@CBtmcHandlerApi@@QAEXXZ @ 7 NONAME ; void CBtmcHandlerApi::DeActivateRemoteVolumeControl(void) + ??1CBtmcHandlerApi@@UAE@XZ @ 8 NONAME ; CBtmcHandlerApi::~CBtmcHandlerApi(void) diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF --- a/bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/eabi/BTMonoCmdHandleru.DEF Fri Apr 16 15:08:36 2010 +0300 @@ -1,12 +1,12 @@ EXPORTS - _ZN15CBtmcHandlerApi19HandleProtocolDataLERK6TDesC8 @ 1 NONAME - _ZN15CBtmcHandlerApi20HandleNrecCompletedLEi @ 2 NONAME - _ZN15CBtmcHandlerApi4NewLER13MBtmcObserver14TBtmcProfileIdRK6TDesC8i @ 3 NONAME - _ZN15CBtmcHandlerApiD0Ev @ 4 NONAME - _ZN15CBtmcHandlerApiD1Ev @ 5 NONAME - _ZN15CBtmcHandlerApiD2Ev @ 6 NONAME - _ZN15CBtmcHandlerApi27ActivateRemoteVolumeControlEv @ 7 NONAME - _ZN15CBtmcHandlerApi29DeActivateRemoteVolumeControlEv @ 8 NONAME - _ZN15CBtmcHandlerApi25GetRemoteSupportedFeatureEv @ 9 NONAME - _ZN15CBtmcHandlerApi18SetHspRvcSupportedEi @ 10 NONAME + _ZN15CBtmcHandlerApi18SetHspRvcSupportedEi @ 1 NONAME + _ZN15CBtmcHandlerApi19HandleProtocolDataLERK6TDesC8 @ 2 NONAME + _ZN15CBtmcHandlerApi20HandleNrecCompletedLEi @ 3 NONAME + _ZN15CBtmcHandlerApi25GetRemoteSupportedFeatureEv @ 4 NONAME + _ZN15CBtmcHandlerApi27ActivateRemoteVolumeControlEv @ 5 NONAME + _ZN15CBtmcHandlerApi29DeActivateRemoteVolumeControlEv @ 6 NONAME + _ZN15CBtmcHandlerApi4NewLER13MBtmcObserver14TBtmcProfileIdRK6TDesC8i @ 7 NONAME + _ZN15CBtmcHandlerApiD0Ev @ 8 NONAME + _ZN15CBtmcHandlerApiD1Ev @ 9 NONAME + _ZN15CBtmcHandlerApiD2Ev @ 10 NONAME diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/group/BTMonoCmdHandler.mmp --- a/bluetoothengine/btmac/group/BTMonoCmdHandler.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/group/BTMonoCmdHandler.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -57,7 +57,9 @@ USERINCLUDE ../../inc USERINCLUDE ../../../inc +#ifdef NO101APPDEPFIXES APP_LAYER_SYSTEMINCLUDE +#endif //NO101APPDEPFIXES MW_LAYER_SYSTEMINCLUDE LIBRARY euser.lib diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/inc/btmonocmdhandler/btmc_defs.h --- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmc_defs.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmc_defs.h Fri Apr 16 15:08:36 2010 +0300 @@ -35,6 +35,16 @@ EBTMonoVoiceRecognitionDeactivatedByRemote, }; +#ifndef NO101APPDEPFIXES +// Local definition of application-layer PubSub key +// (TSINDKeys::ERecognitionState, in KSINDUID = KUidSystemCategoryValue): +const TInt KBTMonoVoiceRecognitionStateKey = 0; + +// Local definition of application-layer key value +// (TRecognitionStateValues::ERecognitionStarted): +const TInt KBTMonoVoiceRecognitionStarted = 0; +#endif //NO101APPDEPFIXES + enum TBTMonoATPhoneIndicatorId { EBTMonoATNetworkIndicator = 1, diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h --- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcnumber.h Fri Apr 16 15:08:36 2010 +0300 @@ -34,6 +34,18 @@ { public: + /** CBtmcNumber states. + */ + enum BtmcNumberState + { + /** Not valid */ + EStateNull = 0, + /** Getting the MSISDN - getting store info*/ + EStateGettingMsisdnStoreInfo = 1, + /** Getting the MSISDN - getting store entry*/ + EStateGettingMsisdnStoreEntry = 2, + }; + /** * Two-phased constructor. */ @@ -76,6 +88,14 @@ TInt aServiceId); void ConstructL(); + /** + * Gets MSISDN store info to check how many numbers are stored on SIM + */ + void GetMsisdnStoreInfo(); + /** + * Gets single MSISDN store entry + */ + void GetMsisdnStoreEntry(); private: CBtmcProtocol& iProtocol; @@ -84,7 +104,21 @@ RMobileONStore iStore; RMobileONStore::TMobileONEntryV1 iEntry; RMobileONStore::TMobileONEntryV1Pckg iPckg; + RMobileONStore::TMobileONStoreInfoV1Pckg iOnStoreInfoPckg; + RMobileONStore::TMobileONStoreInfoV1 iOnStoreInfo; + /** + * Defines current CBtmcNumber state + */ + BtmcNumberState iState; + /** + * Index which is used to get MSISDN entries + */ + TInt iUsedEntriesCount; + /** + * Count of correct numbers returned by MSISDN + */ + TInt iCorrectNumbersCount; }; -#endif \ No newline at end of file +#endif diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/inc/btmonocmdhandler/btmcoperator.h --- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcoperator.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcoperator.h Fri Apr 16 15:08:36 2010 +0300 @@ -86,7 +86,6 @@ CBtmcProtocol& iProtocol; RTelServer iServer; RMobilePhone iPhone; - RMobileONStore iStore; RMmCustomAPI iCustomApi; RMmCustomAPI::TOperatorNameInfo iInfo; }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/inc/btmonocmdhandler/btmcphonestatus.h --- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcphonestatus.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcphonestatus.h Fri Apr 16 15:08:36 2010 +0300 @@ -82,8 +82,6 @@ TInt GetRssiStrength(); - TInt GetVolumeStatus(); - TInt GetBatteryCharge(); void SetRecognitionInitiator(TBTMonoVoiceRecognitionInitiator aInitiator); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocol.h --- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocol.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcprotocol.h Fri Apr 16 15:08:36 2010 +0300 @@ -164,7 +164,6 @@ TBool iHandleCmdPending; CDesC8ArrayFlat* iOutgoPacketQueue; // owned TInt iCredit; // How many commands are allowed to acc - TBool iVolumeSyncFromAccessory; TBool iAccessoryInitiated; // who initiated the connection RMobilePhone::TMobilePhoneIdentityV1 iIdentity; // holds IMEI etc RMobilePhone::TMobilePhoneSubscriberId iId; // holds id diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/inc/btmonocmdhandler/btmcvolume.h --- a/bluetoothengine/btmac/inc/btmonocmdhandler/btmcvolume.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/inc/btmonocmdhandler/btmcvolume.h Fri Apr 16 15:08:36 2010 +0300 @@ -88,6 +88,8 @@ TInt GetNewPhoneVol(); + TBool IsActiveRemoteVolumeControl(); + private: enum TVolSyncAction { @@ -109,8 +111,6 @@ TInt iMaxSpkrVol; // Maximum volume level of the phone TInt iStep; TVolSyncAction iAction; - - TBool iVolCtrlActivated; }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallstatus.cpp --- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallstatus.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmccallstatus.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -620,6 +620,14 @@ void CBtmcCallStatus::ReportCallEventL(TInt aPrevStatus, TInt aNewStatus, TBool /*aOutgoing*/) { TRACE_FUNC_ENTRY + if ( iProtocol.ProtocolStatus().iProfile == EBtmcHSP) + { + // HSP 1.2 requires either RING indicator or in-band ringing + // tone, but not both. + TRACE_INFO((_L(" HSP connection, no call indicator"))) + return; + } + // CCWA if (iProtocol.ProtocolStatus().iCallWaitingNotif == EBTMonoATCallWaitingNotifEnabled && (!(aPrevStatus & KCallRingingBit) && (aNewStatus & KCallRingingBit)) && diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp --- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcnumber.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -57,10 +57,33 @@ void CBtmcNumber::GoActive() { TRACE_ASSERT(!IsActive(), KErrGeneral); - iEntry.iIndex = 1; + GetMsisdnStoreInfo(); + TRACE_FUNC + } + +// ------------------------------------------------------------------------------- +// CBtmcNumber::GetMsisdnStoreInfo +// ------------------------------------------------------------------------------- +void CBtmcNumber::GetMsisdnStoreInfo() + { + TRACE_FUNC_ENTRY + iState = EStateGettingMsisdnStoreInfo; + iStore.GetInfo(iStatus, iOnStoreInfoPckg); + SetActive(); + TRACE_FUNC_EXIT + } + +// ------------------------------------------------------------------------------- +// CBtmcNumber::GetMsisdnStoreEntry +// ------------------------------------------------------------------------------- +void CBtmcNumber::GetMsisdnStoreEntry() + { + TRACE_FUNC_ENTRY + iState = EStateGettingMsisdnStoreEntry; + iEntry.iIndex = iUsedEntriesCount++; iStore.Read(iStatus, iPckg); SetActive(); - TRACE_FUNC + TRACE_FUNC_EXIT } // ------------------------------------------------------------------------------- @@ -70,56 +93,104 @@ { TRACE_FUNC_ENTRY - RATResultPtrArray resarr; - ATObjArrayCleanupResetAndDestroyPushL(resarr); - CATResult* okerr = NULL; - if (iStatus == KErrNone) + switch (iState) { - TBuf8 nameBuf; - nameBuf.Copy(iEntry.iNumber.iTelNumber); - - TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &nameBuf)) - RATParamArray params; - CleanupClosePushL(params); - LEAVE_IF_ERROR(params.Append(TATParam())) - LEAVE_IF_ERROR(params.Append(TATParam(nameBuf, EATDQStringParam))) - - TBTMonoATPhoneNumberType numType; - if (nameBuf.Length() == 0) + case EStateGettingMsisdnStoreEntry: { - numType = EBTMonoATPhoneNumberUnavailable; - } - else if(nameBuf.Locate('+') == 0) - { - numType = EBTMonoATPhoneNumberInternational; + if (iStatus == KErrNone) + { + if(iEntry.iNumber.iTelNumber.Length() == 0) + { + GetMsisdnStoreEntry(); + break; + } + + iCorrectNumbersCount++; + + RATResultPtrArray resarr; + ATObjArrayCleanupResetAndDestroyPushL(resarr); + + TBuf8 telnumberBuf; + telnumberBuf.Copy(iEntry.iNumber.iTelNumber); + + TRACE_INFO((_L8("ao status %d, phonebook returned %S"), iStatus.Int(), &telnumberBuf)) + RATParamArray params; + CleanupClosePushL(params); + LEAVE_IF_ERROR(params.Append(TATParam())) + LEAVE_IF_ERROR(params.Append(TATParam(telnumberBuf, EATDQStringParam))) + + TBTMonoATPhoneNumberType numType; + if(telnumberBuf.Locate('+') == 0) + { + numType = EBTMonoATPhoneNumberInternational; + } + else + { + numType = EBTMonoATPhoneNumberNational; + } + LEAVE_IF_ERROR(params.Append(TATParam(numType))) + LEAVE_IF_ERROR(params.Append(TATParam())) + LEAVE_IF_ERROR(params.Append(TATParam(4))) + CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, ¶ms); + CleanupStack::PushL(code); + resarr.AppendL(code); + CleanupStack::Pop(code); + CleanupStack::PopAndDestroy(¶ms); + + if(iCorrectNumbersCount == iOnStoreInfo.iUsedEntries) + { + CATResult* okerr = CATResult::NewL(EATOK); + CleanupStack::PushL(okerr); + resarr.AppendL(okerr); + CleanupStack::Pop(okerr); + iProtocol.SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + Observer().RequestCompletedL(*this, iStatus.Int()); + } + else + { + iProtocol.SendResponseL(resarr); + CleanupStack::PopAndDestroy(&resarr); + GetMsisdnStoreEntry(); + } + } + else + { + CATResult* okerr = CATResult::NewL(EATERROR); + CleanupStack::PushL(okerr); + iProtocol.SendResponseL(*okerr); + CleanupStack::PopAndDestroy(okerr); + Observer().RequestCompletedL(*this, iStatus.Int()); + } + + break; } - else + case EStateGettingMsisdnStoreInfo: { - numType = EBTMonoATPhoneNumberNational; + if(iStatus==KErrNone && iOnStoreInfo.iUsedEntries>0 && + (iOnStoreInfo.iCaps & RMobilePhoneStore::KCapsIndividualEntry)) + { + GetMsisdnStoreEntry(); + } + else + { + CATResult* okerr = CATResult::NewL(EATOK); + CleanupStack::PushL(okerr); + iProtocol.SendResponseL(*okerr); + CleanupStack::PopAndDestroy(okerr); + Observer().RequestCompletedL(*this, iStatus.Int()); + } + break; } - LEAVE_IF_ERROR(params.Append(TATParam(numType))) - LEAVE_IF_ERROR(params.Append(TATParam())) - LEAVE_IF_ERROR(params.Append(TATParam(4))) - CATResult* code = CATResult::NewL(EATCNUM, EATActionResult, ¶ms); - CleanupStack::PushL(code); - resarr.AppendL(code); - CleanupStack::Pop(code); - CleanupStack::PopAndDestroy(¶ms); - okerr = CATResult::NewL(EATOK); + + default: + break; } - else - { - okerr = CATResult::NewL(EATERROR); - } - CleanupStack::PushL(okerr); - resarr.AppendL(okerr); - CleanupStack::Pop(okerr); - iProtocol.SendResponseL(resarr); - CleanupStack::PopAndDestroy(&resarr); - Observer().RequestCompletedL(*this, iStatus.Int()); + TRACE_FUNC_EXIT } + // ------------------------------------------------------------------------------- // CBtmcNumber::DoCancel // ------------------------------------------------------------------------------- @@ -147,7 +218,8 @@ CBtmcProtocol& aProtocol, CActive::TPriority aPriority, TInt aServiceId) - : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry) + : CBtmcActive(aObserver, aPriority, aServiceId), iProtocol(aProtocol), iPckg(iEntry), + iOnStoreInfoPckg(iOnStoreInfo), iState(EStateNull), iUsedEntriesCount(1), iCorrectNumbersCount(0) { } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcoperator.cpp --- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcoperator.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcoperator.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -122,7 +122,6 @@ void CBtmcOperator::DoCancel() { TRACE_FUNC - iStore.CancelAsyncRequest(EMobilePhoneStoreRead); } // ------------------------------------------------------------------------------- diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcphonestatus.cpp --- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcphonestatus.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcphonestatus.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -19,7 +19,9 @@ // INCLUDE FILES #include "btmcphonestatus.h" +#ifdef NO101APPDEPFIXES #include +#endif //NO101APPDEPFIXES #include #include "atcodec.h" #include "btmcprotocol.h" @@ -100,7 +102,11 @@ if (aEnabled && !iVoiceRecognitionEnabled) { // AO for Voice Dial +#ifdef NO101APPDEPFIXES LEAVE_IF_ERROR(iVoiceDialProperty.Attach(KSINDUID, ERecognitionState)) +#else //NO101APPDEPFIXES + LEAVE_IF_ERROR(iVoiceDialProperty.Attach(KUidSystemCategory, KBTMonoVoiceRecognitionStateKey)) +#endif //NO101APPDEPFIXES CBtmcActive* ao = CBtmcActive::NewLC(*this, CActive::EPriorityStandard, KVoiceDialSubscribe); iActives.AppendL(ao); iVoiceDialProperty.Subscribe(ao->iStatus); @@ -207,7 +213,11 @@ TRACE_INFO((_L("Voice dial Initiator %d, Voice dial event %d"), iVoiceRecogInitiator, aEnabled)) TBTMonoATVoiceRecognition value = EBTMonoATVoiceRecognitionOff; +#ifdef NO101APPDEPFIXES if (iVoiceRecogInitiator != EBTMonoVoiceRecognitionActivatedByRemote && aEnabled == ERecognitionStarted) +#else //NO101APPDEPFIXES + if (iVoiceRecogInitiator != EBTMonoVoiceRecognitionActivatedByRemote && aEnabled == KBTMonoVoiceRecognitionStarted) +#endif //NO101APPDEPFIXES {// phone activated or headset deactivated voice recognition, informs headset status change value = EBTMonoATVoiceRecognitionOn; } @@ -302,14 +312,6 @@ } } -TInt CBtmcPhoneStatus::GetVolumeStatus() - { - if(iVol) - return iVol->GetVolume(); - else - return 0; - } - // ----------------------------------------------------------------------------- // CBtmcPhoneStatus::CBtmcPhoneStatus // ----------------------------------------------------------------------------- diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp --- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcprotocol.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -389,7 +389,6 @@ { iCallStatus->ReportCallStatusL(); } - iVolumeSyncFromAccessory = EFalse; TRACE_FUNC_EXIT } @@ -938,12 +937,15 @@ LEAVE_IF_ERROR(aCmd.Parameter(0, param)) TInt value; LEAVE_IF_ERROR(param.Int(value)) - if (!iPhoneStatus) + // In HFP, AT+VGS is not valid before service level connection + // has established. + // In HSP, AT+VGS is allowed at any time. + if (!iPhoneStatus && iProtocolStatus->iProfile == EBtmcHSP ) { iPhoneStatus = CBtmcPhoneStatus::NewL(*this, iPhone, iProtocolStatus->iProfile); iPhoneStatus->SetVolumeControlFeatureL(ETrue); } - if(iVolumeSyncFromAccessory) + if(iPhoneStatus) { iPhoneStatus->SetSpeakerVolumeL(value); } @@ -1025,37 +1027,9 @@ CleanupStack::Pop(ok); SendResponseL(resarr); CleanupStack::PopAndDestroy(&resarr); - - // solution to volume sync - phone will always send its volume status back to accessory - - if( (aCmd.Id() == EATVGS) && (iVolumeSyncFromAccessory == EFalse) ) - { - iVolumeSyncFromAccessory = ETrue; - TInt vol(KErrNotFound); - - if(iPhoneStatus) - { - vol = iPhoneStatus->GetVolumeStatus(); - } - - if(vol > KErrNotFound) // volume exists - { - TATParam param = TATParam(); - LEAVE_IF_ERROR(aCmd.Parameter(0, param)) - TInt value; - LEAVE_IF_ERROR(param.Int(value)) - if(value != vol) - { - CATResult* event = CATResult::NewLC(EATVGS, EATUnsolicitedResult, vol); - SendUnsoltResultL(*event); - CleanupStack::PopAndDestroy(event); - } - } - } CmdHandlingCompletedL(); } - // ----------------------------------------------------------------------------- // CBtmcProtocol::HandleActionCommandL // diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp --- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -60,11 +60,13 @@ void CBtmcVolume::SetSpeakerVolumeL(TInt aHfVol) { TRACE_FUNC - TRACE_INFO((_L("phone vol %d, acc vol %d"), iPhnSpkrVol, iAccSpkrVol)) + TRACE_INFO((_L("current vols phone %d, acc %d"), iPhnSpkrVol, iAccSpkrVol)) + // Store the new volume setting of headset regardless of + // whether volume control is active or not currently iAccSpkrVol = HfToPhoneVolScale(aHfVol); - if (iVolCtrlActivated) + TRACE_INFO((_L("new acc vol %d"), iAccSpkrVol)) + if ( IsActiveRemoteVolumeControl() ) { - TRACE_INFO((_L("to new vol %d"), iAccSpkrVol)) TInt vol = GetNewPhoneVol(); if (vol != KNoAudioStreaming) { @@ -73,10 +75,6 @@ DoSetSpeakerVolL( prevPhVol ); } } - else - { - TRACE_INFO((_L("volume control inactive!"))) - } } void CBtmcVolume::SetMicrophoneVolumeL(TInt /*aHfVol*/) @@ -86,13 +84,11 @@ void CBtmcVolume::ActivateRemoteVolumeControl() { - if (!iVolCtrlActivated) + TRACE_FUNC + if (!IsActiveRemoteVolumeControl() ) { - TRACE_FUNC iVolLevelProperty.Subscribe(iActive->iStatus); iActive->GoActive(); - - iVolCtrlActivated = ETrue; TInt vol = GetNewPhoneVol(); TRACE_INFO((_L("current phone vol %d, acc vol %d"), vol, iAccSpkrVol)) if (vol != KNoAudioStreaming) @@ -109,11 +105,7 @@ void CBtmcVolume::DeActivateRemoteVolumeControl() { - if (iVolCtrlActivated) - { - iVolCtrlActivated = EFalse; - iActive->Cancel(); - } + iActive->Cancel(); TRACE_FUNC } @@ -211,11 +203,15 @@ diff1 = Abs( aPrevPhVol - iAccSpkrVol ); diff2 = Abs( iPhnSpkrVol - iAccSpkrVol ); - if( diff2 >= diff1 ) + if (diff2 > diff1) { // the previous phone volume is closer to current headset volume setting volClick = ( aPrevPhVol < iPhnSpkrVol ) ? KPSVolumeDownClicked : KPSVolumeUpClicked; } + else if ( (diff2 == diff1) && (diff1 !=0) ) + { + volClick = ( aPrevPhVol < iPhnSpkrVol ) ? KPSVolumeDownClicked : KPSVolumeUpClicked; + } // otherwise we have roughly synchronized vol in both ends. } else if( iAccSpkrVol != iPhnSpkrVol ) @@ -242,21 +238,15 @@ volClick = (iAccSpkrVol > iPhnSpkrVol) ? KPSVolumeUpClicked : KPSVolumeDownClicked; } } - + TInt err( KErrNotFound ); if( volClick ) { - iAction = ESpeakerVolSet; - TInt err = iVolKeyEventProperty.Set( volClick ); - if( err ) - { - iAction = ESpeakerVolSubscribe; - TRACE_ERROR((_L("Set KMediaKeysVolumeKeyEvent err %d"), err)); - } + err = iVolKeyEventProperty.Set( volClick ); + TRACE_INFO((_L("Set KMediaKeysVolumeKeyEvent click %d err %d"), volClick, err)); } - else - { - iAction = ESpeakerVolSubscribe; - } + + iAction = err ? ESpeakerVolSubscribe : ESpeakerVolSet; + TRACE_FUNC_EXIT } @@ -313,4 +303,9 @@ return iPhnSpkrVol; } +TBool CBtmcVolume::IsActiveRemoteVolumeControl() + { + return iActive->IsActive(); + } + // End of file diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp --- a/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -229,16 +229,20 @@ { TRACE_FUNC_ENTRY TRACE_INFO((_L("err %d"), aErr)) - + + if (aErr == KErrNone) + { + TBTSockAddr sockAddr; + iDataSocket->RemoteName(sockAddr); + iRemote = sockAddr.BTAddr(); + } + // Process the connect complete before issuing a receive request to ensure that // we are ready to process the data when it is received. iObserver->RfcommConnectCompletedL(aErr); - if (!aErr) + if (aErr == KErrNone) { - TBTSockAddr sockAddr; - iDataSocket->RemoteName(sockAddr); - iRemote = sockAddr.BTAddr(); iInData.ReAllocL(256); RequestMasterRole(); TInt err = iAda.Open(iServer, iRemote); @@ -256,17 +260,20 @@ { TRACE_FUNC_ENTRY - iRemoteHasConnected = ETrue; + if (aErr == KErrNone) + { + iRemoteHasConnected = ETrue; + TBTSockAddr sockAddr; + iDataSocket->RemoteName(sockAddr); + iRemote = sockAddr.BTAddr(); + } // Process the accept complete before issuing a receive request to ensure that // we are ready to process the data when it is received. iObserver->RfcommAcceptCompletedL(aErr, iService); - if (!aErr) + if (aErr == KErrNone) { - TBTSockAddr sockAddr; - iDataSocket->RemoteName(sockAddr); - iRemote = sockAddr.BTAddr(); iInData.ReAllocL(256); RequestMasterRole(); TInt err = iAda.Open(iServer, iRemote); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp --- a/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/ecom/BtnotifWrapper.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -27,6 +27,10 @@ #endif #include // notifier id for power mode setting +// @todo remove this declaration once both stack and UI layers are in codeline +const TUid KBTUserConfirmationNotifierUidCopyForWrapper={0x2002E224}; + + const TInt KMaxSynchReplyBufLength = 256; //what should be? const TUid KBTInquiryChannel = {0x00000601}; // Channel for inquiry notifier @@ -45,6 +49,7 @@ const TInt KBTGenericQueryNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; const TInt KBTNumericComparisonPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP const TInt KBTPasskeyEntryNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP +const TInt KBTUserConfirmationNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; // for SSP const TInt KBTPairedDeviceSettingPriority = MEikSrvNotifierBase2::ENotifierPriorityVHigh; const TInt KBTEnterpriseItSecurityInfoNotifierPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; @@ -78,64 +83,109 @@ KBTInquiryPriority, _L("BTNotif.dll"), KMaxSynchReplyBufLength); - + + CleanupStack::PushL( master ); subjects->AppendL( master ); - - // Notifiers using masters session - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTManAuthNotifierUid, - KBTAuthorisationChannel, - KBTAuthorisationPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTPinCodeEntryNotifierUid, - KBTAuthenticationChannel, - KBTAuthenticationPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTObexPasskeyQueryNotifierUid, - KBTObexPINChannel, - KBTObexPinPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KPowerModeSettingNotifierUid, - KBTPowerModeChannel, - KBTPowerModePriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTGenericInfoNotifierUid, - KBTGenericInfoNotifierUid, - KBTGenericInfoNotifierPriority)); + CleanupStack::Pop( master ); + + // Notifiers using masters session + CAknNotifierWrapperLight* notif = NULL; + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTManAuthNotifierUid, + KBTAuthorisationChannel, + KBTAuthorisationPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTPinCodeEntryNotifierUid, + KBTAuthenticationChannel, + KBTAuthenticationPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTObexPasskeyQueryNotifierUid, + KBTObexPINChannel, + KBTObexPinPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KPowerModeSettingNotifierUid, + KBTPowerModeChannel, + KBTPowerModePriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTGenericInfoNotifierUid, + KBTGenericInfoNotifierUid, + KBTGenericInfoNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTGenericQueryNotifierUid, - KBTGenericQueryNotifierUid, - KBTGenericQueryNotifierPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KPbapAuthNotifierUid, - KBTObexPINChannel, - KBTObexPinPriority)); - - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTPairedDeviceSettingNotifierUid, - KBTPairedDeviceSettingChannel, - KBTPairedDeviceSettingPriority)); + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTGenericQueryNotifierUid, + KBTGenericQueryNotifierUid, + KBTGenericQueryNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KPbapAuthNotifierUid, + KBTObexPINChannel, + KBTObexPinPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTPairedDeviceSettingNotifierUid, + KBTPairedDeviceSettingChannel, + KBTPairedDeviceSettingPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTNumericComparisonNotifierUid, - KBTNumericComparisonNotifierUid, - KBTNumericComparisonPriority)); + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTNumericComparisonNotifierUid, + KBTNumericComparisonNotifierUid, + KBTNumericComparisonPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTPasskeyDisplayNotifierUid, + KBTPasskeyDisplayNotifierUid, + KBTPasskeyEntryNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); + + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTUserConfirmationNotifierUidCopyForWrapper, + KBTUserConfirmationNotifierUidCopyForWrapper, + KBTUserConfirmationNotifierPriority); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTPasskeyDisplayNotifierUid, - KBTPasskeyDisplayNotifierUid, - KBTPasskeyEntryNotifierPriority)); + notif = new (ELeave) CAknNotifierWrapperLight(*master, + KBTEnterpriseItSecurityInfoNotifierUid, + KBTEnterpriseItSecurityInfoNotifierUid, + KBTEnterpriseItSecurityInfoNotifierPriority); - subjects->AppendL(new (ELeave) CAknNotifierWrapperLight(*master, - KBTEnterpriseItSecurityInfoNotifierUid, - KBTEnterpriseItSecurityInfoNotifierUid, - KBTEnterpriseItSecurityInfoNotifierPriority)); + CleanupStack::PushL( notif ); + subjects->AppendL( notif ); + CleanupStack::Pop( notif ); CleanupStack::Pop(); // array cleanup return(subjects); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/group/BTNotif.mmp --- a/bluetoothengine/btnotif/group/BTNotif.mmp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/group/BTNotif.mmp Fri Apr 16 15:08:36 2010 +0300 @@ -40,6 +40,7 @@ SOURCE btnpaireddevsettnotifier.cpp SOURCE btnssppasskeyentrynotifier.cpp SOURCE btnumcmpnotifier.cpp +SOURCE btuserconfnotifier.cpp SOURCE btnotifuiutil.cpp SOURCE btnotifactive.cpp SOURCE btnpairnotifier.cpp diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/group/bld.inf --- a/bluetoothengine/btnotif/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -33,7 +33,10 @@ OPTION TARGETFILE btnotif.mif OPTION HEADERFILE btnotif.mbg OPTION SOURCES -c8,8 qgn_note_bt_popup -c8,8 qgn_note_bt_popup_2 \ - -c8,8 qgn_note_bt_popup_3 -c8,8 qgn_indi_bt_blocked + -c8,8 qgn_note_bt_popup_3 -c8,8 qgn_indi_bt_blocked \ + -c8,8 qgn_indi_bt_signal_good_add \ + -c8,8 qgn_indi_bt_signal_low_add \ + -c8,8 qgn_indi_bt_signal_med_add END PRJ_MMPFILES diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h --- a/bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/BTNGenericInfoNotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -80,7 +80,7 @@ * @param aBuffer A package buffer containing received parameters. * @return None. */ - void ProcessParamBufferL(const TDesC8& aBuffer); + void ProcessParamBufferL(const TDesC8& aBuffer, TBool aSyncCall); /** * C++ default constructor. @@ -90,10 +90,10 @@ /** * Show Information note and complete message. */ - void ShowNoteAndCompleteL(); + void ShowNoteAndCompleteL(TBool aSyncCall); private: - HBufC* iQueryMessage; + RBuf iQueryMessage; TInt iMessageResourceId; TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand; }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h --- a/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -95,14 +95,14 @@ private: - HBufC* iQueryMessage; - HBufC* iQueryHeader; + RBuf iQueryMessage; + HBufC* iQueryHeader; HBufC* iName; TInt iMessageResourceId; TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand; TBool iIsMessageQuery; - TBool iIsNameQuery; + TBool iIsNameQuery; }; #endif diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnotifier.h --- a/bluetoothengine/btnotif/inc/btnotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -293,8 +293,12 @@ TBTDevAddr iBTAddr; // Gotten from PckBuffer, constant no matter how iDevice changes. CBTNotifUIUtil* iNotifUiUtil; // Utility to show UI notes & queries CBTEngSettings* iBTEngSettings; + TBool iIsCoverUI; + private: CBTEngDevMan* iDevMan; // for BT registry manipulation + + }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnotifuiutil.h --- a/bluetoothengine/btnotif/inc/btnotifuiutil.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnotifuiutil.h Fri Apr 16 15:08:36 2010 +0300 @@ -21,7 +21,7 @@ #include #include #include -#include +#include // CONSTANTS // Literals for resource and bitmap files ( drive, directory, filename(s) ) diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h --- a/bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnpaireddevsettnotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -83,11 +83,6 @@ private: /** - * Leave function called by non-leave btengdevman callback function HandleGetDevicesComplete(). - *@param aErr. Passed by caller. - */ - - /** * Parse the data out of the message that is sent by the client of the notifier. * @param aBuffer A package buffer containing received parameters. * @return None. diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnpairnotifier.h --- a/bluetoothengine/btnotif/inc/btnpairnotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnpairnotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -84,8 +84,9 @@ /** * Generate prompt based on subclass's own needs. + * @param aRBuf the descriptor to which the prompt will be loaded. */ - virtual HBufC* GenerateQueryPromoptLC(); + virtual void GenerateQueryPromptL( RBuf& aRBuf ); private: /** diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnpinnotifier.h --- a/bluetoothengine/btnotif/inc/btnpinnotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnpinnotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -72,8 +72,9 @@ /** * From CBTNPairNotifierBase * Generate prompt in Pin query dialog. + * @param aRBuf the descriptor to which the prompt will be loaded. */ - HBufC* GenerateQueryPromoptLC(); + void GenerateQueryPromptL(RBuf& aRBuf); private: diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h --- a/bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnssppasskeyentrynotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -77,10 +77,9 @@ /** * Generate prompt for passkey entry query. - * @param None. - * @return None. + * @param aRBuf the descriptor to which the prompt will be loaded. */ - HBufC* GenerateQueryPromoptLC(); + void GenerateQueryPromptL( RBuf& aRBuf ); private: diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btnumcmpnotifier.h --- a/bluetoothengine/btnotif/inc/btnumcmpnotifier.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/inc/btnumcmpnotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -75,10 +75,9 @@ /** * From CBTNPairNotifierBase - * @param None. - * @return None. + * @param aRBuf the descriptor to which the prompt will be loaded. */ - HBufC* GenerateQueryPromoptLC(); + void GenerateQueryPromptL( RBuf& aRBuf ); private: diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/inc/btuserconfnotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/inc/btuserconfnotifier.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2010 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: Declares User confirmation notifier for Secure Simle Pairing +* +*/ + + +#ifndef BTUSERCONFNOTIFIER_H +#define BTUSERCONFNOTIFIER_H + +// INCLUDES + +#include "btnpairnotifier.h" // Base class + +// These declarations are here temporarily so the submission of the notifiers and the stack do not have to be synchronised. +// Should be removed once all submissions are in. + +const TUid KBTUserConfirmationNotifierUidCopy={0x2002E224}; + +NONSHARABLE_CLASS(TBTNotifierParams2Copy) + { +public: + inline TBTDevAddr DeviceAddress() const { return iBDAddr; }; + inline TPtrC DeviceName() const { return iName; }; +private: + TBTDevAddr iBDAddr; + TBTDeviceName iName; + + // This data padding has been added to help prevent future binary compatibility breaks + // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used + TUint32 iPadding1; + TUint32 iPadding2; + }; + +NONSHARABLE_CLASS(TBTUserConfirmationParamsCopy) + : public TBTNotifierParams2Copy + { +public: + inline TBool LocallyInitiated() const { return iLocallyInitiated; }; +private: + TBool iLocallyInitiated; + + // This data padding has been added to help prevent future binary compatibility breaks + // Neither iPadding1 nor iPadding2 have been zero'd because they are currently not used + TUint32 iPadding1; + TUint32 iPadding2; + }; + +typedef TPckgBuf TBTUserConfirmationParamsPckgCopy; + +// CLASS DECLARATION +/** +* This class is used to ask user to compare passcode in two devices. +*/ + + +NONSHARABLE_CLASS(CBTUserConfNotifier): public CBTNPairNotifierBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CBTUserConfNotifier* NewL(); // Constructor (public) + + /** + * Destructor. + */ + virtual ~CBTUserConfNotifier(); // Destructor + + private: + /** + * From CBTNotifierBase Called when a notifier is first loaded + * to allow any initial construction that is required. + * @param None. + * @return A structure containing priority and channel info. + */ + TNotifierInfo RegisterL(); + + + /** + * From CBTNotifierBase Used in asynchronous notifier launch to + * store received parameters into members variables and + * make needed initializations. + * @param aBuffer A buffer containing received parameters + * @param aReturnVal The return value to be passed back. + * @param aMessage Should be completed when the notifier is deactivated. + * @return None. + */ + void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage); // Get input parameters + + /** + * From CBTNotifierBase + * Show notes to ask user response and return to Notifier caller by completing message. + */ + void HandleGetDeviceCompletedL(const CBTDevice* aDev); + + private: + + /** + * C++ default constructor. + */ + CBTUserConfNotifier(); // Default constructor + }; + +#endif + +// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNAuthNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -17,7 +17,6 @@ // INCLUDE FILES -#include // Localisation stringloader #include // Own resources #include "btnauthnotifier.h" // Own class definition #include "btNotifDebug.h" // Debugging macros @@ -39,6 +38,7 @@ #include #include // The bt hrh info is needed, for help launching #endif +#include #include "btnotifnameutils.h" @@ -120,30 +120,31 @@ { User::Leave(KErrInUse); } - else if ( AutoLockOnL() ) + + iMessage = aMessage; + iReplySlot = aReplySlot; + + if ( AutoLockOnL() ) { // The phone is locked, access denied. // Write results back to caller and complete message. - CompleteMessage(EFalse, KErrNone); + CompleteMessage(EFalse, KErrNone); return; } - TBTAuthorisationParams param; - TPckgC pckg(param); - pckg.Set(aBuffer); + TBTAuthorisationParams param; + TPckgC pckg(param); + pckg.Set(aBuffer); - iServiceUid = pckg().iUid.iUid; // Pick up service uid from message - iBTAddr = pckg().iBDAddr; - if ( OtherOutgoPairing( iBTAddr ) ) + iServiceUid = pckg().iUid.iUid; // Pick up service uid from message + iBTAddr = pckg().iBDAddr; + if ( OtherOutgoPairing( iBTAddr ) ) { // We won't allow connection request from another device during outgoing pairing: FLOG(_L("[BTNOTIF]\t CBTAuthNotifier: outgoing pair in progress, reject request from other device")); CompleteMessage(KErrCancel); return; - } - - iMessage = aMessage; - iReplySlot = aReplySlot; + } // create iDevice so that the name won't be lost if the device does // not exist in registry. @@ -201,9 +202,12 @@ if ( !iDevice->IsValidFriendlyName() && iDevice->IsValidDeviceName()) { // Create new prompt string with new device name - HBufC* stringholder = StringLoader::LoadL( iStrResourceId, BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())); - CleanupStack::PushL( stringholder ); - iNotifUiUtil->UpdateQueryDlgL( *stringholder ); + RBuf stringholder; + CleanupClosePushL( stringholder ); + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, iStrResourceId, + BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()), 0 ); + iNotifUiUtil->UpdateQueryDlgL( stringholder ); iNotifUiUtil->UpdateCoverUiL( iDevice->DeviceName() ); CleanupStack::PopAndDestroy(); // stringholder } @@ -500,8 +504,11 @@ TBTDeviceName tempDeviceName; BtNotifNameUtils::GetDeviceDisplayName(tempDeviceName, iDevice); - HBufC* stringholder = StringLoader::LoadLC( iStrResourceId, tempDeviceName); - TInt keypress = iNotifUiUtil->ShowQueryL( *stringholder, R_BT_AUTHORISATION_QUERY, + RBuf stringholder; + CleanupClosePushL( stringholder ); + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, iStrResourceId, tempDeviceName, 0); + TInt keypress = iNotifUiUtil->ShowQueryL( stringholder, R_BT_AUTHORISATION_QUERY, iCoverUiDlgId, tempDeviceName, CAknQueryDialog::EConfirmationTone ); CleanupStack::PopAndDestroy(); // stringholder // If this notifier is cancelled by the caller, no need to perform the rest operation: diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -24,6 +24,7 @@ #include "btNotifDebug.h" // Debugging macros #include #include +#include #include "btnotifnameutils.h" // ================= MEMBER FUNCTIONS ======================= @@ -59,7 +60,7 @@ CBTGenericInfoNotifier::~CBTGenericInfoNotifier() { Cancel(); // Free own resources - delete iQueryMessage; + iQueryMessage.Close(); } // ---------------------------------------------------------- @@ -84,10 +85,13 @@ TPtrC8 CBTGenericInfoNotifier::StartL( const TDesC8& aBuffer ) { FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL()")); - ProcessParamBufferL(aBuffer); + if( !iNotifUiUtil ) + { + iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); + } + ProcessParamBufferL(aBuffer, ETrue); + FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL() completed")); - FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::StartL() completed")); - TPtrC8 ret(KNullDesC8); return (ret); } @@ -108,7 +112,7 @@ return; } iMessage = aMessage; - ProcessParamBufferL(aBuffer); + ProcessParamBufferL(aBuffer, EFalse); } // ---------------------------------------------------------- @@ -116,10 +120,10 @@ // Parse the data out of the message that is sent by the // client of the notifier. // ---------------------------------------------------------- -void CBTGenericInfoNotifier::ProcessParamBufferL(const TDesC8& aBuffer) +void CBTGenericInfoNotifier::ProcessParamBufferL(const TDesC8& aBuffer, TBool aSyncCall) { TBTGenericInfoNotifierParams bParams; - TPckgC bPckg(bParams); + TPckgC bPckg(bParams); bPckg.Set( aBuffer ); iSecondaryDisplayCommand = ECmdBTnotifUnavailable; @@ -203,18 +207,25 @@ User::Leave(KErrNotFound); } - // if the logic string contains substitute indicator "%U", replace it with device name: - iQueryMessage = StringLoader::LoadL( iMessageResourceId); - _LIT(PU,"%U"); - if( iQueryMessage->Find(PU) != KErrNotFound) + // if the logic string contains substitute indicator "%U", replace it with device name: + HBufC* buf = StringLoader::LoadL( iMessageResourceId); + iQueryMessage.Assign( buf ); + + TInt keyLen; + TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( + iQueryMessage, 0, keyLen ); + if( pos > KErrNotFound) { iBTAddr = TBTDevAddr( bPckg().iRemoteAddr ); - iDevice = CBTDevice::NewL(iBTAddr); + if( !iDevice ) + { + iDevice = CBTDevice::NewL(iBTAddr); + } GetDeviceFromRegL( iBTAddr ); } else { - ShowNoteAndCompleteL(); + ShowNoteAndCompleteL(aSyncCall); } } @@ -223,10 +234,13 @@ // Shows the notifier in backround // ---------------------------------------------------------- // -void CBTGenericInfoNotifier::ShowNoteAndCompleteL() +void CBTGenericInfoNotifier::ShowNoteAndCompleteL(TBool aSyncCall) { - iNotifUiUtil->ShowInfoNoteL( *iQueryMessage, iSecondaryDisplayCommand ); - CompleteMessage(KErrNone); + iNotifUiUtil->ShowInfoNoteL( iQueryMessage, iSecondaryDisplayCommand ); + if (!aSyncCall) + { + CompleteMessage(KErrNone); + } FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete")); } @@ -234,14 +248,13 @@ { FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()")); - delete iQueryMessage; - iQueryMessage=NULL; - TBTDeviceName name; BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); - iQueryMessage = StringLoader::LoadL( iMessageResourceId, name); + iQueryMessage.Zero(); + BluetoothUiUtil::LoadResourceAndSubstringL( + iQueryMessage, iMessageResourceId, name, 0); - ShowNoteAndCompleteL(); + ShowNoteAndCompleteL(EFalse); FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete")); } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -23,6 +23,7 @@ #include #include // Own resources #include +#include #include "BTNGenericQueryNotifier.h" // Own class definition #include "btNotifDebug.h" // Debugging macros @@ -65,7 +66,7 @@ { Cancel(); // Free own resources delete iName; - delete iQueryMessage; + iQueryMessage.Close(); delete iQueryHeader; } @@ -226,14 +227,15 @@ } // if the logic string contains substitute indicator "%U", replace it with device name: - // - iQueryMessage = StringLoader::LoadL( iMessageResourceId); - _LIT(PU,"%U"); - if( iQueryMessage->Find(PU) != KErrNotFound) + // + HBufC* buf = StringLoader::LoadL( iMessageResourceId); + iQueryMessage.Assign( buf ); + + TInt keyLen; + TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( + iQueryMessage, 0, keyLen ); + if( pos > KErrNotFound) { - delete iQueryMessage; - iQueryMessage=NULL; - //if no device name provided, default name will be used: if( !bPckg().iNameExists ) iName=StringLoader::LoadL(R_BT_DIALOG_DEF_NAME); @@ -242,7 +244,8 @@ iName=HBufC::NewL(bPckg().iName.Length() ); iName->Des().Copy(bPckg().iName); } - iQueryMessage = StringLoader::LoadL( iMessageResourceId,*iName); + BluetoothUiUtil::LoadResourceAndSubstringL( + iQueryMessage, iMessageResourceId, *iName, 0); } else { @@ -258,18 +261,16 @@ TPtrC8 CBTGenericQueryNotifier::UpdateL(const TDesC8& aBuffer) { FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL")); - delete iQueryMessage; - iQueryMessage = NULL; ProcessParamBufferL(aBuffer); if( !iNotifUiUtil->IsQueryReleased() ) { if(iIsMessageQuery ) { - iNotifUiUtil->UpdateMessageQueryDlgL(*iQueryMessage); + iNotifUiUtil->UpdateMessageQueryDlgL(iQueryMessage); } else { - iNotifUiUtil->UpdateQueryDlgL(*iQueryMessage); + iNotifUiUtil->UpdateQueryDlgL(iQueryMessage); } } FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete")); @@ -325,12 +326,12 @@ if( iIsMessageQuery ) { - keypress = iNotifUiUtil->ShowMessageQueryL(*iQueryMessage, *iQueryHeader, + keypress = iNotifUiUtil->ShowMessageQueryL(iQueryMessage, *iQueryHeader, R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); } else { - keypress = iNotifUiUtil->ShowQueryL( *iQueryMessage, R_BT_GENERIC_QUERY, + keypress = iNotifUiUtil->ShowQueryL( iQueryMessage, R_BT_GENERIC_QUERY, iSecondaryDisplayCommand, name, CAknQueryDialog::EConfirmationTone ); } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNInqNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNInqNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNInqNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -59,6 +59,7 @@ { FLOG(_L("[BTNOTIF]\t CBTInqNotifier::~CBTInqNotifier()")); delete iUi; + iUi = NULL; FLOG(_L("[BTNOTIF]\t CBTInqNotifier::~CBTInqNotifier() completed")); } @@ -84,7 +85,7 @@ { FLOG(_L("[BTNOTIF]\t CBTInqNotifier::GetParamsL()")); - if( iUi || iReplySlot!=NULL || !iMessage.IsNull() ) + if( !iMessage.IsNull() ) { aMessage.Complete(KErrInUse); return; @@ -124,6 +125,8 @@ if( iUi ) { iUi->Cancel(); + delete iUi; + iUi = NULL; } CBTNotifierBase::Cancel(); FLOG(_L("[BTNOTIF]\t CBTInqNotifier::Cancel() completed")); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNInqUI.cpp --- a/bluetoothengine/btnotif/src/BTNInqUI.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNInqUI.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -22,7 +22,6 @@ #include #include #include -#include // Localisation stringloader #include // For WLAN state checking #include #include @@ -30,9 +29,9 @@ #include // Own resources #include #include -#include // Borrow WLan signal strenth bar to show RSSI #include #include +#include #include "btninqui.h" // Own class definition #include "btNotifDebug.h" // Debugging macros #include "btnotifnameutils.h" @@ -46,8 +45,7 @@ const TInt KHighStrength = 82; const TUint32 ExcludePairedDeviceMask = 0x800000; const TUint32 ResetExcludePairedDeviceMask = 0xFF7FFFFF; -_LIT(KBtnotifBmpFileName,"btnotif.mbm"); -_LIT(KWLanBmpFileName,"wlanplugin.mif"); +_LIT(KBtnotifBmpFileName,"btnotif.mif"); //mif is target file under resource folder // ================= MEMBER FUNCTIONS ======================= @@ -727,23 +725,18 @@ GetColorIconL( bmpFilename, KAknsIIDQgnIndiBtBlocked, EMbmBtnotifQgn_indi_bt_blocked, EMbmBtnotifQgn_indi_bt_blocked_mask, iconList ); - - bmpFilename.Zero(); - bmpFilename.Append( KFileDrive ); - bmpFilename.Append( KDC_APP_BITMAP_DIR ); - bmpFilename.Append( KWLanBmpFileName ); + + GetColorIconL( bmpFilename, KAknsIIDQgnIndiBtSignalLowAdd, + EMbmBtnotifQgn_indi_bt_signal_low_add, + EMbmBtnotifQgn_indi_bt_signal_low_add_mask, iconList); - GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalLowAdd, - EMbmWlanpluginQgn_indi_wlan_signal_low_add, - EMbmWlanpluginQgn_indi_wlan_signal_low_add_mask, iconList); - - GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalMedAdd, - EMbmWlanpluginQgn_indi_wlan_signal_med_add, - EMbmWlanpluginQgn_indi_wlan_signal_med_add_mask, iconList ); + GetColorIconL( bmpFilename, KAknsIIDQgnIndiBtSignalMedAdd, + EMbmBtnotifQgn_indi_bt_signal_med_add, + EMbmBtnotifQgn_indi_bt_signal_med_add_mask, iconList ); - GetColorIconL( bmpFilename, KAknsIIDQgnIndiWlanSignalGoodAdd, - EMbmWlanpluginQgn_indi_wlan_signal_good_add, - EMbmWlanpluginQgn_indi_wlan_signal_good_add_mask, iconList ); + GetColorIconL( bmpFilename, KAknsIIDQgnIndiBtSignalGoodAdd, + EMbmBtnotifQgn_indi_bt_signal_good_add, + EMbmBtnotifQgn_indi_bt_signal_good_add_mask, iconList ); // Transfer iconlist ownership to the listbox // @@ -1047,21 +1040,14 @@ TInt CBTInqUI::QueryUnblockDeviceL(CBTDevice* aDevice) { FLOG(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL()")); - - HBufC* stringholder = NULL; - - if (aDevice->IsValidFriendlyName()) - { - stringholder = StringLoader::LoadLC(R_BT_UNBLOCK_DEVICE, aDevice->FriendlyName()); - } - else - { - stringholder = StringLoader::LoadLC(R_BT_UNBLOCK_DEVICE, BTDeviceNameConverter::ToUnicodeL(aDevice->DeviceName())); - } - - TBTDeviceName name(KNullDesC); + RBuf stringholder; + stringholder.CleanupClosePushL(); + TBTDeviceName name; + BtNotifNameUtils::GetDeviceDisplayName( name, aDevice ); + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, R_BT_UNBLOCK_DEVICE, name, 0 ); TInt keypress(0); - keypress = iUiUtil->ShowQueryL( *stringholder, R_BT_UNBLOCK_QUERY, + keypress = iUiUtil->ShowQueryL( stringholder, R_BT_UNBLOCK_QUERY, ECmdBTnotifUnavailable, name, CAknQueryDialog::EConfirmationTone ); CleanupStack::PopAndDestroy(); // stringholder FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::QueryUnblockDeviceL() keypress= %d"),keypress)); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNMain.cpp --- a/bluetoothengine/btnotif/src/BTNMain.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNMain.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -32,6 +32,7 @@ #include "btnpaireddevsettnotifier.h" #include "btnssppasskeyentrynotifier.h" #include "btnumcmpnotifier.h" +#include "btuserconfnotifier.h" #include "btnenterpriseitsecurityinfonotifier.h" // CONSTANTS @@ -105,6 +106,12 @@ aNotifiers->AppendL( numCmpNotifier ); CleanupStack::Pop( numCmpNotifier ); + CBTUserConfNotifier* userConfNotifier = CBTUserConfNotifier::NewL(); + CleanupStack::PushL(userConfNotifier); + aNotifiers->AppendL( userConfNotifier ); + CleanupStack::Pop( userConfNotifier ); + + CBTEnterpriseItSecurityInfoNotifier* enterpriseItSecurityNotifier = CBTEnterpriseItSecurityInfoNotifier::NewL(); CleanupStack::PushL(enterpriseItSecurityNotifier); aNotifiers->AppendL(enterpriseItSecurityNotifier); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -84,17 +84,18 @@ { User::Leave(KErrInUse); } - else if ( AutoLockOnL() ) + + iMessage = aMessage; + iReplySlot = aReplySlot; + + if ( AutoLockOnL() ) { // The phone is locked, access denied. // CompleteMessage(KErrCancel); return; } - - iMessage = aMessage; - iReplySlot = aReplySlot; - + ShowNoteCompleteMessageL(); FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::GetParamsL() completed")); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -92,16 +92,17 @@ { User::Leave(KErrInUse); } - else if ( AutoLockOnL() ) + + iMessage = aMessage; + iReplySlot = aReplySlot; + + if ( AutoLockOnL() ) { // The phone is locked, access denied. // CompleteMessage(KErrCancel); return; } - - iMessage = aMessage; - iReplySlot = aReplySlot; ShowNoteCompleteMessageL(); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNPinNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNPinNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNPinNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -24,6 +24,7 @@ #include #include #include // Own resources +#include #include "btnotif.hrh" // Own resource header #include "btnpinnotifier.h" // Own class definition #include "btNotifDebug.h" // Debugging macros @@ -167,11 +168,12 @@ FOREVER { TBuf tempResultBuffer; - - HBufC* prompt = GenerateQueryPromoptLC(); // prompt still in stack. - TInt keypress = iNotifUiUtil->ShowTextInputQueryL(tempResultBuffer, *prompt, R_BT_ENTER_PASSKEY_QUERY, + RBuf prompt; + prompt.CleanupClosePushL(); + GenerateQueryPromptL( prompt ); + TInt keypress = iNotifUiUtil->ShowTextInputQueryL(tempResultBuffer, prompt, R_BT_ENTER_PASSKEY_QUERY, ECmdShowBtOpenCoverNote, CAknQueryDialog::EConfirmationTone ); - CleanupStack::PopAndDestroy( prompt ); + CleanupStack::PopAndDestroy( &prompt ); if( keypress ) // OK pressed { @@ -248,35 +250,32 @@ } // ---------------------------------------------------------- -// CBTPinNotifier::GenerateQueryPromoptLC +// CBTPinNotifier::GenerateQueryPromptL // ---------------------------------------------------------- -HBufC* CBTPinNotifier::GenerateQueryPromoptLC() +void CBTPinNotifier::GenerateQueryPromptL( RBuf& aRBuf ) { - FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromoptLC() >>")); - HBufC* prompt = NULL; - + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromptLC() >>")); TBTDeviceName devName; - BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); + BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); if (iPasskeyLength > 0) //Minimum length passkey is defined { - CDesCArray* stringArray = new ( ELeave ) CDesCArrayFlat( 1 ); - CleanupStack::PushL( stringArray ); - CArrayFix* indexArray = new(ELeave) CArrayFixFlat(1); - CleanupStack::PushL( indexArray ); + BluetoothUiUtil::LoadResourceAndSubstringL( + aRBuf, R_BT_MIN_PASSKEY_PROMPT, devName, 1 ); - stringArray->AppendL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()) ); - indexArray->AppendL( iPasskeyLength); - prompt = StringLoader::LoadL( R_BT_MIN_PASSKEY_PROMPT, *stringArray, *indexArray ); - - CleanupStack::PopAndDestroy( indexArray ); - CleanupStack::PopAndDestroy( stringArray ); - CleanupStack::PushL( prompt ); + RBuf tmpBuf; + tmpBuf.CleanupClosePushL(); + tmpBuf.Swap( aRBuf ); + aRBuf.ReAllocL( aRBuf.MaxLength() + sizeof(TUint)); + aRBuf.Zero(); + // Passkey length should be localized, hope StringLoader can make it: + StringLoader::Format( aRBuf, tmpBuf, 0, iPasskeyLength ); + CleanupStack::PopAndDestroy( &tmpBuf ); } else { - prompt = StringLoader::LoadLC( R_BT_PASSKEY_PROMPT, devName ); + BluetoothUiUtil::LoadResourceAndSubstringL( + aRBuf, R_BT_PASSKEY_PROMPT, devName, 0 ); } - FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromoptLC() <<")); - return prompt; + FLOG(_L("[BTNOTIF]\t CBTPinNotifier::GenerateQueryPromptLC() <<")); } // End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/BTNotifier.cpp --- a/bluetoothengine/btnotif/src/BTNotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/BTNotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -31,7 +31,7 @@ #include // Own resources #include // Feature Manager API #include // CnvUtfConverter - +#include #include "btnotifier.h" // Own class definition #include "btNotifDebug.h" // Debugging macros #include "btnotiflock.h" @@ -85,14 +85,14 @@ { // Sets up TLS, must be done before FeatureManager is used. FeatureManager::InitializeLibL(); - TBool isCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) + iIsCoverUI = ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) ? ETrue : EFalse; // Frees the TLS. Must be done after FeatureManager is used. FeatureManager::UnInitializeLib(); iBTEngSettings = CBTEngSettings::NewL(); iDevMan = CBTEngDevMan::NewL( this ); - iNotifUiUtil = CBTNotifUIUtil::NewL( isCoverUI ); + iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); } // ---------------------------------------------------------- @@ -145,6 +145,11 @@ // void CBTNotifierBase::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) { + if( !iNotifUiUtil ) + { + iNotifUiUtil = CBTNotifUIUtil::NewL( iIsCoverUI ); + } + TRAPD(err, GetParamsL(aBuffer, aReplySlot, aMessage)); if (err) { @@ -423,6 +428,10 @@ TBTRegistrySearch mySearch; mySearch.FindAddress( aAddr ); iDeviceArray = new (ELeave) CBTDeviceArray(1); + if( !iDevMan ) + { + iDevMan = CBTEngDevMan::NewL( this ); + } TInt err = iDevMan->GetDevices( mySearch, iDeviceArray ); if(err) { @@ -449,12 +458,14 @@ TInt resId = IsUserAwarePaired( iDevice->AsNamelessDevice() ) ? R_BT_BLOCK_PAIRED_DEVICE_NOHELP : R_BT_BLOCK_DEVICE_NOHELP; - HBufC* stringHolder = StringLoader::LoadLC( resId, bName ); + RBuf stringholder; + stringholder.CleanupClosePushL(); + BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resId, bName, 0 ); - TInt keypress = iNotifUiUtil->ShowMessageQueryL( *stringHolder, *header, + TInt keypress = iNotifUiUtil->ShowMessageQueryL( stringholder, *header, R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone ); - CleanupStack::PopAndDestroy(stringHolder); + CleanupStack::PopAndDestroy(&stringholder); CleanupStack::PopAndDestroy(header); if( keypress )// user replied "Yes" @@ -479,12 +490,20 @@ iDevice->DeleteLinkKey(); iBTRegistryQueryState = ESetDeviceBlocked; - TInt devManErr = iDevMan->ModifyDevice( *iDevice ); - - // if error, complete message, otherwise waiting for devman callback - // - if(devManErr != KErrNone) - CompleteMessage(devManErr); + TInt err = KErrNone; + if( !iDevMan ) + { + TRAP(err, iDevMan = CBTEngDevMan::NewL( this )); + } + if( !err ) + { + err = iDevMan->ModifyDevice( *iDevice ); + } + if( err ) + { + // if error, complete message, otherwise waiting for devman callback + CompleteMessage(err); + } } void CBTNotifierBase::ChangeAuthorizeState( TBool aTrust ) @@ -496,13 +515,19 @@ iDevice->SetGlobalSecurity(sec); iBTRegistryQueryState = ESetDeviceAuthorizeState; - TInt devManErr = iDevMan->ModifyDevice( *iDevice ); - - // if error, complete message, otherwise waiting for devman callback - // - if(devManErr != KErrNone) + TInt err = KErrNone; + if( !iDevMan ) + { + TRAP(err, iDevMan = CBTEngDevMan::NewL( this )); + } + if( !err ) { - CompleteMessage(devManErr); + err = iDevMan->ModifyDevice( *iDevice ); + } + if( err ) + { + // if error, complete message, otherwise waiting for devman callback + CompleteMessage(err); TBTNotifLockPublish::DeleteNotifLocks( EBTNotiferLockPairedDeviceSetting, iDevice->BDAddr() ); } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp --- a/bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/btnenterpriseitsecurityinfonotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -18,7 +18,7 @@ // INCLUDE FILES #include // Own resources #include "btnenterpriseitsecurityinfonotifier.h" // Own class definition -#include "BTNotifDebug.h" // Debugging macros +#include "btNotifDebug.h" // Debugging macros #include #include #include diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btnotifuiutil.cpp --- a/bluetoothengine/btnotif/src/btnotifuiutil.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/btnotifuiutil.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -17,12 +17,12 @@ #include // BAFL utils (for language file) #include "btnotifuiutil.h" -#include "BTNotifDebug.h" // Debugging macros -#include // Localisation stringloader -#include // Information note +#include "btNotifDebug.h" // Debugging macros +#include // Localisation stringloader +#include // Information note #include // for the blocking query -#include // CoverUI -#include // Backlight control +#include // CoverUI +#include // Backlight control #include // Application Key enable/disable CBTNotifUIUtil* CBTNotifUIUtil::NewL( TBool aCoverDisplayEnabled ) diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp --- a/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -18,22 +18,22 @@ // INCLUDE FILES -#include // Localisation stringloader #include // Own resources #include +#include #include "btnotiflock.h" -#include "btnpaireddevsettNotifier.h" // Own class definition -#include "BTNotifDebug.h" // Debugging macros +#include "btnpaireddevsettnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros #include #include "btnotifnameutils.h" -#include +#include #include -#include // CoverUI +#include // CoverUI #ifdef __SERIES60_HELP -#include +#include #include // The bt hrh info is needed, for help launching #endif @@ -127,26 +127,23 @@ TBTDeviceName name; BtNotifNameUtils::GetDeviceDisplayName(name, iDevice); + RBuf stringholder; + stringholder.CleanupClosePushL(); + // 1. Show pairing status note FTRACE(FPrint(_L("[BTNOTIF]\t CBTPairedDevSettNotifier iPairingStatus: %d"), iPairingStatus)); TInt resourceId = ProcessPairingErrorCode( iPairingStatus ); - HBufC* stringholder = StringLoader::LoadLC( resourceId ); - _LIT(PU,"%U"); - if( stringholder->Find(PU) != KErrNotFound) - { - CleanupStack::PopAndDestroy( stringholder ); - stringholder = StringLoader::LoadLC( resourceId, name ); - } - + BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, resourceId, name, 0 ); + if (!iPairingStatus) { - iNotifUiUtil->ShowConfirmationNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name ); + iNotifUiUtil->ShowConfirmationNoteL( ETrue, stringholder, iSecondaryDisplayCommand, name ); } else { - iNotifUiUtil->ShowErrorNoteL( ETrue, *stringholder, iSecondaryDisplayCommand, name ); + iNotifUiUtil->ShowErrorNoteL( EFalse, stringholder, iSecondaryDisplayCommand, name ); } - CleanupStack::PopAndDestroy( stringholder ); // stringholder + CleanupStack::PopAndDestroy( &stringholder ); if( iPairingStatus || (iDevice && iDevice->GlobalSecurity().Banned() ) ) { diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btnpairnotifier.cpp --- a/bluetoothengine/btnotif/src/btnpairnotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/btnpairnotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -22,10 +22,10 @@ #include // new file introduced by xSymbian #endif -#include // Localisation stringloader #include // Unicode character conversion utilities #include #include // Own resources +#include #include "btnpairnotifier.h" #include "btNotifDebug.h" #include "btnotifnameutils.h" @@ -80,16 +80,17 @@ { User::Leave(KErrInUse); } - else if ( AutoLockOnL() ) + + iMessage = (RMessage2)aMessage; + iReplySlot = aReplySlot; + + if ( AutoLockOnL() ) { // The phone is locked, access denied. // CompleteMessage(KErrCancel); - return; } - iMessage = (RMessage2)aMessage; - iReplySlot = aReplySlot; } // ---------------------------------------------------------- @@ -127,9 +128,11 @@ // and user has not given a alias for device. if( !iNotifUiUtil->IsQueryReleased() && !iDevice->IsValidFriendlyName() ) { - HBufC* prompt = GenerateQueryPromoptLC(); - iNotifUiUtil->UpdateQueryDlgL( *prompt ); - CleanupStack::PopAndDestroy( prompt ); + RBuf prompt; + prompt.CleanupClosePushL(); + GenerateQueryPromptL( prompt ); + iNotifUiUtil->UpdateQueryDlgL( prompt ); + CleanupStack::PopAndDestroy( &prompt ); } } @@ -203,13 +206,16 @@ TBTDeviceName devName; BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); - HBufC* prompt = StringLoader::LoadLC( R_BT_ACCEPT_PAIRING_REQUEST, devName ); + RBuf prompt; + prompt.CleanupClosePushL(); + BluetoothUiUtil::LoadResourceAndSubstringL( + prompt, R_BT_ACCEPT_PAIRING_REQUEST, devName, 0 ); - TBTDeviceName nameCoverUi( KNullDesC ); + devName.Zero(); // Show query for use to accept/reject incoming pairing request - TInt keypress = iNotifUiUtil->ShowQueryL( *prompt, R_BT_GENERIC_QUERY, - ECmdBTnotifUnavailable, nameCoverUi, CAknQueryDialog::EConfirmationTone ); - CleanupStack::PopAndDestroy( prompt ); + TInt keypress = iNotifUiUtil->ShowQueryL( prompt, R_BT_GENERIC_QUERY, + ECmdBTnotifUnavailable, devName, CAknQueryDialog::EConfirmationTone ); + CleanupStack::PopAndDestroy( &prompt ); if( iMessage.IsNull() ) // cancelled by the stack { @@ -236,11 +242,12 @@ } // ---------------------------------------------------------- -// CBTNPairNotifierBase::GenerateQueryPromoptLC +// CBTNPairNotifierBase::GenerateQueryPromptL // To be implemented in derived classes. // ---------------------------------------------------------- // -HBufC* CBTNPairNotifierBase::GenerateQueryPromoptLC() +void CBTNPairNotifierBase::GenerateQueryPromptL( RBuf& aRBuf ) { - return NULL; + FLOG(_L("[BTNOTIF]\t CBTNPairNotifierBase::GenerateQueryPromptL WARNING ")); + (void) aRBuf; } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp --- a/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -31,7 +31,7 @@ #endif #include // Own resources #include - +#include #include "btnotif.hrh" // Own resource header #include "btnssppasskeyentrynotifier.h" // Own class definition #include "btNotifDebug.h" // Debugging macros @@ -184,9 +184,11 @@ } if ( !iNotifUiUtil->IsQueryReleased() ) { - HBufC* update = GenerateQueryPromoptLC(); - iNotifUiUtil->UpdateQueryDlgL( *update ); - CleanupStack::PopAndDestroy( update ); + RBuf prompt; + prompt.CleanupClosePushL(); + GenerateQueryPromptL( prompt ); + iNotifUiUtil->UpdateQueryDlgL( prompt ); + CleanupStack::PopAndDestroy( &prompt ); } FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::UpdateL() completed")); @@ -226,11 +228,14 @@ iBuf.Zero(); iBuf.Append(iPasskey); iBuf.Append(_L(" ")); - HBufC* prompt = GenerateQueryPromoptLC(); - TInt answer = iNotifUiUtil->ShowQueryL( *prompt, R_BT_PASSKEY_QUERY, + RBuf prompt; + prompt.CleanupClosePushL(); + GenerateQueryPromptL( prompt ); + + TInt answer = iNotifUiUtil->ShowQueryL( prompt, R_BT_PASSKEY_QUERY, ECmdBTnotifUnavailable, nameCoverUi ); - CleanupStack::PopAndDestroy( prompt ); + CleanupStack::PopAndDestroy( &prompt ); if( iAnswer ) // user pressed entry key from remote keyboard. { @@ -260,23 +265,18 @@ } // ---------------------------------------------------------- -// CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC +// CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL // ---------------------------------------------------------- // -HBufC* CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC() +void CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL( RBuf& aRBuf ) { - FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC()")); + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL()")); TBTDeviceName devName; BtNotifNameUtils::GetDeviceDisplayName(devName, iDevice); - - CPtrCArray* subsPrompt = new (ELeave) CPtrCArray(2); - CleanupStack::PushL( subsPrompt ); - subsPrompt->AppendL( devName ); - subsPrompt->AppendL( iBuf ); - HBufC* prompt = StringLoader::LoadL( R_BT_SSP_PASSKEY_ENTRY , *subsPrompt ); - CleanupStack::PopAndDestroy( subsPrompt ); - CleanupStack::PushL( prompt ); - FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromoptLC() << ")); - return prompt; + BluetoothUiUtil::LoadResourceAndSubstringL( + aRBuf, R_BT_SSP_PASSKEY_ENTRY, devName, 0 ); + BluetoothUiUtil::AddSubstringL( aRBuf, iBuf, 1 ); + FLOG(_L("[BTNOTIF]\t CBTSSPPasskeyEntryNotifier::GenerateQueryPromptL() << ")); + } // End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btnumcmpnotifier.cpp --- a/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -33,6 +33,7 @@ #include #include #include +#include #include "btnotifnameutils.h" #ifdef __SERIES60_HELP @@ -154,9 +155,11 @@ // For outgoing pairing request or accepted incoming pairing request, // ask user to compare the pincodes in two devices. TBTDeviceName nameCoverUi( KNullDesC ); - HBufC* prompt = GenerateQueryPromoptLC(); - TInt answer = iNotifUiUtil->ShowQueryL( *prompt, R_BT_GENERIC_QUERY, ECmdShowBtOpenCoverNote, nameCoverUi ); - CleanupStack::PopAndDestroy( prompt ); + RBuf prompt; + prompt.CleanupClosePushL(); + GenerateQueryPromptL( prompt ); + TInt answer = iNotifUiUtil->ShowQueryL( prompt, R_BT_GENERIC_QUERY, ECmdShowBtOpenCoverNote, nameCoverUi ); + CleanupStack::PopAndDestroy( &prompt ); if( answer ) { @@ -187,20 +190,18 @@ } // ---------------------------------------------------------- -// CBTNumCmpNotifier::GenerateQueryPromoptLC +// CBTNumCmpNotifier::GenerateQueryPromptL // Generate prompt for Numeric Comparison query and return. // ---------------------------------------------------------- // -HBufC* CBTNumCmpNotifier::GenerateQueryPromoptLC() +void CBTNumCmpNotifier::GenerateQueryPromptL( RBuf& aRBuf ) { - FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromoptLC()")); + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromptL()")); TBTDeviceName devName; BtNotifNameUtils::GetDeviceDisplayName( devName, iDevice ); - - CPtrCArray* subs = new (ELeave) CPtrCArray(2); - CleanupStack::PushL( subs ); TBuf shortName; + TPtrC namePtr; // Cut the name and put ellipsis in the middle if necessary // By example "SampleSymbianDevice" after this operation will be shown in // the dialog as "Sam...ice"(for 7 chars device name limit) @@ -215,18 +216,20 @@ //adding only end of the name to the final string shortName.Append( devName.Right( shortName.MaxLength() - shortName.Length() ) ); - subs->AppendL( shortName ); + namePtr.Set( shortName ); } else { - subs->AppendL( devName ); + namePtr.Set( devName ); } - subs->AppendL( iPasskeyToShow ); - HBufC* prompt = StringLoader::LoadL( R_BT_SSP_PASSKEY_COMPARISON_PROMPT, *subs ); - CleanupStack::PopAndDestroy( subs ); - CleanupStack::PushL( prompt ); - FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromoptLC() <<")); - return prompt; + + BluetoothUiUtil::LoadResourceAndSubstringL( + aRBuf, R_BT_SSP_PASSKEY_COMPARISON_PROMPT, namePtr, 0 ); + // Numeric comparison key shall not be localized either, use our own + // string loading: + BluetoothUiUtil::AddSubstringL( aRBuf, iPasskeyToShow, 1); + FLOG(_L("[BTNOTIF]\t CBTNumCmpNotifier::GenerateQueryPromptL() <<")); + } // End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btnotif/src/btuserconfnotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btnotif/src/btuserconfnotifier.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,153 @@ +/* +* Copyright (c) 2010 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: Declares User confirmation notifier for Secure Simle Pairing +* +*/ + + +// INCLUDE FILES +#include // Localisation stringloader +#include // Unicode character conversion utilities +#include +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#else +#include +#include +#endif +#include // Own resources +#include "btnotif.hrh" // Own resource header +#include "btuserconfnotifier.h" // Own class definition +#include "btNotifDebug.h" // Debugging macros +#include +#include +#include +#include +#include "btnotifnameutils.h" + +#ifdef __SERIES60_HELP +#include +#include // The bt hrh info is needed, for help launching +#endif + +// ================= MEMBER FUNCTIONS ======================= + +// ---------------------------------------------------------- +// CBTUserConfNotifier::NewL +// Two-phased constructor. +// ---------------------------------------------------------- +// +CBTUserConfNotifier* CBTUserConfNotifier::NewL() + { + CBTUserConfNotifier* self=new (ELeave) CBTUserConfNotifier(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::CBTUserConfNotifier +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------- +// +CBTUserConfNotifier::CBTUserConfNotifier() + { + + } + +// ---------------------------------------------------------- +// Destructor +// ---------------------------------------------------------- +// +CBTUserConfNotifier::~CBTUserConfNotifier() + { + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::RegisterL +// Register notifier. +// ---------------------------------------------------------- +// +CBTUserConfNotifier::TNotifierInfo CBTUserConfNotifier::RegisterL() + { + iInfo.iUid = KBTUserConfirmationNotifierUidCopy; + iInfo.iChannel = KBTUserConfirmationNotifierUidCopy; + iInfo.iPriority=ENotifierPriorityVHigh; + return iInfo; + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::GetParamsL +// Initialize parameters and check if device is already +// in registry. Jump to RunL as soon as possible. +// ---------------------------------------------------------- +// +void CBTUserConfNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) + { + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL()")); + + CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage ); + + TBTUserConfirmationParamsPckgCopy pckg; + pckg.Copy(aBuffer); + iBTAddr = pckg().DeviceAddress(); + if ( OtherOutgoPairing( iBTAddr) ) + { + // We won't allow incoming pairing during outgoing pairing: + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier: outgoing pair in progress, reject incoming pair")); + CompleteMessage(KErrCancel); + return; + } + + iLocallyInitiated = pckg().LocallyInitiated(); + + // base class + ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() ); + + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL() completed")); + } + +// ---------------------------------------------------------- +// CBTUserConfNotifier::HandleGetDeviceCompletedL +// Ask user response and return it to caller. +// Store device into registry if user has accepted pairing. +// ---------------------------------------------------------- +// +void CBTUserConfNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/) + { + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL()")); + + // Check if blocked device. + if( CheckBlockedDeviceL() ) + return; + + // Turn lights on and deactivate apps -key + iNotifUiUtil->TurnLightsOn(); + + // For incoming pairing request + TBool answer = AuthoriseIncomingPairingL(); + if( !answer ) + { + //User rejects the incoming pairing, complete message in QueryBlockDevice. + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() <<")); + return; + } + CompleteMessage(answer, KErrNone); + + FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() completed")); + } + +// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btsac/btrcc/inc/btrccLinker.h --- a/bluetoothengine/btsac/btrcc/inc/btrccLinker.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btsac/btrcc/inc/btrccLinker.h Fri Apr 16 15:08:36 2010 +0300 @@ -319,7 +319,6 @@ CBTRCCVolumeLevelControllerBase* iVolController; CBTRCCVolumeLevelControllerBase* iAbsoluteVolController; - CBTRCCVolumeLevelControllerBase* iLegacyVolController; TInt iRegisterVolumeChangeNotificationCounter;//Counter for re-register for remote volume control notification }; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h --- a/bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h Fri Apr 16 15:08:36 2010 +0300 @@ -125,6 +125,11 @@ TBool IsMusicPlayerRunning(); /** + * Tells if Video player is running or not. + */ + TBool IsVideoPlayerRunning(); + + /** * Launch MPX player. */ void LaunchMusicPlayerL(); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btsac/btrcc/src/btrccLinker.cpp --- a/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -25,7 +25,6 @@ #include #include #include "btaudioremconpskeys.h" -#include "btrccLegacyVolumeLevelController.h" #include "btrccAbsoluteVolumeLevelController.h" #include "btrccLinker.h" #include "btrccplayerstarter.h" @@ -87,7 +86,6 @@ if (iAccObserver.IsAvrcpVolCTSupported()) { iAbsoluteVolController = CBTRCCAbsoluteVolumeLevelController::NewL(*iInterfaceSelector, *this); - iLegacyVolController = CBTRCCLegacyVolumeLevelController::NewL(*iInterfaceSelector, *this); } else { @@ -101,8 +99,6 @@ iRemConBatteryTgt = CRemConBatteryApiTarget::NewL(*iInterfaceSelector, *this); -// iBrowsingAdapter = CBTRCCBrowsingAdapter::NewL(*iInterfaceSelector); - if (iAccObserver.IsAvrcpVolCTSupported()) { iInterfaceSelector->OpenControllerL(); @@ -129,7 +125,6 @@ User::RequestComplete(iClientRequest, KErrAbort); delete iAbsoluteVolController; - delete iLegacyVolController; delete iPlayerStarter; Cancel(); iStateArray.ResetAndDestroy(); @@ -437,17 +432,18 @@ if (iAccObserver.IsAvrcpVolCTSupported()) { // Choose based on SDP result whether to create - // absolute controller or legacy controller. + // absolute controller or not. if(!iVolController) { if (iAccObserver.IsAbsoluteVolumeSupported(iRemoteAddr)) { iVolController = iAbsoluteVolController; + TRACE_INFO(_L("Absolute volume supported, taking it into use.")) } else - { - iVolController = iLegacyVolController; - } + { + TRACE_INFO(_L("No absolute volume supported, so no volume control.")) + } } } if (iVolController) @@ -466,6 +462,7 @@ if (iVolController) { iVolController->Stop(); + iVolController = NULL; } } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp --- a/bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -33,6 +33,7 @@ _LIT(KMpxPlayerExeName, "mpx.exe"); _LIT(KMpxPlayerSearchPatternBySID, "*102072c3*"); +_LIT(KVideoPlayerSearchPatternBySID, "*200159B2*"); static const TInt KPlayCmdToPlayerDelay = 6000000; // value will be tuned later @@ -243,7 +244,7 @@ { return; } - if (!IsMusicPlayerRunning()) + if (!IsMusicPlayerRunning() && !IsVideoPlayerRunning()) { TRAPD(err, LaunchMusicPlayerL()); // Send the response of play command to remote device @@ -269,6 +270,22 @@ return running; } +TBool CPlayerStarter::IsVideoPlayerRunning() + { + TRACE_FUNC + // Video player is running if we can find a thread whose name contains + // Video Player's SID. + TFindThread findt(KVideoPlayerSearchPatternBySID); + TFullName result; + TBool running(EFalse); + if (!findt.Next(result)) + { + TRACE_INFO((_L("Thread '%S'is found"), &result)); + running = ETrue; + } + return running; + } + void CPlayerStarter::LaunchMusicPlayerL() { RApaLsSession ls; diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/group/bld.inf --- a/bluetoothengine/btui/Ecom/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/Ecom/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -20,10 +20,8 @@ PRJ_PLATFORMS - PRJ_EXPORTS - PRJ_MMPFILES ./BtuiPlugin.mmp diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/inc/bluetoothuiutil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/bluetoothuiutil.h Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2010 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: This provides utility for loading a BT device name without +* localised to a string to be shown in GUI. +* +*/ +#include + +class BluetoothUiUtil + { +public: + +/* + * Gets the starting position of a key whose pattern matches + * '%'{(0)*|} where 0 and is the decimal value + * of the specified position and is the symbol of the key, + * either 'U' or 'N'. + * + * For example, if the specified position of a number key + * is 0, both "%N" and "%0N" match, + * but "%1N" doesn't. If the position n is greater than 0, + * only "%N" matches. + * @param aDes the descriptor where a key parameter will be searched. + * @param aKey the specified key, 'U' or 'N' + * @param aKeyPos the position of the key. position starts from 0. + * @param aKeyLength the length of the key at return if the key exists. + * @return the start position of the key in aDes. KErrNotFound if the key + * is not available. + */ +inline static TInt GetSubstringKeyPos( const TDes& aDes, const TDesC& aKey, + TInt aKeyPos, TInt& aKeyLength ); + +/* + * Gets the starting position of a string key whose pattern matches + * '%'{(0)*|}'U' where 0 and is the decimal value + * of the specified position. + * + * For example, if the specified position is 0, both "%U" and "%0U" match, + * but "%1U" doesn't. If the position n is greater than 0, + * only "%U" matches. + * @param aDes the descriptor in which a string key will be searched. + * @param aKeyPos the position of the string key. position starts from 0. + * @param aKeyLength the length of the string key at return if the key exists. + * @return the start position of the string key in aDes. KErrNotFound if the key + * is not available. + */ +inline static TInt GetStringSubstringKeyPos( const TDes& aDes, TInt aKeyPos, TInt& aKeyLength ); + +/* + * Add a substring to the specified RBuf descriptor. + * ( Replace "%U" at the specified position withe the given string. + * @param aBuf the RBuf descriptor in which a "%U" will be replaced. + * @param aSub the substring that will replace a "%U". + * @param aSubPos the position of the "%U" to be replaced. Position starts from 0. + */ +inline static void AddSubstringL( RBuf& aBuf, const TDesC& aSub, TInt aSubPos); + +/* + * Load a string specified by the given resource ID, + * remove substrings that match "[" and ends with "]" and finally + * replace the "%U" or "%U" at the specified position with the + * given substring. + * + * This function is intended for adding a Bluetooth device name to a UI + * string but without localizing this name. + * + * (Using StringLoader will get the device name localized in some variants. + * This is a workaround to tackle the unwanted localization.) + * + * @param aBuf the RBuf descriptor in which a "%U" will be replaced. + * @param aSub the substring that will replace a "%U". + * @param aSubPos the position of the "%U" to be replaced. Position starts from 0. + */ +inline static void LoadResourceAndSubstringL(RBuf& aBuf, + TInt aResourceId, const TDesC& aSub, TInt aSubPos ); + }; + +#include "bluetoothuiutil.inl" + +// End of File + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/inc/bluetoothuiutil.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bluetoothengine/btui/Ecom/inc/bluetoothuiutil.inl Fri Apr 16 15:08:36 2010 +0300 @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2010 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: This provides utility for loading a BT device name without +* localised to a string to be shown in GUI. +* +*/ + +inline TInt BluetoothUiUtil::GetSubstringKeyPos( + const TDes& aDes, const TDesC& aKey, + TInt aKeyPos, TInt& aKeyLength ) + { + ASSERT( aKeyPos > KErrNotFound ); + _LIT(KPercentSymbol, "%" ); + // 32 would be to fit any key substring in practice: + TBuf<32> key; + TInt pos( KErrNotFound ); + // if the specified position is 0, check if "%" (%U or %N) exists. + if ( aKeyPos == 0 ) + { + key.Copy( KPercentSymbol ); + key.Append(aKey); + pos = aDes.Find( key ); + } + // Either the key is not found, or aKeyPos is not 0. + if ( pos == KErrNotFound ) + { + key.Copy( KPercentSymbol ); + key.AppendNum( aKeyPos ); + key.Append( aKey ); + pos = aDes.Find( key ); + } + if ( pos > KErrNotFound ) + { + aKeyLength = key.Length(); + } + return pos; + } + +inline TInt BluetoothUiUtil::GetStringSubstringKeyPos( + const TDes& aDes, TInt aKeyPos, TInt& aKeyLength ) + { + _LIT(KStringKeyword,"U"); + TPtrC ptr( KStringKeyword ); + return GetSubstringKeyPos(aDes, ptr, aKeyPos, aKeyLength ); + } + +inline void BluetoothUiUtil::AddSubstringL( + RBuf& aBuf, const TDesC& aSub, TInt aSubPos) + { + // Find the position of the specified "%U" or %[0-9]U in aBuf. + TInt keyLength; + TInt pos = GetStringSubstringKeyPos( aBuf, aSubPos, keyLength ); + if ( pos == KErrNotFound ) + { + User::Leave( pos ); + } + // Enlarge the max length of aBuf if needed: + TInt reqedLen = aBuf.Length() - keyLength + aSub.Length(); + if ( aBuf.MaxLength() < reqedLen ) + { + aBuf.ReAllocL( reqedLen ); + } + aBuf.Replace( pos, keyLength, aSub ); + } + +inline void BluetoothUiUtil::LoadResourceAndSubstringL(RBuf& aBuf, + TInt aResourceId, const TDesC& aSub, TInt aSubPos ) + { + HBufC* string = StringLoader::LoadL( aResourceId ); + aBuf.Assign( string ); + // Logical loc strings may contain redundant "[]" for some reason. + // This sub-string should be removed in our ad hoc parameter loading method. + _LIT( KLeftSquareBracket,"[" ); + _LIT( KRightSquareBracket,"]" ); + while ( 1 ) + { + TInt lpos = aBuf.Find( KLeftSquareBracket ); + TInt rpos = aBuf.Find( KRightSquareBracket ); + if ( lpos > KErrNotFound && rpos > KErrNotFound && ( rpos > lpos ) ) + { + aBuf.Delete(lpos, rpos - lpos + 1 ); + continue; + } + // No sub-strings that match "[" and ends with "]". Done + break; + } + // Add the substring to this string loaded from resource: + AddSubstringL( aBuf, aSub, aSubPos ); + } + +// End of File + diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp --- a/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -36,7 +36,9 @@ #include #include // Tab icon for General Setting +#include #include "BTUIMainView.h" // base View. + // --------------------------------------------------------- // CBTUIBlockedDevicesView::ConstructL // Symbian 2nd phase constructor can leave. @@ -177,12 +179,16 @@ TBTDevice device; device.iIndex = bItemIndex; iModel->GetDevice(device); - + + RBuf s; + CleanupClosePushL( s ); + BluetoothUiUtil::LoadResourceAndSubstringL( + s, R_BT_WARN_ERASE_BLOCKED, device.iName, 0); + CAknQueryDialog* dialog = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone); - HBufC* s = StringLoader::LoadLC(R_BT_WARN_ERASE_BLOCKED,device.iName); - TInt keypress = dialog->ExecuteLD(R_BT_GENERIC_QUERY, *s); + TInt keypress = dialog->ExecuteLD(R_BT_GENERIC_QUERY, s); - CleanupStack::PopAndDestroy(s); + CleanupStack::PopAndDestroy(&s); if(keypress) // User has accepted the dialog { diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/src/BTUIDeviceContainer.cpp --- a/bluetoothengine/btui/Ecom/src/BTUIDeviceContainer.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/Ecom/src/BTUIDeviceContainer.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -32,7 +32,7 @@ #include "debug.h" #include "btui.h" // Global declarations -const TInt KBTNumberOfIcons = 13; // Number of class of device icons +const TInt KBTNumberOfIcons = 14; // Number of class of device icons + extra one DEV_STATUS_AUTHORIZED _LIT( DEV_TYPE_COMPUTER,"0\t"); _LIT( DEV_TYPE_PHONE,"1\t"); diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp --- a/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -48,8 +48,10 @@ #include #include // Tab icon for General Setting +#include #include "BTUIMainView.h" // base View. + const TInt KAutoConnect2ndTry = 1; const TUint32 SetExcludePairedDeviceMask = 0x800000; @@ -287,6 +289,11 @@ TBTDevice device; device.iIndex = iContainer->CurrentItemIndex(); iModel->GetDevice(device); + if ( device.iStatus & EStatusBtuiConnected ) + { + // If device is already connected, we do nothing here. + break; + } device.iOperation = EOpConnect; ConnectL( device, ETrue ); break; @@ -620,20 +627,15 @@ device.iIndex = index; iModel->GetDevice(device); - HBufC* stringholder = NULL; + RBuf stringholder; + CleanupClosePushL( stringholder ); TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; // Choose confirmation phrase - // - if ( device.iStatus & tmp ) - { - stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE_CONNECTED, - device.iName); - } - else - { - stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE, device.iName ); - } + TInt resourceId = ( device.iStatus & tmp ) ? R_BT_WARN_ERASE_CONNECTED : + R_BT_WARN_ERASE; + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, resourceId, device.iName, 0 ); // Create confirmation query // @@ -653,9 +655,9 @@ covercl->BufStream().CommitL(); // no more data to send so commit buf } } - TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, *stringholder); + TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, stringholder); - CleanupStack::PopAndDestroy(stringholder); // stringholder + CleanupStack::PopAndDestroy(&stringholder); // stringholder if(keypress) // User has accepted the dialog { @@ -772,19 +774,23 @@ HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); - HBufC* stringHolder = NULL; + RBuf stringHolder; + CleanupClosePushL( stringHolder ); + TInt resouseId; if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) - stringHolder = StringLoader::LoadLC( - (iHelpEnabled? R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_HELP: - R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_NOHELP ), - device.iName); + { + resouseId = iHelpEnabled? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : + R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; + } else - stringHolder = StringLoader::LoadLC( - (iHelpEnabled?R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP:R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP), - device.iName); + { + resouseId = iHelpEnabled ? R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP : + R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP; + } + BluetoothUiUtil::LoadResourceAndSubstringL( + stringHolder, resouseId, device.iName, 0 ); - - CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (*stringHolder, + CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (stringHolder, CAknQueryDialog::EConfirmationTone); queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); @@ -816,7 +822,7 @@ keypress = queryDialog->RunLD(); } - CleanupStack::PopAndDestroy(stringHolder); + CleanupStack::PopAndDestroy(&stringHolder); CleanupStack::PopAndDestroy(header); if(keypress) @@ -978,11 +984,14 @@ TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) { TRAPD(err, - HBufC* stringholder = StringLoader::LoadLC(aNoteTextResource , aDevName ); + RBuf stringholder; + CleanupClosePushL( stringholder ); + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, aNoteTextResource, aDevName, 0 ); aWaitDialog = new (ELeave) CAknWaitDialog( reinterpret_cast(&aWaitDialog), ETrue); aWaitDialog->PrepareLC(aNoteResource); - aWaitDialog->SetTextL(*stringholder); + aWaitDialog->SetTextL(stringholder); if(iCoverDisplayEnabled) { @@ -998,7 +1007,7 @@ aWaitDialog->SetCallback(this); // for capturing Cancel keypress aWaitDialog->RunLD(); - CleanupStack::PopAndDestroy(stringholder); // stringholder + CleanupStack::PopAndDestroy(&stringholder); // stringholder ); // if the above functions leaves the iWaitNote is deleted, but // not set to NULL. This will cause a problem, when @@ -1065,11 +1074,21 @@ TBTDevice device; device.iIndex = index; iModel->GetDevice(device); + + if ( !( device.iStatus & EStatusBtuiConnected) ) + { + // If device is already disconnected, return immediately. + return; + } + iDisconnectQueryDevice = device;//remember device related with query dialog // Create confirmation query - HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName); - if (!iDisconnectQueryDlg) + RBuf stringholder; + CleanupClosePushL( stringholder ); + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, R_BT_DISCONNECT_FROM, device.iName, 0 ); + if ( !iDisconnectQueryDlg ) { iDisconnectQueryDlg = CAknQueryDialog::NewL(); } @@ -1086,9 +1105,9 @@ } } - TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, *stringholder); + TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, stringholder); - CleanupStack::PopAndDestroy(stringholder); // stringholder + CleanupStack::PopAndDestroy(&stringholder); // stringholder iDisconnectQueryDlg = NULL; if(keypress) // User has accepted the dialog @@ -1189,22 +1208,22 @@ break; case KErrAlreadyExists: // connection exists allready { - HBufC* stringholder = NULL; + RBuf stringholder; + CleanupClosePushL( stringholder ); if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) { if(aConflictingDeviceNames->Count() == 1) { - stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_PROMPT, - *(*aConflictingDeviceNames)[0],iCoeEnv ); + BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, + R_BT_DISCONNECT_FIRST_PROMPT, + *(*aConflictingDeviceNames)[0], 0 ); } else { - CPtrC16Array* aa=new(ELeave) CPtrC16Array(1+1); - aa->InsertL(0, *(*aConflictingDeviceNames)[0] ); - aa->InsertL(1, *(*aConflictingDeviceNames)[1] ); - stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_STEREO_PROMPT , - *aa,iCoeEnv); - delete(aa); + BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, + R_BT_DISCONNECT_FIRST_STEREO_PROMPT, + *(*aConflictingDeviceNames)[0], 0 ); + BluetoothUiUtil::AddSubstringL( stringholder, *(*aConflictingDeviceNames)[1], 1 ); } TRACE_INFO(_L("KErrAllreadyExists")) } @@ -1235,8 +1254,8 @@ } } - note->ExecuteLD(*stringholder); - CleanupStack::PopAndDestroy(stringholder); + note->ExecuteLD(stringholder); + CleanupStack::PopAndDestroy(&stringholder); } break; case KErrServerBusy: @@ -1261,68 +1280,28 @@ // CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); - HBufC* stringHolder = NULL; + RBuf stringHolder; + CleanupClosePushL( stringHolder ); + + BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, + R_BT_CONF_CONNECTED_PROMPT, aDevice.iName, 0 ); - if (!FeatureManager::FeatureSupported(KFeatureIdAccessoryFw)) - { - if (CallOnGoing()) - { - stringHolder = StringLoader::LoadLC(R_BT_AUDIOS_ACCESSORY_PROMPT); // qtn_bt_audio_accessory "Audio routed to BT handsfree" - - if(iCoverDisplayEnabled) - { - CleanupStack::PushL(notePtr); - notePtr->PublishDialogL(ECmdBtuiShowBtAudioAccessory, KUidCoverUiCategoryBtui); // initializes cover support - CleanupStack::Pop(notePtr); - } - - notePtr->ExecuteLD(*stringHolder); - } - else - { - TRACE_INFO(_L("No call ongoing. Connected to")) - stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); // "Connected to %U" - - if(iCoverDisplayEnabled) - { - CleanupStack::PushL(notePtr); - notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support - CleanupStack::Pop(notePtr); + if(iCoverDisplayEnabled) + { + CleanupStack::PushL(notePtr); + notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support + CleanupStack::Pop(notePtr); - CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided - if (covercl) // returns null if __COVER_DISPLAY is not defined - { - covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); - covercl->BufStream().CommitL(); // no more data to send so commit buf - } - } - - notePtr->ExecuteLD(*stringHolder); - } - } - else - { - TRACE_INFO(_L("AccFW Supported. Connected to")) - stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); + CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided + if (covercl) // returns null if __COVER_DISPLAY is not defined + { + covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); + covercl->BufStream().CommitL(); // no more data to send so commit buf + } + } - if(iCoverDisplayEnabled) - { - CleanupStack::PushL(notePtr); - notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support - CleanupStack::Pop(notePtr); - - CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided - if (covercl) // returns null if __COVER_DISPLAY is not defined - { - covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); - covercl->BufStream().CommitL(); // no more data to send so commit buf - } - } - - notePtr->ExecuteLD(*stringHolder); - } - - CleanupStack::PopAndDestroy(stringHolder); + notePtr->ExecuteLD(stringHolder); + CleanupStack::PopAndDestroy(&stringHolder); } TRAP_IGNORE(LaunchSettingViewL();) @@ -1330,13 +1309,17 @@ case KErrNotSupported: { - TRACE_INFO(_L("error = KErrNotSupported")) - + TRACE_INFO(_L("error = KErrNotSupported")) + + RBuf stringHolder; + CleanupClosePushL( stringHolder ); + + BluetoothUiUtil::LoadResourceAndSubstringL( stringHolder, + R_BT_DEVICE_NOT_SUPPORTED, aDevice.iName, 0 ); // create note // CAknInformationNote* note = new (ELeave) CAknInformationNote(); - HBufC* stringHolder = StringLoader::LoadLC(R_BT_DEVICE_NOT_SUPPORTED,aDevice.iName); if(iCoverDisplayEnabled) { @@ -1351,8 +1334,8 @@ covercl->BufStream().CommitL(); // no more data to send so commit buf } } - note->ExecuteLD(*stringHolder); - CleanupStack::PopAndDestroy(stringHolder); + note->ExecuteLD(stringHolder); + CleanupStack::PopAndDestroy(&stringHolder); } break; @@ -1613,14 +1596,17 @@ } TRACE_FUNC_EXIT } + + // ------------------------------------------------------ // CBTUIPairedDevicesView::ShowDisconnecNote // ------------------------------------------------------ void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) { - HBufC* stringholder = StringLoader::LoadLC( - R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName); - + RBuf stringholder; + CleanupClosePushL( stringholder ); + BluetoothUiUtil::LoadResourceAndSubstringL( + stringholder, R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName, 0 ); // Launch a waiting confirmation note // CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); @@ -1639,9 +1625,9 @@ CleanupStack::Pop(note); } - note->ExecuteLD(*stringholder); + note->ExecuteLD(stringholder); - CleanupStack::PopAndDestroy(stringholder); // stringholder + CleanupStack::PopAndDestroy(&stringholder); // stringholder } diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/Ecom/src/BTUISap.cpp --- a/bluetoothengine/btui/Ecom/src/BTUISap.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/Ecom/src/BTUISap.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -18,7 +18,6 @@ #include #include -#include // localisation stringloader #include // Compiled resource ids #include #include @@ -29,13 +28,13 @@ #include #include // For EnterpriseEnablementL() #include - +#include +#include #include "btdevmodel.h" #include "debug.h" #include "BTUIMainView.h" -#include // ---------------------------------------------------- // CBTUIMainView::SetSapStatusL // ---------------------------------------------------- @@ -72,26 +71,28 @@ { // Create confirmation query - HBufC* stringholder = StringLoader::LoadLC( R_BT_DISCONNECT_FROM, connectedSap ); + RBuf stringholder; + CleanupClosePushL( stringholder ); + BluetoothUiUtil::LoadResourceAndSubstringL( stringholder, + R_BT_DISCONNECT_FROM, connectedSap, 0 ); CAknQueryDialog* dlg = CAknQueryDialog::NewL(); if(iCoverDisplayEnabled) { CleanupStack::PushL(dlg); dlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support - CleanupStack::Pop(dlg); - CAknMediatorFacade* covercl = AknMediatorFacade(dlg); // uses MOP, so control provided if (covercl) // returns null if __COVER_DISPLAY is not defined { covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(connectedSap);// takes copy so consts are ok too covercl->BufStream().CommitL(); // no more data to send so commit buf - } + } + CleanupStack::Pop(dlg); } - TInt keypress = dlg->ExecuteLD( R_BT_DISCONNECT_FROM_QUERY, *stringholder ); + TInt keypress = dlg->ExecuteLD( R_BT_DISCONNECT_FROM_QUERY, stringholder ); - CleanupStack::PopAndDestroy(stringholder); // stringholder + CleanupStack::PopAndDestroy(&stringholder); // stringholder if( keypress ) // User has accepted the dialog { diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/devmodel/src/btpairedmodel.cpp --- a/bluetoothengine/btui/devmodel/src/btpairedmodel.cpp Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/devmodel/src/btpairedmodel.cpp Fri Apr 16 15:08:36 2010 +0300 @@ -419,12 +419,35 @@ if(di >=0 ) { nameArray.Append(&iDeviceArray[di]->iName); - } + } } - if(iObserver ) - { - iObserver->NotifyChangeDeviceComplete(aErr, connectedDevice, &nameArray); - } + + // we will unset the connect status of the device if connection failed & + // it is found in paired devices. + if( index >= 0 ) + { + // add EStatusBtuiConnected status if the device has a profile connection + TBTEngConnectionStatus connStatus; + iConnMan->IsConnected(connectedDevice.iAddr, connStatus); + + if (connStatus != EBTEngConnecting && connStatus != EBTEngConnected) + { + TRACE_INFO(_L("Unset EStatusBtuiConnected")) + UnsetStatusFlags(iDeviceArray[index]->iStatus,EStatusBtuiConnected ); + } + } + + if(iObserver) + { + //Show only phone issued request complete notes + //Do not show notes for device issued request when BTUI is active + if ( requestIssuedFromPhone ) + { + iObserver->NotifyChangeDeviceComplete(aErr, connectedDevice, &nameArray); + } + + SendRefreshIfNoError(aErr); + } nameArray.Reset(); } else diff -r 0b192a3a05a4 -r 00f9ee97d895 bluetoothengine/btui/group/bld.inf --- a/bluetoothengine/btui/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ b/bluetoothengine/btui/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -28,6 +28,8 @@ ../rom/BtuiResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(BtuiResources.iby) ../inc/BtuiPluginInterface.h |../../inc/BtuiPluginInterface.h ../inc/BtuiPluginInterface.inl |../../inc/BtuiPluginInterface.inl +../Ecom/inc/bluetoothuiutil.h |../../inc/bluetoothuiutil.h +../Ecom/inc/bluetoothuiutil.inl |../../inc/bluetoothuiutil.inl // Help exports #include "../help/group/bld.inf" diff -r 0b192a3a05a4 -r 00f9ee97d895 btservices_info/btservices_metadata/btservices_metadata.mrp --- a/btservices_info/btservices_metadata/btservices_metadata.mrp Tue Feb 02 00:20:42 2010 +0200 +++ b/btservices_info/btservices_metadata/btservices_metadata.mrp Fri Apr 16 15:08:36 2010 +0300 @@ -1,3 +1,19 @@ +# +# 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: +# + component btservices_metadata source \sf\mw\btservices\btservices_info\btservices_metadata source \sf\mw\btservices\package_definition.xml diff -r 0b192a3a05a4 -r 00f9ee97d895 group/bld.inf --- a/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ b/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -21,6 +21,7 @@ #include "../btservices_plat/group/bld.inf" #include "../btservices_pub/group/bld.inf" #include "../bluetoothengine/group/bld.inf" +#include "../atcommands/group/bld.inf" PRJ_EXPORTS diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/conf/obexservapitest.cfg --- a/tsrc/public/basic/conf/obexservapitest.cfg Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -[Test] -title Get file system status -create obexservapitest Message_Handler_Tester -Message_Handler_Tester GetFileSystemStatus -delete Message_Handler_Tester -[Endtest] -[Test] -title Get MMC file system status -create obexservapitest Message_Handler_Tester -Message_Handler_Tester GetMmcFileSystemStatus -delete Message_Handler_Tester -[Endtest] -[Test] -title Get message center drive -create obexservapitest Message_Handler_Tester -Message_Handler_Tester GetMessageCentreDriveL -delete Message_Handler_Tester -[Endtest] -[Test] -title Create default mtm service -create obexservapitest Message_Handler_Tester -Message_Handler_Tester CreateDefaultMtmServiceL -delete Message_Handler_Tester -[Endtest] -[Test] -title Get cenrep key int value -create obexservapitest Message_Handler_Tester -Message_Handler_Tester GetCenRepKeyIntValueL -delete Message_Handler_Tester -[Endtest] -[Test] -title Get PubSub key int value -create obexservapitest Message_Handler_Tester -Message_Handler_Tester GetPubSubKeyIntValue -delete Message_Handler_Tester -[Endtest] -[Test] -title Create and remove outpox entry -create obexservapitest Message_Handler_Tester -Message_Handler_Tester CreateOutBoxEntry -Message_Handler_Tester RemoveOutBoxEntry -delete Message_Handler_Tester -[Endtest] -[Test] -title Crate and remove outpox entry -create obexservapitest Message_Handler_Tester -Message_Handler_Tester SaveObjToInbox -delete Message_Handler_Tester -[Endtest] -[Test] -title Save object to inbox -create obexservapitest Message_Handler_Tester -Message_Handler_Tester SaveObjToInbox -delete Message_Handler_Tester -[Endtest] -[Test] -title Create and save attacment -create obexservapitest Message_Handler_Tester -Message_Handler_Tester CreateEntryToInbox -Message_Handler_Tester SaveRFileObjectToInbox -delete Message_Handler_Tester -[Endtest] -[Test] -title Create and Remove attacment -create obexservapitest Message_Handler_Tester -Message_Handler_Tester CreateEntryToInbox -Message_Handler_Tester RemoveObjectFromInbox -delete Message_Handler_Tester -[Endtest] - diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/conf/test.xml --- a/tsrc/public/basic/conf/test.xml Tue Feb 02 00:20:42 2010 +0200 +++ b/tsrc/public/basic/conf/test.xml Fri Apr 16 15:08:36 2010 +0300 @@ -34,24 +34,7 @@ - - install - - - - - - - - - install - - - - - - - + install @@ -61,7 +44,7 @@ - + install @@ -70,7 +53,7 @@ - + install @@ -79,7 +62,7 @@ - + install @@ -89,39 +72,25 @@ - + makedir - + makedir - - - makedir - - - - - + + makedir - - run-cases - - - - - - - + run-cases @@ -129,7 +98,7 @@ - + run-cases @@ -162,18 +131,11 @@ fetch-log - - - - - - fetch-log - - + fetch-log @@ -188,12 +150,10 @@ LCDo_APITestDrop/images/LCDo_test_API_rnd.fpsx LCDo_APITestDrop/images/LCDo_test_API_rnd_erase.fpsx LCDo_APITestDrop/components/armv5_urel/btengapitest.dll - LCDo_APITestDrop/components/armv5_urel/obexservapitest.dll LCDo_APITestDrop/components/armv5_urel/atextpluginapitest.dll LCDo_APITestDrop/components/armv5_urel/atextpluginstub.dll LCDo_APITestDrop/general/atextpluginstub.rsc LCDo_APITestDrop/general/btengapi_scripter.cfg - LCDo_APITestDrop/general/obexservapitest.cfg LCDo_APITestDrop/general/atextpluginapi_scripter.cfg diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/group/bld.inf --- a/tsrc/public/basic/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ b/tsrc/public/basic/group/bld.inf Fri Apr 16 15:08:36 2010 +0300 @@ -19,7 +19,6 @@ PRJ_PLATFORMS DEFAULT #include "../btengapitest/group/bld.inf" -#include "../obexservapitest/group/bld.inf" #include "../atextpluginapitest/group/bld.inf" //build files for shortlinkconn diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/Bmarm/ObexServAPItestU.DEF --- a/tsrc/public/basic/obexservapitest/Bmarm/ObexServAPItestU.DEF Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &) - diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/Bwins/ObexServAPItestU.DEF --- a/tsrc/public/basic/obexservapitest/Bwins/ObexServAPItestU.DEF Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &) - diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/EABI/ObexServAPItestU.def --- a/tsrc/public/basic/obexservapitest/EABI/ObexServAPItestU.def Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - _Z9LibEntryLR13CTestModuleIf @ 1 NONAME - diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/group/bld.inf --- a/tsrc/public/basic/obexservapitest/group/bld.inf Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* -* Copyright (c) 2002 - 2007 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: ?Description -* -*/ - - - -PRJ_PLATFORMS -// specify the platforms your component needs to be built for here -// defaults to WINS MARM so you can ignore this if you just build these -DEFAULT - -PRJ_TESTEXPORTS -// NOTE: If using ARS requirements all export operations should be done under this. -// 'abld test export' - -PRJ_EXPORTS -// Specify the source file followed by its destination here -// copy will be used to copy the source file to its destination -// If there's no destination then the source file will be copied -// to the same name in /epoc32/include -// Example: -/* -/agnmodel/inc/AGMCOMON.H -*/ - -PRJ_TESTMMPFILES -// NOTE: If using ARS requirements .mmp file operation should be done under this. -// 'abld test build' - -PRJ_MMPFILES -// Specify the .mmp files required for building the important component -// releasables. -// -// Specify "tidy" if the component you need to build doesn't need to be -// released. Specify "ignore" if the MMP file exists but should be -// ignored. -// Example: -/* -/agnmodel/group/agnmodel.mmp -#if defined(MARM) -/agnmodel/group/agsvexe.mmp -#endif -*/ -obexservapitest.mmp - -// End of File \ No newline at end of file diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/group/obexservapitest.mmp --- a/tsrc/public/basic/obexservapitest/group/obexservapitest.mmp Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/*TYPE TESTCLASS*/ -/* -* Copyright (c) 2002 - 2007 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: ?Description -* -*/ - - -#if defined(__S60_) - // To get the OS_LAYER_SYSTEMINCLUDE-definition - #include -#endif - -TARGET obexservapitest.dll -TARGETTYPE dll -UID 0x1000008D 0x101FB3E3 - -CAPABILITY ALL -TCB -/* Remove comments and replace 0x00000000 with correct vendor id */ -// VENDORID 0x00000000 -/* Remove comments and replace 0x00000000 with correct secure id */ -// SECUREID 0x00000000 - -//TARGETPATH ?target_path -DEFFILE ObexServAPItest.def - -SOURCEPATH ../src -SOURCE ObexServAPItest.cpp -SOURCE ObexServAPItestBlocks.cpp -SOURCE testlogger.cpp - - -USERINCLUDE ../inc - -MW_LAYER_SYSTEMINCLUDE - - -LIBRARY euser.lib -LIBRARY stiftestinterface.lib -LIBRARY sysutil.lib -LIBRARY obexutils.lib -LIBRARY irobex.lib -LIBRARY efsrv.lib - -LANG SC - -// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/inc/ObexServAPItest.h --- a/tsrc/public/basic/obexservapitest/inc/ObexServAPItest.h Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,211 +0,0 @@ -/* -* Copyright (c) 2002 - 2007 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: ?Description -* -*/ - - - -#ifndef OBEXSERVAPITEST_H -#define OBEXSERVAPITEST_H - -// INCLUDES -#include -#include -#include -#include -#include "testlogger.h" - - -// FORWARD DECLARATIONS -class CObexServAPItest; - - -// CLASS DECLARATION - -/** -* CObexServAPItest test class for STIF Test Framework TestScripter. -*/ -NONSHARABLE_CLASS(CObexServAPItest) : public CScriptBase - { - public: // Constructors and destructor - - /** - * Two-phased constructor. - */ - static CObexServAPItest* NewL( CTestModuleIf& aTestModuleIf ); - - /** - * Destructor. - */ - virtual ~CObexServAPItest(); - - public: // New functions - - - - public: // Functions from base classes - - /** - * From CScriptBase Runs a script line. - * @since ?Series60_version - * @param aItem Script line containing method name and parameters - * @return Symbian OS error code - */ - virtual TInt RunMethodL( CStifItemParser& aItem ); - - - - private: - - /** - * C++ default constructor. - */ - CObexServAPItest( CTestModuleIf& aTestModuleIf ); - - /** - * By default Symbian 2nd phase constructor is private. - */ - void ConstructL(); - - // Prohibit copy constructor if not deriving from CBase. - // ?classname( const ?classname& ); - // Prohibit assigment operator if not deriving from CBase. - // ?classname& operator=( const ?classname& ); - - /** - * Frees all resources allocated from test methods. - * @since ?Series60_version - */ - void Delete(); - - void TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ); - - /** - * Test methods are listed below. - */ - - /** - * Test code for getting file system status. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt GetFileSystemStatusL( CStifItemParser& aItem ); - - /** - * Test code for getting mmc file system status. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt GetMmcFileSystemStatusL( CStifItemParser& aItem ); - - /** - * Test code for getting message center drive. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt GetMessageCentreDriveL( CStifItemParser& aItem ); - - /** - * Test code for creating Default MTM services. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt CreateDefaultMtmServiceL( CStifItemParser& aItem ); - - /** - * Test code for Getting CenRep key. . - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt GetCenRepKeyIntValueL( CStifItemParser& aItem ); - - /** - * Test code for Getting PubSub key. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt GetPubSubKeyIntValueL( CStifItemParser& aItem ); - - /** - * Test code for Creating outbox entry. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt CreateOutBoxEntryL( CStifItemParser& aItem ); - - /** - * Test code for removing outbox entry. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt RemoveOutBoxEntryL( CStifItemParser& aItem ); - - /** - * Test code for save received file to inbox. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt SaveObjToInboxL( CStifItemParser& aItem ); - - /** - * Test code for creating entry to inbox. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt CreateEntryToInboxL( CStifItemParser& aItem ); - - /** - * Test code for creating entry to inbox. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt SaveRFileObjectToInboxL( CStifItemParser& aItem ); - - /** - * Test code for removing entry to inbox. - * @since ?Series60_version - * @param aItem Script line containing parameters. - * @return Symbian OS error code. - */ - virtual TInt RemoveObjectL( CStifItemParser& aItem ); - - - - private: // Data - - - - TMsvId iMessageServerIndex; - CObexBufObject* iObexObject; - RFile iFile; - CBufFlat* iBuf; - CObexTestLogger* iTestLogger; - - }; - -#endif // OBEXSERVAPITEST_H - -// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/inc/testlogger.h --- a/tsrc/public/basic/obexservapitest/inc/testlogger.h Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* -* Copyright (c) 2007 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: -* -*/ - - -#ifndef BTTESTLOGGER_H -#define BTTESTLOGGER_H - -// INCLUDES -#include - -// FORWARD DECLARATIONS -class CStifLogger; -class CTestModuleIf; - -#define TLFUNCLOG (TUint8*) __FUNCTION__ - -// CLASS DECLARATION - -NONSHARABLE_CLASS( CObexTestLogger ) : public CBase -{ - public: - - static CObexTestLogger* NewL(const CTestModuleIf* aTestModuleIf); - virtual ~CObexTestLogger(); - - public: // Data used by functions - - enum TLogLevel {ETLError, ETLResult, ETLInfo, ETLDebug}; - - public: // New functions - - TBool GetEnabled() const; - CStifLogger* GetLogger() const; - const CTestModuleIf* GetTestModuleIf() const; - TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; - TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; - TInt Log(TLogLevel aLevel, TRefByValue aLogText, ...) const; - TInt Log(const TDesC& aCategory, TRefByValue aLogText, ...) const; - TInt LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const; - TInt LogNewLine() const; - void SetEnabled(TBool aEnabled); - void SetLogger(CStifLogger* aLog); - void SetTestModuleIf(const CTestModuleIf* aTestModuleIf); - - public: // Functions from base classes - - private: // New functions - - TInt WriteLog(TLogLevel aLevel, TDes16& aLog) const; - TInt WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const; - static TPtrC GetPrefix(TLogLevel aLevel); - TInt CheckLogFile(); - void LogHeadSectionL(); - void LogTimeStampL(TDes& aBuf, TBool aTime = ETrue) const; - - private: // Constructors - - CObexTestLogger(const CTestModuleIf* aTestModuleIf); - void ConstructL(); - - public: // Data - static const TInt KPrefixLength; - - private: // Data - - TBool iEnabled; - CStifLogger* iLog; - const CTestModuleIf* iTestModuleIf; - }; - -#endif // BTTESTLOGGER_H - diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/rom/obexservapitest.iby --- a/tsrc/public/basic/obexservapitest/rom/obexservapitest.iby Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* -* Copyright (c) 2007-2007 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: Image description file for project bteng -* -*/ - -#ifndef BTENGAPITEST_IBY -#define BTENGAPITEST_IBY - -#include - -file=ABI_DIR\BUILD_DIR\ObexServAPItest.dll SHARED_LIB_DIR\ObexServAPItest.dll - -#endif // BTENGAPITEST_IBY diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/src/ObexServAPItest.cpp --- a/tsrc/public/basic/obexservapitest/src/ObexServAPItest.cpp Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,145 +0,0 @@ -/* -* Copyright (c) 2002 - 2007 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: ?Description -* -*/ - - - -// INCLUDE FILES -#include -#include "ObexServAPItest.h" - -// EXTERNAL DATA STRUCTURES -//extern ?external_data; - -// EXTERNAL FUNCTION PROTOTYPES -//extern ?external_function( ?arg_type,?arg_type ); - -// CONSTANTS -//const ?type ?constant_var = ?constant; - -// MACROS -//#define ?macro ?macro_def - -// LOCAL CONSTANTS AND MACROS -//const ?type ?constant_var = ?constant; -//#define ?macro_name ?macro_def - -// MODULE DATA STRUCTURES -//enum ?declaration -//typedef ?declaration - -// LOCAL FUNCTION PROTOTYPES -//?type ?function_name( ?arg_type, ?arg_type ); - -// FORWARD DECLARATIONS -//class ?FORWARD_CLASSNAME; - -// ============================= LOCAL FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// ?function_name ?description. -// ?description -// Returns: ?value_1: ?description -// ?value_n: ?description_line1 -// ?description_line2 -// ----------------------------------------------------------------------------- -// -/* -?type ?function_name( - ?arg_type arg, // ?description - ?arg_type arg) // ?description - { - - ?code // ?comment - - // ?comment - ?code - } -*/ - -// ============================ MEMBER FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// CObexServAPItest::CObexServAPItest -// C++ default constructor can NOT contain any code, that -// might leave. -// ----------------------------------------------------------------------------- -// -CObexServAPItest::CObexServAPItest( - CTestModuleIf& aTestModuleIf ): - CScriptBase( aTestModuleIf ) - { - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::ConstructL -// Symbian 2nd phase constructor can leave. -// ----------------------------------------------------------------------------- -// -void CObexServAPItest::ConstructL() - { - - iTestLogger = CObexTestLogger::NewL( &TestModuleIf() ); - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::NewL -// Two-phased constructor. -// ----------------------------------------------------------------------------- -// -CObexServAPItest* CObexServAPItest::NewL( - CTestModuleIf& aTestModuleIf ) - { - CObexServAPItest* self = new (ELeave) CObexServAPItest( aTestModuleIf ); - - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop(); - - return self; - - } - -// Destructor -CObexServAPItest::~CObexServAPItest() - { - - // Delete resources allocated from test methods - Delete(); - - // Delete logger - delete iTestLogger; - iTestLogger = NULL; - } - -// ========================== OTHER EXPORTED FUNCTIONS ========================= - -// ----------------------------------------------------------------------------- -// LibEntryL is a polymorphic Dll entry point. -// Returns: CScriptBase: New CScriptBase derived object -// ----------------------------------------------------------------------------- -// -EXPORT_C CScriptBase* LibEntryL( - CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework - { - - return ( CScriptBase* ) CObexServAPItest::NewL( aTestModuleIf ); - - } - - -// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/src/ObexServAPItestBlocks.cpp --- a/tsrc/public/basic/obexservapitest/src/ObexServAPItestBlocks.cpp Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,412 +0,0 @@ -/* -* Copyright (c) 2002 - 2007 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: ?Description -* -*/ - - - -// INCLUDE FILES -#include -#include -#include -#include -#include -#include -#include -#include -#include "testlogger.h" -#include "ObexServAPItest.h" - - - -// ============================ MEMBER FUNCTIONS =============================== - -// ----------------------------------------------------------------------------- -// CObexServAPItest::Delete -// Delete here all resources allocated and opened from test methods. -// Called from destructor. -// ----------------------------------------------------------------------------- -// -void CObexServAPItest::Delete() - { - delete iObexObject; - iObexObject = NULL; - delete iBuf; - iBuf = NULL; - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::RunMethodL -// Run specified method. Contains also table of test mothods and their names. -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::RunMethodL( - CStifItemParser& aItem ) - { - - static TStifFunctionInfo const KFunctions[] = - { - // Copy this line for every implemented function. - // First string is the function name used in TestScripter script file. - // Second is the actual implementation member function. - ENTRY( "GetFileSystemStatus", CObexServAPItest::GetFileSystemStatusL ), - ENTRY( "GetMmcFileSystemStatus", CObexServAPItest::GetMmcFileSystemStatusL ), - ENTRY( "GetMessageCentreDriveL", CObexServAPItest::GetMessageCentreDriveL ), - ENTRY( "CreateDefaultMtmServiceL", CObexServAPItest::CreateDefaultMtmServiceL ), - ENTRY( "GetCenRepKeyIntValueL", CObexServAPItest::GetCenRepKeyIntValueL ), - ENTRY( "GetPubSubKeyIntValue", CObexServAPItest::GetPubSubKeyIntValueL ), - ENTRY( "CreateOutBoxEntry", CObexServAPItest::CreateOutBoxEntryL ), - ENTRY( "RemoveOutBoxEntry", CObexServAPItest::RemoveOutBoxEntryL ), - ENTRY( "SaveObjToInbox", CObexServAPItest::SaveObjToInboxL ), - ENTRY( "CreateEntryToInbox", CObexServAPItest::CreateEntryToInboxL ), - ENTRY( "SaveRFileObjectToInbox", CObexServAPItest::SaveRFileObjectToInboxL ), - ENTRY( "RemoveObjectFromInbox", CObexServAPItest::RemoveObjectL ), - }; - - const TInt count = sizeof( KFunctions ) / - sizeof( TStifFunctionInfo ); - - return RunInternalL( KFunctions, count, aItem ); - - } - - // ----------------------------------------------------------------------------- -// CBtApiTest::TestCompleted -// ----------------------------------------------------------------------------- -// -void CObexServAPItest::TestCompleted( TInt aErr, const TUint8* aFunc, const TDesC& aArg ) - { - iTestLogger->LogResult( (TPtrC8( aFunc )), aArg, aErr ); - Signal( aErr ); - } - - -// ----------------------------------------------------------------------------- -// CObexServAPItest::GetFileSystemStatusL -// Test code for getting file system status. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::GetFileSystemStatusL( CStifItemParser& /*aItem*/ ) - { - // Print to log file - TInt retVal=TObexUtilsMessageHandler::GetFileSystemStatus(); - if (retVal == 0 || retVal == KErrDiskFull) - { - TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); - } - else - { - TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); - } - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::GetMmcFileSystemStatusL -// Test code for getting mmc file system status. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::GetMmcFileSystemStatusL( CStifItemParser& /*aItem*/ ) - { - TInt retVal=TObexUtilsMessageHandler::GetMmcFileSystemStatus(); - if (retVal == 0 || retVal == KErrDiskFull) - { - TestCompleted( KErrNone, TLFUNCLOG, _L("GetFileSystemStatusL")); - } - else - { - TestCompleted( retVal, TLFUNCLOG, _L("Error getting files ystem status")); - } - - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::GetMessageCentreDriveL -// Test code for getting message center drive. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::GetMessageCentreDriveL( CStifItemParser& /*aItem*/ ) - { - - TInt retVal = TObexUtilsMessageHandler::GetMessageCentreDriveL(); - if (retVal >= 0 ) - { - TestCompleted( KErrNone, TLFUNCLOG, _L("GetMessageCentreDrive")); - } - else - { - TestCompleted( retVal, TLFUNCLOG, _L("GetMessageCentreDrive failed")); - } - - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::CreateDefaultMtmServiceL -// Test code for creating Default MTM services. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::CreateDefaultMtmServiceL( CStifItemParser& /*aItem*/ ) - { - - TRAPD(error, TObexUtilsMessageHandler::CreateDefaultMtmServiceL(KUidMsgTypeBt) ); - if (error == KErrNone) - { - TestCompleted( KErrNone, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); - } - else - { - TestCompleted( error, TLFUNCLOG, _L("CreateDefaultMtmServiceL")); - } - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::GetCenRepKeyIntValueL -// Test code for Getting CenRep key. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::GetCenRepKeyIntValueL( CStifItemParser& /*aItem*/ ) - { - TInt limit=0; - TInt error=0; - TRAPD(leaveVal, error = TObexUtilsMessageHandler::GetCenRepKeyIntValueL(KCRUidUiklaf, - KUikOODDiskCriticalThreshold, - limit)); - if( leaveVal != KErrNone ) - { - TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValueL leaves")); - } - else if (error == KErrNone) - { - TestCompleted( leaveVal, TLFUNCLOG, _L("GetCenRepKeyIntValue return error")); - } - else - { - TestCompleted( KErrNone, TLFUNCLOG, _L("GetCenRepKeyIntValueL")); - } - - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::GetPubSubKeyIntValueL -// Test code for Getting PubSub key. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::GetPubSubKeyIntValueL( CStifItemParser& /*aItem*/ ) - { - TInt status = KErrNone; - TInt retVal = KErrNone; - - TRAPD(leaveVal, retVal = TObexUtilsMessageHandler::GetPubSubKeyIntValue(KPSUidUikon, KUikFFSFreeLevel, status)); - - if( leaveVal != KErrNone ) - { - TestCompleted( leaveVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL leaves")); - } - else if (retVal == KErrNone) - { - TestCompleted( retVal, TLFUNCLOG, _L("GetPubSubKeyIntValueL return error")); - } - else - { - TestCompleted( KErrNone, TLFUNCLOG, _L("GetPubSubKeyIntValue")); - } - - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::OutBoxEntryL -// Test code for Creating outbox entry. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::CreateOutBoxEntryL( CStifItemParser& /*aItem*/ ) - { - TRAPD(error, iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( KUidMsgTypeBt, R_BT_SEND_OUTBOX_SENDING )); - if( error != KErrNone) - { - TestCompleted( error, TLFUNCLOG, _L("CreateOutBoxEntryL leaves")); - } - else - { - TestCompleted( KErrNone, TLFUNCLOG, _L("CreateOutBoxEntryL")); - } - - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::OutBoxEntryL -// Test code for removing outbox entry. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::RemoveOutBoxEntryL( CStifItemParser& /*aItem*/ ) - { - - TRAPD(error, TObexUtilsMessageHandler::DeleteOutboxEntryL( iMessageServerIndex )); - if( error != KErrNone) - { - TestCompleted( error, TLFUNCLOG, _L("RemoveOutBoxEntryL leaves")); - } - else - { - TestCompleted( KErrNone, TLFUNCLOG, _L("RemoveOutBoxEntryL")); - } - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::SaveObjToInboxL -// Test code for save received file to inbox. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::SaveObjToInboxL( CStifItemParser& /*aItem*/ ) - { - - CObexBufObject* obexobject = CObexBufObject::NewL( NULL ); - CleanupStack::PushL(obexobject); - - TRAP_IGNORE(TObexUtilsMessageHandler::SaveObjToInboxL(obexobject , - KNullDesC, - KUidMsgTypeBt )); - TestCompleted( KErrNone, TLFUNCLOG, _L("SaveObjToInboxL leaves")); - - CleanupStack::PopAndDestroy(obexobject); - return KErrNone; - - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::CreateAndSaveObjectL -// Test code for creating entry to inbox. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::CreateEntryToInboxL( CStifItemParser& /*aItem*/ ) - { - iFile = RFile(); - - if ( iObexObject) - { - delete iObexObject; - iObexObject = NULL; - } - - iObexObject = CObexBufObject::NewL( NULL ); - - TRAPD( error, TObexUtilsMessageHandler::CreateInboxAttachmentL( iObexObject, - KUidMsgTypeBt, - iMessageServerIndex, - iFile)); - - - iBuf = CBufFlat::NewL(1024); - iBuf->ResizeL(1024); - - TObexRFileBackedBuffer bufferdetails(*iBuf,iFile,CObexBufObject::EDoubleBuffering); - - TRAP_IGNORE( iObexObject->SetDataBufL( bufferdetails) ); - - - - iFile.Write(_L8("test")); - iObexObject->SetNameL(_L("test.txt")); - - if( error != KErrNone) - { - TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL leaves")); - } - else - { - TestCompleted( error, TLFUNCLOG, _L("CreateEntryToInboxL")); - } - return KErrNone; - } - - -// ----------------------------------------------------------------------------- -// CObexServAPItest::CreateAndSaveObjectL -// Test code for creating entry to inbox. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::SaveRFileObjectToInboxL( CStifItemParser& /*aItem*/ ) - { - TRAPD( error, TObexUtilsMessageHandler::SaveObjToInboxL( - iObexObject, - iFile, - iMessageServerIndex)); - - delete iBuf; - iBuf = NULL; - if( error != KErrNone) - { - TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); - } - else - { - TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); - } - - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// CObexServAPItest::RemoveObjectL -// Test code for removing entry to inbox. -// (other items were commented in a header). -// ----------------------------------------------------------------------------- -// -TInt CObexServAPItest::RemoveObjectL( CStifItemParser& /*aItem*/ ) - { - TRAPD(error,TObexUtilsMessageHandler::RemoveInboxEntriesL(iObexObject, iMessageServerIndex)); - delete iBuf; - iBuf = NULL; - if( error != KErrNone) - { - TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL leaves")); - } - else - { - TestCompleted( error, TLFUNCLOG, _L("SaveObjToInboxL")); - } - return KErrNone; - } - - -// ========================== OTHER EXPORTED FUNCTIONS ========================= -// None - -// End of File diff -r 0b192a3a05a4 -r 00f9ee97d895 tsrc/public/basic/obexservapitest/src/testlogger.cpp --- a/tsrc/public/basic/obexservapitest/src/testlogger.cpp Tue Feb 02 00:20:42 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,530 +0,0 @@ -/* -* Copyright (c) 2007 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: -* -*/ - -// INCLUDES - -#include "testlogger.h" - -#include -#include - -#include -#include -#include - -// RDebug -#include - -const TInt CObexTestLogger::KPrefixLength = 8; -// Timestamp string length -const TInt KTimeStampStrLen = 21; -// Extended Timestamp string length -const TInt KExtTimeStampStrLen = 40; -// Extended time stamp -typedef TBuf TExtTimeStamp; -// Logging path -_LIT( KObexServAPITestSystemLogPath, "e:\\logs\\ObexServAPItest\\" ); -// Log file -_LIT( KObexServAPITestSystemLogFile, "ObexServAPItest.html" ); -// Log file -_LIT( KObexServAPITestSystemLogFullName, "\\logs\\ObexServAPItest\\ObexServAPItest%x.html" ); -// Time stamp format string -_LIT( KFormatTimeStamp, "
[%H:%T:%S.%*C4] " ); -// Date format string -_LIT( KFormatDate, "%F%D %N %Y" ); -// HTML header section -_LIT( KHtmlHeadSection, "\n\nObex Message Handler Test System results\n\n\n\n\n\n" ); -// HTML code which will display the statistics -_LIT( KHtmlStatSection, "

Logfile created on %S at %S
\nS60 version %S

\n\n
\n
\n\n" ); -// HTML identifier for test case start -_LIT( KHtmlTestCaseStart, "
" ); -// Test case result logging -_LIT( KTestCaseResult, "Test completed; function %S, parameter %S, result
%d
" ); -// JavaScript function for calculating test result -#define KJSSECTION _L( "" ) - -// Construction and destruction. - -// ----------------------------------------------------------------------------- -// CObexTestLogger::NewL -// Static constructor to constructor builder objects. -// ----------------------------------------------------------------------------- -// -CObexTestLogger* CObexTestLogger::NewL(const CTestModuleIf* aTestModuleIf) - { - CObexTestLogger* self = new (ELeave) CObexTestLogger(aTestModuleIf); - - CleanupStack::PushL( self ); - self->ConstructL(); - CleanupStack::Pop(self); - - return self; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::CObexTestLogger -// Constructor. -// ----------------------------------------------------------------------------- -// -CObexTestLogger::CObexTestLogger(const CTestModuleIf* aTestModuleIf) - : CBase(), - iEnabled(ETrue), - iTestModuleIf(aTestModuleIf) - { - } - -// ----------------------------------------------------------------------------- -// CTestLogger::ConstructL -// 2nd phase constructor. -// ----------------------------------------------------------------------------- -// -void CObexTestLogger::ConstructL() - { - TInt err = CheckLogFile(); - iLog = CStifLogger::NewL( KObexServAPITestSystemLogPath, KObexServAPITestSystemLogFile, - CStifLogger::ETxt, CStifLogger::EFile, EFalse, EFalse ); - if( err == KErrNotFound ) - { // Add info & HTML markup to the beginning of the log file. - LogHeadSectionL(); - } - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::~CObexTestLogger -// Destructor. -// ----------------------------------------------------------------------------- -// -CObexTestLogger::~CObexTestLogger() - { - delete iLog; - } - -// Member functions. - -// ----------------------------------------------------------------------------- -// CObexTestLogger::GetLogger -// Returns a pointer to current STIF logger. -// ----------------------------------------------------------------------------- -// -CStifLogger* CObexTestLogger::GetLogger() const - { - return iLog; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::GetTestModuleIf -// Returns a pointer to current STIF test module interface. -// ----------------------------------------------------------------------------- -// -const CTestModuleIf* CObexTestLogger::GetTestModuleIf() const - { - return iTestModuleIf; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::Log -// Logs 8 bit data to screen and file. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const - { - if (!iEnabled) - { - return KErrNone; - } - - const TDesC8& actualData = aLogText; - - // Check that user does not try to output too much data. - if (actualData.Length() > KMaxLogData - KPrefixLength) - { - return KErrTooBig; - } - - // Buffer to convert 8 bit data to to 16 bit. - TLogInfo8 converter; - - // Create variable argument list. - VA_LIST args; - VA_START(args, aLogText); - - // Format the argument list to the output buffer. - converter.FormatList( aLogText, args ); - - // Free the variable argument list - VA_END(args); - - TLogInfo buffer; - buffer.Copy( converter ); - - // Append log prefix to the output buffer. - buffer.Insert( 0, GetPrefix( aLevel ) ); - - // Log a timestamp - TTimeStamp8 time; - TRAP_IGNORE( LogTimeStampL( time ) ); - buffer.Insert( 0, time ); - - // Write log. - return WriteLog(aLevel, buffer); - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::Log -// Logs 8 bit data to screen and file. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const - { - if (!iEnabled) - { - return KErrNone; - } - - const TDesC8& actualData = aLogText; - - // Check that user does not try to output too much data. - if (actualData.Length() > KMaxLogData - KPrefixLength) - { - return KErrTooBig; - } - - // Buffer to convert 8 bit data to to 16 bit. - TLogInfo8 converter; - - // Create variable argument list. - VA_LIST args; - VA_START(args, aLogText); - - // Format the argument list to the output buffer. - converter.FormatList(aLogText, args); - - // Free the variable argument list - VA_END(args); - - TLogInfo buffer; - buffer.Copy( converter ); - - // Log a timestamp - TTimeStamp8 time; - TRAP_IGNORE( LogTimeStampL( time ) ); - buffer.Insert( 0, time ); - - // Write log. - return WriteLog(aCategory, buffer); - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::Log -// Logs 16 bit data to screen and file. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::Log(TLogLevel aLevel, TRefByValue aLogText, ...) const - { - if (!iEnabled) - { - return KErrNone; - } - - const TDesC16& actualData = aLogText; - // Check that user does not try to output too much data. - if (actualData.Length() + KPrefixLength > KMaxLogData) - { - return KErrTooBig; - } - - TLogInfo buffer; - - // Log a timestamp - TRAP_IGNORE( LogTimeStampL( buffer ) ); - - // Create variable argument list. - VA_LIST args; - VA_START(args, aLogText); - - // Format the argument list to the output buffer. - buffer.AppendFormatList(aLogText, args); - - // Free the variable argument list - VA_END(args); - - // Write log. - return WriteLog(aLevel, buffer); - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::Log -// Logs 16 bit data to screen and file. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::Log(const TDesC& aCategory, TRefByValue aLogText, ...) const - { - if (!iEnabled) - { - return KErrNone; - } - - const TDesC16& actualData = aLogText; - // Check that user does not try to output too much data. - if (actualData.Length() + KPrefixLength > KMaxLogData) - { - return KErrTooBig; - } - - TLogInfo buffer; - - // Log a timestamp - TRAP_IGNORE( LogTimeStampL( buffer ) ); - - // Create variable argument list. - VA_LIST args; - VA_START(args, aLogText); - - // Format the argument list to the output buffer. - buffer.AppendFormatList(aLogText, args); - - // Free the variable argument list - VA_END(args); - - // Write log. - return WriteLog(aCategory, buffer); - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::LogNewLine -// Logs an HTML newline and timestamp. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::LogResult( const TDesC8& aFunc, const TDesC& aArg, TInt aRes ) const - { - TExtTimeStamp func; - func.Copy( aFunc ); // Copy 8-bit string to 16-bit buffer - - Log( CObexTestLogger::ETLResult, KTestCaseResult, &func, &aArg, aRes ); - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::LogNewLine -// Logs an HTML newline and timestamp. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::LogNewLine() const - { - if (!iEnabled) - { - return KErrNone; - } - TExtTimeStamp time; - TRAPD( err, LogTimeStampL( time ) ); - if( !err ) - { - time.Insert( 0, KHtmlTestCaseStart ); - err = iLog->Log( time ); - } - return err; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::SetEnabled -// Returns a pointer to current STIF logger. -// ----------------------------------------------------------------------------- -// -void CObexTestLogger::SetEnabled(TBool aEnabled) - { - iEnabled = aEnabled; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::SetLogger -// Sets a pointer to current STIF logger. -// ----------------------------------------------------------------------------- -// -void CObexTestLogger::SetLogger(CStifLogger* aLog) - { - iLog = aLog; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::SetTestModuleIf -// Sets a pointer to current STIF test module. -// ----------------------------------------------------------------------------- -// -void CObexTestLogger::SetTestModuleIf(const CTestModuleIf* aTestModuleIf) - { - iTestModuleIf = aTestModuleIf; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::WriteLog -// Writes log. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::WriteLog(TLogLevel aLevel, TDes16& aLog) const - { - // Write log to file if file logger is available. - if (iLog != 0) - { - iLog->Log(aLog); - } - // Remove the timestamp from the logging data. - TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); - - // Write log with RDebug. - RDebug::Print(log); - - // Write log to screen if test module interface is available. - if (iTestModuleIf != 0) - { - CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); - nonStaticLogger->Printf(aLevel, _L(""), log); - } - - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::WriteLog -// Writes log. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::WriteLog(const TDesC16& aCategory, const TDesC16& aLog) const - { - // Write log to file if file logger is available. - if (iLog != 0) - { - iLog->Log(aLog); - } - // Remove the timestamp from the logging data. - TPtrC16 log( aLog.Mid( KTimeStampStrLen ) ); - - // Write log with RDebug. - RDebug::Print(log); - - // Write log to screen if test module interface is available. - if (iTestModuleIf != 0) - { - CTestModuleIf* nonStaticLogger = const_cast(iTestModuleIf); - nonStaticLogger->Printf(0, aCategory, log); - } - - return KErrNone; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::GetPrefix -// Returns the prefix for a given logging level. -// ----------------------------------------------------------------------------- -// -TPtrC CObexTestLogger::GetPrefix(TLogLevel aLevel) - { - // Select a prefix for a log level and return a pointer to it. - switch(aLevel) - { - case ETLError: - { - TPtrC logPrefix = _L("ERROR : "); - return logPrefix; - } - case ETLInfo: - case ETLResult: - { - TPtrC logPrefix = _L("INFO : "); - return logPrefix; - } - case ETLDebug: - { - TPtrC logPrefix = _L("DEBUG : "); - return logPrefix; - } - default: - { - // Return a null pointer. - return TPtrC(); - } - - } - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::CheckLogFile -// Check if a log file is already existing, otherwise HTML formatting -// should be added. -// ----------------------------------------------------------------------------- -// -TInt CObexTestLogger::CheckLogFile() - { - RThread thread; - TInt id = thread.Id(); - TBuf file; - file.Format( KObexServAPITestSystemLogFullName, id ); - RFs fs; - TInt err = fs.Connect(); - TBool open = EFalse; - if( !err ) - { - err = fs.IsFileOpen( file, open ); - } - fs.Close(); - return err; - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::LogTimeStamp -// Log HTML head section and general information in a newly created logfile. -// ----------------------------------------------------------------------------- -// -void CObexTestLogger::LogHeadSectionL() - { - iLog->Log( KHtmlHeadSection ); - iLog->Log( KJSSECTION ); - TBuf version( _L( "Version unknown!" ) ); - (void) SysUtil::GetSWVersion( version ); - TTimeStamp8 date; - LogTimeStampL( date, EFalse ); - TTimeStamp8 time; - LogTimeStampL( time ); - TPtrC timePtr( time.Mid( 6, 13 ) ); - iLog->Log( KHtmlStatSection, &date, &timePtr, &version ); - } - -// ----------------------------------------------------------------------------- -// CObexTestLogger::LogTimeStamp -// Format a timestamp for logging. -// If aTime is set to false, the (formatted) date is returned. -// ----------------------------------------------------------------------------- -// -void CObexTestLogger::LogTimeStampL(TDes& aBuf, TBool aTime) const - { - TTime time; - time.HomeTime(); // Get time and format it - if( aTime ) - { - time.FormatL( aBuf, KFormatTimeStamp ); - } - else - { - time.FormatL( aBuf, KFormatDate ); - } - }