emailcontacts/contactactionservice/src/cfsccontactactionserviceimpl.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Implementation of the class CFscContactActionServiceImpl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCUDES
       
    20 #include "emailtrace.h"
       
    21 #include <ecom/implementationproxy.h>
       
    22 #include "mfsccontactactionserviceobserver.h"
       
    23 
       
    24 #include "cfsccontactactionserviceimpl.h"
       
    25 #include "fsccontactactionserviceuids.hrh"
       
    26 #include "cfsccontactactionpluginengine.h"
       
    27 #include "cfsccontactactionplugin.h"
       
    28 #include "cfsccontactset.h"
       
    29 #include "cfscstorecontactset.h"
       
    30 #include "cfsccontactlinkset.h"
       
    31 
       
    32 
       
    33 const TImplementationProxy ImplementationTable[] =
       
    34     {
       
    35     IMPLEMENTATION_PROXY_ENTRY( KFscContactActionServiceImplImpUid, 
       
    36                                 CFscContactActionServiceImpl::NewL )
       
    37     };
       
    38     
       
    39 // ======== LOCAL FUNCTIONS ========
       
    40 
       
    41 // ======== MEMBER FUNCTIONS ========
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // Two-phased constructor.
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CFscContactActionServiceImpl* CFscContactActionServiceImpl::NewL(
       
    48     TAny* aParams )
       
    49     {
       
    50     FUNC_LOG;
       
    51 
       
    52     TFscContactActionServiceConstructParameters* params = reinterpret_cast< 
       
    53             TFscContactActionServiceConstructParameters* >( aParams );
       
    54     
       
    55     CFscContactActionServiceImpl* self = 
       
    56         new ( ELeave ) CFscContactActionServiceImpl( *params );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60         
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Destructor.
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CFscContactActionServiceImpl::~CFscContactActionServiceImpl()
       
    69     {
       
    70     FUNC_LOG;
       
    71     delete iPluginEngine;
       
    72     delete iActionList;
       
    73     ClearContactSet();
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Method for setting current contact set to the service.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CFscContactActionServiceImpl::SetContactSetL( 
       
    81     MFscContactLinkIterator* aIterator )
       
    82     {
       
    83     FUNC_LOG;
       
    84     
       
    85     ClearContactSet();
       
    86     
       
    87     iContactSet = CFscContactLinkSet::NewL( iVPbkContactManager, aIterator );
       
    88     
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Method for setting current contact set to the service.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CFscContactActionServiceImpl::SetContactSetL( 
       
    96     const RFscStoreContactList& aStoreContactList )
       
    97     {
       
    98     FUNC_LOG;
       
    99     
       
   100     ClearContactSet();
       
   101     
       
   102     iContactSet = CFscStoreContactSet::NewL( iVPbkContactManager, 
       
   103             aStoreContactList );
       
   104     
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // Method for quering available actions.
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CFscContactActionServiceImpl::QueryActionsL(
       
   112     MFscContactActionServiceObserver* aObserver,
       
   113     TBool aStopWhenOneActionFound, TUint64 aActionTypeFlags, 
       
   114     TInt aMinPriority )
       
   115     {
       
   116     FUNC_LOG;
       
   117     iObserver = aObserver;
       
   118 
       
   119     
       
   120     if ( !iIsCasUsed )
       
   121         {
       
   122         iIsCasUsed = ETrue;
       
   123         
       
   124         if ( !iPluginEngine->PluginsLoaded() )
       
   125             {
       
   126             iPluginEngine->LoadPluginsL();
       
   127             }
       
   128         iActionList->Reset();
       
   129     
       
   130         iPluginEngine->QueryActionsL( *iActionList, *iContactSet, 
       
   131             aStopWhenOneActionFound, aActionTypeFlags, aMinPriority, this );
       
   132         }
       
   133     else
       
   134         {
       
   135         aObserver->QueryActionsFailed( KErrInUse );
       
   136         }
       
   137     
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------------------------
       
   141 // Cancels async method QueryActionsL.
       
   142 // ---------------------------------------------------------------------------
       
   143 //
       
   144 void CFscContactActionServiceImpl::CancelQueryActions()
       
   145     {
       
   146     FUNC_LOG;
       
   147     if ( iIsCasUsed )
       
   148         {
       
   149         iPluginEngine->CancelQueryActions();
       
   150         iIsCasUsed = EFalse;
       
   151         }
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // Called when QueryActionsL method is complete.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 void CFscContactActionServiceImpl::QueryActionsComplete()
       
   159     {
       
   160     FUNC_LOG;
       
   161     iIsCasUsed = EFalse;
       
   162     iObserver->QueryActionsComplete();
       
   163     }
       
   164  
       
   165 // ---------------------------------------------------------------------------
       
   166 // Called when QueryActionsL method failed.
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CFscContactActionServiceImpl::QueryActionsFailed( TInt aError )
       
   170     {
       
   171     FUNC_LOG;
       
   172     iIsCasUsed = EFalse;
       
   173     iObserver->QueryActionsFailed( aError );
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // Return action query results.
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 const CFscContactActionList& 
       
   181     CFscContactActionServiceImpl::QueryResults() const
       
   182     {
       
   183     return *iActionList;
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // Execute action.
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 void CFscContactActionServiceImpl::ExecuteL( TUid aActionUid, 
       
   191     MFscContactActionServiceObserver* aObserver )
       
   192     {
       
   193     FUNC_LOG;
       
   194     iObserver = aObserver;
       
   195     
       
   196     if ( !iIsCasUsed )
       
   197         {
       
   198         iIsCasUsed = ETrue;
       
   199     
       
   200         if ( !iPluginEngine->PluginsLoaded() )
       
   201             {
       
   202             iPluginEngine->LoadPluginsL();
       
   203             }
       
   204     
       
   205         iPluginEngine->ExecuteL( aActionUid, *iContactSet, this );
       
   206         }
       
   207     else
       
   208         {
       
   209         aObserver->ExecuteFailed( KErrInUse );
       
   210         }
       
   211     
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // Cancels async method ExecuteL.
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 void CFscContactActionServiceImpl::CancelExecute()
       
   219     {
       
   220     FUNC_LOG;
       
   221     if ( iIsCasUsed )
       
   222         {
       
   223         iPluginEngine->CancelExecute();
       
   224         iIsCasUsed = EFalse;
       
   225         }
       
   226     }
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // Called when ExecuteL method is complete.
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 void CFscContactActionServiceImpl::ExecuteComplete()
       
   233     {
       
   234     FUNC_LOG;
       
   235     iIsCasUsed = EFalse;
       
   236     iObserver->ExecuteComplete();
       
   237     }
       
   238    
       
   239 // ---------------------------------------------------------------------------
       
   240 // Called when ExecuteL method failed.
       
   241 // ---------------------------------------------------------------------------
       
   242 //
       
   243 void CFscContactActionServiceImpl::ExecuteFailed( TInt aError )
       
   244     {
       
   245     FUNC_LOG;
       
   246     iIsCasUsed = EFalse;
       
   247     iObserver->ExecuteFailed( aError );
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // Constructor.
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 CFscContactActionServiceImpl::CFscContactActionServiceImpl( 
       
   255     const TFscContactActionServiceConstructParameters& aParams )
       
   256     : CFscContactActionService(), 
       
   257       iVPbkContactManager( aParams.iVPbkContactManager ),
       
   258       iIsCasUsed( EFalse )
       
   259     {
       
   260     FUNC_LOG;
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------------------------
       
   264 // Second phase constructor.
       
   265 // ---------------------------------------------------------------------------
       
   266 //
       
   267 void CFscContactActionServiceImpl::ConstructL()
       
   268     {
       
   269     FUNC_LOG;
       
   270     
       
   271     iPluginEngine = 
       
   272         CFscContactActionPluginEngine::NewL( iVPbkContactManager );
       
   273     
       
   274     iActionList = new ( ELeave ) CFscContactActionList( 5 );
       
   275     } 
       
   276    
       
   277 // ---------------------------------------------------------------------------
       
   278 // Clear contacts and groups
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 void CFscContactActionServiceImpl::ClearContactSet()
       
   282     {
       
   283     FUNC_LOG;
       
   284     delete iContactSet;
       
   285     iContactSet = NULL;
       
   286     }      
       
   287 
       
   288     
       
   289 // ======== GLOBAL FUNCTIONS ========
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // ImplementationGroupProxy
       
   293 // ---------------------------------------------------------------------------
       
   294 //
       
   295 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
       
   296     TInt& aTableCount )
       
   297     {
       
   298     aTableCount = sizeof( ImplementationTable ) / 
       
   299         sizeof( TImplementationProxy );
       
   300     return ImplementationTable;
       
   301     }
       
   302