meetingrequest/mrguicommon/src/cesmrlistquery.cpp
branchRCL_3
changeset 16 4ce476e64c59
child 24 b5fbb9b25d57
equal deleted inserted replaced
13:0396474f30f5 16:4ce476e64c59
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Implementation for mrui list queries
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "emailtrace.h"
       
    21 #include "cesmrlistquery.h"
       
    22 
       
    23 #include <aknlists.h>
       
    24 //<cmail>
       
    25 #include "esmrdef.h"
       
    26 //</cmail>
       
    27 #include <aknpopup.h>
       
    28 #include <bautils.h>
       
    29 #include <esmrgui.rsg>
       
    30 #include <stringloader.h>
       
    31 #include <data_caging_path_literals.hrh>
       
    32 
       
    33 #include "esmrgui.hrh"
       
    34 #include "cesmralarm.h"
       
    35 #include "cesmrrecurrence.h"
       
    36 #include "esmrhelper.h"//locateresourcefile
       
    37 
       
    38 // CONSTANTS
       
    39 // Unnamed namespace for local definitions
       
    40 namespace {
       
    41 
       
    42 // resource file:
       
    43 _LIT( KResourceFileName, "esmrgui.rsc");
       
    44 
       
    45 } // namespace
       
    46 
       
    47 // ======== MEMBER FUNCTIONS ========
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CESMRListQuery::CESMRListQuery
       
    51 // C++ default constructor can NOT contain any code, that
       
    52 // might leave.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 inline CESMRListQuery::CESMRListQuery( TESMRListQueryType aType )
       
    56     : iType( aType )
       
    57     {
       
    58     FUNC_LOG;
       
    59     // Do nothing
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CESMRListQuery::CESMRListQuery
       
    64 // C++ default constructor can NOT contain any code, that
       
    65 // might leave.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 inline CESMRListQuery::CESMRListQuery(
       
    69         TESMRListQueryType aType, 
       
    70         RArray<TInt>& aFilter )
       
    71     : iType( aType ), iFilter( aFilter )
       
    72     {
       
    73     FUNC_LOG;
       
    74     // Do nothing
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CESMRListQuery::~CESMRListQuery
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CESMRListQuery::~CESMRListQuery()
       
    82     {
       
    83     FUNC_LOG;
       
    84     iAlarmArray.ResetAndDestroy();
       
    85     iRecurrenceArray.ResetAndDestroy();
       
    86     iEnv->DeleteResourceFile(iResourceOffset);
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CESMRListQuery::NewL
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 EXPORT_C CESMRListQuery*
       
    94     CESMRListQuery::NewL( TESMRListQueryType aType )
       
    95     {
       
    96     CESMRListQuery* self = new (ELeave) CESMRListQuery(aType);
       
    97     CleanupStack::PushL( self );
       
    98     self->ConstructL( );
       
    99     CleanupStack::Pop( self );
       
   100     return self;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CESMRListQuery::NewL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C CESMRListQuery*
       
   108     CESMRListQuery::NewL( TESMRListQueryType aType, RArray<TInt>& aFilter )
       
   109     {
       
   110     CESMRListQuery* self = new (ELeave) CESMRListQuery(aType, aFilter);
       
   111     CleanupStack::PushL( self );
       
   112     self->ConstructL( );
       
   113     CleanupStack::Pop( self );
       
   114     return self;
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CESMRListQuery::ConstructL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CESMRListQuery::ConstructL()
       
   122     {
       
   123     FUNC_LOG;
       
   124     TFileName filename;
       
   125 
       
   126     iEnv = CEikonEnv::Static();  // codescanner::eikonenvstatic
       
   127 
       
   128     ESMRHelper::LocateResourceFile(
       
   129             KResourceFileName,
       
   130             KDC_RESOURCE_FILES_DIR,
       
   131             filename,
       
   132             &iEnv->FsSession() );
       
   133 
       
   134     //for localization
       
   135     BaflUtils::NearestLanguageFile(iEnv->FsSession(),filename); 
       
   136     iResourceOffset = iEnv->AddResourceFileL(filename);
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CESMRListQuery::SetAttendeeStatus
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CESMRListQuery::SetAttendeeStatus(TESMRAttendeeStatus aStatus)
       
   144     {
       
   145     FUNC_LOG;
       
   146     iStatus = aStatus;
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CESMRListQuery::ExecuteL
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C TInt CESMRListQuery::ExecuteEditBeforeSendL(
       
   154 		TESMRAttendeeStatus aStatus)
       
   155     {
       
   156     FUNC_LOG;
       
   157     CESMRListQuery* query =
       
   158             CESMRListQuery::NewL( EESMREditBeforeSendQuery );
       
   159     CleanupStack::PushL(query);
       
   160     query->SetAttendeeStatus(aStatus);
       
   161     TInt ret = query->ExecuteLD();
       
   162     CleanupStack::Pop(query);
       
   163     return ret;
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CESMRListQuery::ExecuteL
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 EXPORT_C TInt CESMRListQuery::ExecuteEditBeforeSendWithSendOptOnlyL(
       
   171                  TESMRAttendeeStatus aStatus )
       
   172     {
       
   173     FUNC_LOG;
       
   174     CESMRListQuery* query =
       
   175             CESMRListQuery::NewL( 
       
   176             		EESMREditBeforeSendQueryWithSendOptionsOnly );
       
   177     CleanupStack::PushL(query);
       
   178     query->SetAttendeeStatus(aStatus);
       
   179     TInt ret = query->ExecuteLD();
       
   180     CleanupStack::Pop(query);
       
   181     return ret;
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CESMRListQuery::ExecuteL
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C TInt CESMRListQuery::ExecuteL( TESMRListQueryType aType )
       
   189     {
       
   190     FUNC_LOG;
       
   191     CESMRListQuery* query = CESMRListQuery::NewL( aType );
       
   192     CleanupStack::PushL( query );
       
   193     TInt ret = query->ExecuteLD();
       
   194     CleanupStack::Pop( query );
       
   195     return ret;
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CESMRListQuery::ExecuteL
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C TInt CESMRListQuery::ExecuteL( TESMRListQueryType aType, 
       
   203 					RArray<TInt>& aFilter )
       
   204     {
       
   205     FUNC_LOG;
       
   206     CESMRListQuery* query = CESMRListQuery::NewL( aType, aFilter );
       
   207     CleanupStack::PushL( query );
       
   208     TInt ret = query->ExecuteLD();
       
   209     CleanupStack::Pop( query );
       
   210     return ret;
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CESMRListQuery::SetListQueryTextsL
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CESMRListQuery::SetListQueryTextsL(
       
   218         CDesCArrayFlat* aItemArray,
       
   219         CAknPopupList* aPopupList)
       
   220     {
       
   221     FUNC_LOG;
       
   222     if ( iType == EESMREditBeforeSendQuery ||
       
   223          iType == EESMREditBeforeSendQueryWithSendOptionsOnly)
       
   224         {
       
   225         // Set title:
       
   226         if (iStatus == EESMRAttendeeStatusAccept)
       
   227             {
       
   228             aPopupList->SetTitleL(*iEnv->AllocReadResourceAsDes16LC(
       
   229                     R_QTN_MEET_REQ_SEND_QUERY_ACCEPTED));
       
   230             CleanupStack::PopAndDestroy(); // Resource string
       
   231             }
       
   232         else if (iStatus == EESMRAttendeeStatusTentative)
       
   233             {
       
   234             aPopupList->SetTitleL(*iEnv->AllocReadResourceAsDes16LC(
       
   235                     R_QTN_MEET_REQ_SEND_QUERY_TENTATIVE));
       
   236             CleanupStack::PopAndDestroy(); // Resource string
       
   237             }
       
   238         else if (iStatus == EESMRAttendeeStatusDecline)
       
   239             {
       
   240             aPopupList->SetTitleL(*iEnv->AllocReadResourceAsDes16LC(
       
   241                     R_QTN_MEET_REQ_SEND_QUERY_DECLINED));
       
   242             CleanupStack::PopAndDestroy(); // Resource string
       
   243             }
       
   244 
       
   245         // Set list items:
       
   246         aItemArray->AppendL(*iEnv->AllocReadResourceAsDes16LC(
       
   247                 R_QTN_MEET_REQ_SEND_NOW));
       
   248         CleanupStack::PopAndDestroy(); // Resource string
       
   249         aItemArray->AppendL(*iEnv->AllocReadResourceAsDes16LC(
       
   250                 R_QTN_MEET_REQ_EDIT_BEFORE_SEND));
       
   251         CleanupStack::PopAndDestroy(); // Resource string
       
   252 
       
   253         if ( iType == EESMREditBeforeSendQuery )
       
   254             {
       
   255             aItemArray->AppendL(*iEnv->AllocReadResourceAsDes16LC(
       
   256                     R_QTN_MEET_REQ_DONT_SEND_RESPONSE));
       
   257             CleanupStack::PopAndDestroy(); // Resource string
       
   258             }
       
   259         }
       
   260 
       
   261     else if ( iType == EESMRSendUpdateToAllQuery )
       
   262         {
       
   263         // Set title:
       
   264         aPopupList->SetTitleL(*iEnv->AllocReadResourceAsDes16LC(
       
   265                 R_QTN_MEET_REQ_SEND_UPDATE_QUERY));
       
   266         CleanupStack::PopAndDestroy(); // Resource string
       
   267 
       
   268         // Set list items:
       
   269         aItemArray->AppendL(*iEnv->AllocReadResourceAsDes16LC(
       
   270                 R_QTN_MEET_REQ_SEND_UPDATE_ALL_QUERY));
       
   271         CleanupStack::PopAndDestroy(); // Resource string
       
   272         aItemArray->AppendL(*iEnv->AllocReadResourceAsDes16LC(
       
   273                 R_QTN_MEET_REQ_SEND_UPDATE_UPDATED_QUERY));
       
   274         CleanupStack::PopAndDestroy(); // Resource string
       
   275         }
       
   276     else if ( iType == EESMRRecurrenceQuery )
       
   277         {
       
   278         // Set title:
       
   279         aPopupList->SetTitleL(*iEnv->AllocReadResourceAsDes16LC(
       
   280                 R_QTN_MEET_REQ_SET_RECURRENCE_HEADER));
       
   281         CleanupStack::PopAndDestroy(); // Resource string
       
   282         const TInt count(iRecurrenceArray.Count());
       
   283         for ( TInt i=0; i<count; i++ )
       
   284             {
       
   285             
       
   286             aItemArray->AppendL(iRecurrenceArray[i]->RecurrenceText());
       
   287             }
       
   288         }
       
   289     else if ( iType == EESMRRelativeAlarmTimeQuery )
       
   290         {
       
   291         aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   292                 R_QTN_MEET_REQ_SET_ALARM_HEADER));
       
   293         CleanupStack::PopAndDestroy(); // Resource string
       
   294 
       
   295         const TInt count(iAlarmArray.Count());
       
   296         for ( TInt i=0; i<count; i++ )
       
   297             {
       
   298             aItemArray->AppendL(*iAlarmArray[i]->Text());
       
   299             }
       
   300         }
       
   301     else if ( iType == EESMROpenThisOccurenceOrSeriesQuery )
       
   302         {
       
   303         // Set title:
       
   304         aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   305                 R_QTN_MEET_REQ_RECURRENT_HEADING_OPEN));
       
   306         CleanupStack::PopAndDestroy(); // Resource string
       
   307         aItemArray->AppendL(*StringLoader::LoadLC(
       
   308                 R_QTN_MEET_REQ_RECURRENT_THIS_OCCURRENCE));
       
   309         CleanupStack::PopAndDestroy(); // Resource string
       
   310         aItemArray->AppendL(*StringLoader::LoadLC(
       
   311                 R_QTN_MEET_REQ_RECURRENT_SERIES));
       
   312         CleanupStack::PopAndDestroy(); // Resource string
       
   313         }
       
   314     else if (iType == EESMRDeleteThisOccurenceOrSeriesQuery )
       
   315         {
       
   316         // Deleting recurrent event
       
   317         aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   318                 R_QTN_MEET_REQ_RECURRENT_HEADING_DELETE));
       
   319         CleanupStack::PopAndDestroy(); // Resource string
       
   320         aItemArray->AppendL(*StringLoader::LoadLC(
       
   321                 R_QTN_MEET_REQ_RECURRENT_THIS_OCCURRENCE_DELETE));
       
   322         CleanupStack::PopAndDestroy(); // Resource string
       
   323         aItemArray->AppendL(*StringLoader::LoadLC(
       
   324                 R_QTN_MEET_REQ_RECURRENT_SERIES_DELETE));
       
   325         CleanupStack::PopAndDestroy(); // Resource string
       
   326         }
       
   327     else if ( iType == EESMRForwardThisOccurenceOrSeriesQuery )
       
   328         {
       
   329         // Set title:
       
   330         aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   331                 R_QTN_MEET_REQ_RECURRENT_HEADING_FORWARD));
       
   332         CleanupStack::PopAndDestroy(); // Resource string
       
   333         aItemArray->AppendL(*StringLoader::LoadLC(
       
   334                 R_QTN_MEET_REQ_RECURRENT_FW_THIS_OCCURRENCE));
       
   335         CleanupStack::PopAndDestroy(); // Resource string
       
   336         aItemArray->AppendL(*StringLoader::LoadLC(
       
   337                 R_QTN_MEET_REQ_FW_RECURRENT_SERIES));
       
   338         CleanupStack::PopAndDestroy(); // Resource string
       
   339         }
       
   340     else if ( iType == EESMRPriorityPopup || iType == EESMRTodoPriorityPopup)
       
   341         {
       
   342         // Set title:
       
   343         aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   344                 R_QTN_MEET_REQ_OPT_PRIORITY));
       
   345         CleanupStack::PopAndDestroy(); // Resource string
       
   346         aItemArray->AppendL(*StringLoader::LoadLC(
       
   347                 R_QTN_CALENDAR_TASK_PRIORITY_HIGH));
       
   348         CleanupStack::PopAndDestroy(); // Resource string
       
   349         aItemArray->AppendL(*StringLoader::LoadLC(
       
   350                 R_QTN_CALENDAR_TASK_PRIORITY_NORMAL));
       
   351         CleanupStack::PopAndDestroy(); // Resource string
       
   352         aItemArray->AppendL(*StringLoader::LoadLC(
       
   353                 R_QTN_CALENDAR_TASK_PRIORITY_LOW));
       
   354         CleanupStack::PopAndDestroy(); // Resource string
       
   355         }
       
   356     else if ( iType == EESMRSynchronizationPopup )
       
   357         {
       
   358         // Set title:
       
   359         aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   360                 R_QTN_CALENDAR_TASK_SYNC_TITLE));
       
   361         CleanupStack::PopAndDestroy(); // Resource string
       
   362         aItemArray->AppendL(*StringLoader::LoadLC(
       
   363                 R_QTN_CALENDAR_TASK_SYNC_PRIVATE));
       
   364         CleanupStack::PopAndDestroy(); // Resource string
       
   365         aItemArray->AppendL(*StringLoader::LoadLC(
       
   366                 R_QTN_CALENDAR_TASK_SYNC_PUBLIC));
       
   367         CleanupStack::PopAndDestroy(); // Resource string
       
   368         aItemArray->AppendL(*StringLoader::LoadLC(
       
   369                 R_QTN_CALENDAR_TASK_SYNC_NONE));
       
   370         CleanupStack::PopAndDestroy(); // Resource string
       
   371         }
       
   372     else if ( iType == EESMRUnifiedEditorPopup )
       
   373 		{
       
   374 		// Set title:
       
   375 		aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   376 				R_QTN_CALENDAR_TASK_UNIFIED_TITLE));
       
   377 		CleanupStack::PopAndDestroy(); // Resource string
       
   378 		aItemArray->AppendL(*StringLoader::LoadLC(
       
   379 				R_QTN_MEET_REQ_TITLE_MEETING));
       
   380 		CleanupStack::PopAndDestroy(); // Resource string
       
   381 		aItemArray->AppendL(*StringLoader::LoadLC(
       
   382 				R_QTN_CALENDAR_TITLE_MEETING));
       
   383 		CleanupStack::PopAndDestroy(); // Resource string
       
   384 		aItemArray->AppendL(*StringLoader::LoadLC(
       
   385 				R_QTN_CALENDAR_TITLE_MEMO));
       
   386 		CleanupStack::PopAndDestroy(); // Resource string
       
   387 		aItemArray->AppendL(*StringLoader::LoadLC(
       
   388 				R_QTN_CALENDAR_TITLE_ANNIVERSARY));
       
   389 		CleanupStack::PopAndDestroy(); // Resource string
       
   390 		aItemArray->AppendL(*StringLoader::LoadLC(
       
   391 				R_QTN_CALENDAR_TITLE_TODO));
       
   392 		CleanupStack::PopAndDestroy(); // Resource string
       
   393 		}
       
   394 	    else if ( iType == EESMRNormalResponseQuery)
       
   395 	        {
       
   396 	        aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   397 	                R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND));
       
   398 	        CleanupStack::PopAndDestroy(); // Resource string
       
   399 	        aItemArray->AppendL(*StringLoader::LoadLC(
       
   400 	                R_QTN_MEET_REQ_RESPONSE_ACCEPT));
       
   401 	        CleanupStack::PopAndDestroy(); // Resource string
       
   402 	        aItemArray->AppendL(*StringLoader::LoadLC(
       
   403 	                R_QTN_MEET_REQ_RESPONSE_TENTATIVE));
       
   404 	        CleanupStack::PopAndDestroy(); // Resource string
       
   405 	        aItemArray->AppendL(*StringLoader::LoadLC(
       
   406 	                R_QTN_MEET_REQ_RESPONSE_DECLINE));
       
   407 	        CleanupStack::PopAndDestroy(); // Resource string
       
   408 	        }
       
   409 	    else if ( iType == EESMRRemoveResponseQuery)
       
   410 	        {
       
   411 	        aPopupList->SetTitleL(*StringLoader::LoadLC(
       
   412 	                R_QTN_MEET_REQ_RESPONSE_PLEASE_RESPOND));
       
   413 	        CleanupStack::PopAndDestroy(); // Resource string
       
   414 	        aItemArray->AppendL(*StringLoader::LoadLC(
       
   415 	        		R_QTN_MEET_REQ_OPTIONS_REMOVE_FROM_CAL));
       
   416 	        CleanupStack::PopAndDestroy(); // Resource string
       
   417 	        }
       
   418     }
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CESMRListQuery::MapSelectedIndexToReturnValue
       
   422 // -----------------------------------------------------------------------------
       
   423 //
       
   424 TInt CESMRListQuery::MapSelectedIndexToReturnValue(TInt aIndex)
       
   425     {
       
   426     FUNC_LOG;
       
   427     TInt response (KErrCancel);
       
   428 
       
   429     if (iType == EESMREditBeforeSendQuery ||
       
   430         iType == EESMREditBeforeSendQueryWithSendOptionsOnly )
       
   431         {
       
   432         switch( aIndex )
       
   433             {
       
   434             case 0:
       
   435                 {
       
   436                 response = EESMRResponsePlain;
       
   437                 break;
       
   438                 }
       
   439             case 1:
       
   440                 {
       
   441                 response = EESMRResponseMessage;
       
   442                 break;
       
   443                 }
       
   444             case 2:
       
   445                 {
       
   446                 response = EESMRResponseDontSend;
       
   447                 break;
       
   448                 }
       
   449             default:
       
   450                 {
       
   451                 break;
       
   452                 }
       
   453             }
       
   454         }
       
   455     else if (iType == EESMRSendUpdateToAllQuery )
       
   456         {
       
   457         switch( aIndex )
       
   458             {
       
   459             case 0:
       
   460                 {
       
   461                 response = EESMRSendToAllParticipants;
       
   462                 break;
       
   463                 }
       
   464             case 1:
       
   465                 {
       
   466                 response = EESMRSendToAddedOrRemovedParticipants;
       
   467                 break;
       
   468                 }
       
   469             default:
       
   470                 {
       
   471                 break;
       
   472                 }
       
   473             }
       
   474         }
       
   475     else if ( iType == EESMRRecurrenceQuery )
       
   476         {
       
   477         return iRecurrenceArray[aIndex]->RecurrenceValue();
       
   478         }
       
   479     else if ( iType == EESMRRelativeAlarmTimeQuery )
       
   480         {
       
   481         return iAlarmArray[aIndex]->Id();
       
   482         }
       
   483     else if ( iType == EESMROpenThisOccurenceOrSeriesQuery ||
       
   484               iType == EESMRDeleteThisOccurenceOrSeriesQuery ||
       
   485               iType == EESMRForwardThisOccurenceOrSeriesQuery )
       
   486         {
       
   487         switch ( aIndex )
       
   488             {
       
   489             case 0:
       
   490                 {
       
   491                 response = EESMRThisOccurence;
       
   492                 break;
       
   493                 }
       
   494             case 1:
       
   495                 {
       
   496                 response = EESMRSeries;
       
   497                 break;
       
   498                 }
       
   499             default:
       
   500                 break;
       
   501             }
       
   502         }
       
   503     else if ( iType == EESMRPriorityPopup )
       
   504         {
       
   505         switch ( aIndex )
       
   506             {
       
   507             case 0:
       
   508                 {
       
   509                 response = EFSCalenMRPriorityHigh;
       
   510                 break;
       
   511                 }
       
   512             case 1:
       
   513                 {
       
   514                 response = EFSCalenMRPriorityNormal;
       
   515                 break;
       
   516                 }
       
   517             case 2:
       
   518                 {
       
   519                 response = EFSCalenMRPriorityLow;
       
   520                 break;
       
   521                 }
       
   522             default:
       
   523                 break;
       
   524             }
       
   525         }
       
   526     else if ( iType == EESMRTodoPriorityPopup )
       
   527         {
       
   528         switch ( aIndex )
       
   529             {
       
   530             case 0:
       
   531                 {
       
   532                 response = EFSCalenTodoPriorityHigh;
       
   533                 break;
       
   534                 }
       
   535             case 1:
       
   536                 {
       
   537                 response = EFSCalenTodoPriorityNormal;
       
   538                 break;
       
   539                 }
       
   540             case 2:
       
   541                 {
       
   542                 response = EFSCalenTodoPriorityLow;
       
   543                 break;
       
   544                 }
       
   545             default:
       
   546                 break;
       
   547             }
       
   548 
       
   549         }
       
   550     else if ( iType == EESMRSynchronizationPopup )
       
   551         {
       
   552         switch ( aIndex )
       
   553             {
       
   554             case 0:
       
   555                 {
       
   556                 response = ESyncPublic;
       
   557                 break;
       
   558                 }
       
   559             case 1:
       
   560                 {
       
   561                 response = ESyncPrivate;
       
   562                 break;
       
   563                 }
       
   564             case 2:
       
   565                 {
       
   566                 response = ESyncNone;
       
   567                 break;
       
   568                 }
       
   569             default:
       
   570                 break;
       
   571             }
       
   572         }
       
   573     else if ( iType == EESMRUnifiedEditorPopup )
       
   574         {
       
   575         switch ( aIndex )
       
   576             {
       
   577             case 0:
       
   578                 {
       
   579                 response = EMRTypeMeetingRequest;
       
   580                 break;
       
   581                 }
       
   582             case 1:
       
   583                 {
       
   584                 response = EMRTypeMeeting;
       
   585                 break;
       
   586                 }
       
   587             case 2:
       
   588                 {
       
   589                 response = EMRTypeMemo;
       
   590                 break;
       
   591                 }
       
   592             case 3:
       
   593 				{
       
   594 				response = EMRTypeAnniversary;
       
   595 				break;
       
   596 				}
       
   597             case 4:
       
   598 				{
       
   599 				response = EMRTypeToDo;
       
   600 				break;
       
   601 				}
       
   602             default:
       
   603                 break;
       
   604             }
       
   605         }
       
   606         else if( iType == EESMRNormalResponseQuery )
       
   607         	{
       
   608             switch ( aIndex )
       
   609                 {
       
   610                 case 0:
       
   611                     {
       
   612                     response = EESMRCmdAcceptMR;
       
   613                     break;
       
   614                     }
       
   615                 case 1:
       
   616                     {
       
   617                     response = EESMRCmdTentativeMR;
       
   618                     break;
       
   619                     }
       
   620                 case 2:
       
   621                     {
       
   622                     response = EESMRCmdDeclineMR;
       
   623                     break;
       
   624                     }
       
   625                 default:
       
   626                     break;
       
   627                 }
       
   628         	}
       
   629         else if( iType == EESMRRemoveResponseQuery )
       
   630         	{
       
   631             switch ( aIndex )
       
   632                 {
       
   633                 case 0:
       
   634                     {
       
   635                     response = EESMRCmdRemoveFromCalendar;
       
   636                     break;
       
   637                     }
       
   638                 default:
       
   639                     break;
       
   640                 }
       
   641         	}
       
   642         
       
   643     return response;
       
   644     }
       
   645 
       
   646 // -----------------------------------------------------------------------------
       
   647 // CESMRListQuery::ExecuteLD
       
   648 // -----------------------------------------------------------------------------
       
   649 //
       
   650 void CESMRListQuery::LoadTextsFromResourceL()
       
   651     {
       
   652     FUNC_LOG;
       
   653     if ( iType == EESMRRelativeAlarmTimeQuery )
       
   654         {
       
   655         TResourceReader reader;
       
   656         iEnv->CreateResourceReaderLC( reader, R_ESMREDITOR_ALARMS );
       
   657 
       
   658         // Read alarm items to array
       
   659         iAlarmArray.Reset();
       
   660         TInt count = reader.ReadInt16();
       
   661         for ( TInt i(0); i < count; i++ )
       
   662             {
       
   663             CESMRAlarm* alarm = new (ELeave) CESMRAlarm;
       
   664             CleanupStack::PushL( alarm );
       
   665             alarm->ConstructFromResourceL( reader );
       
   666             alarm->LoadTextL( iEnv );
       
   667             CleanupStack::Pop( alarm );
       
   668             iAlarmArray.Append( alarm );
       
   669             }
       
   670         CleanupStack::PopAndDestroy(); // resource reader
       
   671         }
       
   672     else if ( iType == EESMRRecurrenceQuery )
       
   673         {
       
   674         TResourceReader reader;
       
   675         iEnv->CreateResourceReaderLC( reader, R_ESMREDITOR_RECURRENCE );
       
   676 
       
   677         // Read alarm items to array
       
   678         iRecurrenceArray.Reset();
       
   679         TInt count = reader.ReadInt16();
       
   680         for ( TInt i(0); i < count; i++ )
       
   681             {
       
   682             CESMRRecurrence* recurrence = new (ELeave) CESMRRecurrence;
       
   683             CleanupStack::PushL( recurrence );
       
   684             recurrence->ConstructFromResourceL( iEnv, reader );
       
   685             CleanupStack::Pop( recurrence );
       
   686             iRecurrenceArray.Append( recurrence );
       
   687             }
       
   688         CleanupStack::PopAndDestroy(); // resource reader
       
   689         }
       
   690     }
       
   691 
       
   692 // -----------------------------------------------------------------------------
       
   693 // CESMRListQuery::ExecuteLD
       
   694 // -----------------------------------------------------------------------------
       
   695 //
       
   696 EXPORT_C TInt CESMRListQuery::ExecuteLD()
       
   697     {
       
   698     FUNC_LOG;
       
   699     TInt response(KErrCancel);
       
   700 
       
   701     CAknSinglePopupMenuStyleListBox* list =
       
   702         new(ELeave)CAknSinglePopupMenuStyleListBox;
       
   703     CleanupStack::PushL(list);
       
   704 
       
   705     CAknPopupList* popupList = CAknPopupList::NewL(list,
       
   706             R_AVKON_SOFTKEYS_OK_CANCEL,
       
   707             AknPopupLayouts::EMenuGraphicHeadingWindow);
       
   708     CleanupStack::PushL(popupList);
       
   709 
       
   710     list->ConstructL(popupList, 0);
       
   711     list->CreateScrollBarFrameL(ETrue);
       
   712     list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
       
   713                                                     CEikScrollBarFrame::EOn);
       
   714 
       
   715     CDesCArrayFlat* itemArray = new(ELeave)CDesCArrayFlat(2);
       
   716     CleanupStack::PushL(itemArray);
       
   717 
       
   718     LoadTextsFromResourceL();
       
   719 
       
   720     SetListQueryTextsL(itemArray, popupList);
       
   721 
       
   722     CleanupStack::Pop(itemArray);
       
   723     
       
   724     // Dynamic popup for Unified Editor does not include every item
       
   725     if ( iType == EESMRUnifiedEditorPopup )
       
   726     	{
       
   727     	// Looped backwards. When removing multiple indexes from array,
       
   728     	// incorrect items would otherwise be removed.
       
   729         for ( TInt index( iFilter.Count() - 1 ); index >= 0; --index )
       
   730             {
       
   731             itemArray->Delete( ( TInt )iFilter[index] );
       
   732             }
       
   733     	}
       
   734     
       
   735     list->Model()->SetItemTextArray(itemArray);
       
   736     list->Model()->SetOwnershipType(ELbmOwnsItemArray);
       
   737 
       
   738     // Show popup list and then show return value.
       
   739     TInt popupOk = popupList->ExecuteLD();
       
   740 
       
   741     if (popupOk)
       
   742         {
       
   743         if ( iType == EESMRUnifiedEditorPopup )
       
   744             {
       
   745             response = MapUnifiedEditorItemTextToIndexL( *list );
       
   746             ASSERT( KErrNotFound != response );
       
   747             }
       
   748         else
       
   749             {
       
   750             response = MapSelectedIndexToReturnValue( 
       
   751 												list->CurrentItemIndex() );
       
   752             }
       
   753         }
       
   754 
       
   755     CleanupStack::Pop(popupList);
       
   756     CleanupStack::PopAndDestroy(list);
       
   757     delete this; // red key works correctly and no double destruction possible
       
   758 
       
   759     return response;
       
   760     }
       
   761 
       
   762 // -----------------------------------------------------------------------------
       
   763 // CESMRListQuery::ExecuteLD
       
   764 // -----------------------------------------------------------------------------
       
   765 //
       
   766 EXPORT_C TInt CESMRListQuery::ExecuteLD( RArray<TPtrC>& aCalenNameList )
       
   767     {
       
   768     TInt response(KErrCancel);
       
   769 
       
   770     CAknSinglePopupMenuStyleListBox* list =
       
   771         new(ELeave)CAknSinglePopupMenuStyleListBox;
       
   772     CleanupStack::PushL(list);
       
   773 
       
   774     CAknPopupList* popupList = CAknPopupList::NewL(list,
       
   775             R_AVKON_SOFTKEYS_OK_CANCEL,
       
   776             AknPopupLayouts::EMenuGraphicHeadingWindow);
       
   777     CleanupStack::PushL(popupList);
       
   778 
       
   779     list->ConstructL(popupList, 0);
       
   780     list->CreateScrollBarFrameL(ETrue);
       
   781     list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
       
   782                                                         CEikScrollBarFrame::EOn);
       
   783 
       
   784     CDesCArrayFlat* itemArray = new(ELeave)CDesCArrayFlat(2);
       
   785     CleanupStack::PushL(itemArray);
       
   786     
       
   787     // Set title: TODO: Change title
       
   788     popupList->SetTitleL(*StringLoader::LoadLC(
       
   789             R_QTN_CALENDAR_TASK_CALENDAR_TITLE));
       
   790     CleanupStack::PopAndDestroy(); // Resource string
       
   791             
       
   792     TInt count = aCalenNameList.Count();
       
   793     
       
   794     for ( TInt i(0); i < count; i++ )
       
   795         {
       
   796         itemArray->AppendL( aCalenNameList[i] );        
       
   797         }         
       
   798     
       
   799     CleanupStack::Pop(itemArray);
       
   800     list->Model()->SetItemTextArray(itemArray);
       
   801     list->Model()->SetOwnershipType(ELbmOwnsItemArray);
       
   802     
       
   803     // Show popup list and then show return value.
       
   804     TInt popupOk = popupList->ExecuteLD();
       
   805     
       
   806     if (popupOk)
       
   807         {
       
   808         response = list->CurrentItemIndex();
       
   809         }
       
   810     
       
   811     CleanupStack::Pop(popupList);
       
   812     CleanupStack::PopAndDestroy(list);
       
   813     delete this; // red key works correctly and no double destruction possible
       
   814     
       
   815     return response;
       
   816     }
       
   817 
       
   818 // -----------------------------------------------------------------------------
       
   819 // CESMRListQuery::ExecuteL
       
   820 // -----------------------------------------------------------------------------
       
   821 //
       
   822 EXPORT_C TInt CESMRListQuery::ExecuteL(
       
   823         TESMRListQueryType aType,  RArray<TPtrC>& aCalenNameList )
       
   824     {
       
   825     CESMRListQuery* query = CESMRListQuery::NewL(aType);
       
   826     CleanupStack::PushL(query);
       
   827     TInt ret = query->ExecuteLD( aCalenNameList );
       
   828     CleanupStack::Pop(query);
       
   829     return ret;
       
   830     }
       
   831 
       
   832 // -----------------------------------------------------------------------------
       
   833 // CESMRListQuery::MapUnifiedEditorItemTextToIndexL
       
   834 // -----------------------------------------------------------------------------
       
   835 //
       
   836 TInt CESMRListQuery::MapUnifiedEditorItemTextToIndexL(
       
   837         CAknSinglePopupMenuStyleListBox& aList )
       
   838     {
       
   839     FUNC_LOG;
       
   840     
       
   841     TInt index( KErrNotFound );
       
   842     
       
   843     TInt itemIndex( aList.CurrentItemIndex() );
       
   844     TPtrC selItemText(
       
   845             aList.Model()->ItemText( itemIndex ) );
       
   846     
       
   847     // Meeting Request
       
   848     HBufC* mrText      = StringLoader::LoadLC( R_QTN_MEET_REQ_TITLE_MEETING );
       
   849     HBufC* meetingText = StringLoader::LoadLC( R_QTN_CALENDAR_TITLE_MEETING );
       
   850     HBufC* memoText    = StringLoader::LoadLC( R_QTN_CALENDAR_TITLE_MEMO );
       
   851     HBufC* annivText   = StringLoader::LoadLC( R_QTN_CALENDAR_TITLE_ANNIVERSARY );
       
   852     HBufC* todoText    = StringLoader::LoadLC( R_QTN_CALENDAR_TITLE_TODO );
       
   853     
       
   854     if ( !selItemText.Compare( *mrText ) )
       
   855         {
       
   856         index = EESMREventTypeMeetingRequest;
       
   857         }
       
   858     else if ( !selItemText.Compare( *meetingText ) )
       
   859         {
       
   860         index = EESMREventTypeAppt;
       
   861         }    
       
   862     else if ( !selItemText.Compare( *memoText ) )
       
   863         {
       
   864         index = EESMREventTypeEEvent;
       
   865         }
       
   866     else if ( !selItemText.Compare( *annivText ) )
       
   867         {
       
   868         index = EESMREventTypeEAnniv;
       
   869         }
       
   870     else if ( !selItemText.Compare( *todoText ) )
       
   871         {
       
   872         index = EESMREventTypeETodo;
       
   873         }
       
   874     
       
   875     CleanupStack::PopAndDestroy( todoText );
       
   876     CleanupStack::PopAndDestroy( annivText ); 
       
   877     CleanupStack::PopAndDestroy( memoText ); 
       
   878     CleanupStack::PopAndDestroy( meetingText ); 
       
   879     CleanupStack::PopAndDestroy( mrText );     
       
   880     
       
   881     return index;
       
   882     }
       
   883 
       
   884 //  End of File