syncmlfw/ds/hostserver/dshostserverbase/src/Nsmldsasynccallback.cpp
changeset 0 b497e44ab2fc
child 12 9e9792ae22e3
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  array for storing dataproviders and datastores.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <s32mem.h>
       
    21 
       
    22 #include <nsmldebug.h>
       
    23 #include "nsmldshostconstants.h"
       
    24 #include "Nsmldsasyncrequesthandler.h"
       
    25 #include "Nsmldsdataproviderarray.h"
       
    26 
       
    27 #ifdef __HOST_SERVER_MTEST__
       
    28 #include "../../stif/DSHostServerTest/inc/fakedataprovider.h"
       
    29 #else
       
    30 #include <SmlDataProvider.h>
       
    31 #endif
       
    32 
       
    33 // ======================================= MEMBER FUNCTIONS =======================================
       
    34 
       
    35 // ------------------------------------------------------------------------------------------------
       
    36 // CNSmlDSAsyncCallBack::CNSmlDSAsyncCallBack
       
    37 // ------------------------------------------------------------------------------------------------
       
    38 CNSmlDSAsyncCallBack::CNSmlDSAsyncCallBack( CNSmlDSHostSession* aSession, 
       
    39                            TNSmlDSDataStoreElement* aDSItem, 
       
    40                            const RMessage2& aMessage, 
       
    41                            RequestFinishedFunction aReqFinishedFunc,
       
    42                            TAny* aPtr ) :
       
    43     CNSmlDSAsyncRequestHandler( EPriorityStandard, aSession, aDSItem, aMessage ), 
       
    44     iReqFinishedFunc( aReqFinishedFunc )
       
    45     {
       
    46     iPtr = aPtr;
       
    47     }
       
    48     
       
    49 // ------------------------------------------------------------------------------------------------
       
    50 // CNSmlDSAsyncCallBackForOpen::CNSmlDSAsyncCallBackForOpen
       
    51 // ------------------------------------------------------------------------------------------------    
       
    52 CNSmlDSAsyncCallBackForOpen::CNSmlDSAsyncCallBackForOpen( 
       
    53 		CNSmlDSHostSession* aSession, 
       
    54         const RMessage2& aMessage,
       
    55         RequestFinishedFunction aReqFinishedFunc ) : 
       
    56     CNSmlDSAsyncCallBack(aSession, NULL, aMessage, aReqFinishedFunc ),
       
    57     iServerId(NULL), iRemoteDB(NULL)
       
    58 	{
       
    59 	}
       
    60 	
       
    61 // ------------------------------------------------------------------------------------------------
       
    62 // CNSmlDSAsyncCallBack::~CNSmlDSAsyncCallBack()
       
    63 // ------------------------------------------------------------------------------------------------
       
    64 CNSmlDSAsyncCallBack::~CNSmlDSAsyncCallBack()
       
    65     {
       
    66     Cancel();
       
    67     	
       
    68     if ( iReqFinishedFunc )
       
    69         {
       
    70         RequestFinishedFunction ReqFinFunc = iReqFinishedFunc;
       
    71         iReqFinishedFunc = NULL;
       
    72         ( *iSession.*ReqFinFunc )( this, EFree );
       
    73         
       
    74         ASSERT( iPtr == NULL );
       
    75         }
       
    76     }
       
    77     
       
    78 // ------------------------------------------------------------------------------------------------
       
    79 // CNSmlDSAsyncCallBack::DoCancel()
       
    80 // ------------------------------------------------------------------------------------------------
       
    81 void CNSmlDSAsyncCallBack::DoCancel()
       
    82     {
       
    83     if ( iDSItem )
       
    84     	{
       
    85     	iDSItem->iDataStore->CancelRequest();
       
    86     	}
       
    87 
       
    88     if ( iReqFinishedFunc != NULL )
       
    89     	{
       
    90     	( *iSession.*iReqFinishedFunc )( this, ECanceled );
       
    91     	}
       
    92     }
       
    93 
       
    94 // ------------------------------------------------------------------------------------------------
       
    95 // CNSmlDSAsyncCallBack::RunL()
       
    96 // ------------------------------------------------------------------------------------------------
       
    97 void CNSmlDSAsyncCallBack::RunL()
       
    98     {
       
    99     if ( iReqFinishedFunc == NULL )
       
   100         {
       
   101         iMessage.Complete( iStatus.Int() );
       
   102         }
       
   103     else
       
   104         {
       
   105         TInt status = ( *iSession.*iReqFinishedFunc )( this, EFinished );
       
   106         iMessage.Complete( status );
       
   107         }
       
   108     delete this;
       
   109     }
       
   110 
       
   111 // End of File