ncdengine/provider/client/src/ncdcreateaccesspointoperationproxy.cpp
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Implements CNcdCreateAccessPointOperationProxy
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdcreateaccesspointoperationproxy.h"
       
    20 
       
    21 #include <s32strm.h>
       
    22 
       
    23 #include "ncdcreateaccesspointoperationobserver.h"
       
    24 #include "ncdoperationproxyremovehandler.h"
       
    25 #include "catalogsclientserver.h"
       
    26 
       
    27 #include "catalogsdebug.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // 
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CNcdCreateAccessPointOperationProxy* CNcdCreateAccessPointOperationProxy::NewL( 
       
    36     MCatalogsClientServer& aSession,
       
    37     CNcdNodeManagerProxy* aNodeManager,
       
    38     TInt aHandle,
       
    39     MNcdOperationProxyRemoveHandler& aRemoveHandler,
       
    40     MNcdCreateAccessPointOperationObserver& aObserver )
       
    41     {
       
    42     CNcdCreateAccessPointOperationProxy* self = 
       
    43         CNcdCreateAccessPointOperationProxy::NewLC( 
       
    44             aSession, aNodeManager, aHandle, aRemoveHandler, aObserver );
       
    45     CleanupStack::Pop( self );
       
    46     return self;
       
    47     }
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // 
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CNcdCreateAccessPointOperationProxy* CNcdCreateAccessPointOperationProxy::NewLC( 
       
    55     MCatalogsClientServer& aSession,
       
    56     CNcdNodeManagerProxy* aNodeManager,
       
    57     TInt aHandle,
       
    58     MNcdOperationProxyRemoveHandler& aRemoveHandler,
       
    59     MNcdCreateAccessPointOperationObserver& aObserver )
       
    60     {
       
    61     CNcdCreateAccessPointOperationProxy* self =
       
    62         new (ELeave) CNcdCreateAccessPointOperationProxy( aObserver );
       
    63     
       
    64     self->AddRef();
       
    65     CleanupReleasePushL( *self );    
       
    66     self->ConstructL( aSession, aNodeManager, aHandle, aRemoveHandler );
       
    67     return self;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // From MNcdOperation
       
    72 // Operation type getter
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 TNcdInterfaceId CNcdCreateAccessPointOperationProxy::OperationType() const
       
    76     {
       
    77     return static_cast< TNcdInterfaceId >( 
       
    78         MNcdCreateAccessPointOperation::KInterfaceUid );
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Constructor
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 CNcdCreateAccessPointOperationProxy::CNcdCreateAccessPointOperationProxy( 
       
    87     MNcdCreateAccessPointOperationObserver& aObserver )
       
    88     : CNcdOperation< MNcdCreateAccessPointOperation >( NULL ), 
       
    89       iObserver( aObserver )
       
    90     {
       
    91     }
       
    92 
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Destructor
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 CNcdCreateAccessPointOperationProxy::~CNcdCreateAccessPointOperationProxy()
       
    99     {
       
   100     DLTRACEIN( ( "" ) );         
       
   101     if ( iRemoveHandler )
       
   102         {
       
   103         iRemoveHandler->RemoveOperationProxy( *this );
       
   104         }
       
   105     }
       
   106 
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // ConstructL
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CNcdCreateAccessPointOperationProxy::ConstructL(
       
   113     MCatalogsClientServer& aSession,
       
   114     CNcdNodeManagerProxy* aNodeManager,
       
   115     TInt aHandle,
       
   116     MNcdOperationProxyRemoveHandler& aRemoveHandler )
       
   117     {
       
   118     DLTRACEIN( ( "" ) );
       
   119     CNcdBaseOperationProxy::ConstructL( 
       
   120         aSession, 
       
   121         aHandle, 
       
   122         &aRemoveHandler,
       
   123         NULL, 
       
   124         aNodeManager );
       
   125     }
       
   126 
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // Return the ap id
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 TUint32 CNcdCreateAccessPointOperationProxy::AccessPoint() const
       
   133     {
       
   134     return iAccessPoint;
       
   135     }
       
   136 
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // Handle progress callback
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CNcdCreateAccessPointOperationProxy::ProgressCallback()
       
   143     {
       
   144     DLTRACEIN( ( "" ) );
       
   145     }
       
   146     
       
   147     
       
   148 // ---------------------------------------------------------------------------
       
   149 // Handle query received callback
       
   150 // ---------------------------------------------------------------------------
       
   151 //
       
   152 void CNcdCreateAccessPointOperationProxy::QueryReceivedCallback( 
       
   153     CNcdQuery* /*aQuery*/ )
       
   154     {
       
   155     DLTRACEIN( ( "" ) );
       
   156     // Needed because this is abstract in baseoperation
       
   157     }
       
   158     
       
   159 // ---------------------------------------------------------------------------
       
   160 // Handle operation complete
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CNcdCreateAccessPointOperationProxy::CompleteCallback( TInt aError )
       
   164     {
       
   165     DLTRACEIN( ( "Error: %d", aError ) );
       
   166     
       
   167     AddRef();   // in case last reference would be released in OperationComplete callback.
       
   168     iObserver.OperationComplete( *this, aError );
       
   169     Release();
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // HandleCompletedMessage
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 void CNcdCreateAccessPointOperationProxy::HandleCompletedMessage(
       
   177     TNcdOperationMessageCompletionId aCompletionId,
       
   178     RReadStream& aReadStream,
       
   179     TInt aDataLength )
       
   180     {
       
   181     DLTRACEIN(( "aCompletionId =%d, aDataLength =%d", aCompletionId,
       
   182         aDataLength));
       
   183     switch ( aCompletionId )
       
   184         {
       
   185         // Handle operation completion
       
   186         case ENCDOperationMessageCompletionComplete:
       
   187             {
       
   188             DLTRACE( ( "ENCDOperationMessageCompletionComplete" ) );
       
   189                  // Read progress info
       
   190             TRAPD( err,
       
   191                 {                
       
   192                 TNcdSendableProgress progress; 
       
   193                 progress.InternalizeL( aReadStream );
       
   194                 iAccessPoint = progress.iProgress;
       
   195                 }); //TRAPD
       
   196             aReadStream.Close();  
       
   197             
       
   198             SetState( MNcdOperation::EStateComplete );
       
   199             CompleteCallback( err );          
       
   200             break;
       
   201             }
       
   202                                 
       
   203         default:
       
   204             {
       
   205             DLTRACE(("Calling base class"));
       
   206             // Call base class
       
   207             CNcdBaseOperationProxy::HandleCompletedMessage( aCompletionId,
       
   208                 aReadStream,
       
   209                 aDataLength );
       
   210             
       
   211             break;
       
   212             }
       
   213         }
       
   214     DLTRACEOUT((""));
       
   215     }