ncdengine/provider/server/src/ncdserverreportoperationimpl.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdserverreportoperationimpl.h"
       
    20 #include "ncdreportmanager.h"
       
    21 #include "catalogsbasemessage.h"
       
    22 #include "catalogscontext.h"
       
    23 #include "ncdgeneralmanager.h"
       
    24 
       
    25 #include "catalogsdebug.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // NewL
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CNcdServerReportOperation* CNcdServerReportOperation::NewL(
       
    34     CNcdGeneralManager& aGeneralManager,
       
    35     MNcdOperationRemoveHandler& aRemoveHandler, 
       
    36     CNcdReportManager& aReportManager,
       
    37     MCatalogsSession& aSession )
       
    38     {
       
    39     CNcdServerReportOperation* self = new( ELeave ) CNcdServerReportOperation( 
       
    40         aGeneralManager, aRemoveHandler, aReportManager, aSession );
       
    41     CleanupClosePushL( *self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop();
       
    44     return self;
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Destructor
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CNcdServerReportOperation::~CNcdServerReportOperation()
       
    53     {
       
    54     DLTRACEIN( ( "" ) );    
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // Report manager
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CNcdReportManager& CNcdServerReportOperation::ReportManager()
       
    63     {
       
    64     return iReportManager;
       
    65     }
       
    66 
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // Cancel
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CNcdServerReportOperation::Cancel() 
       
    73     {    
       
    74     DLTRACEIN(( "" ));
       
    75     ReportManager().CancelReportSending();
       
    76     DLTRACEOUT(( "" ));
       
    77     }
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // RunOperation
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 TInt CNcdServerReportOperation::RunOperation()
       
    85     {
       
    86     DLTRACEIN(( "Pending message: %X", iPendingMessage ));
       
    87     
       
    88     if ( !iPendingMessage ) 
       
    89         {      
       
    90         DLTRACE(("No pending message"));  
       
    91         return KErrNotReady;
       
    92         }
       
    93     
       
    94     // Start download.
       
    95     DLINFO(("Starting reporting"));
       
    96     TRAPD( trapError, ReportManager().StartSendReportsL( *this ) );
       
    97 
       
    98     DLTRACEOUT(("trapError: %d", trapError));
       
    99     return trapError;
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // Constructor
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 CNcdServerReportOperation::CNcdServerReportOperation(
       
   108     CNcdGeneralManager& aGeneralManager,
       
   109     MNcdOperationRemoveHandler& aRemoveHandler,
       
   110     CNcdReportManager& aReportManager,
       
   111     MCatalogsSession& aSession )
       
   112     :
       
   113     CNcdBaseOperation( aGeneralManager, &aRemoveHandler, EServerReportOperation, aSession ), 
       
   114     iReportManager( aReportManager )        
       
   115     {
       
   116     }
       
   117 
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // ConstructL
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 void CNcdServerReportOperation::ConstructL()
       
   124     {
       
   125     DLTRACEIN( ( "" ) );
       
   126 
       
   127     // Call ConstructL for the base class
       
   128     CNcdBaseOperation::ConstructL();
       
   129 
       
   130     DLTRACEOUT(( "" ));
       
   131     }
       
   132     
       
   133 void CNcdServerReportOperation::Progress( CNcdBaseOperation& /*aOperation*/ )
       
   134     {
       
   135     DLTRACEIN((""));
       
   136     }
       
   137 
       
   138 void CNcdServerReportOperation::QueryReceived(
       
   139     CNcdBaseOperation& /*aOperation*/, CNcdQuery* /*aQuery*/ )
       
   140     {
       
   141     DLTRACEIN((""));
       
   142     }
       
   143 
       
   144 void CNcdServerReportOperation::OperationComplete( 
       
   145     CNcdBaseOperation* aOperation, TInt aError )
       
   146     {
       
   147     DLTRACEIN(("aOperation=%08x, aError=%d", aOperation, aError));
       
   148     (void) aOperation; // suppresses compiler warning
       
   149 
       
   150     // Check if pending message still exists.
       
   151     // In case of the operation cancel, the pending message may have
       
   152     // already been completed and set to NULL. Then, do not try to
       
   153     // complete the same message again.
       
   154     if ( iPendingMessage )
       
   155         {
       
   156         DLINFO(("Completing server report operation with %d", aError));
       
   157         CompleteMessage( iPendingMessage, 
       
   158             aError != KErrNone ? 
       
   159                 ENCDOperationMessageCompletionError : 
       
   160                 ENCDOperationMessageCompletionComplete, 
       
   161             aError );        
       
   162         }
       
   163     }
       
   164