meetingrequest/mrgui/mrfieldbuilderplugin/src/CESMRFieldBuilderPlugin.cpp
changeset 0 8466d47a6819
child 12 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-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:  MRUI field build plugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include "CESMRFieldBuilderPlugin.h"
       
    21 
       
    22 //<cmail>
       
    23 #include "esmrdef.h"
       
    24 //</cmail>
       
    25 #include "mesmrresponseobserver.h"
       
    26 
       
    27 // Editor fields
       
    28 #include "cesmrsubjectfield.h"
       
    29 #include "cesmrtimefield.h"
       
    30 #include "cesmrdatefield.h"
       
    31 #include "cesmrlocationfield.h"
       
    32 #include "cesmralarmfield.h"
       
    33 #include "cesmrrecurencefield.h"
       
    34 #include "cesmrdescriptionfield.h"
       
    35 #include "cesmrcheckbox.h"
       
    36 #include "cesmrsingletimefield.h"
       
    37 #include "cesmrbooleanfield.h"
       
    38 #include "cesmrsyncfield.h"
       
    39 #include "cesmrpriorityfield.h"
       
    40 
       
    41 // Viewer fields
       
    42 #include "cesmrviewerlabelfield.h"
       
    43 #include "cesmrviewerlocationfield.h"
       
    44 #include "cesmrviewerstartdatefield.h"
       
    45 #include "cesmrviewertimefield.h"
       
    46 #include "cesmrvieweralarmfield.h"
       
    47 #include "cesmrviewerdescriptionfield.h"
       
    48 #include "cesmrviewerstopdatefield.h"
       
    49 #include "cesmrviewerrecurrencefield.h"
       
    50 #include "cesmrviewerrecurrencedatefield.h"
       
    51 #include "cesmrviewersyncfield.h"
       
    52 #include "cesmrviewerpriorityfield.h"
       
    53 #include "cesmrvieweralldayeventfield.h"
       
    54 #include "cesmrvieweralarmdatefield.h"
       
    55 #include "cesmrvieweralarmtimefield.h"
       
    56 #include "cesmrviewerdetailedsubjectfield.h"
       
    57 #include "cesmrrepeatuntil.h"
       
    58 
       
    59 // <cmail> Removed profiling.</cmail>
       
    60 
       
    61 /// Unnamed namespace for local definitions
       
    62 namespace { // codescanner::namespace
       
    63 
       
    64 #ifdef _DEBUG
       
    65 
       
    66 // Panic literal
       
    67 _LIT( KESMRFieldBuilderPlugin, "ESMRFieldBuilderPlugin" );
       
    68 
       
    69 /** Panic codes */
       
    70 enum TESMRFieldBuilderPluginPanic
       
    71     {
       
    72     EInvalidFieldId = 0 // Invalid field id
       
    73     };
       
    74 
       
    75 void Panic( TESMRFieldBuilderPluginPanic aPanic )
       
    76     {
       
    77     User::Panic( KESMRFieldBuilderPlugin, aPanic );
       
    78     }
       
    79 
       
    80 #endif // _DEBUG
       
    81 
       
    82 }  // namespace
       
    83 
       
    84 // ======== MEMBER FUNCTIONS ========
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CESMRFieldBuilderPlugin::CESMRFieldBuilderPlugin
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CESMRFieldBuilderPlugin::CESMRFieldBuilderPlugin()
       
    91     :iExtension(NULL),
       
    92     iFieldExtension(NULL)
       
    93     {
       
    94     FUNC_LOG;
       
    95     //do nothing
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // CESMRFieldBuilderPlugin::~CESMRFieldBuilderPlugin
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CESMRFieldBuilderPlugin::~CESMRFieldBuilderPlugin()
       
   103     {
       
   104     FUNC_LOG;
       
   105     delete iExtension;
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CESMRFieldBuilderPlugin::NewL
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 CESMRFieldBuilderPlugin* CESMRFieldBuilderPlugin::NewL()
       
   113     {
       
   114     FUNC_LOG;
       
   115     CESMRFieldBuilderPlugin* self = new (ELeave) CESMRFieldBuilderPlugin;
       
   116     return self;
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CESMRFieldBuilderPlugin::ExtensionL
       
   121 // ----------------------------------------------------------------------------
       
   122 //
       
   123 TAny* CESMRFieldBuilderPlugin::ExtensionL( TUid aExtensionUid )
       
   124     {
       
   125     FUNC_LOG;
       
   126     if(!iExtension)
       
   127         {
       
   128         LoadExtensionL();
       
   129         }
       
   130 
       
   131     TAny* extension = NULL;
       
   132     if ( iExtension )
       
   133         {
       
   134         extension = iExtension->ExtensionL( aExtensionUid );
       
   135         }
       
   136     return extension;
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // CESMRFieldBuilderPlugin::FieldBuilderL()
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 MESMRFieldBuilder* CESMRFieldBuilderPlugin::FieldBuilderL()
       
   144     {
       
   145     FUNC_LOG;
       
   146     return this;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CESMRFieldBuilderPlugin::CreateEditorFieldL()
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 CESMRField* CESMRFieldBuilderPlugin::CreateEditorFieldL(
       
   154         MESMRFieldValidator* aValidator,
       
   155         TESMREntryField aField )
       
   156     {
       
   157     FUNC_LOG;
       
   158     CESMRField* field = NULL;
       
   159     switch ( aField.iFieldId )
       
   160         {
       
   161         case EESMRFieldMeetingTime:
       
   162             field = CESMRTimeField::NewL( aValidator );
       
   163             break;
       
   164         case EESMRFieldStartDate:
       
   165             field = CESMRDateField::NewL( aValidator, aField.iFieldId );
       
   166             break;
       
   167         case EESMRFieldStopDate:
       
   168             field = CESMRDateField::NewL( aValidator, aField.iFieldId );
       
   169             break;
       
   170         case EESMRFieldLocation:
       
   171             field = CESMRLocationField::NewL();
       
   172             break;
       
   173         case EESMRFieldAlarm:
       
   174             field = CESMRAlarmField::NewL( aValidator );
       
   175             break;
       
   176         case EESMRFieldAllDayEvent:
       
   177             field = CESMRCheckBox::NewL( aValidator );
       
   178             break;
       
   179         case EESMRFieldAlarmOnOff:
       
   180             field = CESMRBooleanField::NewL( aValidator );
       
   181             break;
       
   182         case EESMRFieldAlarmTime:
       
   183             field = CESMRSingleTimeField::NewL( aValidator );
       
   184             break;
       
   185         case EESMRFieldAlarmDate:
       
   186             field = CESMRDateField::NewL( aValidator, aField.iFieldId );
       
   187             break;
       
   188         case EESMRFieldSubject:
       
   189             field = CESMRSubjectField::NewL();
       
   190             break;
       
   191         case EESMRFieldDescription:
       
   192             field = CESMRDescriptionField::NewL();
       
   193             break;
       
   194         case EESMRFieldRecurrence:
       
   195             field = CESMRRecurenceField::NewL( aValidator );
       
   196             break;
       
   197         case EESMRFieldRecurrenceDate:
       
   198             field = CESMRRepeatUntilField::NewL( aValidator );
       
   199             break;
       
   200         case EESMRFieldSync:
       
   201             field = CESMRSyncField::NewL();
       
   202             break;
       
   203         case EESMRFieldOccasion:
       
   204             field = CESMRSubjectField::NewL( CESMRSubjectField::ETypeOccasion );
       
   205             break;
       
   206         case EESMRFieldPriority:
       
   207             field = CESMRPriorityField::NewL();
       
   208             break;
       
   209         default:
       
   210             {
       
   211             field = FieldBuilderExtensionL()->CreateEditorFieldL(
       
   212                     aValidator,
       
   213                     aField );
       
   214             }
       
   215             break;
       
   216         }
       
   217 
       
   218     __ASSERT_DEBUG( field, Panic(EInvalidFieldId) );
       
   219     return field;
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------------------------
       
   223 // CESMRFieldBuilderPlugin::CreateViewerFieldL()
       
   224 // ---------------------------------------------------------------------------
       
   225 //
       
   226 CESMRField* CESMRFieldBuilderPlugin::CreateViewerFieldL( MESMRResponseObserver* aResponseObserver,
       
   227                                                    TESMREntryField aField,
       
   228                                                    TBool aResponseReady )
       
   229     {
       
   230     FUNC_LOG;
       
   231     CESMRField* field = NULL;
       
   232     switch ( aField.iFieldId )
       
   233         {
       
   234         case EESMRFieldMeetingTime:
       
   235             {
       
   236             field = CESMRViewerTimeField::NewL();
       
   237             break;
       
   238             }
       
   239         case EESMRFieldStartDate:
       
   240             {
       
   241             field = CESMRViewerStartDateField::NewL();
       
   242             break;
       
   243             }
       
   244         case EESMRFieldStopDate:
       
   245             {
       
   246             field = CESMRViewerStopDateField::NewL();
       
   247             break;
       
   248             }
       
   249         case EESMRFieldLocation:
       
   250             {
       
   251             field = CESMRViewerLocationField::NewL();
       
   252             break;
       
   253             }
       
   254         case EESMRFieldAlarm:
       
   255             {
       
   256             field = CESMRViewerAlarmField::NewL();
       
   257             break;
       
   258             }
       
   259         case EESMRFieldDescription:
       
   260             {
       
   261             field = CESMRViewerDescriptionField::NewL();
       
   262             break;
       
   263             }
       
   264         case EESMRFieldRecurrence:
       
   265             {
       
   266             field = CESMRViewerRecurrenceField::NewL();
       
   267             break;
       
   268             }
       
   269         case EESMRFieldRecurrenceDate:
       
   270             {
       
   271             field = CESMRViewerRecurrenceDateField::NewL();
       
   272             break;
       
   273             }
       
   274         case EESMRFieldSync:
       
   275             {
       
   276             field = CESMRViewerSyncField::NewL();
       
   277             break;
       
   278             }
       
   279         case EESMRFieldPriority:
       
   280             {
       
   281             field = CESMRViewerPriorityField::NewL();
       
   282             break;
       
   283             }
       
   284         case EESMRFieldAllDayEvent:
       
   285             {
       
   286             field = CESMRViewerAllDayEventField::NewL();
       
   287             break;
       
   288             }
       
   289         case EESMRFieldAlarmDate:
       
   290             {
       
   291             field = CESMRViewerAlarmDateField::NewL();
       
   292             break;
       
   293             }
       
   294         case EESMRFieldAlarmTime:
       
   295             {
       
   296             field = CESMRViewerAlarmTimeField::NewL();
       
   297             break;
       
   298             }
       
   299         case EESMRFieldDetailedSubject:
       
   300             {
       
   301             field = CESMRViewerDetailedSubjectField::NewL();
       
   302             break;
       
   303             }
       
   304         default:
       
   305             {
       
   306             MESMRFieldBuilder* extension = FieldBuilderExtensionL();
       
   307             if ( extension )
       
   308                 {
       
   309                 field = extension->CreateViewerFieldL(
       
   310                         aResponseObserver,
       
   311                         aField,
       
   312                         aResponseReady );
       
   313                 }
       
   314             }
       
   315             break;
       
   316         }
       
   317 
       
   318     __ASSERT_DEBUG( field, Panic(EInvalidFieldId) );
       
   319     // Set field mode
       
   320     field->SetFieldMode( EESMRFieldModeView );
       
   321     
       
   322     return field;
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CESMRFieldBuilderPlugin::FieldBuilderExtensionL()
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 MESMRFieldBuilder* CESMRFieldBuilderPlugin::FieldBuilderExtensionL()
       
   330     {
       
   331     FUNC_LOG;
       
   332     if(!iFieldExtension)
       
   333         {
       
   334         LoadExtensionL();
       
   335         }
       
   336 
       
   337     return iFieldExtension;
       
   338     }
       
   339 
       
   340 // ---------------------------------------------------------------------------
       
   341 // CESMRFieldBuilderPlugin::LoadExtensionL()
       
   342 // ---------------------------------------------------------------------------
       
   343 //
       
   344 void CESMRFieldBuilderPlugin::LoadExtensionL()
       
   345     {
       
   346     FUNC_LOG;
       
   347     CESMRFieldBuilderInterface* extension = NULL;
       
   348 
       
   349     TRAPD(error,
       
   350             extension = CESMRFieldBuilderInterface::CreatePluginL(
       
   351                     TUid::Uid(KESMRUIFieldBuilderPluginExtensionImplUId) ) );
       
   352 
       
   353     if ( error == KErrNone && extension )
       
   354         {
       
   355         delete iExtension;
       
   356         iExtension = extension;
       
   357         iFieldExtension = iExtension->FieldBuilderL();
       
   358         }
       
   359 
       
   360     }
       
   361 //EOF
       
   362