phonebookui/Phonebook2/CommandsExtension/src/CPbk2CommandFactory.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Creates Phonebook 2 command objects.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPbk2CommandFactory.h"
       
    21 
       
    22 // Phonebook 2
       
    23 #include <CPbk2UIExtensionManager.h>
       
    24 
       
    25 // include command handlers
       
    26 #include "CPbk2DeleteContactsCmd.h"
       
    27 #include "CPbk2GoToURLCmd.h"
       
    28 #include "CPbk2CreateNewContactCmd.h"
       
    29 #include "CPbk2EditContactCmd.h"
       
    30 #include "CPbk2SendMessageCmd.h"
       
    31 #include "CPbk2SetThumbnailCmd.h"
       
    32 #include "CPbk2AssignDefaultsCmd.h"
       
    33 #include "CPbk2RemoveThumbnailCmd.h"
       
    34 #include "CPbk2AssignSpeedDialCmd.h"
       
    35 #include "CPbk2RemoveSpeedDialCmd.h"
       
    36 #include "CPbk2SendContactCmd.h"
       
    37 #include "CPbk2SetImageCmd.h"
       
    38 #include "CPbk2ViewImageCmd.h"
       
    39 #include "CPbk2RemoveImageCmd.h"
       
    40 #include "CPbk2CopyContactsStarterCmd.h"
       
    41 #include "CPbk2CopyNumberToClipboardCmd.h"
       
    42 #include "CPbk2InfoDialogCmd.h"
       
    43 #include "CPbk2CopyDetailToClipboardCmd.h" 
       
    44 #include "CPbk2CopyAddressToClipboardCmd.h" 
       
    45 #include "CPbk2MergeContactsCmd.h"
       
    46 #include "CPbkRclCmd.h"  //RCL_ADD
       
    47 // Send UI Uids
       
    48 #include <SenduiMtmUids.h>
       
    49 
       
    50 /// Unnamed namespace for local definitions
       
    51 namespace {
       
    52 
       
    53 typedef MPbk2Command* (CPbk2CommandFactory::*CommandCreationFunction)
       
    54     (MPbk2ContactUiControl&) const;
       
    55 
       
    56 struct TPbk2CommandIdMapping
       
    57     {
       
    58     TPbk2CommandId iCommandId;
       
    59     CommandCreationFunction iCreationFunctionL;
       
    60     };
       
    61 
       
    62 static const TPbk2CommandIdMapping CommandIdMapping[] =
       
    63     {
       
    64     {EPbk2CmdDeleteMe,
       
    65         &CPbk2CommandFactory::CreateDeleteContactsCommandL},
       
    66     {EPbk2CmdGoToURL,
       
    67         &CPbk2CommandFactory::CreateGoToURLCommandL},
       
    68     {EPbk2CmdCreateNew,
       
    69         &CPbk2CommandFactory::CreateNewContactCommandL},
       
    70     {EPbk2CmdRcl,  //RCL_ADD
       
    71         &CPbk2CommandFactory::CreateRclCommandL},
       
    72     {EPbk2CmdEditMe,
       
    73         &CPbk2CommandFactory::CreateEditContactCommandL},
       
    74     {EPbk2CmdWrite,
       
    75         &CPbk2CommandFactory::CreateSendMessageCommandL},
       
    76     {EPbk2CmdFetchThumbnail,
       
    77         &CPbk2CommandFactory::CreateSetThumbnailCommandL},
       
    78     {EPbk2CmdDefaultSettings,
       
    79         &CPbk2CommandFactory::CreateAssignDefaultsCommandL},
       
    80     {EPbk2CmdRemoveThumbnail,
       
    81         &CPbk2CommandFactory::CreateRemoveThumbnailCommandL},
       
    82     {EPbk2CmdAssignSpeedDial,
       
    83         &CPbk2CommandFactory::CreateAssignSpeedDialCommandL},
       
    84     {EPbk2CmdRemoveSpeedDial,
       
    85         &CPbk2CommandFactory::CreateRemoveSpeedDialCommandL},
       
    86     {EPbk2CmdSend,
       
    87         &CPbk2CommandFactory::CreateSendContactCommandL},
       
    88     {EPbk2CmdAddImage,
       
    89         &CPbk2CommandFactory::CreateAddImageCommandL},
       
    90     {EPbk2CmdViewImage,
       
    91         &CPbk2CommandFactory::CreateViewImageCommandL},
       
    92     {EPbk2CmdChangeImage,
       
    93         &CPbk2CommandFactory::CreateChangeImageCommandL},
       
    94     {EPbk2CmdRemoveImage,
       
    95         &CPbk2CommandFactory::CreateRemoveImageCommandL},
       
    96     {EPbk2CmdCopy,
       
    97         &CPbk2CommandFactory::CreateCopyContactsStarterCommandL},
       
    98     {EPbk2CmdCopyNumber,
       
    99         &CPbk2CommandFactory::CreateCopyNumberToClipboardCommandL},
       
   100     {EPbk2CmdPhonebook2Info,
       
   101         &CPbk2CommandFactory::CreateLaunchInfoDialogCommandL},
       
   102     {EPbk2CmdWriteNoQuery,
       
   103         &CPbk2CommandFactory::CreateSendMessageNoQueryCommandL},
       
   104     {EPbk2CmdCopyDetail,
       
   105         &CPbk2CommandFactory::CreateCopyDetailToClipboardCommandL},
       
   106     {EPbk2CmdCopyAddress,
       
   107         &CPbk2CommandFactory::CreateCopyAddressToClipboardCommandL},
       
   108     {EPbk2CmdMergeContacts,
       
   109         &CPbk2CommandFactory::CreateMergeContactsCommandL},
       
   110     {EPbk2CmdLast,
       
   111         NULL}
       
   112     };
       
   113 
       
   114 } /// namespace
       
   115 
       
   116 // --------------------------------------------------------------------------
       
   117 // CPbk2CommandFactory::CPbk2CommandFactory
       
   118 // --------------------------------------------------------------------------
       
   119 //
       
   120 CPbk2CommandFactory::CPbk2CommandFactory()
       
   121     {
       
   122     }
       
   123 
       
   124 // --------------------------------------------------------------------------
       
   125 // CPbk2CommandFactory::~CPbk2CommandFactory
       
   126 // --------------------------------------------------------------------------
       
   127 //
       
   128 CPbk2CommandFactory::~CPbk2CommandFactory()
       
   129     {
       
   130     }
       
   131 
       
   132 // --------------------------------------------------------------------------
       
   133 // CPbk2CommandFactory::NewL
       
   134 // --------------------------------------------------------------------------
       
   135 //
       
   136 CPbk2CommandFactory* CPbk2CommandFactory::NewL()
       
   137     {
       
   138     CPbk2CommandFactory* self = new ( ELeave ) CPbk2CommandFactory;
       
   139     return self;
       
   140     }
       
   141 
       
   142 // --------------------------------------------------------------------------
       
   143 // CPbk2CommandFactory::CreateCommandForIdL
       
   144 // --------------------------------------------------------------------------
       
   145 //
       
   146 MPbk2Command* CPbk2CommandFactory::CreateCommandForIdL
       
   147         ( TPbk2CommandId aCommandId,
       
   148           MPbk2ContactUiControl& aUiControl ) const
       
   149     {
       
   150     MPbk2Command* result = NULL;
       
   151     for (TInt i = 0; CommandIdMapping[i].iCommandId != EPbk2CmdLast; ++i)
       
   152         {
       
   153         if (CommandIdMapping[i].iCommandId == aCommandId)
       
   154             {
       
   155             result = (this->*CommandIdMapping[i].iCreationFunctionL)
       
   156                 (aUiControl);
       
   157             break;
       
   158             }
       
   159         }
       
   160                 
       
   161     return result;
       
   162     }
       
   163 
       
   164 // --------------------------------------------------------------------------
       
   165 // CPbk2CommandFactory::CreateDeleteContactsCommandL
       
   166 // --------------------------------------------------------------------------
       
   167 //
       
   168 MPbk2Command* CPbk2CommandFactory::CreateDeleteContactsCommandL
       
   169         (MPbk2ContactUiControl& aUiControl) const
       
   170     {
       
   171     return CPbk2DeleteContactsCmd::NewL(aUiControl);
       
   172     }
       
   173 
       
   174 // --------------------------------------------------------------------------
       
   175 // CPbk2CommandFactory::CreateGoToURLCommandL
       
   176 // --------------------------------------------------------------------------
       
   177 //
       
   178 MPbk2Command* CPbk2CommandFactory::CreateGoToURLCommandL
       
   179         (MPbk2ContactUiControl& aUiControl) const
       
   180     {
       
   181     return CPbk2GoToURLCmd::NewL(aUiControl);
       
   182     }
       
   183 
       
   184 // --------------------------------------------------------------------------
       
   185 // CPbk2CommandFactory::CreateNewContactCommandL
       
   186 // --------------------------------------------------------------------------
       
   187 //
       
   188 MPbk2Command* CPbk2CommandFactory::CreateNewContactCommandL(
       
   189         MPbk2ContactUiControl& aUiControl) const
       
   190     {
       
   191     return CPbk2CreateNewContactCmd::NewL(aUiControl);
       
   192     }
       
   193 
       
   194 // --------------------------------------------------------------------------
       
   195 // CPbk2CommandFactory::CreateEditContactCommandL
       
   196 // --------------------------------------------------------------------------
       
   197 //
       
   198 MPbk2Command* CPbk2CommandFactory::CreateEditContactCommandL(
       
   199     MPbk2ContactUiControl& aUiControl) const
       
   200     {
       
   201     return CPbk2EditContactCmd::NewL(aUiControl);
       
   202     }
       
   203 
       
   204 // --------------------------------------------------------------------------
       
   205 // CPbk2CommandFactory::CreateSendMessageCommandL
       
   206 // --------------------------------------------------------------------------
       
   207 //
       
   208 MPbk2Command* CPbk2CommandFactory::CreateSendMessageCommandL(
       
   209     MPbk2ContactUiControl& aUiControl) const
       
   210     {
       
   211     return CPbk2SendMessageCmd::NewL(aUiControl);
       
   212     }
       
   213 
       
   214 // --------------------------------------------------------------------------
       
   215 // CPbk2CommandFactory::CreateSetThumbnailCommandL
       
   216 // --------------------------------------------------------------------------
       
   217 //
       
   218 MPbk2Command* CPbk2CommandFactory::CreateSetThumbnailCommandL(
       
   219     MPbk2ContactUiControl& aUiControl) const
       
   220     {
       
   221     return CPbk2SetThumbnailCmd::NewL(aUiControl);
       
   222     }
       
   223 
       
   224 // --------------------------------------------------------------------------
       
   225 // CPbk2CommandFactory::CreateAssignDefaultsCommandL
       
   226 // --------------------------------------------------------------------------
       
   227 //
       
   228 MPbk2Command* CPbk2CommandFactory::CreateAssignDefaultsCommandL(
       
   229     MPbk2ContactUiControl& aUiControl) const
       
   230     {
       
   231     return CPbk2AssignDefaultsCmd::NewL(aUiControl);
       
   232     }
       
   233 
       
   234 // --------------------------------------------------------------------------
       
   235 // CPbk2CommandFactory::CreateRemoveThumbnailCommandL
       
   236 // --------------------------------------------------------------------------
       
   237 //
       
   238 MPbk2Command* CPbk2CommandFactory::CreateRemoveThumbnailCommandL(
       
   239     MPbk2ContactUiControl& aUiControl) const
       
   240     {
       
   241     return CPbk2RemoveThumbnailCmd::NewL(aUiControl);
       
   242     }
       
   243 
       
   244 // --------------------------------------------------------------------------
       
   245 // CPbk2CommandFactory::CreateAddImageCommandL
       
   246 // --------------------------------------------------------------------------
       
   247 //
       
   248 MPbk2Command* CPbk2CommandFactory::CreateAddImageCommandL(
       
   249     MPbk2ContactUiControl& aUiControl) const
       
   250     {
       
   251     return CPbk2SetImageCmd::NewL(aUiControl);
       
   252     }
       
   253 
       
   254 // --------------------------------------------------------------------------
       
   255 // CPbk2CommandFactory::CreateViewImageCommandL
       
   256 // --------------------------------------------------------------------------
       
   257 //
       
   258 MPbk2Command* CPbk2CommandFactory::CreateViewImageCommandL(
       
   259     MPbk2ContactUiControl& aUiControl) const
       
   260     {
       
   261     return CPbk2ViewImageCmd::NewL(aUiControl);
       
   262     }
       
   263 
       
   264 // --------------------------------------------------------------------------
       
   265 // CPbk2CommandFactory::CreateChangeImageCommandL
       
   266 // --------------------------------------------------------------------------
       
   267 //
       
   268 MPbk2Command* CPbk2CommandFactory::CreateChangeImageCommandL(
       
   269     MPbk2ContactUiControl& aUiControl) const
       
   270     {
       
   271     return CPbk2SetImageCmd::NewL(aUiControl);
       
   272     }
       
   273 
       
   274 // --------------------------------------------------------------------------
       
   275 // CPbk2CommandFactory::CreateRemoveImageCommandL
       
   276 // --------------------------------------------------------------------------
       
   277 //
       
   278 MPbk2Command* CPbk2CommandFactory::CreateRemoveImageCommandL(
       
   279     MPbk2ContactUiControl& aUiControl) const
       
   280     {
       
   281     return CPbk2RemoveImageCmd::NewL(aUiControl);
       
   282     }
       
   283 
       
   284 
       
   285 // --------------------------------------------------------------------------
       
   286 // CPbk2CommandFactory::CreateAssignSpeedDialCommandL
       
   287 // --------------------------------------------------------------------------
       
   288 //
       
   289 MPbk2Command* CPbk2CommandFactory::CreateAssignSpeedDialCommandL(
       
   290         MPbk2ContactUiControl& aUiControl) const
       
   291     {
       
   292     return CPbk2AssignSpeedDialCmd::NewL(aUiControl);
       
   293     }
       
   294 
       
   295 // --------------------------------------------------------------------------
       
   296 // CPbk2CommandFactory::CreateRemoveSpeedDialCommandL
       
   297 // --------------------------------------------------------------------------
       
   298 //
       
   299 MPbk2Command* CPbk2CommandFactory::CreateRemoveSpeedDialCommandL(
       
   300         MPbk2ContactUiControl& aUiControl) const
       
   301     {
       
   302     return CPbk2RemoveSpeedDialCmd::NewL(aUiControl);
       
   303     }
       
   304 
       
   305 // --------------------------------------------------------------------------
       
   306 // CPbk2CommandFactory::CreateSendContactCommandL
       
   307 // --------------------------------------------------------------------------
       
   308 //
       
   309 MPbk2Command* CPbk2CommandFactory::CreateSendContactCommandL(
       
   310     MPbk2ContactUiControl& aUiControl) const
       
   311     {
       
   312     return CPbk2SendContactCmd::NewL(aUiControl);
       
   313     }
       
   314 
       
   315 // --------------------------------------------------------------------------
       
   316 // CPbk2CommandFactory::CreateCopyContactsStarterCommandL
       
   317 // --------------------------------------------------------------------------
       
   318 //
       
   319 MPbk2Command* CPbk2CommandFactory::CreateCopyContactsStarterCommandL(
       
   320             MPbk2ContactUiControl& aUiControl) const
       
   321     {
       
   322     return CPbk2CopyContactsStarterCmd::NewL(aUiControl);
       
   323     }
       
   324 
       
   325 // --------------------------------------------------------------------------
       
   326 // CPbk2CommandFactory::CreateCopyNumberToClipboardCommandL
       
   327 // --------------------------------------------------------------------------
       
   328 //
       
   329 MPbk2Command* CPbk2CommandFactory::CreateCopyNumberToClipboardCommandL(
       
   330             MPbk2ContactUiControl& aUiControl) const
       
   331     {
       
   332     return CPbk2CopyNumberToClipboardCmd::NewL(aUiControl);
       
   333     }
       
   334 
       
   335 // --------------------------------------------------------------------------
       
   336 // CPbk2CommandFactory::CreateCopyDetailToClipboardCommandL
       
   337 // --------------------------------------------------------------------------
       
   338 //
       
   339 MPbk2Command* CPbk2CommandFactory::CreateCopyDetailToClipboardCommandL(
       
   340             MPbk2ContactUiControl& aUiControl) const
       
   341     {
       
   342     return CPbk2CopyDetailToClipboardCmd::NewL(aUiControl);
       
   343     }
       
   344 
       
   345 // --------------------------------------------------------------------------
       
   346 // CPbk2CommandFactory::CreateCopyAddressToClipboardCommandL
       
   347 // --------------------------------------------------------------------------
       
   348 //
       
   349 MPbk2Command* CPbk2CommandFactory::CreateCopyAddressToClipboardCommandL(
       
   350             MPbk2ContactUiControl& aUiControl) const
       
   351     {
       
   352     return CPbk2CopyAddressToClipboardCmd::NewL(aUiControl);
       
   353     }
       
   354 
       
   355 // --------------------------------------------------------------------------
       
   356 // CPbk2CommandFactory::CreateLaunchInfoDialogCommandL
       
   357 // --------------------------------------------------------------------------
       
   358 //
       
   359 MPbk2Command* CPbk2CommandFactory::CreateLaunchInfoDialogCommandL(
       
   360             MPbk2ContactUiControl& aUiControl) const
       
   361     {
       
   362     return CPbk2InfoDialogCmd::NewL(aUiControl);
       
   363     }
       
   364 
       
   365 // --------------------------------------------------------------------------
       
   366 // CPbk2CommandFactory::CreateSendMessageNoQueryCommandL
       
   367 // --------------------------------------------------------------------------
       
   368 //
       
   369 MPbk2Command* CPbk2CommandFactory::CreateSendMessageNoQueryCommandL(
       
   370     MPbk2ContactUiControl& aUiControl) const
       
   371     {
       
   372     CPbk2SendMessageCmd* cmd = CPbk2SendMessageCmd::NewL(aUiControl);
       
   373 
       
   374     // Unified message editor used as default 
       
   375     // when message type not queried from the user
       
   376     cmd->SetMtmUid( KSenduiMtmUniMessageUid );
       
   377     return cmd;
       
   378     }
       
   379 	
       
   380 //RCL_ADD
       
   381 // --------------------------------------------------------------------------
       
   382 // CPbk2CommandFactory::CreateLaunchInfoDialogCommandL
       
   383 // --------------------------------------------------------------------------
       
   384 //
       
   385 MPbk2Command* CPbk2CommandFactory::CreateRclCommandL(
       
   386             MPbk2ContactUiControl& aUiControl) const
       
   387     {
       
   388     return CPbkRclCmd::NewL(aUiControl);
       
   389     }
       
   390 	
       
   391 // --------------------------------------------------------------------------
       
   392 // CPbk2CommandFactory::CreateMergeContactsCommandL
       
   393 // --------------------------------------------------------------------------
       
   394 //
       
   395 MPbk2Command* CPbk2CommandFactory::CreateMergeContactsCommandL(
       
   396             MPbk2ContactUiControl& aUiControl) const
       
   397     {
       
   398     return CPbk2MergeContactsCmd::NewL(aUiControl);
       
   399     }
       
   400 
       
   401 // End of File
       
   402