ncdengine/provider/client/src/ncdsubscriptionoperationproxy.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 CNcdSubscriptionOperationProxy
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdsubscriptionoperationproxy.h"
       
    20 #include "ncdsubscriptionoperationobserver.h"
       
    21 #include "ncdsubscriptionmanagerproxy.h"
       
    22 #include "ncdqueryimpl.h"
       
    23 #include "catalogsutils.h"
       
    24 #include "ncdoperationproxyremovehandler.h"
       
    25 
       
    26 CNcdSubscriptionOperationProxy* CNcdSubscriptionOperationProxy::NewL(
       
    27     MCatalogsClientServer& aSession,
       
    28     MNcdSubscriptionOperation::TType aSubscriptionType,
       
    29     TInt aHandle,
       
    30     MNcdOperationProxyRemoveHandler* aRemoveHandler,
       
    31     MNcdSubscriptionOperationObserver& aObserver,
       
    32     CNcdSubscriptionManagerProxy* aSubscriptionManager,
       
    33     CNcdNodeManagerProxy* aNodeManager,
       
    34     MNcdClientLocalizer* aLocalizer )
       
    35     {
       
    36     CNcdSubscriptionOperationProxy* self =
       
    37         CNcdSubscriptionOperationProxy::NewLC(
       
    38             aSession,
       
    39             aSubscriptionType,
       
    40             aHandle,
       
    41             aRemoveHandler,
       
    42             aObserver,
       
    43             aSubscriptionManager,
       
    44             aNodeManager,
       
    45             aLocalizer );
       
    46 
       
    47     CleanupStack::Pop( self );
       
    48 
       
    49     return self;
       
    50     }
       
    51 
       
    52 CNcdSubscriptionOperationProxy* CNcdSubscriptionOperationProxy::NewLC(
       
    53     MCatalogsClientServer& aSession,
       
    54     MNcdSubscriptionOperation::TType aSubscriptionType,
       
    55     TInt aHandle,
       
    56     MNcdOperationProxyRemoveHandler* aRemoveHandler,
       
    57     MNcdSubscriptionOperationObserver& aObserver,
       
    58     CNcdSubscriptionManagerProxy* aSubscriptionManager,
       
    59     CNcdNodeManagerProxy* aNodeManager,
       
    60     MNcdClientLocalizer* aLocalizer )
       
    61     {
       
    62     CNcdSubscriptionOperationProxy* self =
       
    63         new( ELeave ) CNcdSubscriptionOperationProxy( aObserver, aLocalizer );
       
    64     
       
    65     self->AddRef();
       
    66     CleanupReleasePushL( *self );    
       
    67     self->ConstructL(
       
    68         aSession,
       
    69         aSubscriptionType,
       
    70         aHandle,
       
    71         aRemoveHandler,
       
    72         aSubscriptionManager,
       
    73         aNodeManager );
       
    74 
       
    75     return self;
       
    76     }
       
    77 
       
    78 MNcdSubscriptionOperation::TType
       
    79     CNcdSubscriptionOperationProxy::SubscriptionOperationType() const
       
    80     {
       
    81     return iSubscriptionOperationType;
       
    82     }
       
    83 
       
    84 TNcdInterfaceId CNcdSubscriptionOperationProxy::OperationType() const
       
    85     {
       
    86     return static_cast<TNcdInterfaceId>(MNcdSubscriptionOperation::KInterfaceUid);
       
    87     }
       
    88 
       
    89 CNcdSubscriptionOperationProxy::CNcdSubscriptionOperationProxy(
       
    90     MNcdSubscriptionOperationObserver& aObserver,
       
    91     MNcdClientLocalizer* aClientLocalizer)
       
    92     : CNcdOperation< MNcdSubscriptionOperation >( aClientLocalizer ), 
       
    93       iObserver( aObserver )
       
    94     {
       
    95     }
       
    96 
       
    97 CNcdSubscriptionOperationProxy::~CNcdSubscriptionOperationProxy()
       
    98     {
       
    99     DASSERT( iRemoveHandler );
       
   100     if ( iRemoveHandler )
       
   101         {        
       
   102         DLTRACE(("Removing proxy from remove handler"));
       
   103         iRemoveHandler->RemoveOperationProxy( *this );
       
   104         }
       
   105     }
       
   106 
       
   107 void CNcdSubscriptionOperationProxy::ConstructL(
       
   108     MCatalogsClientServer& aSession,
       
   109     MNcdSubscriptionOperation::TType aSubscriptionType,
       
   110     TInt aHandle,
       
   111     MNcdOperationProxyRemoveHandler* aRemoveHandler,
       
   112     CNcdSubscriptionManagerProxy* aSubscriptionManager,
       
   113     CNcdNodeManagerProxy* aNodeManager )
       
   114     {
       
   115     DLTRACEIN( ( "" ) );
       
   116     CNcdBaseOperationProxy::ConstructL(
       
   117         aSession,
       
   118         aHandle,
       
   119         aRemoveHandler,
       
   120         NULL,
       
   121         aNodeManager );
       
   122     
       
   123     iSubscriptionOperationType = aSubscriptionType;
       
   124 
       
   125     iSubscriptionManager = aSubscriptionManager;
       
   126 
       
   127     DLTRACEOUT( ( "" ) );    
       
   128     }
       
   129 
       
   130 
       
   131 void CNcdSubscriptionOperationProxy::ProgressCallback()
       
   132     {
       
   133     DLTRACEIN( ( "" ) );
       
   134 
       
   135     TNcdSendableProgress& sendableProgress( SendableProgress() );
       
   136     TNcdProgress progress( sendableProgress.iProgress, 
       
   137                            sendableProgress.iMaxProgress );
       
   138 
       
   139     DLTRACE(("Progress: %d/%d", sendableProgress.iProgress,
       
   140         sendableProgress.iMaxProgress ));
       
   141 
       
   142     iObserver.SubscriptionProgress( *this, progress );
       
   143 
       
   144     DLTRACEOUT( ( "" ) );
       
   145     }
       
   146 
       
   147 void CNcdSubscriptionOperationProxy::QueryReceivedCallback(
       
   148     CNcdQuery* aQuery )
       
   149     {
       
   150     DLTRACEIN( ( "" ) );
       
   151 
       
   152     aQuery->AddRef();
       
   153     iObserver.QueryReceived( *this, aQuery );
       
   154 
       
   155     DLTRACEOUT( ( "" ) );
       
   156     }
       
   157 
       
   158 void CNcdSubscriptionOperationProxy::CompleteCallback( TInt aError )
       
   159     {
       
   160     DLTRACEIN( ( "Error: %d", aError ) );
       
   161 
       
   162     // Subscription manager on server side handles the informing
       
   163     // of all relevant proxies so no internalization here is needed
       
   164     // for the subscription manager proxy.
       
   165     
       
   166     iObserver.OperationComplete( *this, aError );
       
   167 
       
   168     DLTRACEOUT( ( "" ) );
       
   169     }