Revision: 201003 PDK_3.0.g
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 00:45:58 +0200
changeset 1 388a17646e40
parent 0 c3e98f10fcf4
child 5 11d83199e2d9
child 6 15c5de4f0ae2
child 13 0feebc799606
Revision: 201003 Kit: 201005
localconnectivityservice/group/bld.inf
localconnectivityservice/lcstylustap/tsrc/LcStylusTapTest/conf/ui_LcStylusTapTest.cfg
localconnectivityservice/modematplugin/group/bld.inf
localconnectivityservice/modematplugin/group/modematplugin.mmp
localconnectivityservice/modematplugin/inc/atcopscmd.h
localconnectivityservice/modematplugin/inc/cmdpluginobserver.h
localconnectivityservice/modematplugin/inc/debug.h
localconnectivityservice/modematplugin/inc/debugconfig.h
localconnectivityservice/modematplugin/inc/modematplugin.h
localconnectivityservice/modematplugin/inc/prjconfig.h
localconnectivityservice/modematplugin/rom/modematplugin.iby
localconnectivityservice/modematplugin/src/20029fbf.rss
localconnectivityservice/modematplugin/src/atcopscmd.cpp
localconnectivityservice/modematplugin/src/modematplugin.cpp
localconnectivityservice/modematplugin/src/proxy.cpp
localconnectivityservice/obexreceiveservices/bip/inc/BIPController.h
localconnectivityservice/obexreceiveservices/bip/src/BIPController.cpp
localconnectivityservice/obexreceiveservices/opp/inc/oppcontroller.h
localconnectivityservice/obexreceiveservices/opp/src/oppcontroller.cpp
localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTSBPPController.h
localconnectivityservice/obexsendservices/obexservicesendutils/src/BTSBPPController.cpp
localconnectivityservice/obexserviceman/obexservicemanserver/inc/SrcsServiceManager.h
localconnectivityservice/obexserviceman/obexservicemanserver/src/SrcsServiceManager.cpp
localconnectivityservice/obexserviceman/utils/bwins/OBEXUTILSU.DEF
localconnectivityservice/obexserviceman/utils/eabi/obexutilsu.DEF
localconnectivityservice/obexserviceman/utils/src/obexutilsdialog.cpp
localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp
localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp
localconnectivityservice/obexserviceman/utils/src/obexutilsuilayer.cpp
shortlinkconn_plat/obex_service_utils_api/inc/obexutilsmessagehandler.h
--- a/localconnectivityservice/group/bld.inf	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/group/bld.inf	Tue Feb 02 00:45:58 2010 +0200
@@ -27,6 +27,7 @@
 #include "../lccustomplugin/group/bld.inf"
 #include "../lcstylustap/group/bld.inf"
 #include "../legacymodemplugin/group/bld.inf"
+#include "../modematplugin/group/bld.inf"
 #include "../generichid/group/bld.inf"
 #include "../headset/group/bld.inf"
 
--- a/localconnectivityservice/lcstylustap/tsrc/LcStylusTapTest/conf/ui_LcStylusTapTest.cfg	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/lcstylustap/tsrc/LcStylusTapTest/conf/ui_LcStylusTapTest.cfg	Tue Feb 02 00:45:58 2010 +0200
@@ -2,9 +2,9 @@
 * 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 the License "Symbian Foundation License v1.0"
+* under the terms of the License "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
-* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/group/bld.inf	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../rom/modematplugin.iby         CORE_MW_LAYER_IBY_EXPORT_PATH(modematplugin.iby)
+
+PRJ_MMPFILES
+modematplugin.mmp
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/group/modematplugin.mmp	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <platform_paths.hrh>
+
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/inc/atcopscmd.h	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <e32base.h>
+#include <e32cmn.h>
+#include <RMmCustomAPI.h>
+#include <etelpckt.h>
+#include <etelmm.h>
+#include <mmretrieve.h>
+#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 (<cr>) 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 <cr><lf><result code><cr><lf>
+     *
+     * 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 (<cr>) 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<KMaxOperatorNameLength>& 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<HBufC8> 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/inc/cmdpluginobserver.h	Tue Feb 02 00:45:58 2010 +0200
@@ -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<HBufC8>& 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/inc/debug.h	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <e32base.h>
+#include "debugconfig.h"
+
+#ifdef PRJ_ENABLE_TRACE
+
+#ifdef PRJ_FILE_TRACE
+#include <flogger.h>
+#else
+#include <e32debug.h>
+#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<const TDesC16> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TBuf16<KMaxLogLineLength> theFinalString;
+    theFinalString.Append(KTracePrefix16);
+    TOverflowTruncate16 overflow;
+    theFinalString.AppendFormatList(aFmt,list,&overflow);
+    RDebug::Print(theFinalString);
+#endif
+    }
+
+inline void Trace(TRefByValue<const TDesC8> aFmt, ...)
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+#ifdef PRJ_FILE_TRACE
+    RFileLogger::WriteFormat(KLogDir, KLogFile, EFileLoggingModeAppend, aFmt, list);
+#else
+    TOverflowTruncate8 overflow;
+    TBuf8<KMaxLogLineLength> buf8;
+    buf8.Append(KTracePrefix8);
+    buf8.AppendFormatList(aFmt, list, &overflow);
+    TBuf16<KMaxLogLineLength> buf16(buf8.Length());
+    buf16.Copy(buf8);
+    TRefByValue<const TDesC> 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<KMaxLogLineLength> 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<KMaxLogLineLength> 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<void>(User::LeaveIfError(REASON));}
+
+#define LEAVE_IF_NULL(PTR) {static_cast<void>(User::LeaveIfNull(PTR));}
+
+#define LEAVE(REASON) {static_cast<void>(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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/inc/debugconfig.h	Tue Feb 02 00:45:58 2010 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/inc/modematplugin.h	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <atextpluginbase.h>
+#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 (<cr>) 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 <cr><lf><result code><cr><lf>
+     *
+     * 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 (<cr>) 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 (<cr>) 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 <cr><lf><result code><cr><lf>
+     *
+     * 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 (<cr>) 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<HBufC8>& 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<CATCommandHandlerBase> 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/inc/prjconfig.h	Tue Feb 02 00:45:58 2010 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/rom/modematplugin.iby	Tue Feb 02 00:45:58 2010 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/src/20029fbf.rss	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <registryinfo.rh>
+
+// 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 = "";
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/src/atcopscmd.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -0,0 +1,1109 @@
+/*
+* 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 <MmTsy_names.h>
+#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, <format>, 
+<oper> 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<TNetworkRegistrationMode>(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<TAccessTechnology>(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<KMaxOperatorNameLength>& 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(); 
+	    }
+    // 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: 
+            // 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<KMaxOperatorNameLength> 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
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/src/modematplugin.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -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; i<count; i++ )
+        {
+        CATCommandHandlerBase* handler = iHandlers[i]; 
+        TBool supported = handler->IsCommandSupported( 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<KErrorReplyLength> 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<HBufC8>& 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;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/modematplugin/src/proxy.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -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 <e32base.h>
+#include <ECom\ImplementationProxy.h>
+#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
--- a/localconnectivityservice/obexreceiveservices/bip/inc/BIPController.h	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexreceiveservices/bip/inc/BIPController.h	Tue Feb 02 00:45:58 2010 +0200
@@ -104,7 +104,6 @@
     inline TBool ReceivingIndicatorActive() const { return (iProgressDialog || iWaitDialog); }
     void UpdateReceivingIndicator();
     void CloseReceivingIndicator(TBool aResetDisplayedState = ETrue);
-    void ShowFileReceivedQueryL();
     TInt GetDriveWithMaximumFreeSpaceL();
     
 private:
@@ -146,7 +145,6 @@
     CBTDeviceArray*             iResultArray;
     TBTDeviceName               iRemoteDeviceName;
     TFileName                   iReceivingFileName;
-    RArray<TMsvId>              iMsvIdArray;
     TFileName                   iCenRepFolder;
     };
     
--- a/localconnectivityservice/obexreceiveservices/bip/src/BIPController.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexreceiveservices/bip/src/BIPController.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -191,7 +191,6 @@
     iFile = RFile();
     iFullPathFilename.Zero();
     iCapabilityFileName.Zero();
-    iMsvIdArray.Reset(); 
     }
 
 // ---------------------------------------------------------
@@ -236,7 +235,11 @@
 void CBIPController::TransportDownIndication()
     {
     TRACE_FUNC   
-    TRAP_IGNORE(ShowFileReceivedQueryL());
+    // Remove receiving buffer and files used during file receiving.
+    //
+    delete iBTObject;
+    iBTObject = NULL;
+    TRAP_IGNORE(TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename));  
     iFs.Close();
     }
 
@@ -566,7 +569,7 @@
                                                                    iRemoteDeviceName));
     if ( retVal == KErrNone)
         {
-        TRAP (retVal, TObexUtilsMessageHandler::AddEntryToInboxL(iMsvIdParent, iFullPathFilename, &iMsvIdArray));
+        TRAP (retVal, TObexUtilsMessageHandler::AddEntryToInboxL(iMsvIdParent, iFullPathFilename));
         }
     
     
@@ -808,55 +811,6 @@
     }
  
  // ---------------------------------------------------------
- // ShowFileReceivedQuery()
- // ---------------------------------------------------------
- // 
- void CBIPController::ShowFileReceivedQueryL()
-     {
-     // Remove receiving buffer and files used during file receiving.
-     //
-    delete iBTObject;
-    iBTObject = NULL;
-    TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename);    
-    
-    TInt fileCount = iMsvIdArray.Count();         
-    if ( fileCount )
-        {
-        TBool answer = EFalse;        
-        TInt resourceID = R_BT_SAVED_SINGLE;
-        if( fileCount > 1)
-            {
-            resourceID = R_BT_SAVED_MULTIPLE;
-            }
-        answer = TObexUtilsUiLayer::ShowGlobalFileOpenConfirmationQueryL(resourceID, iDefaultFolder);
-        
-        TInt sortMethod = 2; // 0 = by name 1 = by type 2 = most recent file and 3 = largest file
-        
-        if ( answer && fileCount == 1 )  // User accepts the query
-            {
-            TRAPD( error,  TObexUtilsUiLayer::LaunchEditorApplicationL(iMsvIdArray[0]));
-            if ( error != KErrNone )  // file is unsupported
-                {
-                TObexUtilsUiLayer::LaunchFileManagerL(iFullPathFilename,
-                                                      sortMethod,
-                                                      EFalse);  // EFalse -> start file manager in standalone mode
-                }
-            }
-        
-        if ( answer && fileCount > 1 )
-            {
-            // we open the file manager at default folder
-            //
-            TObexUtilsUiLayer::LaunchFileManagerL(iFullPathFilename,
-                                                      sortMethod,
-                                                      EFalse);  // EFalse -> start file manager in standalone mode
-            }
-        iMsvIdArray.Reset();
-        }
-    }
- 
- 
- // ---------------------------------------------------------
  // GetDriveWithMaximumFreeSpace()
  // ---------------------------------------------------------
  // 
--- a/localconnectivityservice/obexreceiveservices/opp/inc/oppcontroller.h	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexreceiveservices/opp/inc/oppcontroller.h	Tue Feb 02 00:45:58 2010 +0200
@@ -99,7 +99,6 @@
     inline TBool ReceivingIndicatorActive() const { return (iProgressDialog || iWaitDialog); }
     void UpdateReceivingIndicator();
     void CloseReceivingIndicator(TBool aResetDisplayedState = ETrue);
-    void ShowFileReceivedQueryL();
     TInt GetDriveWithMaximumFreeSpaceL();    
 
 private:
@@ -136,7 +135,6 @@
     CGlobalProgressDialog*      iProgressDialog;
     CGlobalDialog*              iWaitDialog;
     TBool                       iNoteDisplayed;
-    RArray<TMsvId>              iMsvIdArray;
     CBTEngDevMan*               iDevMan;
     CBTDeviceArray*             iResultArray;
     TBTDeviceName               iRemoteDeviceName;
--- a/localconnectivityservice/obexreceiveservices/opp/src/oppcontroller.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexreceiveservices/opp/src/oppcontroller.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -155,7 +155,6 @@
 
     iFile = RFile();
     iFullPathFilename.Zero();
-    iMsvIdArray.Reset();  
 	}
 
 // ---------------------------------------------------------
@@ -205,7 +204,11 @@
 void COPPController::TransportDownIndication()
     {
     TRACE_FUNC
-    TRAP_IGNORE(ShowFileReceivedQueryL());
+    // Remove receiving buffer and files used during file receiving.
+    //
+    delete iObexObject;
+    iObexObject = NULL;
+    TRAP_IGNORE(TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename)); 
     iFs.Close();
     }
 
@@ -516,7 +519,7 @@
 	TRACE_ASSERT( iMediaType!=ESrcsMediaIrDA, KErrNotSupported);
 	if ( retVal == KErrNone)
 	    {
-	    TRAP (retVal, TObexUtilsMessageHandler::AddEntryToInboxL(iMsvIdParent, iFullPathFilename, &iMsvIdArray));		    
+	    TRAP (retVal, TObexUtilsMessageHandler::AddEntryToInboxL(iMsvIdParent, iFullPathFilename));		    
                 
     if( retVal != KErrNone )
         {
@@ -769,55 +772,6 @@
     }
 
  // ---------------------------------------------------------
- // ShowFileReceivedQuery()
- // ---------------------------------------------------------
- // 
- void COPPController::ShowFileReceivedQueryL()
-     {
-     // Remove receiving buffer and files used during file receiving.
-     //
-    delete iObexObject;
-    iObexObject = NULL;
-    TObexUtilsMessageHandler::RemoveTemporaryRFileL (iFullPathFilename);    
-    
-    TInt fileCount = iMsvIdArray.Count();     
-    if ( fileCount )
-        {
-        TBool answer = EFalse;        
-        TInt resourceID = R_BT_SAVED_SINGLE;
-        if( fileCount > 1)
-            {
-            resourceID = R_BT_SAVED_MULTIPLE;
-            }
-        answer = TObexUtilsUiLayer::ShowGlobalFileOpenConfirmationQueryL(resourceID, iDefaultFolder);
-        
-        TInt sortMethod = 2; // 0 = 'By name' 1 = 'By type' 2 = 'Most recent first' and 3 = 'Largest first'
-        
-         if ( answer && fileCount == 1 )  // User accepts the query
-            {
-            TRAPD( error, TObexUtilsUiLayer::LaunchEditorApplicationL(iMsvIdArray[0]));
-            if ( error != KErrNone )  // File is not supported
-                {
-                TObexUtilsUiLayer::LaunchFileManagerL(iFullPathFilename,
-                                                             sortMethod,
-                                                             EFalse);  // EFalse -> start file manager in standalone mode
-                }         
-            }
-        
-        if ( answer && fileCount > 1 )
-            {
-            // We open the file manager at default folder
-            //
-            TObexUtilsUiLayer::LaunchFileManagerL(iFullPathFilename,
-                                                         sortMethod,
-                                                         EFalse);  // EFalse -> start file manager in standalone mode
-            }
-        iMsvIdArray.Reset();
-        }
-    
-    }
-
- // ---------------------------------------------------------
   // GetDriveWithMaximumFreeSpace()
   // ---------------------------------------------------------
   // 
--- a/localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTSBPPController.h	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTSBPPController.h	Tue Feb 02 00:45:58 2010 +0200
@@ -162,6 +162,8 @@
 
     private:    // Data
         
+        // Owned
+        //
         CBTSBPPObjectServer*        iServer;
         CBTSBPPServerWait*          iServerWait;
 
--- a/localconnectivityservice/obexsendservices/obexservicesendutils/src/BTSBPPController.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexsendservices/obexservicesendutils/src/BTSBPPController.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -109,9 +109,16 @@
 // Destructor
 CBTSBPPController::~CBTSBPPController()
     {
-    delete iClient;
-    delete iServer;
-    delete iServerWait;
+    if ( iServer )
+        {
+        delete iServer;
+        iServer = NULL;
+        }
+    if ( iServerWait )
+        {            
+        delete iServerWait;
+        iServerWait = NULL;
+        }
     }
 
 
@@ -311,8 +318,11 @@
     // For some reason the printer didn't establish server connection although
     // there were referenced objects
     //
-    delete iServerWait;
-    iServerWait = NULL;
+    if ( iServerWait )
+        {   
+        delete iServerWait;
+        iServerWait = NULL;
+        }
 
     // The client was waiting for server, but now another object 
     // can be sent.
--- a/localconnectivityservice/obexserviceman/obexservicemanserver/inc/SrcsServiceManager.h	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/obexservicemanserver/inc/SrcsServiceManager.h	Tue Feb 02 00:45:58 2010 +0200
@@ -133,7 +133,13 @@
     * @since    S60 v3.2
     */
     void DoCancel();    
-	
+
+    /**
+    * Handling of Service array 
+    * 
+    */	
+    void ServiceArray(CArrayPtr<CSrcsTransport> &aTransport, TBool aState);
+    
 private:
 
    /**
@@ -143,11 +149,12 @@
     
     CArrayPtr<CSrcsTransport>*		iBTConnectionArray;		// array of BT Connections
     CArrayPtr<CSrcsTransport>*		iUSBConnectionArray;	// array of USB Connections
-	CArrayPtr<CSrcsTransport>*		iIrDAConnectionArray;	// array of IrDA Connections	
-	MObexSMRequestObserver*         iRequestObserver;		
-	MObexSMRequestObserver*         iObserver; 
+    CArrayPtr<CSrcsTransport>*		iIrDAConnectionArray;	// array of IrDA Connections
+    MObexSMRequestObserver*         iRequestObserver;	
+    MObexSMRequestObserver*         iObserver; 
     RMessage2                       iMessage;
     TInt                            iErrorState;
+    TPtrC8                          iTransportName;     // Service name
     };
 #endif      // SRCSSERVICEMANAGER_H
 
--- a/localconnectivityservice/obexserviceman/obexservicemanserver/src/SrcsServiceManager.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/obexservicemanserver/src/SrcsServiceManager.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -177,36 +177,46 @@
 void CSrcsServiceManager::RealDoManageServiceL(TSrcsTransport aTransport, TBool aState)
     {    
     FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RealDoManageServiceL"));
-    CArrayPtr<CSrcsTransport>* connectionArray=NULL;
-    TPtrC8 transportName;
 
     switch(aTransport)
         {
     case ESrcsTransportBT:
-	    FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Bluetooth)"));
-        transportName.Set(KSrcsTransportBT);
-        connectionArray = iBTConnectionArray;
+        FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Bluetooth)"));
+        iTransportName.Set(KSrcsTransportBT);
+        ServiceArray(*iBTConnectionArray, aState);
         break;
     case ESrcsTransportUSB:
-	    FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(USB)"));
-        transportName.Set(KSrcsTransportUSB);
-        connectionArray = iUSBConnectionArray;        
+        FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(USB)"));
+        iTransportName.Set(KSrcsTransportUSB);
+        ServiceArray(*iUSBConnectionArray, aState);
         break;
     case ESrcsTransportIrDA:
-	    FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(IrDA)"));
-        transportName.Set(KSrcsTransportIrDA);
-        connectionArray = iIrDAConnectionArray;
+        FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(IrDA)"));
+        iTransportName.Set(KSrcsTransportIrDA);
+        ServiceArray(*iIrDAConnectionArray, aState);
         break;
     default:
         FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL. Transport not supported.")));
-        iErrorState = KErrNotSupported;              
+        User::Leave(KErrNotSupported);              
         }
+        
+    }
+
+// ---------------------------------------------------------
+// CSrcsServiceManager
+// Method to manage Service arrays
+// ---------------------------------------------------------
+//     
+void CSrcsServiceManager::ServiceArray(CArrayPtr<CSrcsTransport> &aTransport, TBool aState)
+    {
+    FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ServiceArray"));
+
     // We start and stop services by aState value
     if ( aState ) // trun on service
         {
 	    FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Turn ON)"));
         // We do not re-start services if they have been started        
-        if ( connectionArray && !(connectionArray->Count()) )
+        if (!(aTransport.Count()))
             {   			
 			//Declare array of service controllers
             RImplInfoPtrArray infoArrayServiceController;                        
@@ -219,7 +229,7 @@
 
             //List all SRCS transport plugin implementations
             FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL about to list Transport Impl"));
-            CSrcsTransport::ListImplementationsL(transportName,infoArrayTranport);
+            CSrcsTransport::ListImplementationsL(iTransportName,infoArrayTranport);
 
 			//Found SRCS transport plugin. Then start to enumerate service controller and make connections.
             if(infoArrayTranport.Count())
@@ -233,7 +243,7 @@
                 FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL. Using Transport ImplementationUid %x"), infoArrayTranport[0]->ImplementationUid()));
 
 				//enumerate service controllers
-                CSrcsInterface::ListImplementationsL(transportName,infoArrayServiceController);
+                CSrcsInterface::ListImplementationsL(iTransportName,infoArrayServiceController);
 
                 // Loop through each found service controller, 
                 // create SRCS transport connection for each found service controller
@@ -255,7 +265,7 @@
                     else
                         {
                         // Add this connection to the list
-                        connectionArray->AppendL(cm);
+                        aTransport.AppendL(cm);
                         FTRACE(FPrint(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL: Implementation created successfully.")));
                         }
                     }
@@ -274,8 +284,8 @@
         }
     else // turn off service
         {
-	    FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Turn OFF)"));          	        
-        connectionArray->ResetAndDestroy();                 
+        FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: ManageServicesL(Turn OFF)"));    	        
+        aTransport.ResetAndDestroy();                 
         }        
     FLOG(_L("[SRCS]\tserver\tCSrcsServiceManager: RealDoManageServiceL exit"));
     }    
--- a/localconnectivityservice/obexserviceman/utils/bwins/OBEXUTILSU.DEF	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/utils/bwins/OBEXUTILSU.DEF	Tue Feb 02 00:45:58 2010 +0200
@@ -57,4 +57,5 @@
 	?RemoveTemporaryRFileL@TObexUtilsMessageHandler@@SAXABV?$TBuf@$0BAA@@@@Z @ 56 NONAME ; void TObexUtilsMessageHandler::RemoveTemporaryRFileL(class TBuf<256> const &)
 	?LaunchFileManagerL@TObexUtilsUiLayer@@SAXAAVTDesC16@@HH@Z @ 57 NONAME ; void TObexUtilsUiLayer::LaunchFileManagerL(class TDesC16 &, int, int)
 	?SaveFileToFileSystemL@TObexUtilsMessageHandler@@SAXAAPAVCObexBufObject@@VTUid@@AAJAAV?$TBuf@$0BAA@@@AAVRFile@@ABVTDesC16@@@Z @ 58 NONAME ; void TObexUtilsMessageHandler::SaveFileToFileSystemL(class CObexBufObject * &, class TUid, long &, class TBuf<256> &, class RFile &, class TDesC16 const &)
+	?AddEntryToInboxL@TObexUtilsMessageHandler@@SAXAAJAAV?$TBuf@$0BAA@@@@Z @ 59 NONAME ; void TObexUtilsMessageHandler::AddEntryToInboxL(long &, class TBuf<256> &)
 
--- a/localconnectivityservice/obexserviceman/utils/eabi/obexutilsu.DEF	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/utils/eabi/obexutilsu.DEF	Tue Feb 02 00:45:58 2010 +0200
@@ -59,4 +59,5 @@
 	_ZN17TObexUtilsUiLayer36ShowGlobalFileOpenConfirmationQueryLERKiRK7TDesC16 @ 58 NONAME
 	_ZN24TObexUtilsMessageHandler16AddEntryToInboxLERlR4TBufILi256EEP6RArrayIlE @ 59 NONAME
 	_ZN21CGlobalProgressDialog19ShowProgressDialogLEi @ 60 NONAME
+	_ZN24TObexUtilsMessageHandler16AddEntryToInboxLERlR4TBufILi256EE @ 61 NONAME
 
--- a/localconnectivityservice/obexserviceman/utils/src/obexutilsdialog.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/utils/src/obexutilsdialog.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -99,9 +99,7 @@
     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog()"));
 
     CCoeEnv::Static()->DeleteResourceFile( iResourceFileId );
-    delete iProgressDialog;
     delete iObexDialogTimer;
-    delete iWaitDialog;
 
     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog() completed"));
     }
@@ -168,7 +166,8 @@
         }
 
     iWaitDialog = new( ELeave ) CAknWaitDialog(
-        ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ), ETrue );
+            ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ), EFalse );
+    
     iWaitDialog->SetCallback( this );
     PrepareDialogExecuteL( aResId, iWaitDialog );
     iWaitDialog->ExecuteLD( aResId );
@@ -185,7 +184,9 @@
 
     if( iWaitDialog )
         {
+        iWaitDialog->SetCallback(NULL);
         iWaitDialog->ProcessFinishedL();
+        iWaitDialog = NULL;
         }
 
     FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL() completed"));
--- a/localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/utils/src/obexutilslaunchwaiter.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -92,8 +92,12 @@
     TInt error = KErrNone;
     TBool isCompleteSelf = EFalse;  
     
-    RFile attachFile;
+    RFile attachFile;        
     TRAP( error, attachFile = store->AttachmentManagerL().GetAttachmentFileL(0));
+    TFileName fullName;
+    attachFile.FullName(fullName);
+    attachFile.Close();
+    
     if ( KErrNone == error )
         {
         CleanupClosePushL(attachFile);  // 4th push
@@ -106,17 +110,16 @@
             // Launches an application in embedded mode
             iDocumentHandler = CDocumentHandler::NewL( CEikonEnv::Static()->Process() );
             iDocumentHandler->SetExitObserver( this );
-            TRAP( error, iDocumentHandler->OpenFileEmbeddedL( attachFile, dataType, *paramList ));
+            RFile64 shareableFile;
+            TRAP( error, iDocumentHandler->OpenTempFileL(fullName,shareableFile));
+            if ( error == KErrNone)
+                {
+                TRAP( error, iDocumentHandler->OpenFileEmbeddedL( shareableFile, dataType, *paramList ));
+                }
+            shareableFile.Close();
             }
-        else
-            {
-            // Launches an application in standalone mode
-            iDocumentHandler = CDocumentHandler::NewL( );
-            // We do not observe exit event when file is launched in standalone mode.            
-            iDocumentHandler->SetExitObserver( NULL );
-            TRAP( error, iDocumentHandler->OpenFileL( attachFile, dataType));
-            }
-            
+        
+           
         if ( error == KErrNotSupported )  
             // If file is not supported, we open the file manager at file location.
             {
@@ -126,12 +129,9 @@
                
             TInt sortMethod = 2;  // 0 = 'By name', 1 = 'By type', 
                                   // 2 = 'Most recent first' and 3 = 'Largest first'
-            TFileName fullName;
-            attachFile.FullName(fullName);
-          
-            TRAP (error, TObexUtilsUiLayer::LaunchFileManagerL( fullName, 
-                                                                       sortMethod, 
-                                                                       ETrue )); // ETrue -> launch file manager in embedded mode.
+           TRAP (error, TObexUtilsUiLayer::LaunchFileManagerL( fullName, 
+                                                               sortMethod, 
+                                                               ETrue )); // ETrue -> launch file manager in embedded mode.
             isCompleteSelf = ETrue;
             }  // KErrNotSupported
         
--- a/localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/utils/src/obexutilsmessagehandler.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -254,12 +254,12 @@
     // Save the size of all the attachment & make visible.
     TMsvEntry parentTEntry = aParentEntry->Entry();
     parentTEntry.iDate = GetCurrentTime();
-    parentTEntry.iSize = aFileEntry.iSize; 
-    parentTEntry.SetUnread(EFalse);    
+    parentTEntry.iSize = aFileEntry.iSize;  
     // Saved OK. Make the entry visible and flag it as complete.
     parentTEntry.SetVisible(ETrue);                   // visible
+    parentTEntry.SetUnread(ETrue);
     parentTEntry.SetInPreparation(EFalse);            // complete
-    parentTEntry.iDescription.Set(aFileNameParser.Name());  // "Subject"
+    parentTEntry.iDescription.Set(aFileNameParser.FullName());        // "Subject" 
     aParentEntry->ChangeL(parentTEntry);              // commit changes
     aStore->CommitL();
     
@@ -841,7 +841,7 @@
     TMsvEntry parentTEntry;   
     parentTEntry.iMtm = aMtmId;
     parentTEntry.SetVisible(EFalse); // Make invisible..
-    parentTEntry.SetUnread(EFalse);  // Msgs received via bluetooth will always be set to READ.
+    parentTEntry.SetUnread(ETrue);  //  Set msg to Unread
         
     // ...and in preparation to make sure it gets cleaned up on errors.
     //
@@ -945,67 +945,66 @@
 //
 EXPORT_C void TObexUtilsMessageHandler::AddEntryToInboxL( 
     TMsvId& aMsvIdParent,
-    TFileName& aFullName,
-    RArray<TMsvId>* aMsvIdArray)
+    TFileName& aFullName)
     {
     FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() "));
-    
+        
     CDummySessionObserver* sessionObs;
     CMsvSession* msvSession;
     CreateMsvSessionLC(sessionObs, msvSession);
     // 1st, 2nd push
-    
+        
     CMsvEntry* parentEntry = msvSession->GetEntryL(aMsvIdParent);
     CleanupStack::PushL(parentEntry);  // 3th push
     
     CMsvEntry* attachEntry = msvSession->GetEntryL(((*parentEntry)[0]).Id());
     CleanupStack::PushL(attachEntry); // 4th push
-        
+            
     CMsvStore* store = attachEntry->EditStoreL();
     CleanupStack::PushL( store );  // 5th push
-    
+        
     CObexutilsEntryhandler* entryHandler = CObexutilsEntryhandler::NewL();
     CleanupStack::PushL(entryHandler);  // 6th push  
-            
+                
     CMsvAttachment* attachInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
     CleanupStack::PushL(attachInfo);  // 7th push
-       
+           
     // Create attachment Info
     //
     RFs& fsSess = msvSession->FileSession();
-    
+        
     TParse fileNameParser;
     User::LeaveIfError(fileNameParser.Set(aFullName, NULL, NULL));
-    attachInfo->SetAttachmentNameL(fileNameParser.NameAndExt());
-             
+    attachInfo->SetAttachmentNameL( fileNameParser.FullName());
+                 
     TEntry fileEntry;
     User::LeaveIfError(fsSess.Entry( fileNameParser.FullName(), fileEntry) );
     attachInfo->SetSize(fileEntry.iSize);
-        
+            
     // check if it's the bio message
-       
+           
     TUid bioMsgId;  // SaveMimeAndGetBioLC modifies this
     CBIODatabase* bioDB = SaveMimeAndGetBioLC( aFullName, fsSess, attachInfo, bioMsgId );
     // 8th push
     if (bioDB)  // bio message
         {
         FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() BIO"));
-        
+    
         RFile file;
         User::LeaveIfError(file.Open(fsSess,aFullName,EFileRead));
         TReceivedData receivedData;
         receivedData.bytesReceived = fileEntry.iSize;
         receivedData.recTime = fileEntry.iModified;
-        receivedData.msgName = fileNameParser.Name();
-                
+        receivedData.msgName = fileNameParser.Name();     
+                    
         StoreAndUpdateBioMessageL( bioDB, bioMsgId, parentEntry, file );
         FinaliseMessageL(parentEntry, receivedData, store, ETrue);
         TMsvId attachId = attachEntry->EntryId();
         file.Close();
         fsSess.Delete(aFullName);
         CleanupStack::PopAndDestroy(5);  // bioDB, attachInfo, linkHandler,
-                                         // store, attachEntry
-        
+                                             // store, attachEntry
+            
         // PopAndDestroying here because open store locks the entry,
         // it can be deleted only after destroying the store pointer
         parentEntry->DeleteL(attachId);  // invalidate unused attachment
@@ -1022,16 +1021,22 @@
         CleanupStack::PopAndDestroy(entryHandler);  // entryHandler
         FinaliseMessageL(parentEntry, store,fileEntry, fileNameParser);
         CleanupStack::PopAndDestroy(5);         // linkHandler, attachInfo, store, attachEntry,
-                                                // parentEntry, msvSession, sessionObs
-        
-        // File Link is created in INBOX successfully,
-        // We add MsvId to array.
-        //
-        aMsvIdArray->Append(aMsvIdParent);
-        
+                                                    // parentEntry, msvSession, sessionObs                            
         FLOG(_L("[OBEXUTILS]\t TObexUtilsMessageHandler::AddEntryToInboxL() completed "));
         }
-       
+    }
+
+// -----------------------------------------------------------------------------
+// CObexUtilsMessageHandler::AddEntryToInboxL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void TObexUtilsMessageHandler::AddEntryToInboxL( 
+    TMsvId& aMsvIdParent,
+    TFileName& aFullName,
+    RArray<TMsvId>* aMsvIdArray)
+    {
+    AddEntryToInboxL(aMsvIdParent, aFullName);
+    aMsvIdArray->Append(aMsvIdParent);
     }
 
 // -----------------------------------------------------------------------------
--- a/localconnectivityservice/obexserviceman/utils/src/obexutilsuilayer.cpp	Mon Jan 18 21:03:15 2010 +0200
+++ b/localconnectivityservice/obexserviceman/utils/src/obexutilsuilayer.cpp	Tue Feb 02 00:45:58 2010 +0200
@@ -289,6 +289,7 @@
     
     // Initiate query dialog
     TRequestStatus status = KRequestPending;
+    
     CAknGlobalConfirmationQuery* pQ = CAknGlobalConfirmationQuery::NewL();
     CleanupStack::PushL(pQ);
     pQ->ShowConfirmationQueryL(status, manipString, R_AVKON_SOFTKEYS_YES_NO);
--- a/shortlinkconn_plat/obex_service_utils_api/inc/obexutilsmessagehandler.h	Mon Jan 18 21:03:15 2010 +0200
+++ b/shortlinkconn_plat/obex_service_utils_api/inc/obexutilsmessagehandler.h	Tue Feb 02 00:45:58 2010 +0200
@@ -206,6 +206,17 @@
                                                    TFileName& aFullName,
                                                    RFile& aFile,
                                                    const TDesC& aSenderBluetoothName);
+        
+        /**
+         * Add an entry to Inbox
+         * @Since S60 v5.0
+         * @param aMsvIdParent Parent message entry
+         * @param aFullName Contains the full path and file name of the file
+         * @return None
+         */
+        IMPORT_C static void AddEntryToInboxL( TMsvId& aMsvIdParent,
+                                               TFileName& aFullName);
+                                               
         /**
          * Add an entry to Inbox
          * @Since S60 v5.0