Revision: 201025 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 19:38:28 +0300
branchRCL_3
changeset 37 7e0ecb5b116a
parent 35 57266085a3a2
child 38 3dcb815346df
Revision: 201025 Kit: 2010127
localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp
localconnectivityservice/obexsendservices/eabi/obexservicesendutilsu.DEF
localconnectivityservice/obexsendservices/group/sendutils.mmp
localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTServiceDelayedDestroyer.h
localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTServiceStarter.h
localconnectivityservice/obexsendservices/obexservicesendutils/src/BTServiceDelayedDestroyer.cpp
localconnectivityservice/obexsendservices/obexservicesendutils/src/BTServiceStarter.cpp
--- a/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp	Mon Jun 21 16:40:15 2010 +0300
+++ b/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp	Thu Jul 15 19:38:28 2010 +0300
@@ -915,11 +915,14 @@
         iParseInfo.iLimit = cmdLength;
         }
     // Next create a new command
-    if ( !iDecodeInfo.iFirstDecode && !specialCmd )
+    if ( !iDecodeInfo.iFirstDecode )
         {
         _LIT( KAtMsg, "AT" );
         iDecodeInfo.iDecodeBuffer.Append( KAtMsg );
-        iParseInfo.iLimit += 2;  // Length of "AT"
+        if ( !specialCmd )  // Already added with CheckSpecialCommand()
+            {
+            iParseInfo.iLimit += 2;  // Length of "AT"
+            }
         // Note: The length of iDecodeBuffer is not exceeded here because "AT"
         // is added only for the second commands after that.
         }
@@ -1053,9 +1056,18 @@
                                              TInt& aEndIndex )
     {
     FTRACE(FPrint( _L("CDunAtCmdHandler::CheckSpecialCommand()") ));
-    TBuf8<KDunInputBufLength> upperBuf;
+    TInt atMsgLen = 0;
     TInt newLength = iInputBuffer.Length() - aStartIndex;
-    upperBuf.Copy( &iInputBuffer[aStartIndex], newLength );
+    TBuf8<KDunInputBufLength> upperBuf;
+    if ( !iDecodeInfo.iFirstDecode )
+        {
+        // For cases such as "ATM1L3DT*99#" "DT" must have "AT"
+        _LIT8( KATMsg, "AT" );
+        upperBuf.Copy( KATMsg );
+        atMsgLen = 2;  // "AT"
+        newLength += atMsgLen;
+        }
+    upperBuf.Append( &iInputBuffer[aStartIndex], newLength );
     upperBuf.UpperCase();
     TInt i;
     TInt count = iSpecials.Count();
@@ -1077,7 +1089,7 @@
         if ( cmpResult == 0 )
             {
             iParseInfo.iLimit = specialLength;
-            aEndIndex = (origLength-1) + aStartIndex;
+            aEndIndex = (origLength-1) + aStartIndex - atMsgLen;
             FTRACE(FPrint( _L("CDunAtCmdHandler::CheckSpecialCommand() complete") ));
             return ETrue;
             }
--- a/localconnectivityservice/obexsendservices/eabi/obexservicesendutilsu.DEF	Mon Jun 21 16:40:15 2010 +0300
+++ b/localconnectivityservice/obexsendservices/eabi/obexservicesendutilsu.DEF	Thu Jul 15 19:38:28 2010 +0300
@@ -9,8 +9,8 @@
 	_ZN23CBTServiceParameterList9AddImageLE5RFile @ 8 NONAME
 	_ZN23CBTServiceParameterList9AddImageLERK7TDesC16 @ 9 NONAME
 	_ZN23CBTServiceParameterList9AddXhtmlLERK7TDesC16 @ 10 NONAME
-	_ZTI13CBTServiceAPI @ 11 NONAME ; #<TI>#
-	_ZTI23CBTServiceParameterList @ 12 NONAME ; #<TI>#
-	_ZTV13CBTServiceAPI @ 13 NONAME ; #<VT>#
-	_ZTV23CBTServiceParameterList @ 14 NONAME ; #<VT>#
+	_ZTI13CBTServiceAPI @ 11 NONAME
+	_ZTI23CBTServiceParameterList @ 12 NONAME
+	_ZTV13CBTServiceAPI @ 13 NONAME
+	_ZTV23CBTServiceParameterList @ 14 NONAME
 
--- a/localconnectivityservice/obexsendservices/group/sendutils.mmp	Mon Jun 21 16:40:15 2010 +0300
+++ b/localconnectivityservice/obexsendservices/group/sendutils.mmp	Thu Jul 15 19:38:28 2010 +0300
@@ -30,6 +30,7 @@
 SOURCE          BTServiceUtils.cpp
 SOURCE          BTServiceStarter.cpp
 SOURCE          BTServiceParameterList.cpp
+SOURCE          BTServiceDelayedDestroyer.cpp
 
 SOURCE          BTSOPPController.cpp
 SOURCE          BTSBIPController.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTServiceDelayedDestroyer.h	Thu Jul 15 19:38:28 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The base active object declaration
+*
+*/
+
+
+#ifndef BT_SERVICE_DELAYED_DESTROYER_H
+#define BT_SERVICE_DELAYED_DESTROYER_H
+
+//  INCLUDES
+#include <btengdiscovery.h>
+#include <e32base.h>
+
+NONSHARABLE_CLASS (CBTServiceDelayedDestroyer) : public CActive
+    {
+    
+public:
+
+    static CBTServiceDelayedDestroyer* NewL(CActive::TPriority aPriority);
+
+    static CBTServiceDelayedDestroyer* NewLC(CActive::TPriority aPriority);
+
+    virtual ~CBTServiceDelayedDestroyer();
+
+public:
+
+    /**
+     * Calls SetActive().
+     */
+    void GoActive();
+    
+    // Sets the pointer which will be destroyed.
+    // Must be called with GoActive, they are pairs, first 
+    // call SetDestructPointer and then GoActive.
+    void SetDestructPointer(CBTEngDiscovery* aPtr);
+
+private:    
+
+    /**
+     * From CActive. 
+     * cancels the outstanding request.
+     */
+    virtual void DoCancel();
+
+    /**
+     * From CActive. 
+     * Handles the request completion event.
+     * Deletes CBTEngDiscovery object which is passed via SetDestructPointer method.
+     */
+    virtual void RunL();
+
+    /**
+     * From CActive. 
+     * Handles the leave from RunL().
+     * @param aError the leave code in RunL()
+     * @return the error code to Active Scheduler
+     */
+    virtual TInt RunError(TInt aError);
+
+private:    
+
+    CBTServiceDelayedDestroyer(CActive::TPriority aPriority);
+
+private:
+    TRequestStatus iStatus;
+    CBTEngDiscovery* iPtr;    
+    };
+
+#endif  // BT_SERVICE_DELAYED_DESTROYER_H
--- a/localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTServiceStarter.h	Mon Jun 21 16:40:15 2010 +0300
+++ b/localconnectivityservice/obexsendservices/obexservicesendutils/inc/BTServiceStarter.h	Thu Jul 15 19:38:28 2010 +0300
@@ -24,6 +24,7 @@
 #include "BTServiceAPI.h"
 #include "BTServiceUtils.h"
 #include "BTServiceParameterList.h"
+#include "BTServiceDelayedDestroyer.h"
 
 #include <btengdiscovery.h>
 #include <btengsettings.h>
@@ -438,6 +439,7 @@
         TBool                       iFeatureManagerInitialized;
         TBool                       iTriedBIP;
         TBool                       iTriedOPP;
+        CBTServiceDelayedDestroyer* iDelayedDestroyer;
     };
 
 #endif      // BT_SERVICE_CONTROLLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/localconnectivityservice/obexsendservices/obexservicesendutils/src/BTServiceDelayedDestroyer.cpp	Thu Jul 15 19:38:28 2010 +0300
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The base active class definition 
+*
+*/
+
+
+#include "BTServiceDelayedDestroyer.h"
+#include "BTSUDebug.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::NewL()
+// -----------------------------------------------------------------------------
+//  
+CBTServiceDelayedDestroyer* CBTServiceDelayedDestroyer::NewL(CActive::TPriority aPriority)
+    {
+    CBTServiceDelayedDestroyer* self = CBTServiceDelayedDestroyer::NewLC(aPriority);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::NewLC()
+// -----------------------------------------------------------------------------
+//  
+CBTServiceDelayedDestroyer* CBTServiceDelayedDestroyer::NewLC(CActive::TPriority aPriority)
+    {
+    CBTServiceDelayedDestroyer* self = new (ELeave) CBTServiceDelayedDestroyer(aPriority);
+    CleanupStack::PushL(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::CBTServiceDelayedDestroyer()
+// -----------------------------------------------------------------------------
+//  
+CBTServiceDelayedDestroyer::CBTServiceDelayedDestroyer(CActive::TPriority aPriority)
+    : CActive(aPriority), iPtr(NULL)
+    {
+    FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::CBTServiceDelayedDestroyer()"));
+    CActiveScheduler::Add(this);
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::~CBTServiceDelayedDestroyer()
+// -----------------------------------------------------------------------------
+//  
+CBTServiceDelayedDestroyer::~CBTServiceDelayedDestroyer()
+    {
+    FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::Destructor()"));
+    if( iPtr )
+        {
+        delete iPtr;
+        iPtr = NULL;
+        }
+    Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::GoActive()
+// -----------------------------------------------------------------------------
+//  
+void CBTServiceDelayedDestroyer::GoActive()
+    {
+    FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::GoActive()"));
+    if( !IsActive() )
+        {
+        TRequestStatus* status = &iStatus;
+        iStatus = KRequestPending;
+        User::RequestComplete(status, KErrNone);
+    	SetActive();
+        }
+    else
+    	{
+        FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::GoActive(), Already active"));
+    	}
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::SetDestructPointer()
+// Must be called with GoActive, they are pairs, first call SetDestructPointer
+// and then GoActive.
+// -----------------------------------------------------------------------------
+//  
+void CBTServiceDelayedDestroyer::SetDestructPointer(CBTEngDiscovery* aPtr)
+    {
+    FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::SetDestructPointer()"));
+    if( iPtr )
+        {
+        // If previous is not deleted yet, meaning, RunL is not called yet,
+        // we can safely delete previous here.
+        delete iPtr;
+        }
+    iPtr = aPtr;
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::DoCancel()
+// -----------------------------------------------------------------------------
+//  
+void CBTServiceDelayedDestroyer::DoCancel()
+    {
+    FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::DoCancel()"));
+    }
+    
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::RunL()
+// -----------------------------------------------------------------------------
+//  
+void CBTServiceDelayedDestroyer::RunL()
+    {
+    FLOG(_L("[BTSU]\t CBTServiceDelayedDestroyer::RunL()"));
+    delete iPtr;
+    iPtr = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CBTServiceDelayedDestroyer::RunError()
+// -----------------------------------------------------------------------------
+//      
+TInt CBTServiceDelayedDestroyer::RunError(TInt aError)
+    {
+    FTRACE(FPrint(_L("[BTSU]\t CBTServiceStarter::RunError() aError = %d"), aError) );
+    (void) aError;
+    return KErrNone;
+    } 
--- a/localconnectivityservice/obexsendservices/obexservicesendutils/src/BTServiceStarter.cpp	Mon Jun 21 16:40:15 2010 +0300
+++ b/localconnectivityservice/obexsendservices/obexservicesendutils/src/BTServiceStarter.cpp	Thu Jul 15 19:38:28 2010 +0300
@@ -73,6 +73,7 @@
     FLOG(_L("[BTSU]\t CBTServiceStarter::ConstructL()"));
     iDevice = CBTDevice::NewL();
     iDialog = CObexUtilsDialog::NewL( this );
+    iDelayedDestroyer = CBTServiceDelayedDestroyer::NewL(CActive::EPriorityStandard);
     FeatureManager::InitializeLibL();
     iFeatureManagerInitialized = ETrue;
     FLOG(_L("[BTSU]\t CBTServiceStarter::ConstructL() completed"));
@@ -109,7 +110,8 @@
     delete iController;
     delete iBTEngDiscovery;
     delete iDialog;
-
+    delete iDelayedDestroyer;
+    
     if(iWaiter && iWaiter->IsStarted() )
         {
         iWaiter->AsyncStop();
@@ -713,7 +715,7 @@
     {
     FLOG(_L("[BTSU]\t CBTServiceStarter::ServiceAttributeSearchComplete()"));               
     TInt err = KErrNone;
-    if (aErr==KErrEof && aAttr.Count()>0 )
+    if ((aErr==KErrEof || aErr==KErrNone) && aAttr.Count()>0 )
         {            
         RSdpResultArray results=aAttr;    
         iBTEngDiscovery->ParseRfcommChannel(results,iClientChannel);          
@@ -782,9 +784,18 @@
         iState = EBTSStarterFindingBIP;  
         iTriedOPP = ETrue;
         }
+    else if (aErr==KErrNone && aAttr.Count()==0)
+        {
+        //This isn't KErrEoF so we aren't done yet, wait for future matches
+        }
     else
         {
-        delete iBTEngDiscovery;
+        // Set destroyer AO active (destroys CBTEngDiscovery/CBTEngSdpQuery classes). This is done
+        // to ensure that CBTEngDiscovery/CBTEngSdpQuery classes have finished all their activities,
+        // callbacks etc.. Destructing it self is handled in CBTServiceDelayedDestroyer's RunL.
+        iDelayedDestroyer->SetDestructPointer(iBTEngDiscovery);
+        iDelayedDestroyer->GoActive();
+        // Set iBTEngDiscovery pointer to zero. Pointer doesn't exist CBTServiceStarter point of view anymore.
         iBTEngDiscovery = NULL;    
         StopTransfer(EBTSConnectingFailed);    
         }