phonebookengines/mobcntactions/src/mobcntactionfactory.cpp
changeset 24 0ba2181d7c28
child 37 fd64c38c277d
equal deleted inserted replaced
0:e686773b3f54 24:0ba2181d7c28
       
     1 /*
       
     2 * Copyright (c) 2009 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 #ifndef ACTIONFACTORYPLUGINTARGET
       
    18 #define ACTIONFACTORYPLUGINTARGET mobcntactionplugin
       
    19 #endif
       
    20 #ifndef ACTIONFACTORYPLUGINNAME
       
    21 #define ACTIONFACTORYPLUGINNAME SymbianActionFactory
       
    22 #endif
       
    23 
       
    24 #include "mobcntactionfactory.h"
       
    25 #include "mobcntcallaction.h"
       
    26 #include "mobcntvideocallaction.h"
       
    27 #include "mobcntmessageaction.h"
       
    28 #include "mobcntemailaction.h"
       
    29 
       
    30 #define makestr(x) (#x)
       
    31 #define makename(x) makestr(x)
       
    32 
       
    33 
       
    34 //Factory class
       
    35 MobCntActionFactory::MobCntActionFactory() 
       
    36 {
       
    37 	actionList.append(new MobCntCallAction());
       
    38 	actionList.append(new MobCntVideoCallAction());
       
    39     actionList.append(new MobCntMessageAction());
       
    40     actionList.append(new MobCntEmailAction());
       
    41 }
       
    42 
       
    43 MobCntActionFactory::~MobCntActionFactory()
       
    44 {
       
    45 	 while (!actionList.isEmpty())
       
    46 	     delete actionList.takeFirst();
       
    47 }
       
    48 
       
    49 QString MobCntActionFactory::name() const
       
    50 {
       
    51     return QString(makename(ACTIONFACTORYPLUGINNAME));
       
    52 }
       
    53 
       
    54 
       
    55 QList<QContactActionDescriptor> MobCntActionFactory::actionDescriptors() const
       
    56 {
       
    57    QList<QContactActionDescriptor> descriptorList; 
       
    58    
       
    59    //loop through all the actions and add the descriptor to the list
       
    60    for (int i = 0; i < actionList.size(); i++)
       
    61    {
       
    62 	   descriptorList << actionList.at(i)->actionDescriptor();   
       
    63    }
       
    64    
       
    65    return descriptorList;
       
    66 }
       
    67 
       
    68 QContactAction* MobCntActionFactory::instance(const QContactActionDescriptor& descriptor) const
       
    69 {
       
    70     QContactAction *action(0);
       
    71 	
       
    72     //loop through the actions and return the one that supports the descriptor
       
    73     for (int i = 0; i < actionList.size() && action == 0; i++)
       
    74     {
       
    75     	if (actionList.at(i)->actionDescriptionSupported(descriptor)){
       
    76     		//create a new heap object of the action
       
    77     		action = actionList.at(i)->clone();
       
    78     	}    
       
    79     }
       
    80   
       
    81     return action;
       
    82 }
       
    83 
       
    84 QVariantMap MobCntActionFactory::actionMetadata(const QContactActionDescriptor& descriptor) const
       
    85 {
       
    86     Q_UNUSED(descriptor);
       
    87     
       
    88     return QVariantMap();
       
    89 }
       
    90 
       
    91 Q_EXPORT_PLUGIN2(ACTIONFACTORYPLUGINTARGET, MobCntActionFactory);