homesync/contentmanager/mediaservant/src/msfillruleeditlist.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     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:  CMSFillRuleEditList class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mediaservant.rsg>
       
    20 #include <barsread.h>
       
    21 #include <akntextsettingpage.h>
       
    22 #include <StringLoader.h>
       
    23 #include <akncheckboxsettingpage.h>
       
    24 #include <e32math.h>
       
    25 #include <utf.h>
       
    26 
       
    27 #include "cmsqlpropertycontainer.h"
       
    28 #include "mserv.hlp.hrh"
       
    29 #include "cmfillrule.h"
       
    30 #include "cmfillrulecontainer.h"
       
    31 #include "cmmediaserverfull.h"
       
    32 #include "msappui.h"
       
    33 #include "mediaservantuid.h"
       
    34 #include "msengine.h"
       
    35 #include "msconstants.h"
       
    36 #include "msfillruleeditlist.h"
       
    37 #include "msfillruleeditview.h"
       
    38 #include "msruleamountsetting.h"        // Amount
       
    39 #include "msruleserverssetting.h"       // Servers
       
    40 #include "msrulemultiselectionsetting.h"// Artist, genre, album, track
       
    41 #include "msrulefilesizesetting.h"      // File size (min/max)
       
    42 #include "mediaservant.hrh"
       
    43 #include "msmetadatacollector.h"
       
    44 #include "msdebug.h"
       
    45 #include "msfillcontainer.h"
       
    46 #include "msfillview.h"
       
    47 
       
    48 // CONSTANTS
       
    49 _LIT( KSpace, " ");
       
    50 const TInt KDateBufferLength = 20;
       
    51 
       
    52 
       
    53 // --------------------------------------------------------------------------
       
    54 // CMSFillRuleEditList::NewL()
       
    55 // Two phase constructor.
       
    56 // --------------------------------------------------------------------------
       
    57 //
       
    58 CMSFillRuleEditList* CMSFillRuleEditList::NewL(
       
    59                 CMSAppUi& aAppUi, CMSFillRuleEditView& aView )
       
    60     {
       
    61     LOG(_L("[MediaServant]\t CMSFillRuleEditList::NewL"));
       
    62 
       
    63     CMSFillRuleEditList* self = CMSFillRuleEditList::NewLC( aAppUi, aView );        
       
    64     CleanupStack::Pop( self );
       
    65     
       
    66     return self;
       
    67     }
       
    68 
       
    69 // --------------------------------------------------------------------------
       
    70 // CMSFillRuleEditList::NewLC()
       
    71 // Two phase constructor.
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 CMSFillRuleEditList* CMSFillRuleEditList::NewLC(
       
    75                 CMSAppUi& aAppUi, CMSFillRuleEditView& aView )
       
    76     {
       
    77     LOG(_L("[MediaServant]\t CMSFillRuleEditList::NewLC"));
       
    78 
       
    79     CMSFillRuleEditList* self = new ( ELeave ) CMSFillRuleEditList();
       
    80     CleanupStack::PushL( self );
       
    81     self->ConstructL( aAppUi, aView );
       
    82         
       
    83     return self;
       
    84     }
       
    85     
       
    86 // --------------------------------------------------------------------------
       
    87 // CMSFillRuleEditList::CMSFillRuleEditList()
       
    88 // --------------------------------------------------------------------------
       
    89 //
       
    90 CMSFillRuleEditList::CMSFillRuleEditList()
       
    91     {
       
    92     LOG(_L("[MediaServant]\t CMSFillRuleEditList::CMSFillRuleEditList"));
       
    93 
       
    94     iDummyText.Copy(_L(""));
       
    95     iMinFileSize = 0;
       
    96     iMaxFileSize = 0;
       
    97     iMinFileSizeSet = EMSAny;
       
    98     iMaxFileSizeSet = EMSAny;
       
    99     iFileSize = 0;
       
   100     iFileSizeEnum = 0;
       
   101     iTrackLengthEnum = 0;
       
   102     iNewList = EFalse;
       
   103     }
       
   104 
       
   105 // --------------------------------------------------------------------------
       
   106 // CMSFillRuleEditList::~CMSFillRuleEditList()
       
   107 // --------------------------------------------------------------------------
       
   108 //
       
   109 CMSFillRuleEditList::~CMSFillRuleEditList()
       
   110     {
       
   111     LOG(_L("[MediaServant]\t CMSFillRuleEditList::~CMSFillRuleEditList"));
       
   112 
       
   113     delete iMetadataCollector;
       
   114 
       
   115     if ( iServers )
       
   116         {
       
   117         iServers->ResetAndDestroy();
       
   118         iServers->Close();
       
   119         delete iServers;
       
   120         }
       
   121 
       
   122     if ( iServerArray )
       
   123         {
       
   124         iServerArray->ResetAndDestroy();
       
   125         delete iServerArray;
       
   126         }
       
   127 
       
   128     iVisibleRules.Close();
       
   129 
       
   130     iArtistArray.Close();
       
   131     iAlbumArray.Close();
       
   132     iGenreArray.Close();
       
   133     iTrackArray.Close();
       
   134     iVideoTitleArray.Close();
       
   135     
       
   136     }
       
   137 
       
   138 // --------------------------------------------------------------------------
       
   139 // CMSFillRuleEditList::ConstructL()
       
   140 // Second phase constructor.
       
   141 // --------------------------------------------------------------------------
       
   142 //
       
   143 void CMSFillRuleEditList::ConstructL( CMSAppUi& aAppUi,
       
   144                                       CMSFillRuleEditView& aView )
       
   145     {
       
   146     LOG(_L("[MediaServant]\t CMSFillRuleEditList::ConstructL"));
       
   147 
       
   148     iAppUi = &aAppUi;
       
   149     iView = &aView;
       
   150 
       
   151     // Set engine observer
       
   152     iAppUi->MSEngine()->SetObserver( this );
       
   153 
       
   154     // read template
       
   155     iRuleTemplate = iAppUi->ParameterAgent()->GetRuleTemplate();
       
   156 
       
   157     // Edit existing list
       
   158     if ( iRuleTemplate.templateType == EMSCmdEditRule )
       
   159         {
       
   160         // get selected item index from previous screen
       
   161         iSelectedList = iAppUi->ParameterAgent()->FillViewFocusIndex();
       
   162 
       
   163         // get selected list
       
   164         iRule =(*iAppUi->
       
   165                FillRuleController()->FillListArray())[iSelectedList]->List();
       
   166         // List media type
       
   167         iMediaType = iRule->MediaType();
       
   168 
       
   169         // set used template
       
   170         iRuleTemplate.selectedTemplate = iRule->TemplateId();
       
   171 
       
   172         ReadTemplateRulesL( iRuleTemplate.selectedTemplate );
       
   173         // Get values for rules
       
   174         GetRuleValuesL();
       
   175         }
       
   176 
       
   177     else
       
   178         {
       
   179         iNewList = ETrue;
       
   180 
       
   181         // New fill list will be last one - set focus index to it
       
   182         iSelectedList =
       
   183             iAppUi->FillRuleController()->FillListArray()->Count();
       
   184         iAppUi->ParameterAgent()->SetFillViewFocusIndex( iSelectedList );
       
   185 
       
   186         // Create new list
       
   187         iRule = CCmFillRule::NewL();
       
   188 
       
   189         // Read template rules and set default values
       
   190         ReadTemplateRulesL( iRuleTemplate.selectedTemplate );
       
   191 
       
   192         // Use template name as list name
       
   193         iListName.Copy( iRuleTemplate.templateName );
       
   194         HBufC8* temp = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
       
   195                                                             iListName );
       
   196         CleanupStack::PushL( temp );
       
   197         iRule->SetNameL( *temp );
       
   198         CleanupStack::PopAndDestroy( temp );
       
   199         // List type is determined by given menu command
       
   200         // MediaType is also set here
       
   201         SetListType( iRuleTemplate.templateType );
       
   202         iRule->SetTemplateId( iRuleTemplate.selectedTemplate );
       
   203 
       
   204         //Set rule selected by default
       
   205         iRule->SetSelected( ECmSelected );
       
   206 
       
   207         // Initialize fill rule status to ECmToBeFilled
       
   208         // If rule is image rule, status is re-set
       
   209         // according to used template
       
   210         iRule->SetStatus( ECmToBeFilled );
       
   211 
       
   212         InitializeValues();
       
   213 
       
   214         // save new list
       
   215         iAppUi->FillRuleController()->AddRuleL( iRule );
       
   216 
       
   217         // Get list
       
   218         iRule = (*iAppUi->FillRuleController()->
       
   219                                     FillListArray())[iSelectedList]->List();
       
   220         }
       
   221      
       
   222      // should filter the vedio array when construct first time, only selected item can be construct
       
   223      if( iRule->MediaType() == ECmVideo )
       
   224         {
       
   225         // reset track array
       
   226         iTrackArray.Reset();
       
   227         // append the select video title in track array
       
   228         TInt count = iVideoTitleArray.Count();
       
   229         if( count > 0 )
       
   230             {
       
   231             for( TInt i=0; i<count; i++ )
       
   232                 {
       
   233                 iTrackArray.AppendL( iVideoTitleArray[i] );	
       
   234                 }
       
   235             }
       
   236         	
       
   237         }
       
   238     // Creates metadata collector and starts data fetching
       
   239     iMetadataCollector = CMSMetadataCollector::NewL( *iAppUi,
       
   240                                                      iMediaType,
       
   241                                                      iGenreArray,
       
   242                                                      iArtistArray,
       
   243                                                      iAlbumArray,
       
   244                                                      iTrackArray);
       
   245 
       
   246     // get mediaservers and remove not activated
       
   247     GetServersAndCheckActivityL();
       
   248 
       
   249     CreateServerSettingListL();
       
   250     // Construct setting list
       
   251     ConstructListAndStartDataReadingL();
       
   252     
       
   253     iPreviousRuleIdentifier = 0;
       
   254     }
       
   255 
       
   256 // --------------------------------------------------------------------------
       
   257 // CMSFillRuleEditList::StartDataReadingL
       
   258 // starts reading data to multiselection lists from server
       
   259 // --------------------------------------------------------------------------
       
   260 //
       
   261 void CMSFillRuleEditList::ConstructListAndStartDataReadingL()
       
   262     {
       
   263     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
   264     ConstructListAndStartDataReadingL"));
       
   265 
       
   266     switch ( iMediaType )
       
   267         {
       
   268         case ECmVideo:
       
   269             {
       
   270              // construct item list
       
   271             CAknSettingItemList::ConstructFromResourceL(
       
   272                                             R_MS_VIDEO_FILL_RULES );
       
   273             break;
       
   274             }
       
   275         case ECmImage:
       
   276             {
       
   277              // construct item list
       
   278             CAknSettingItemList::ConstructFromResourceL(
       
   279                                             R_MS_IMAGE_FILL_RULES );
       
   280             if ( iNewList )
       
   281                 {
       
   282                 SaveListValuesL();
       
   283                 iAppUi->FillRuleController()->SaveRulesL();
       
   284                 PreprocessListL();
       
   285                 }
       
   286             else
       
   287                 {
       
   288                 CreateAndSetNaviPaneTextL();
       
   289                 }
       
   290             break;
       
   291             }
       
   292         case ECmAudio:
       
   293             {
       
   294              // construct item list
       
   295             CAknSettingItemList::ConstructFromResourceL(
       
   296                                             R_MS_AUDIO_FILL_RULES );
       
   297             break;
       
   298             }
       
   299         default:
       
   300             {
       
   301             break;
       
   302             }
       
   303         }
       
   304 
       
   305     if ( iMediaType == ECmVideo || iMediaType == ECmAudio )
       
   306         {
       
   307         // Show 'reading data' text on navi pane
       
   308         HBufC* naviText = StringLoader::LoadLC(
       
   309                                             R_MS_WAIT_GETTING_DATA_TEXT );
       
   310         iView->SetNavigationPaneTextL( *naviText );
       
   311         CleanupStack::PopAndDestroy( naviText );
       
   312         }
       
   313 
       
   314     }
       
   315 
       
   316 // --------------------------------------------------------------------------
       
   317 // CMSFillRuleEditList::SaveListValuesL
       
   318 // Saves list values from visible setting items
       
   319 // --------------------------------------------------------------------------
       
   320 //
       
   321 void CMSFillRuleEditList::SaveListValuesL()
       
   322     {
       
   323     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SaveListValuesL"));
       
   324 
       
   325     CAknSettingItemArray* itemArray = SettingItemArray();
       
   326     for ( TInt index  = 0; index < itemArray->Count(); index++ )
       
   327         {
       
   328         CAknSettingItem* item = itemArray->At( index );
       
   329         if ( !item->IsHidden() )
       
   330             {
       
   331             SaveValueL( item );
       
   332             }
       
   333         }
       
   334     }
       
   335 
       
   336 // --------------------------------------------------------------------------
       
   337 // CMSFillRuleEditList::PreprocessListL
       
   338 // starts list preprocess and shows info on navi pane
       
   339 // --------------------------------------------------------------------------
       
   340 //
       
   341 void CMSFillRuleEditList::PreprocessListL()
       
   342     {
       
   343     LOG(_L("[MediaServant]\t CMSFillRuleEditList::PreprocessListL"));
       
   344 
       
   345     iAppUi->MSEngine()->PreProcessFillListL( iRule->Name() );
       
   346     HBufC* naviText = StringLoader::LoadLC( R_MS_PREPROCESSING_TEXT );
       
   347     iView->SetNavigationPaneTextL( *naviText );
       
   348     CleanupStack::PopAndDestroy( naviText );
       
   349     }
       
   350 
       
   351 // --------------------------------------------------------------------------
       
   352 // CMSFillRuleEditList::SaveValueL
       
   353 // Save values to rule container
       
   354 // Only values from visible rules are stored
       
   355 // --------------------------------------------------------------------------
       
   356 //
       
   357 void CMSFillRuleEditList::SaveValueL( CAknSettingItem* aItem )
       
   358     {
       
   359     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SaveValueL"));
       
   360 
       
   361     if ( !aItem->IsHidden() )
       
   362         {
       
   363         switch ( aItem->Identifier() )
       
   364             {
       
   365             case EMSListName:
       
   366                 {
       
   367                 // Name is always visible - set rule name
       
   368                 HBufC8* listName =
       
   369                     CnvUtfConverter::ConvertFromUnicodeToUtf8L(
       
   370                        SettingItemArray()->At(EMSListName)->SettingTextL() );
       
   371                 CleanupStack::PushL( listName );
       
   372                 iRule->SetNameL( *listName );
       
   373                 CleanupStack::PopAndDestroy( listName );
       
   374                 break;
       
   375                 }
       
   376             case EMSShrinkImages:
       
   377                 {
       
   378                 // Set shrinking status for images
       
   379                 SetShrinkingStatus();
       
   380                 break;
       
   381                 }
       
   382             case EMSAmount:
       
   383                 {
       
   384                 // set amount of files
       
   385                 iRule->SetAmount( iAmount );
       
   386                 // set limit type
       
   387                 iRule->SetLimitType( iLimitType );
       
   388                 break;
       
   389                 }
       
   390             case EMSStartingWith:
       
   391                 {
       
   392                 iRule->SetMethod(
       
   393                             static_cast<TCmFillMethod> (iStartWith) );
       
   394                 break;
       
   395                 }
       
   396             case EMSDateFrom:
       
   397                 {
       
   398                 DeleteRule( ECmDate, ECmGreater );
       
   399 
       
   400                 TInt ruleIndex = iRule->AddRuleL( ECmDate,
       
   401                                                   ECmGreater );
       
   402                 HBufC8* str = HBufC8::NewL( KDateBufferLength );
       
   403                 CleanupStack::PushL( str );
       
   404                 str->Des().AppendNum(iDateFrom.Int64());
       
   405                 iRule->AddRuleParamL( ruleIndex, *str );
       
   406                 CleanupStack::PopAndDestroy( str );
       
   407                 break;
       
   408                 }
       
   409             case EMSDateUntil:
       
   410                 {
       
   411                 DeleteRule( ECmDate, ECmSmaller );
       
   412 
       
   413                 TInt ruleIndex = iRule->AddRuleL( ECmDate,
       
   414                                                   ECmSmaller );
       
   415                 HBufC8* str = HBufC8::NewL( KDateBufferLength );
       
   416                 CleanupStack::PushL( str );
       
   417                 str->Des().AppendNum(iDateUntil.Int64());
       
   418                 iRule->AddRuleParamL( ruleIndex, *str );
       
   419                 CleanupStack::PopAndDestroy( str );
       
   420 
       
   421                 break;
       
   422                 }
       
   423             case EMSServers:
       
   424                 {
       
   425                 HandleServerSelectionL();
       
   426                 break;
       
   427                 }
       
   428             case EMSFreeText:
       
   429                 {
       
   430                 DeleteRule( ECmFreeText );
       
   431                 if ( iFreeText.Size() )
       
   432                     {
       
   433                     TInt ruleIndex = iRule->AddRuleL( ECmFreeText,
       
   434                                                       ECmConsistOf );
       
   435                     HBufC8* str = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
       
   436                                                                  iFreeText );
       
   437                     CleanupStack::PushL( str );
       
   438                     iRule->AddRuleParamL( ruleIndex, *str );
       
   439                     CleanupStack::PopAndDestroy( str );
       
   440                     }
       
   441                 break;
       
   442                 }
       
   443             case EMSTitleName:
       
   444                 {
       
   445                 DeleteRule( ECmTitle );
       
   446 
       
   447                 if ( iVideoTitleArray.Count() > 0 )
       
   448                     {
       
   449                     AddAdditionalRuleL( iVideoTitleArray,
       
   450                                         ECmTitle,
       
   451                                         ECmEquals );
       
   452                     }
       
   453                 break;
       
   454                 }
       
   455             case EMSMinFileSize:
       
   456                 {
       
   457                 DeleteRule( ECmFileSize, ECmGreater );
       
   458                 if ( iMinFileSizeSet == EMSSetSize )
       
   459                     {
       
   460                     AddAdditionalRuleL( ECmFileSize,
       
   461                                         ECmGreater,
       
   462                                         iMinFileSize*KMega );
       
   463                     }
       
   464                 break;
       
   465                 }
       
   466             case EMSMaxFileSize:
       
   467                 {
       
   468                 DeleteRule( ECmFileSize, ECmSmaller );
       
   469                 if ( iMaxFileSizeSet == EMSSetSize )
       
   470                     {
       
   471                     AddAdditionalRuleL( ECmFileSize,
       
   472                                         ECmSmaller,
       
   473                                         iMaxFileSize*KMega );
       
   474                     }
       
   475                 break;
       
   476                 }
       
   477              case EMSGenre:
       
   478                 {
       
   479                 DeleteRule( ECmGenre );
       
   480 
       
   481                 if ( iGenreArray.Count() > 0 )
       
   482                     {
       
   483                     AddAdditionalRuleL( iGenreArray,
       
   484                                         ECmGenre,
       
   485                                         ECmEquals );
       
   486                     }
       
   487                 break;
       
   488                 }
       
   489              case EMSArtist:
       
   490                 {
       
   491                 DeleteRule( ECmArtist );
       
   492 
       
   493                 if ( iArtistArray.Count() > 0 )
       
   494                     {
       
   495                     AddAdditionalRuleL( iArtistArray,
       
   496                                         ECmArtist,
       
   497                                         ECmEquals );
       
   498                     }
       
   499                 break;
       
   500                 }
       
   501              case EMSAlbum:
       
   502                 {
       
   503                 DeleteRule( ECmAlbum );
       
   504 
       
   505                 if ( iAlbumArray.Count() > 0 )
       
   506                     {
       
   507                     AddAdditionalRuleL( iAlbumArray,
       
   508                                         ECmAlbum,
       
   509                                         ECmEquals );
       
   510                     }
       
   511                 break;
       
   512                 }
       
   513             case EMSTrack:
       
   514                 {
       
   515                 DeleteRule( ECmTitle );
       
   516 
       
   517                 if ( iTrackArray.Count() > 0 )
       
   518                     {
       
   519                     AddAdditionalRuleL( iTrackArray,
       
   520                                         ECmTitle,
       
   521                                         ECmEquals );
       
   522                     }
       
   523                 break;
       
   524                 }
       
   525             case EMSTrackLength:
       
   526                 {
       
   527                 DeleteRule( ECmDuration );
       
   528                 if ( iTrackLengthEnum )
       
   529                     {
       
   530                     SaveTrackDurationL();
       
   531                     }
       
   532                 break;
       
   533                 }
       
   534             case EMSFileSize:
       
   535                 {
       
   536                 DeleteRule( ECmFileSize );
       
   537                 if ( iFileSizeEnum )
       
   538                     {
       
   539                     SaveTrackFileSizeL();
       
   540                     }
       
   541                 break;
       
   542                 }
       
   543             default:
       
   544                 {
       
   545                 LOG(_L("[MediaServant]\t CMSFillRuleEditList::SaveValueL \
       
   546                 no such rule"));
       
   547                 break;
       
   548                 }
       
   549             }
       
   550         }
       
   551     }
       
   552 
       
   553 // --------------------------------------------------------------------------
       
   554 // CAknSettingItem* CMSFillRuleEditList::CreateSettingItemL(TInt aIdentifier)
       
   555 // Takes care of creating actual setting items.
       
   556 // --------------------------------------------------------------------------
       
   557 //
       
   558 CAknSettingItem* CMSFillRuleEditList::CreateSettingItemL( TInt aIdentifier )
       
   559     {
       
   560     CAknSettingItem* settingItem = NULL;
       
   561 
       
   562     // setting item is created according to aIdentifier
       
   563     switch ( aIdentifier )
       
   564         {
       
   565         case EMSListName:
       
   566             {
       
   567             settingItem = new (ELeave ) CMSTextSettingItem(
       
   568                                         aIdentifier,
       
   569                                         iListName );
       
   570             break;
       
   571             }
       
   572         case EMSShrinkImages:
       
   573             {
       
   574             settingItem = new (ELeave ) CMSEnumeratedTextPopupSettingItem(
       
   575                                   aIdentifier,
       
   576                                   reinterpret_cast<TInt&> (iShrinkImages) );
       
   577             break;
       
   578             }
       
   579 
       
   580         case EMSAmount:
       
   581             {
       
   582             settingItem = new (ELeave ) CMSRuleAmountSetting(
       
   583                                         aIdentifier,
       
   584                                         reinterpret_cast<TInt&> (iLimitType),
       
   585                                         iAmount );
       
   586             break;
       
   587             }
       
   588 
       
   589         case EMSStartingWith:
       
   590             {
       
   591             settingItem = new (ELeave ) CMSEnumeratedTextPopupSettingItem(
       
   592                                         aIdentifier,
       
   593                                         iStartWith );
       
   594             break;
       
   595             }
       
   596 
       
   597         case EMSDateFrom:
       
   598             {
       
   599             settingItem = new (ELeave ) CMSTimeOrDateSettingItem(
       
   600                                         R_MS_FILL_RULE_DATE_FROM_SETTING_PAGE,
       
   601                                         aIdentifier,
       
   602                                         CAknTimeOrDateSettingItem::EDate,
       
   603                                         iDateFrom );
       
   604             break;
       
   605             }
       
   606 
       
   607         case EMSDateUntil:
       
   608             {
       
   609             settingItem = new (ELeave ) CMSTimeOrDateSettingItem(
       
   610                                         R_MS_FILL_RULE_DATE_UNTIL_SETTING_PAGE,
       
   611                                         aIdentifier,
       
   612                                         CAknTimeOrDateSettingItem::EDate,
       
   613                                         iDateUntil );
       
   614             break;
       
   615             }
       
   616 
       
   617         case EMSServers:
       
   618             {
       
   619             settingItem = CMSRuleServersSetting::NewL(
       
   620                                                 aIdentifier,
       
   621                                                 *iServerArray,
       
   622                                                 iSettingText,
       
   623                                                 R_MS_VALUE_LIST_ANY_SOURCE_DEVICE);
       
   624             break;
       
   625             }
       
   626 
       
   627         case EMSFreeText:
       
   628             {
       
   629             settingItem = new (ELeave ) CMSTextSettingItem(
       
   630                                         aIdentifier,
       
   631                                         iFreeText );
       
   632             break;
       
   633             }
       
   634         case EMSTitleName:
       
   635             {
       
   636             settingItem = CMSRuleMultiselectionSetting::NewL(
       
   637                                                 aIdentifier,
       
   638                                                 R_MS_RULE_NAME_SETTING,
       
   639                                                 R_MS_VALUE_ANY_NAME,
       
   640                                                 R_MS_VALUE_LIST_ANY_NAME,
       
   641                                                 iMetadataCollector->Tracks(),
       
   642                                                 &iVideoTitleArray,
       
   643                                                 R_MS_RULE_TITLE_ITEM_TEXT,
       
   644                                                 iSettingText );
       
   645             break;
       
   646             }
       
   647 
       
   648         case EMSMinFileSize:
       
   649             {
       
   650             settingItem = new (ELeave ) CMSRuleFileSizeSetting(
       
   651                                         aIdentifier,
       
   652                                         EMSMinFileSize,
       
   653                                         iMinFileSizeSet,
       
   654                                         iMinFileSize );
       
   655             break;
       
   656             }
       
   657 
       
   658         case EMSMaxFileSize:
       
   659             {
       
   660             settingItem = new (ELeave ) CMSRuleFileSizeSetting(
       
   661                                         aIdentifier,
       
   662                                         EMSMaxFileSize,
       
   663                                         iMaxFileSizeSet,
       
   664                                         iMaxFileSize );
       
   665             break;
       
   666             }
       
   667 
       
   668         case EMSGenre:
       
   669             {
       
   670 
       
   671 
       
   672             settingItem = CMSRuleMultiselectionSetting::NewL(
       
   673                                                 aIdentifier,
       
   674                                                 R_MS_RULE_GENRE_SETTING,
       
   675                                                 R_MS_VALUE_ANY_GENRE,
       
   676                                                 R_MS_VALUE_LIST_ANY_GENRE,
       
   677                                                 iMetadataCollector->Genres(),
       
   678                                                 &iGenreArray,
       
   679                                                 R_MS_RULE_GENRE_ITEM_TEXT,
       
   680                                                 iSettingText );
       
   681             break;
       
   682             }
       
   683 
       
   684         case EMSArtist:
       
   685             {
       
   686             settingItem = CMSRuleMultiselectionSetting::NewL(
       
   687                                                 aIdentifier,
       
   688                                                 R_MS_RULE_ARTIST_SETTING,
       
   689                                                 R_MS_VALUE_ANY_ARTIST,
       
   690                                                 R_MS_VALUE_LIST_ANY_ARTIST,
       
   691                                                 iMetadataCollector->Artists(),
       
   692                                                 &iArtistArray,
       
   693                                                 R_MS_RULE_ARTIST_ITEM_TEXT,
       
   694                                                 iSettingText );
       
   695             break;
       
   696             }
       
   697 
       
   698         case EMSAlbum:
       
   699             {
       
   700             settingItem = CMSRuleMultiselectionSetting::NewL(
       
   701                                                 aIdentifier,
       
   702                                                 R_MS_RULE_ALBUM_SETTING,
       
   703                                                 R_MS_VALUE_ANY_ALBUM,
       
   704                                                 R_MS_VALUE_LIST_ANY_ALBUM,
       
   705                                                 iMetadataCollector->Albums(),
       
   706                                                 &iAlbumArray,
       
   707                                                 R_MS_RULE_ALBUM_ITEM_TEXT,
       
   708                                                 iSettingText );
       
   709             break;
       
   710             }
       
   711 
       
   712         case EMSTrack:
       
   713             {
       
   714             settingItem = CMSRuleMultiselectionSetting::NewL(
       
   715                                                 aIdentifier,
       
   716                                                 R_MS_RULE_TRACK_SETTING,
       
   717                                                 R_MS_VALUE_ANY_TRACK,
       
   718                                                 R_MS_VALUE_LIST_ANY_TRACK,
       
   719                                                 iMetadataCollector->Tracks(),
       
   720                                                 &iTrackArray,
       
   721                                                 R_MS_RULE_TRACK_ITEM_TEXT,
       
   722                                                 iSettingText );
       
   723             break;
       
   724             }
       
   725 
       
   726         case EMSTrackLength:
       
   727             {
       
   728             settingItem = new (ELeave ) CMSEnumeratedTextPopupSettingItem(
       
   729                                         aIdentifier,
       
   730                                         iTrackLengthEnum );
       
   731             break;
       
   732             }
       
   733 
       
   734          case EMSFileSize:
       
   735             {
       
   736             settingItem = new (ELeave ) CMSEnumeratedTextPopupSettingItem(
       
   737                                         aIdentifier,
       
   738                                         iFileSizeEnum );
       
   739             break;
       
   740             }
       
   741 
       
   742         case EMSAddMoreRules:
       
   743             {
       
   744             settingItem = new (ELeave ) CMSTextSettingItem(
       
   745                                         aIdentifier,
       
   746                                         iDummyText );
       
   747             break;
       
   748             }
       
   749         default:
       
   750             {
       
   751             LOG(_L("[MediaServant]\t CMSFillRuleEditList::CreateSettingItemL\
       
   752             item not found"));            
       
   753             break;
       
   754             }
       
   755         }
       
   756     return settingItem;
       
   757     }
       
   758 
       
   759 
       
   760 // --------------------------------------------------------------------------
       
   761 // CMSFillRuleEditList::OpenSelectedListboxItemL
       
   762 // --------------------------------------------------------------------------
       
   763 //
       
   764 void CMSFillRuleEditList::OpenSelectedListboxItemL()
       
   765     {
       
   766     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
   767     OpenSelectedListboxItemL"));
       
   768 
       
   769     HandleListBoxEventL( ListBox(), EEventEnterKeyPressed );
       
   770     }
       
   771 
       
   772 // --------------------------------------------------------------------------
       
   773 // CMSFillRuleEditList::HandleListBoxEventL()
       
   774 // Handles listbox events
       
   775 // --------------------------------------------------------------------------
       
   776 //
       
   777 void  CMSFillRuleEditList::HandleListBoxEventL ( CEikListBox *aListBox,
       
   778                                                  TListBoxEvent aEventType)
       
   779     {
       
   780     LOG(_L("[MediaServant]\t CMSFillRuleEditList::HandleListBoxEventL"));
       
   781 
       
   782     CAknSettingItemArray* itemArray = SettingItemArray();
       
   783     TInt currentItem = ListBox()->CurrentItemIndex();
       
   784     TInt realIndex = itemArray->ItemIndexFromVisibleIndex(currentItem);
       
   785     CAknSettingItem* item= (*itemArray)[realIndex];
       
   786 	
       
   787 	// Event type for non-touch UI
       
   788 	if ( aEventType == EEventEnterKeyPressed )
       
   789 		{
       
   790   		if ( item->Identifier() == EMSAddMoreRules )
       
   791 	        {
       
   792 	        AddFillRuleL();
       
   793 	        }
       
   794 	    else
       
   795         	{
       
   796         	CAknSettingItemList::HandleListBoxEventL ( aListBox, aEventType );
       
   797         	}
       
   798 		}
       
   799 	// Event type for touch UI
       
   800 	else if ( aEventType == EEventItemClicked )
       
   801 		{
       
   802 	    // show add fill rule query if last item "Add more rules" selected
       
   803 	    if ( item->Identifier() == EMSAddMoreRules &&
       
   804 	         iPreviousRuleIdentifier == EMSAddMoreRules )
       
   805      	   {
       
   806 	        AddFillRuleL();
       
   807 	        }
       
   808     	else
       
   809 	        {
       
   810 	        CAknSettingItemList::HandleListBoxEventL ( aListBox, aEventType );
       
   811     	    }
       
   812 		iPreviousRuleIdentifier = item->Identifier();
       
   813 	    // values need to be stored
       
   814 		StoreSettingsL();
       
   815 		}
       
   816     else if ( item->Identifier() != EMSAddMoreRules )
       
   817     	{
       
   818 		CAknSettingItemList::HandleListBoxEventL ( aListBox, aEventType );
       
   819     	}
       
   820     
       
   821     }
       
   822 
       
   823 // --------------------------------------------------------------------------
       
   824 // CMSFillRuleEditList::EditItemL()
       
   825 // Called by framework when item is opened
       
   826 // --------------------------------------------------------------------------
       
   827 //
       
   828 void  CMSFillRuleEditList::EditItemL (TInt aIndex, TBool aCalledFromMenu)
       
   829     {
       
   830     LOG(_L("[MediaServant]\t CMSFillRuleEditList::EditItemL"));
       
   831 
       
   832     // cancel ongoing operation
       
   833     iView->CancelAsyncOperation( iAppUi );
       
   834     iState = EMSIdle;
       
   835 
       
   836     CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
       
   837 
       
   838     // get the item information after update
       
   839     CAknSettingItemArray* itemArray = SettingItemArray();
       
   840     TInt currentItem = ListBox()->CurrentItemIndex();
       
   841     TInt realIndex = itemArray->ItemIndexFromVisibleIndex(currentItem);
       
   842     CAknSettingItem* item= (*itemArray)[realIndex];
       
   843 
       
   844     // check if list name is modified
       
   845     if ( item->Identifier() == EMSListName )
       
   846         {
       
   847         HandleListNameL( item );
       
   848         }
       
   849 
       
   850     if ( CheckSettingPageAcceptance( item ) )
       
   851         {
       
   852         // store new value
       
   853         StoreSettingsL();
       
   854         // Save value to rule
       
   855         SaveValueL( item );
       
   856         // save rule and process it
       
   857         SaveAndPreprocesslistL( item );
       
   858         }
       
   859     }
       
   860 
       
   861 // --------------------------------------------------------------------------
       
   862 // CMSFillRuleEditList::HandleListNameL
       
   863 // Handles edit list name -case
       
   864 // --------------------------------------------------------------------------
       
   865 //
       
   866 void CMSFillRuleEditList::HandleListNameL( CAknSettingItem* aItem )
       
   867     {
       
   868     LOG(_L("[MediaServant]\t CMSFillRuleEditList::HandleListNameL"));
       
   869 
       
   870     CMSTextSettingItem* settingItem =
       
   871                             static_cast<CMSTextSettingItem*>( aItem );
       
   872 
       
   873     TPtr searchStr = settingItem->Text();
       
   874 
       
   875     // Deletes leading and trailing whitespace characters
       
   876     searchStr.Trim();
       
   877 
       
   878     HBufC* originalSearchStr =
       
   879                 CnvUtfConverter::ConvertToUnicodeFromUtf8L( iRule->Name() );
       
   880     CleanupStack::PushL( originalSearchStr );
       
   881 
       
   882     // whether they are same or not
       
   883     if ( *originalSearchStr != searchStr )
       
   884         {
       
   885         // if there are same names in other fill rules
       
   886         TBool isSame = CheckSameNameL( searchStr );
       
   887 
       
   888         if ( isSame )
       
   889             {
       
   890             TInt postfix = 0;
       
   891             TPtr itemText = searchStr;
       
   892 
       
   893             // decide which number is added to the end of the name
       
   894             for ( ; ; ++postfix )
       
   895                 {
       
   896                 HBufC* sameStr = HBufC::NewL( KMaxFileName );
       
   897                 CleanupStack::PushL( sameStr );
       
   898                 sameStr->Des().Append( itemText );
       
   899 
       
   900                 // if the name does not add number to the end is unique so keep the original name
       
   901                 if ( 0 != postfix)
       
   902                     {
       
   903                     sameStr->Des().Append( KSpace );
       
   904                     sameStr->Des().AppendNum( postfix );
       
   905                     // do number conversion
       
   906                     TPtr ptr = sameStr->Des();
       
   907                     AknTextUtils::
       
   908                      DisplayTextLanguageSpecificNumberConversion( ptr );
       
   909                     }
       
   910                 // must modify name with append a number
       
   911                 if ( !CheckSameNameL( *sameStr ) || ( *sameStr == *originalSearchStr ) )
       
   912                     {
       
   913                     CleanupStack::PopAndDestroy( sameStr );
       
   914                     break;
       
   915                     }
       
   916                 CleanupStack::PopAndDestroy( sameStr );
       
   917                 }
       
   918 
       
   919             // do not need append a number
       
   920             if ( 0 != postfix)
       
   921                 {
       
   922                 itemText.Append( KSpace );
       
   923                 itemText.AppendNum( postfix );
       
   924 
       
   925                 // do number conversion
       
   926                 AknTextUtils::
       
   927                     DisplayTextLanguageSpecificNumberConversion( itemText );
       
   928                 
       
   929                 iListName.Copy( itemText );
       
   930                 settingItem->LoadL();
       
   931 
       
   932                 aItem->UpdateListBoxTextL();
       
   933                 }
       
   934             }
       
   935         }
       
   936     else
       
   937         {
       
   938         settingItem->LoadL();
       
   939         }
       
   940     CleanupStack::PopAndDestroy( originalSearchStr );
       
   941     }
       
   942 
       
   943 // --------------------------------------------------------------------------
       
   944 // CMSFillRuleEditList::CheckSameNameL
       
   945 // check the name is same or not
       
   946 // --------------------------------------------------------------------------
       
   947 //
       
   948 TBool CMSFillRuleEditList::CheckSameNameL( const TDesC& aName ) const
       
   949     {
       
   950     RPointerArray<CMSFillList>* iFillListArray = 
       
   951                 iAppUi->FillRuleController()->FillListArray();
       
   952 
       
   953     // fill rule name array is not empty
       
   954     if ( iFillListArray->Count() > 0 )
       
   955         {
       
   956         for ( TInt index = 0; index < iFillListArray->Count(); ++index )
       
   957             {
       
   958             // Get fill rule name and put it to the listbox
       
   959             CCmFillRule* rule = (*iFillListArray)[index]->List();
       
   960             HBufC* listName =
       
   961                 CnvUtfConverter::ConvertToUnicodeFromUtf8L( rule->Name() );
       
   962             CleanupStack::PushL( listName );
       
   963             // whether there is a same name fill rule
       
   964             if ( aName == *listName )
       
   965                 {
       
   966                 CleanupStack::PopAndDestroy( listName );
       
   967                 return ETrue;
       
   968                 }
       
   969             CleanupStack::PopAndDestroy( listName );
       
   970             }
       
   971         }
       
   972     return EFalse;
       
   973     }
       
   974 
       
   975 // --------------------------------------------------------------------------
       
   976 // CMSFillRuleEditList::SaveAndPreprocesslistL
       
   977 // Saves modified list and preprocesses it
       
   978 // --------------------------------------------------------------------------
       
   979 //
       
   980 void CMSFillRuleEditList::SaveAndPreprocesslistL( CAknSettingItem* aItem )
       
   981     {
       
   982     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
   983     SaveAndPreprocesslistL"));
       
   984 
       
   985     // save rules
       
   986     iAppUi->FillRuleController()->SaveRulesL();
       
   987     // we'll lost iRule after update...
       
   988     iAppUi->FillRuleController()->UpdateArrayL();
       
   989     // ...so get it again
       
   990     iRule = (*iAppUi->FillRuleController()->
       
   991                     FillListArray())[iSelectedList]->List();
       
   992 
       
   993     // if multiselectionitem is edited start data reading after preprocess
       
   994    if ( aItem->Identifier() == EMSGenre ||
       
   995         aItem->Identifier() == EMSArtist ||
       
   996         aItem->Identifier() == EMSAlbum ||
       
   997         aItem->Identifier() == EMSTrack||
       
   998         aItem->Identifier() == EMSTitleName)
       
   999         {
       
  1000         iState = EMSFetchMetadata;
       
  1001         }
       
  1002 
       
  1003     // if other item than name is changed preprocessing is needed
       
  1004     if ( aItem->Identifier() != EMSListName )
       
  1005         {
       
  1006         PreprocessListL();
       
  1007         }
       
  1008     }
       
  1009 
       
  1010 // --------------------------------------------------------------------------
       
  1011 // CMSFillRuleEditList::ActivateL
       
  1012 // Asks setting page selection status from setting item
       
  1013 // --------------------------------------------------------------------------
       
  1014 //
       
  1015 TBool CMSFillRuleEditList::CheckSettingPageAcceptance(
       
  1016                                             CAknSettingItem* aItem )
       
  1017     {
       
  1018     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1019     CheckSettingPageAcceptance"));
       
  1020 
       
  1021     TBool status( EFalse );
       
  1022 
       
  1023     switch ( aItem->Identifier() )
       
  1024         {
       
  1025         case EMSShrinkImages:
       
  1026         // fall through
       
  1027         case EMSAmount:
       
  1028         // fall through
       
  1029         case EMSStartingWith:
       
  1030         // fall through
       
  1031         case EMSMinFileSize:
       
  1032         // fall through
       
  1033         case EMSMaxFileSize:
       
  1034         // fall through
       
  1035         case EMSTrackLength:
       
  1036         // fall through
       
  1037         case EMSFileSize:
       
  1038             {
       
  1039             CMSEnumeratedTextPopupSettingItem* item =
       
  1040                     static_cast<CMSEnumeratedTextPopupSettingItem*>(aItem);
       
  1041             status = item->SettingAccepted();
       
  1042             break;
       
  1043             }
       
  1044         case EMSListName:
       
  1045         // fall through
       
  1046         case EMSServers:
       
  1047         // fall through
       
  1048         case EMSFreeText:
       
  1049         // fall through
       
  1050         case EMSTitleName:
       
  1051         // fall through
       
  1052         case EMSGenre:
       
  1053         // fall through
       
  1054         case EMSArtist:
       
  1055         // fall through
       
  1056         case EMSAlbum:
       
  1057         // fall through
       
  1058         case EMSTrack:
       
  1059 
       
  1060             {
       
  1061             CMSTextSettingItem* item =
       
  1062                     static_cast<CMSTextSettingItem*>(aItem);
       
  1063             status = item->SettingAccepted();
       
  1064             break;
       
  1065             }
       
  1066 
       
  1067         case EMSDateFrom:
       
  1068         // fall through
       
  1069         case EMSDateUntil:
       
  1070             {
       
  1071             CMSTimeOrDateSettingItem* item =
       
  1072                     static_cast<CMSTimeOrDateSettingItem*>(aItem);
       
  1073             status = item->SettingAccepted();
       
  1074             break;
       
  1075             }
       
  1076         default:
       
  1077             {
       
  1078             LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1079             CheckSettingPageAcceptance no such item"));
       
  1080             break;
       
  1081             }
       
  1082         }
       
  1083 
       
  1084     return status;
       
  1085     }
       
  1086 // --------------------------------------------------------------------------
       
  1087 // CMSFillRuleEditList::ActivateL
       
  1088 // Activates setting list
       
  1089 // --------------------------------------------------------------------------
       
  1090 //
       
  1091 void CMSFillRuleEditList::ActivateL()
       
  1092     {
       
  1093     LOG(_L("[MediaServant]\t CMSFillRuleEditList::ActivateL"));
       
  1094 
       
  1095     // hide all items by default
       
  1096     // index starts from '1' because list name is always visible
       
  1097     // index stops to count-1 because "add more rules" is always visible
       
  1098     for (TInt index = 1 ;index < SettingItemArray()->Count()-1; index++)
       
  1099         {
       
  1100         SettingItemArray()->At( index )->SetHidden(ETrue);
       
  1101         }
       
  1102 
       
  1103     CAknSettingItemArray* itemArray = SettingItemArray();
       
  1104     // set template rules visible
       
  1105     for (TInt idx = 0; idx < iVisibleRules.Count(); idx++)
       
  1106         {
       
  1107         CAknSettingItem* item = SearchItemById( iVisibleRules[idx] );
       
  1108         if ( item )
       
  1109             {
       
  1110             item->SetHidden( EFalse);
       
  1111             }
       
  1112         }
       
  1113     // Show also additional rules if user has changed the default value
       
  1114     DisplayModifiedAdditionalRules();
       
  1115     // visibility of some items may have changed
       
  1116     HandleChangeInItemArrayOrVisibilityL();
       
  1117 
       
  1118     CAknSettingItemList::ActivateL();
       
  1119     }
       
  1120 
       
  1121 // --------------------------------------------------------------------------
       
  1122 // void CMSFillRuleEditList::ReadTemplateRulesL
       
  1123 // reads fill rule name
       
  1124 // --------------------------------------------------------------------------
       
  1125 //
       
  1126 void CMSFillRuleEditList::ReadTemplateRulesL( TInt aTemplate )
       
  1127     {
       
  1128     LOG(_L("[MediaServant]\t CMSFillRuleEditList::ReadTemplateRulesL"));
       
  1129 
       
  1130     TResourceReader rsReader;
       
  1131 
       
  1132     switch ( aTemplate )
       
  1133         {
       
  1134         case EMSDefaultImageList:
       
  1135             {
       
  1136             iCoeEnv->CreateResourceReaderLC(rsReader,
       
  1137                             R_MS_DEFAULT_IMAGE_LIST_RULES);
       
  1138             break;
       
  1139             }
       
  1140         case EMSDefaultVideoList:
       
  1141             {
       
  1142             iCoeEnv->CreateResourceReaderLC(rsReader,
       
  1143                             R_MS_DEFAULT_VIDEO_LIST_RULES);
       
  1144             break;
       
  1145             }
       
  1146         case EMSDefaultMusicList:
       
  1147             {
       
  1148             iCoeEnv->CreateResourceReaderLC(rsReader,
       
  1149                             R_MS_DEFAULT_MUSIC_LIST_RULES);
       
  1150             break;
       
  1151             }
       
  1152         default:
       
  1153             {
       
  1154             LOG(_L("[MediaServant]\t CMSFillRuleEditList::ReadTemplateRulesL\
       
  1155              rule not found"));
       
  1156             break;
       
  1157             }
       
  1158         }
       
  1159 
       
  1160     // get rule count of the template
       
  1161     TInt ruleCount( rsReader.ReadInt16() );
       
  1162 
       
  1163     // List name is always visible -> index starts from EMSListName+1
       
  1164     for ( TInt index = EMSListName+1; index <= ruleCount; index++ )
       
  1165         {
       
  1166         // get rule ID
       
  1167         TMSFillEditItems ruleId =
       
  1168                     static_cast<TMSFillEditItems>(rsReader.ReadInt16());
       
  1169         // get value
       
  1170         TInt value = rsReader.ReadInt16();
       
  1171         // get addional value
       
  1172         TInt addValue = rsReader.ReadInt16();
       
  1173         if ( ruleId == EMSAmount )
       
  1174             {
       
  1175             iLimitType = static_cast<TCmLimitType> (addValue);
       
  1176             }
       
  1177         // Remember IDs of template rules - rules will be set
       
  1178         // visible later
       
  1179         iVisibleRules.AppendL( ruleId );
       
  1180 
       
  1181         // set value of rule
       
  1182         SetDefaultValue( ruleId, value );
       
  1183         }
       
  1184 
       
  1185     CleanupStack::PopAndDestroy();//reader
       
  1186     }
       
  1187 
       
  1188 // --------------------------------------------------------------------------
       
  1189 // CMSFillRuleEditList::SetDefaultValues
       
  1190 // Sets default value defined by template
       
  1191 // --------------------------------------------------------------------------
       
  1192 //
       
  1193 void CMSFillRuleEditList::SetDefaultValue( TInt aId, TInt aValue )
       
  1194     {
       
  1195     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SetDefaultValue"));
       
  1196 
       
  1197     switch ( aId )
       
  1198         {
       
  1199         case EMSShrinkImages:
       
  1200             {
       
  1201             iShrinkImages = static_cast<TMSShrinkImages> (aValue);
       
  1202             break;
       
  1203             }
       
  1204         case EMSAmount:
       
  1205             {
       
  1206             iAmount = aValue;
       
  1207             break;
       
  1208             }
       
  1209         case EMSStartingWith:
       
  1210             {
       
  1211             iStartWith = aValue;
       
  1212             break;
       
  1213             }
       
  1214         default:
       
  1215             {
       
  1216             LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1217             SetDefaultValues item not found"));
       
  1218             }
       
  1219         }
       
  1220     }
       
  1221 // --------------------------------------------------------------------------
       
  1222 // CMSFillRuleEditList::AddFillRuleL
       
  1223 // Sets rule visibility
       
  1224 // --------------------------------------------------------------------------
       
  1225 //
       
  1226 void CMSFillRuleEditList::AddFillRuleL()
       
  1227     {
       
  1228     LOG(_L("[MediaServant]\t CMSFillRuleEditList::AddFillRuleL"));
       
  1229 
       
  1230     TResourceReader reader;
       
  1231 
       
  1232     switch ( iMediaType )
       
  1233         {
       
  1234         case ECmImage:
       
  1235             {
       
  1236             // read image templates
       
  1237             iCoeEnv->CreateResourceReaderLC( reader, R_MS_IMAGE_RULE_LIST );
       
  1238             break;
       
  1239             }
       
  1240         case ECmVideo:
       
  1241             {
       
  1242             // read video templates
       
  1243             iCoeEnv->CreateResourceReaderLC( reader, R_MS_VIDEO_RULE_LIST );
       
  1244             break;
       
  1245             }
       
  1246         case ECmAudio:
       
  1247             {
       
  1248             // read music templates
       
  1249             iCoeEnv->CreateResourceReaderLC( reader, R_MS_MUSIC_RULE_LIST );
       
  1250             break;
       
  1251             }
       
  1252         default:
       
  1253             {
       
  1254             // command not found
       
  1255             return;
       
  1256             }
       
  1257         }
       
  1258 
       
  1259     // read rule count
       
  1260     TInt ruleCount( reader.ReadInt16() );
       
  1261 
       
  1262     CDesCArray* ruleNames = new ( ELeave ) CDesCArrayFlat( ruleCount );
       
  1263     CleanupStack::PushL( ruleNames );
       
  1264 
       
  1265     // array for template ID's
       
  1266     RArray<TInt> indexArray;
       
  1267 
       
  1268     // fill name array
       
  1269     for ( TInt index = 0; index < ruleCount; index++ )
       
  1270         {
       
  1271         // read rule ID
       
  1272         TMSFillEditItems value =
       
  1273                     static_cast<TMSFillEditItems>( reader.ReadInt16() );
       
  1274         // read rule name
       
  1275         TPtrC text = reader.ReadTPtrC();
       
  1276 
       
  1277         // add only hidden items to the list
       
  1278         if ( SearchItemById( value )->IsHidden() )
       
  1279             {
       
  1280             indexArray.AppendL( value );
       
  1281             ruleNames->AppendL( text );
       
  1282             }
       
  1283         }
       
  1284 
       
  1285     TInt selectedRule( 0 );
       
  1286 
       
  1287     if ( iView->ShowTemplateQueryL( R_MSERV_TEMPLATE_QUERY, 
       
  1288                                     R_MS_ADD_RULE_QUERY_HEADING,
       
  1289                                     ruleNames,
       
  1290                                     selectedRule ) )
       
  1291         {
       
  1292         // search item
       
  1293         for ( TInt idx = 0; idx < SettingItemArray()->Count(); idx++ )
       
  1294             {
       
  1295             CAknSettingItem* item = SettingItemArray()->At( idx );
       
  1296             if ( item->Identifier() == indexArray[selectedRule] )
       
  1297                 {
       
  1298                 // Show confirmation query for "From" and for "Until"
       
  1299                 if ( item->Identifier() == EMSDateFrom ||
       
  1300                      item->Identifier() == EMSDateUntil )
       
  1301                 	{
       
  1302     				if ( iView->ShowQueryL( R_MSERV_VIDEO_RULE_QUERY ) )
       
  1303         				{
       
  1304                 		// set item visible
       
  1305                 		item->SetHidden( EFalse );
       
  1306         				}
       
  1307                 	}
       
  1308 	            else
       
  1309 	                {
       
  1310 	           		item->SetHidden( EFalse );
       
  1311 	                }
       
  1312                 }
       
  1313             }
       
  1314         HandleChangeInItemArrayOrVisibilityL();
       
  1315         }
       
  1316     indexArray.Close();
       
  1317     CleanupStack::PopAndDestroy( ruleNames );
       
  1318     CleanupStack::PopAndDestroy(); // resource stuff
       
  1319     }
       
  1320 
       
  1321 // --------------------------------------------------------------------------
       
  1322 // CMSFillRuleEditList::SetListType
       
  1323 // Sets list type based on given command
       
  1324 // --------------------------------------------------------------------------
       
  1325 //
       
  1326 void CMSFillRuleEditList::SetListType( TInt aType )
       
  1327     {
       
  1328     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SetListType"));
       
  1329 
       
  1330     switch ( aType )
       
  1331         {
       
  1332         case EMSCmdNewImageList:
       
  1333             {
       
  1334             iRule->SetMediaType( ECmImage );
       
  1335             iMediaType = ECmImage;
       
  1336             break;
       
  1337             }
       
  1338         case EMSCmdNewVideoList:
       
  1339             {
       
  1340             iRule->SetMediaType( ECmVideo );
       
  1341             iMediaType = ECmVideo;
       
  1342             break;
       
  1343             }
       
  1344         case EMSCmdNewMusicList:
       
  1345             {
       
  1346             iRule->SetMediaType( ECmAudio );
       
  1347             iMediaType = ECmAudio;
       
  1348             break;
       
  1349             }
       
  1350         default:
       
  1351             {
       
  1352             LOG(_L("[MediaServant]\t CMSFillRuleEditList::SetListType \
       
  1353             type not set"));
       
  1354             break;
       
  1355             }
       
  1356         }
       
  1357     }
       
  1358 
       
  1359 // --------------------------------------------------------------------------
       
  1360 // CMSFillRuleEditList::GetRuleValuesL
       
  1361 // Loads rule values for the list
       
  1362 // --------------------------------------------------------------------------
       
  1363 //
       
  1364 void CMSFillRuleEditList::GetRuleValuesL()
       
  1365     {
       
  1366     LOG(_L("[MediaServant]\t CMSFillRuleEditList::GetRuleValuesL"));
       
  1367 
       
  1368     HBufC* listName = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
       
  1369                                                 iRule->Name() );
       
  1370     CleanupStack::PushL( listName );
       
  1371     iListName.Copy( *listName );
       
  1372     CleanupStack::PopAndDestroy( listName );
       
  1373 
       
  1374     // get limit type
       
  1375     iLimitType = iRule->LimitType();
       
  1376 
       
  1377     // get amount
       
  1378     iAmount = iRule->Amount();
       
  1379 
       
  1380     if ( iRule->Status() == ECmToBeShrinked )
       
  1381         {
       
  1382         iShrinkImages = EMSShrinkScreenSize;
       
  1383 
       
  1384         }
       
  1385     else
       
  1386         {
       
  1387         iShrinkImages = EMSShrinkingOff;
       
  1388         }
       
  1389 
       
  1390     // get start with
       
  1391     iStartWith = iRule->Method();
       
  1392 
       
  1393     InitializeValues();
       
  1394 
       
  1395     // Read additional rules
       
  1396     TInt ruleCount = iRule->RuleCount();
       
  1397     // Cycle trough all rules
       
  1398     for ( TInt ruleIndex = 0; ruleIndex < ruleCount; ruleIndex++ )
       
  1399         {
       
  1400         TCmMetadataField metaData;
       
  1401         TCmOperatorType operatorType;
       
  1402         TInt paramCount(0);
       
  1403 
       
  1404         iRule->RuleL( ruleIndex, &metaData, &operatorType, &paramCount );
       
  1405 
       
  1406 
       
  1407         // Cycle trough all params
       
  1408         for ( TInt paramIndex = 0; paramIndex < paramCount; paramIndex++ )
       
  1409             {
       
  1410             TPtrC8 strParam;
       
  1411             iRule->RuleParamL( ruleIndex, paramIndex, &strParam );
       
  1412 
       
  1413             // read index value
       
  1414             TInt ruleParam( 0 );
       
  1415             iRule->RuleParamL( ruleIndex, paramIndex, ruleParam );
       
  1416 
       
  1417             switch ( metaData )
       
  1418                 {
       
  1419                 case ECmArtist:
       
  1420                     {
       
  1421                     iArtistArray.AppendL( ruleParam );
       
  1422                     break;
       
  1423                     }
       
  1424                 case ECmAlbum:
       
  1425                     {
       
  1426                     iAlbumArray.AppendL( ruleParam );
       
  1427                     break;
       
  1428                     }
       
  1429                 case ECmGenre:
       
  1430                     {
       
  1431                     iGenreArray.AppendL( ruleParam );
       
  1432                     break;
       
  1433                     }
       
  1434                 case ECmTitle:
       
  1435                     {
       
  1436                     if ( iMediaType == ECmAudio )
       
  1437                         {
       
  1438                         iTrackArray.AppendL( ruleParam );
       
  1439                         }
       
  1440                     else // video
       
  1441                         {
       
  1442                         iVideoTitleArray.AppendL( ruleParam );
       
  1443                         }
       
  1444 
       
  1445                     break;
       
  1446                     }
       
  1447                 case ECmDuration:
       
  1448                     {
       
  1449                     TLex8 lex( strParam );
       
  1450                     if ( operatorType == ECmGreater )
       
  1451                         {
       
  1452                         lex.Val( iMinTrackLength );
       
  1453                         }
       
  1454                     else if ( operatorType == ECmSmaller )
       
  1455                         {
       
  1456                         lex.Val( iMaxTrackLength );
       
  1457                         }
       
  1458                     break;
       
  1459                     }
       
  1460                 case ECmDate:
       
  1461                     {
       
  1462                     TInt64 value;
       
  1463                     TLex8 lex(strParam);
       
  1464                     lex.Val(value);
       
  1465 
       
  1466                     if ( operatorType == ECmGreater )
       
  1467                         {
       
  1468                         iDateFrom = TTime( value );
       
  1469                         }
       
  1470                     if ( operatorType == ECmSmaller )
       
  1471                         {
       
  1472                         iDateUntil = TTime( value );
       
  1473                         }
       
  1474                     break;
       
  1475                     }
       
  1476                 case ECmFileSize:
       
  1477                     {
       
  1478                     TLex8 lex( strParam );
       
  1479                     if ( operatorType == ECmGreater )
       
  1480                         {
       
  1481                         lex.Val( iMinFileSize );
       
  1482                         iMinFileSize /= KMega;
       
  1483                         // not needed in audio case
       
  1484                         iMinFileSizeSet = EMSSetSize;
       
  1485                         }
       
  1486                     else if ( operatorType == ECmSmaller )
       
  1487                         {
       
  1488                         lex.Val( iMaxFileSize );
       
  1489                         iMaxFileSize /= KMega;
       
  1490                         // not needed in audio case
       
  1491                         iMaxFileSizeSet = EMSSetSize;
       
  1492                         }
       
  1493                     break;
       
  1494                     }
       
  1495                 case ECmBitrate:
       
  1496                     {
       
  1497                     break;
       
  1498                     }
       
  1499                 case ECmResolution:
       
  1500                     {
       
  1501                     break;
       
  1502                     }
       
  1503                 case ECmFreeText:
       
  1504                     {
       
  1505                     HBufC* listName =
       
  1506                         CnvUtfConverter::ConvertToUnicodeFromUtf8L(
       
  1507                                                             strParam );
       
  1508                     CleanupStack::PushL( listName );
       
  1509                     iFreeText.Copy( *listName );
       
  1510                     CleanupStack::PopAndDestroy( listName );
       
  1511                     }
       
  1512                 default:
       
  1513                     {
       
  1514                     break;
       
  1515                     }
       
  1516                 }
       
  1517             }
       
  1518         }
       
  1519 
       
  1520     if  ( iMediaType == ECmAudio )
       
  1521         {
       
  1522         SetAudioFileSizeSelection();
       
  1523         SetAudioFileDurationSelection();
       
  1524         }
       
  1525     }
       
  1526 
       
  1527 // --------------------------------------------------------------------------
       
  1528 // CMSFillRuleEditList::InitializeValues
       
  1529 // Initializes values of rules
       
  1530 // --------------------------------------------------------------------------
       
  1531 //
       
  1532 void CMSFillRuleEditList::InitializeValues()
       
  1533     {
       
  1534     LOG(_L("[MediaServant]\t CMSFillRuleEditList::InitializeValues"));
       
  1535 
       
  1536     // set date
       
  1537     iDateFrom.Set(KDefaultFromDate);
       
  1538     // set date
       
  1539     iDateUntil.HomeTime();
       
  1540     }
       
  1541 
       
  1542 // --------------------------------------------------------------------------
       
  1543 // CMSFillRuleEditList::DeleteRule
       
  1544 // Deletes rule from the list
       
  1545 // --------------------------------------------------------------------------
       
  1546 //
       
  1547 void CMSFillRuleEditList::DeleteRule( TCmMetadataField aField )
       
  1548     {
       
  1549     LOG(_L("[MediaServant]\t CMSFillRuleEditList::DeleteRule"));
       
  1550 
       
  1551     iRule->DeleteRule( aField );
       
  1552     }
       
  1553 
       
  1554 // --------------------------------------------------------------------------
       
  1555 // CMSFillRuleEditList::DeleteRule
       
  1556 // Deletes rule from the list
       
  1557 // --------------------------------------------------------------------------
       
  1558 //
       
  1559 void CMSFillRuleEditList::DeleteRule( TCmMetadataField aField,
       
  1560                                       TCmOperatorType aType  )
       
  1561     {
       
  1562     LOG(_L("[MediaServant]\t CMSFillRuleEditList::DeleteRule"));
       
  1563 
       
  1564     iRule->DeleteRule( aField, aType );
       
  1565     }
       
  1566 
       
  1567 // --------------------------------------------------------------------------
       
  1568 // CMSFillRuleEditList::AddAdditionalRuleL
       
  1569 // Adds additional rules to the list
       
  1570 // --------------------------------------------------------------------------
       
  1571 //
       
  1572 void CMSFillRuleEditList::AddAdditionalRuleL( RArray<TInt>& aArray,
       
  1573                                               TCmMetadataField aField,
       
  1574                                               TCmOperatorType aOperator )
       
  1575     {
       
  1576     LOG(_L("[MediaServant]\t CMSFillRuleEditList::AddAdditionalRuleL"));
       
  1577 
       
  1578     TInt ruleIndex = iRule->AddRuleL( aField, aOperator );
       
  1579     for ( TInt idx = 0; idx < aArray.Count(); idx++)
       
  1580         {
       
  1581         iRule->AddRuleParamL( ruleIndex, aArray[ idx ] );
       
  1582         }
       
  1583     }
       
  1584 
       
  1585 // --------------------------------------------------------------------------
       
  1586 // CMSFillRuleEditList::AppendItemToListL
       
  1587 // Appends item to the list
       
  1588 // --------------------------------------------------------------------------
       
  1589 //
       
  1590 void CMSFillRuleEditList::AppendItemToListL( RArray<TInt>* aArray,
       
  1591                                           TInt aParam )
       
  1592     {
       
  1593     LOG(_L("[MediaServant]\t CMSFillRuleEditList::AppendItemToListL"));
       
  1594 
       
  1595     aArray->AppendL( aParam );
       
  1596     }
       
  1597 
       
  1598 // --------------------------------------------------------------------------
       
  1599 // CMSFillRuleEditList::AddAdditionalRuleL
       
  1600 // sets numeric type rule
       
  1601 // --------------------------------------------------------------------------
       
  1602 //
       
  1603 void CMSFillRuleEditList::AddAdditionalRuleL( TCmMetadataField aMetadataField,
       
  1604                                               TCmOperatorType aOperator,
       
  1605                                               TInt aValue )
       
  1606     {
       
  1607     LOG(_L("[MediaServant]\t CMSFillRuleEditList::AddAdditionalRuleL"));
       
  1608 
       
  1609     TInt ruleIndex = iRule->AddRuleL( aMetadataField, aOperator );
       
  1610     HBufC8* str = HBufC8::NewLC( 10 );
       
  1611     str->Des().Format(_L8("%d"), aValue );
       
  1612     iRule->AddRuleParamL( ruleIndex, *str );
       
  1613     CleanupStack::PopAndDestroy( str );
       
  1614     }
       
  1615 
       
  1616 // --------------------------------------------------------------------------
       
  1617 // CMSFillRuleEditList::SaveTrackFileSizeL
       
  1618 // Saves track file size
       
  1619 // --------------------------------------------------------------------------
       
  1620 //
       
  1621 void CMSFillRuleEditList::SaveTrackFileSizeL()
       
  1622     {
       
  1623     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SaveTrackFileSizeL"));
       
  1624 
       
  1625     switch ( iFileSizeEnum )
       
  1626         {
       
  1627         case EMSFileSizeLess_1_mb:
       
  1628             {
       
  1629             AddAdditionalRuleL( ECmFileSize, ECmSmaller, KMSSize_1_MB );
       
  1630             break;
       
  1631             }
       
  1632         case EMSFileSize_15_mb:
       
  1633             {
       
  1634             AddAdditionalRuleL( ECmFileSize, ECmGreater, KMSSize_1_MB );
       
  1635             AddAdditionalRuleL( ECmFileSize, ECmSmaller, KMSSize_5_MB );
       
  1636             break;
       
  1637             }
       
  1638         case EMSFileSize_510_mb:
       
  1639             {
       
  1640             AddAdditionalRuleL( ECmFileSize, ECmGreater, KMSSize_5_MB );
       
  1641             AddAdditionalRuleL( ECmFileSize, ECmSmaller, KMSSize_10_MB );
       
  1642             break;
       
  1643             }
       
  1644         case EMSFileSize_1050_mb:
       
  1645             {
       
  1646             AddAdditionalRuleL( ECmFileSize, ECmGreater, KMSSize_10_MB );
       
  1647             AddAdditionalRuleL( ECmFileSize, ECmSmaller, KMSSize_50_MB );
       
  1648             break;
       
  1649             }
       
  1650         case EMSFileSizeMore_10:
       
  1651             {
       
  1652             AddAdditionalRuleL( ECmFileSize, ECmGreater, KMSSize_50_MB );
       
  1653             break;
       
  1654             }
       
  1655         default:
       
  1656             {
       
  1657             LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1658             SetAudioFileSizeSelection enum not found"));
       
  1659             break;
       
  1660             }
       
  1661         }
       
  1662     }
       
  1663 
       
  1664 // --------------------------------------------------------------------------
       
  1665 // CMSFillRuleEditList::SetAudioFileSizeSelection
       
  1666 // set selection for audio file size
       
  1667 // --------------------------------------------------------------------------
       
  1668 //
       
  1669 void CMSFillRuleEditList::SetAudioFileSizeSelection()
       
  1670     {
       
  1671     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1672     SetAudioFileSizeSelection"));
       
  1673 
       
  1674     if ( ( KMega * iMinFileSize ) == KMSSize_0_MB &&
       
  1675         ( KMega * iMaxFileSize ) == KMSSize_1_MB )
       
  1676         {
       
  1677         iFileSizeEnum = EMSFileSizeLess_1_mb;
       
  1678         }
       
  1679     else if ( ( KMega * iMinFileSize ) == KMSSize_1_MB &&
       
  1680               ( KMega * iMaxFileSize ) == KMSSize_5_MB )
       
  1681         {
       
  1682         iFileSizeEnum = EMSFileSize_15_mb;
       
  1683         }
       
  1684     else if ( ( KMega * iMinFileSize ) == KMSSize_5_MB &&
       
  1685               ( KMega * iMaxFileSize ) == KMSSize_10_MB )
       
  1686         {
       
  1687         iFileSizeEnum = EMSFileSize_510_mb;
       
  1688         }
       
  1689     else if ( ( KMega * iMinFileSize ) == KMSSize_10_MB &&
       
  1690               ( KMega * iMaxFileSize ) == KMSSize_50_MB )
       
  1691         {
       
  1692         iFileSizeEnum = EMSFileSize_1050_mb;
       
  1693         }
       
  1694     else if ( ( KMega * iMinFileSize ) == KMSSize_50_MB &&
       
  1695               ( KMega * iMaxFileSize ) == KMSSize_0_MB )
       
  1696         {
       
  1697         iFileSizeEnum = EMSFileSizeMore_10;
       
  1698         }
       
  1699     else
       
  1700         {
       
  1701         iFileSizeEnum = EMSFileSizeAny;
       
  1702         }
       
  1703     }
       
  1704 
       
  1705 // --------------------------------------------------------------------------
       
  1706 // CMSFillRuleEditList::SaveTrackDurationL
       
  1707 // Saves track duration
       
  1708 // --------------------------------------------------------------------------
       
  1709 //
       
  1710 void CMSFillRuleEditList::SaveTrackDurationL()
       
  1711     {
       
  1712     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SaveTrackDurationL"));
       
  1713 
       
  1714     switch ( iTrackLengthEnum)
       
  1715         {
       
  1716         case EMSTrackLenLess_1:
       
  1717             {
       
  1718             AddAdditionalRuleL( ECmDuration, ECmSmaller,
       
  1719                                 KMSTrackLength_1_min );
       
  1720             break;
       
  1721             }
       
  1722         case EMSTrackLen_16:
       
  1723             {
       
  1724             AddAdditionalRuleL( ECmDuration, ECmGreater,
       
  1725                                 KMSTrackLength_1_min );
       
  1726             AddAdditionalRuleL( ECmDuration, ECmSmaller,
       
  1727                                 KMSTrackLength_6_min );
       
  1728             break;
       
  1729             }
       
  1730         case EMSTrackLen_68:
       
  1731             {
       
  1732             AddAdditionalRuleL( ECmDuration, ECmGreater,
       
  1733                                 KMSTrackLength_6_min );
       
  1734             AddAdditionalRuleL( ECmDuration, ECmSmaller,
       
  1735                                 KMSTrackLength_8_min );
       
  1736             break;
       
  1737             }
       
  1738         case EMSTrackLen_830:
       
  1739             {
       
  1740             AddAdditionalRuleL( ECmDuration, ECmGreater,
       
  1741                                 KMSTrackLength_8_min );
       
  1742             AddAdditionalRuleL( ECmDuration, ECmSmaller,
       
  1743                                 KMSTrackLength_30_min );
       
  1744             break;
       
  1745             }
       
  1746         case EMSTrackLenMore_4:
       
  1747             {
       
  1748             AddAdditionalRuleL( ECmDuration, ECmGreater,
       
  1749                                 KMSTrackLength_30_min );
       
  1750             break;
       
  1751             }
       
  1752         default:
       
  1753             {
       
  1754             LOG(_L("[MediaServant]\t CMSFillRuleEditList::SaveTrackDurationL\
       
  1755             enum not found"));
       
  1756             break;
       
  1757             }
       
  1758         }
       
  1759     }
       
  1760 
       
  1761 // --------------------------------------------------------------------------
       
  1762 // CMSFillRuleEditList::SetAudioFileDurationSelection
       
  1763 // set selection for audio file duration
       
  1764 // --------------------------------------------------------------------------
       
  1765 //
       
  1766 void CMSFillRuleEditList::SetAudioFileDurationSelection()
       
  1767     {
       
  1768     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1769     SetAudioFileDurationSelection"));
       
  1770 
       
  1771     if ( iMinTrackLength == KMSTrackLength_0_min &&
       
  1772          iMaxTrackLength == KMSTrackLength_1_min )
       
  1773         {
       
  1774         iTrackLengthEnum = EMSTrackLenLess_1;
       
  1775         }
       
  1776     else if ( iMinTrackLength == KMSTrackLength_1_min &&
       
  1777               iMaxTrackLength == KMSTrackLength_6_min )
       
  1778         {
       
  1779         iTrackLengthEnum = EMSTrackLen_16;
       
  1780         }
       
  1781     else if ( iMinTrackLength == KMSTrackLength_6_min &&
       
  1782               iMaxTrackLength == KMSTrackLength_8_min )
       
  1783         {
       
  1784         iTrackLengthEnum = EMSTrackLen_68;
       
  1785         }
       
  1786     else if ( iMinTrackLength == KMSTrackLength_8_min &&
       
  1787               iMaxTrackLength == KMSTrackLength_30_min )
       
  1788         {
       
  1789         iTrackLengthEnum = EMSTrackLen_830;
       
  1790         }
       
  1791     else if ( iMinTrackLength == KMSTrackLength_30_min &&
       
  1792               iMaxTrackLength == KMSTrackLength_0_min )
       
  1793         {
       
  1794         iTrackLengthEnum = EMSTrackLenMore_4;
       
  1795         }
       
  1796     else
       
  1797         {
       
  1798         iTrackLengthEnum = EMSTrackLenAny;
       
  1799         }
       
  1800     }
       
  1801 
       
  1802 // --------------------------------------------------------------------------
       
  1803 // CMSFillRuleEditList::DisplayModifiedAdditionalRules
       
  1804 // Displays additional rule if user has set value on it.
       
  1805 // --------------------------------------------------------------------------
       
  1806 //
       
  1807 void CMSFillRuleEditList::DisplayModifiedAdditionalRules()
       
  1808     {
       
  1809     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1810     DisplayModifiedAdditionalRules"));
       
  1811 
       
  1812     CAknSettingItemArray* itemArray = SettingItemArray();
       
  1813 
       
  1814     // loop trough rules
       
  1815     for ( TInt index = 0; index < itemArray->Count(); index++ )
       
  1816         {
       
  1817         CAknSettingItem* item= itemArray->At( index );
       
  1818         if ( item->IsHidden() )
       
  1819             {
       
  1820             switch ( item->Identifier() )
       
  1821                 {
       
  1822                 case EMSFreeText:
       
  1823                     {
       
  1824                     item->SetSettingPageFlags(
       
  1825                                 CAknTextSettingPage::EZeroLengthAllowed );
       
  1826                     if ( iFreeText.Size() )
       
  1827                         {
       
  1828                         item->SetHidden( EFalse );
       
  1829                         }
       
  1830                     break;
       
  1831                     }
       
  1832                 case EMSServers:
       
  1833                     {
       
  1834                     if ( iRule->MediaServerCount() )
       
  1835                         {
       
  1836                         item->SetHidden( EFalse );
       
  1837                         }
       
  1838                     break;
       
  1839                     }
       
  1840                 case EMSDateFrom:
       
  1841                     {
       
  1842                     if ( iDateFrom != TTime( KDefaultFromDate ) )
       
  1843                         {
       
  1844                         item->SetHidden( EFalse );
       
  1845                         }
       
  1846                     break;
       
  1847                     }
       
  1848                 case EMSDateUntil:
       
  1849                     {
       
  1850                     TTime currentDate;
       
  1851                     currentDate.HomeTime();
       
  1852 					
       
  1853 					if ( iDateUntil.DateTime().Day() != currentDate.DateTime().Day() || 
       
  1854 					     iDateUntil.DateTime().Month() != currentDate.DateTime().Month() || 
       
  1855 					     iDateUntil.DateTime().Year() != currentDate.DateTime().Year() )
       
  1856                         {
       
  1857                         item->SetHidden( EFalse );
       
  1858                         }
       
  1859                     break;
       
  1860                     }
       
  1861                 case EMSTrackLength:
       
  1862                     {
       
  1863                     if ( iTrackLengthEnum )
       
  1864                         {
       
  1865                         item->SetHidden( EFalse );
       
  1866                         }
       
  1867                     break;
       
  1868                     }
       
  1869                 case EMSFileSize:
       
  1870                     {
       
  1871                     if ( iFileSizeEnum )
       
  1872                         {
       
  1873                         item->SetHidden( EFalse );
       
  1874                         }
       
  1875                     break;
       
  1876                     }
       
  1877                 default:
       
  1878                     {
       
  1879                     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1880                     SetAudioFileSizeSelection item not found"));
       
  1881                     break;
       
  1882                     }
       
  1883                 }
       
  1884             }
       
  1885         }
       
  1886     }
       
  1887 
       
  1888 // --------------------------------------------------------------------------
       
  1889 // CMSFillRuleEditList::SearchItemById
       
  1890 // Searches item from the itemarray by given ID
       
  1891 // --------------------------------------------------------------------------
       
  1892 //
       
  1893 CAknSettingItem* CMSFillRuleEditList::SearchItemById( TMSFillEditItems aId )
       
  1894     {
       
  1895     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SearchItemById"));
       
  1896 
       
  1897     CAknSettingItem* item = NULL;
       
  1898     CAknSettingItemArray* itemArray = SettingItemArray();
       
  1899 
       
  1900     for ( TInt index = 0; index < itemArray->Count(); index++ )
       
  1901         {
       
  1902         if ( itemArray->At( index )->Identifier() == aId )
       
  1903             {
       
  1904             item = itemArray->At( index );
       
  1905             index = itemArray->Count(); // break out from the loop
       
  1906             }
       
  1907         }
       
  1908     return item;
       
  1909     }
       
  1910 
       
  1911 // --------------------------------------------------------------------------
       
  1912 // CMSFillRuleEditList::SetShrinkingStatus
       
  1913 // Sets shrinking status to fill list
       
  1914 // --------------------------------------------------------------------------
       
  1915 //
       
  1916 void CMSFillRuleEditList::SetShrinkingStatus()
       
  1917     {
       
  1918     LOG(_L("[MediaServant]\t CMSFillRuleEditList::SetShrinkingStatus"));
       
  1919 
       
  1920     switch ( iShrinkImages )
       
  1921         {
       
  1922         case EMSShrinkScreenSize:
       
  1923             {
       
  1924             iRule->SetStatus( ECmToBeShrinked );
       
  1925             break;
       
  1926             }
       
  1927         case EMSShrinkingOff:
       
  1928             {
       
  1929             iRule->SetStatus( ECmToBeFilled );
       
  1930             break;
       
  1931             }
       
  1932         default:
       
  1933             {
       
  1934             LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  1935             SetShrinkingStatus shrink status not found"));
       
  1936             break;
       
  1937             }
       
  1938         }
       
  1939     }
       
  1940 
       
  1941 // --------------------------------------------------------------------------
       
  1942 // CMSFillRuleEditList::ReadyL()
       
  1943 // engine observer callback
       
  1944 // --------------------------------------------------------------------------
       
  1945 //
       
  1946 void CMSFillRuleEditList::ReadyL( TCmService aService, TInt /*aError*/ )
       
  1947     {
       
  1948     LOG(_L("[MediaServant]\t CMSFillRuleEditList::ReadyL"));
       
  1949 
       
  1950     switch ( aService )
       
  1951         {
       
  1952         case ECmServicePreProcessingFilllist:
       
  1953             {
       
  1954             // we'll lost iRule after update...
       
  1955             iAppUi->FillRuleController()->UpdateArrayL();
       
  1956             // ...so get it again
       
  1957             iRule = (*iAppUi->FillRuleController()->
       
  1958                             FillListArray())[iSelectedList]->List();
       
  1959             // show file info
       
  1960             CreateAndSetNaviPaneTextL();
       
  1961 
       
  1962             if ( iState == EMSFetchMetadata )
       
  1963                 {
       
  1964                 if( iRule->MediaType() == ECmVideo )
       
  1965 	                {
       
  1966 	                // reset track array
       
  1967 	                iTrackArray.Reset();
       
  1968 	                // append the select video title in track array
       
  1969 	                TInt count = iVideoTitleArray.Count();
       
  1970 	                if( count > 0 )
       
  1971 		                {
       
  1972 		                for( TInt i=0; i<count; i++ )
       
  1973 			                {
       
  1974 			                iTrackArray.AppendL( iVideoTitleArray[i] );	
       
  1975 			                }
       
  1976 		                }
       
  1977 	                	
       
  1978 	                }
       
  1979                 iMetadataCollector->GetFilteredMetadataL();
       
  1980 
       
  1981                 // Show 'reading data' text on navi pane
       
  1982                 HBufC* naviText = StringLoader::LoadLC(
       
  1983                                             R_MS_WAIT_GETTING_DATA_TEXT );
       
  1984                 iView->SetNavigationPaneTextL( *naviText );
       
  1985                 CleanupStack::PopAndDestroy( naviText );
       
  1986 
       
  1987                 }
       
  1988             iState = EMSIdle;
       
  1989             break;
       
  1990             }
       
  1991         case ECmServiceFill:
       
  1992             {
       
  1993             UpdateSettingItemsL();
       
  1994             if ( iNewList )
       
  1995                 {
       
  1996                 SaveListValuesL();
       
  1997                 iAppUi->FillRuleController()->SaveRulesL();
       
  1998                 PreprocessListL();
       
  1999                 }
       
  2000             else
       
  2001                 {
       
  2002                 // show item counts
       
  2003                 CreateAndSetNaviPaneTextL();
       
  2004                 }
       
  2005 
       
  2006             break;
       
  2007             }
       
  2008         default:
       
  2009             {
       
  2010             LOG(_L("[MediaServant]\t CMSFillRuleEditList::ReadyL \
       
  2011             service not found"));
       
  2012             break;
       
  2013             }
       
  2014         }
       
  2015     }
       
  2016 
       
  2017 // --------------------------------------------------------------------------
       
  2018 // CMSFillRuleEditList::UpdateSettingItemsL()
       
  2019 // updates items in multiselection settings
       
  2020 // --------------------------------------------------------------------------
       
  2021 //
       
  2022 void CMSFillRuleEditList::UpdateSettingItemsL()
       
  2023     {
       
  2024     LOG(_L("[MediaServant]\t CMSFillRuleEditList::UpdateSettingItemsL"));
       
  2025 
       
  2026     // update setting item text
       
  2027     CAknSettingItem* item = NULL;
       
  2028     if ( iMediaType == ECmVideo )
       
  2029         {
       
  2030          item = SearchItemById( EMSTitleName );
       
  2031         }
       
  2032     else
       
  2033         {
       
  2034          item = SearchItemById( EMSTrack );
       
  2035         }
       
  2036 
       
  2037     CMSRuleMultiselectionSetting* settingItem =
       
  2038                         static_cast<CMSRuleMultiselectionSetting*> (item);
       
  2039         if ( item )
       
  2040         {
       
  2041         settingItem->CreateItemListL();
       
  2042         //DrawDeferred();
       
  2043         }
       
  2044 
       
  2045     if ( iMediaType == ECmAudio )
       
  2046         {
       
  2047         // update setting item text
       
  2048         item = SearchItemById( EMSArtist );
       
  2049          settingItem =
       
  2050                      static_cast<CMSRuleMultiselectionSetting*> (item);
       
  2051         if ( item )
       
  2052             {
       
  2053             settingItem->CreateItemListL();
       
  2054             //DrawDeferred();
       
  2055             }
       
  2056 
       
  2057         // update setting item text
       
  2058         item = SearchItemById( EMSGenre );
       
  2059         settingItem = static_cast<CMSRuleMultiselectionSetting*> (item);
       
  2060         if ( item )
       
  2061             {
       
  2062             settingItem->CreateItemListL();
       
  2063             //DrawDeferred();
       
  2064             }
       
  2065         // update setting item text
       
  2066         item = SearchItemById( EMSAlbum );
       
  2067         settingItem = static_cast<CMSRuleMultiselectionSetting*> (item);
       
  2068             if ( item )
       
  2069             {
       
  2070             settingItem->CreateItemListL();
       
  2071             }
       
  2072         }
       
  2073     DrawDeferred();
       
  2074     }
       
  2075 
       
  2076 // Sets navi pane text
       
  2077 // --------------------------------------------------------------------------
       
  2078 // CMSFillRuleEditList::CreateAndSetNaviPaneTextL()
       
  2079 // Sets navi pane text
       
  2080 // --------------------------------------------------------------------------
       
  2081 //
       
  2082 void CMSFillRuleEditList::CreateAndSetNaviPaneTextL()
       
  2083     {
       
  2084     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  2085     CreateAndSetNaviPaneTextL"));
       
  2086 
       
  2087     RPointerArray<CMSFillList>* fillListArray =
       
  2088                         iAppUi->FillRuleController()->FillListArray();
       
  2089 
       
  2090     // Set navi pane text
       
  2091     // magic: only two numbers
       
  2092     CArrayFix<TInt>* infoArray = new ( ELeave ) CArrayFixFlat<TInt>(2);
       
  2093     CleanupStack::PushL( infoArray );
       
  2094 
       
  2095     TReal size( 0 );
       
  2096     Math::Round( size,
       
  2097                  TReal((*fillListArray)[iSelectedList]->ListSize()) / KMega,
       
  2098                  0 );
       
  2099     TUint32 count = (*fillListArray)[iSelectedList]->ItemCount();
       
  2100 
       
  2101     HBufC* naviText = NULL;
       
  2102 
       
  2103     switch ( count )
       
  2104         {
       
  2105         case 0:
       
  2106             {
       
  2107             naviText = StringLoader::LoadLC(
       
  2108                         R_MS_RULE_NAVI_0_ITEMS, size );
       
  2109             break;
       
  2110             }
       
  2111         case 1:
       
  2112             {
       
  2113             naviText = StringLoader::LoadLC(
       
  2114                         R_MS_RULE_NAVI_1_ITEM, size );
       
  2115             break;
       
  2116             }
       
  2117         default:
       
  2118             {
       
  2119             infoArray->AppendL( size );
       
  2120             infoArray->AppendL( count );
       
  2121             naviText = StringLoader::LoadLC(
       
  2122                         R_MS_RULE_NAVI_MANY_ITEMS, *infoArray );
       
  2123             break;
       
  2124             }
       
  2125         }
       
  2126 
       
  2127     // do number conversion
       
  2128     TPtr ptr = naviText->Des();
       
  2129     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );
       
  2130 
       
  2131     iView->SetNavigationPaneTextL( *naviText );
       
  2132     CleanupStack::PopAndDestroy( naviText );
       
  2133     CleanupStack::PopAndDestroy( infoArray );
       
  2134     }
       
  2135 
       
  2136 // --------------------------------------------------------------------------
       
  2137 // CMSFillRuleEditList::RemoveCurrentRule
       
  2138 // Hides current rule
       
  2139 // --------------------------------------------------------------------------
       
  2140 //
       
  2141 void CMSFillRuleEditList::RemoveCurrentRuleL()
       
  2142     {
       
  2143     LOG( _L( "[MediaServant]\t CMSFillRuleEditList::RemoveCurrentRuleL" ) );
       
  2144 
       
  2145     CAknSettingItemArray* itemArray = SettingItemArray();
       
  2146 
       
  2147     TInt currentItem = ListBox()->CurrentItemIndex();
       
  2148     TInt realIndex = itemArray->ItemIndexFromVisibleIndex(currentItem);
       
  2149 
       
  2150     CAknSettingItem* item= (*itemArray)[realIndex];
       
  2151 
       
  2152     // free text must be deleted here because user can't enter empty text
       
  2153     switch ( item->Identifier() )
       
  2154         {
       
  2155         case EMSFreeText:
       
  2156             {
       
  2157             DeleteRule( ECmFreeText );
       
  2158             iFreeText.Zero();
       
  2159             item->LoadL();
       
  2160             break;
       
  2161             }
       
  2162         case EMSServers:
       
  2163             {
       
  2164             DeleteAllServersFromRuleL();
       
  2165             break;
       
  2166             }
       
  2167         case EMSDateFrom:
       
  2168             {
       
  2169             DeleteRule( ECmDate );
       
  2170 		    iDateFrom.Set( KDefaultFromDate );
       
  2171             break;
       
  2172             }
       
  2173         case EMSDateUntil:
       
  2174             {
       
  2175             DeleteRule( ECmDate );
       
  2176     		iDateUntil.HomeTime();
       
  2177             break;
       
  2178             }
       
  2179         case EMSTrackLength:
       
  2180             {
       
  2181             DeleteRule( ECmDuration );
       
  2182             break;
       
  2183             }
       
  2184         case EMSFileSize:
       
  2185             {
       
  2186             DeleteRule( ECmFileSize );
       
  2187             break;
       
  2188             }
       
  2189         default:
       
  2190             {
       
  2191             LOG( _L( "[MediaServant]\t CMSFillRuleEditList::\
       
  2192             RemoveCurrentRuleL no such item" ) );
       
  2193             break;
       
  2194             }
       
  2195         }
       
  2196 
       
  2197     // Menu command is shown only hidden items
       
  2198     item->SetHidden( ETrue );
       
  2199     // visibility changed
       
  2200     HandleChangeInItemArrayOrVisibilityL();
       
  2201     // cancel ongoing operation
       
  2202     iView->CancelAsyncOperation( iAppUi );
       
  2203     // set idle state
       
  2204     iState = EMSIdle;
       
  2205     // update list info
       
  2206     SaveAndPreprocesslistL( item );
       
  2207     }
       
  2208 
       
  2209 // --------------------------------------------------------------------------
       
  2210 // CMSFillRuleEditList::IsCurrentRuleAdditional
       
  2211 // Tests if current rule is additional
       
  2212 // --------------------------------------------------------------------------
       
  2213 //
       
  2214 TBool CMSFillRuleEditList::IsCurrentRuleAdditional()
       
  2215     {
       
  2216     LOG( _L( "[MediaServant]\t CMSFillRuleEditList::\
       
  2217     IsCurrentRuleAdditional" ) );
       
  2218 
       
  2219     TBool isAdditional = EFalse;
       
  2220 
       
  2221     TInt currentItem = ListBox()->CurrentItemIndex();
       
  2222 
       
  2223     CAknSettingItemArray* itemArray = SettingItemArray();
       
  2224     TInt realIndex = itemArray->ItemIndexFromVisibleIndex(currentItem);
       
  2225     CAknSettingItem* item= (*itemArray)[realIndex];
       
  2226 
       
  2227     TInt id = item->Identifier();
       
  2228 
       
  2229     if ( id == EMSServers ||
       
  2230          id == EMSFreeText ||
       
  2231          id == EMSTrackLength ||
       
  2232          id == EMSFileSize )
       
  2233         {
       
  2234         isAdditional = ETrue;
       
  2235         }
       
  2236     // From and Until are additional rules in Video list    
       
  2237     else if ( iMediaType == ECmVideo && 
       
  2238               ( id == EMSDateFrom || id == EMSDateUntil ) )
       
  2239     	{
       
  2240     	isAdditional = ETrue;
       
  2241     	}
       
  2242     
       
  2243     return isAdditional;
       
  2244     }
       
  2245 
       
  2246 // --------------------------------------------------------------------------
       
  2247 // CMSFillRuleEditList::ListMediaType
       
  2248 // Returns media type of the list
       
  2249 // --------------------------------------------------------------------------
       
  2250 //
       
  2251 TCmMediaType CMSFillRuleEditList::ListMediaType()
       
  2252     {
       
  2253     return iMediaType;
       
  2254     }
       
  2255 
       
  2256 // --------------------------------------------------------------------------
       
  2257 // CMSFillRuleEditList::SizeChanged()
       
  2258 // Called by framework when the view size is changed.
       
  2259 // --------------------------------------------------------------------------
       
  2260 //
       
  2261 void CMSFillRuleEditList::SizeChanged()
       
  2262     {
       
  2263     ListBox()->SetRect( Rect() ); // Set rectangle of listbox.
       
  2264     }
       
  2265 
       
  2266 // --------------------------------------------------------------------------
       
  2267 // CMSFillRuleEditList::HandleResourceChange
       
  2268 // Handles layout change
       
  2269 // --------------------------------------------------------------------------
       
  2270 //
       
  2271 void CMSFillRuleEditList::HandleResourceChange( TInt aType )
       
  2272     {
       
  2273     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  2274         {
       
  2275         SetRect( iView->ClientRect() );
       
  2276         }
       
  2277 
       
  2278     CCoeControl::HandleResourceChange( aType );
       
  2279     }
       
  2280 
       
  2281 // --------------------------------------------------------------------------
       
  2282 // CMSRuleServersSetting::CreateServerSettingListL
       
  2283 // Creates selection item list
       
  2284 // --------------------------------------------------------------------------
       
  2285 //
       
  2286 void CMSFillRuleEditList::CreateServerSettingListL()
       
  2287     {
       
  2288     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  2289     CreateServerSettingListL"));
       
  2290 
       
  2291     if ( iServerArray )
       
  2292         {
       
  2293         iServerArray->ResetAndDestroy();
       
  2294         delete iServerArray;
       
  2295         iServerArray = NULL;
       
  2296         }
       
  2297 
       
  2298     iServerArray =
       
  2299             new ( ELeave ) CSelectionItemList( 8 );
       
  2300 
       
  2301     TBuf8<KMaxFileName> itemText;
       
  2302     TInt selectedItemCount( 0 );
       
  2303 
       
  2304     TInt serverCount(0);
       
  2305     if ( iServers )
       
  2306         {
       
  2307         serverCount = iServers->Count();
       
  2308         }
       
  2309 
       
  2310     // Cycle trough all servers
       
  2311     for ( TInt idx = 0; idx < serverCount; idx++ )
       
  2312         {
       
  2313         // get server
       
  2314         CCmMediaServerFull* server = (*iServers)[idx];
       
  2315 
       
  2316         // Add all servers to the list
       
  2317         HBufC* devName =
       
  2318             CnvUtfConverter::ConvertToUnicodeFromUtf8L(
       
  2319                                     server->MediaServerName() );
       
  2320         CleanupStack::PushL( devName );
       
  2321         CSelectableItem* item = new ( ELeave ) CSelectableItem(
       
  2322                                                     *devName, EFalse);
       
  2323 
       
  2324         CleanupStack::PushL( item );
       
  2325         // item must be constructed
       
  2326         item->ConstructL();
       
  2327 
       
  2328         // count of servers set to rule
       
  2329         TInt ruleServerCount = iRule->MediaServerCount();
       
  2330 
       
  2331         // Cycle trough all servers
       
  2332         for (TInt index = 0; index < ruleServerCount; index++ )
       
  2333             {
       
  2334             TInt serverId( 0 );
       
  2335             iRule->MediaServerL( index, serverId );
       
  2336 
       
  2337             if ( serverId == server->DbId() ) // compare IDs
       
  2338                 {
       
  2339                 // found - break this loop
       
  2340                 index = ruleServerCount;
       
  2341                 // found - mark selected
       
  2342                 item->SetSelectionStatus( ETrue );
       
  2343                 selectedItemCount++;
       
  2344                 }
       
  2345             }
       
  2346         // append item to list
       
  2347         iServerArray->AppendL(item);
       
  2348         CleanupStack::Pop( item );
       
  2349         CleanupStack::PopAndDestroy( devName );
       
  2350         }
       
  2351 
       
  2352     // Create and append default item and put it first
       
  2353     HBufC* itemName = StringLoader::LoadLC( R_MS_VALUE_ANY_SOURCE_DEVICE );
       
  2354     CSelectableItem* item = NULL;
       
  2355     if ( selectedItemCount )
       
  2356         {
       
  2357         item = new ( ELeave ) CSelectableItem( *itemName, EFalse );
       
  2358         }
       
  2359     else
       
  2360         {
       
  2361         item = new ( ELeave ) CSelectableItem( *itemName, ETrue );
       
  2362         }
       
  2363 
       
  2364     CleanupStack::PushL( item );
       
  2365     item->ConstructL();
       
  2366     iServerArray->InsertL(0, item);
       
  2367     CleanupStack::Pop( item );
       
  2368     CleanupStack::PopAndDestroy( itemName );
       
  2369 
       
  2370     }
       
  2371 
       
  2372 // --------------------------------------------------------------------------
       
  2373 // CMSFillRuleEditList::HandleServerSelectionL
       
  2374 // Adds selected servers from the list to the rule
       
  2375 // --------------------------------------------------------------------------
       
  2376 //
       
  2377 void CMSFillRuleEditList::HandleServerSelectionL()
       
  2378     {
       
  2379     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  2380     HandleServerSelectionL"));
       
  2381 
       
  2382     DeleteAllServersFromRuleL();
       
  2383 
       
  2384     // Check if first item ("Any") selected
       
  2385     if ( (*iServerArray)[0]->SelectionStatus() == EFalse )
       
  2386        {
       
  2387        for ( TInt index = 1; index < iServerArray->Count(); index++ )
       
  2388             {
       
  2389             CSelectableItem* item = (*iServerArray)[index];
       
  2390             TBool selected = item->SelectionStatus();
       
  2391 
       
  2392             CCmMediaServerFull* server = (*iServers)[index-1];
       
  2393 
       
  2394             // add server
       
  2395             if ( item->SelectionStatus() )
       
  2396                 {
       
  2397                 iRule->AddMediaServerL( server->DbId() );
       
  2398                 }
       
  2399             }
       
  2400         }
       
  2401     }
       
  2402 
       
  2403 // --------------------------------------------------------------------------
       
  2404 // CMSFillRuleEditList::DeleteAllServersFromRuleL
       
  2405 // Deletes all servers from rule
       
  2406 // --------------------------------------------------------------------------
       
  2407 //
       
  2408 void CMSFillRuleEditList::DeleteAllServersFromRuleL()
       
  2409     {
       
  2410     LOG(_L("[MediaServant]\t CMSFillRuleEditList::\
       
  2411     DeleteAllServersFromRuleL"));
       
  2412 
       
  2413     // count of servers set to rule
       
  2414     TInt ruleServerCount = iRule->MediaServerCount();
       
  2415 
       
  2416     for ( TInt index = ruleServerCount-1; index >= 0; index-- )
       
  2417         {
       
  2418         TInt serverId( 0 );
       
  2419         iRule->MediaServerL( index , serverId );
       
  2420         iRule->DeleteMediaServer( serverId );
       
  2421         }
       
  2422     }
       
  2423 
       
  2424 // --------------------------------------------------------------------------
       
  2425 // CMSFillRuleEditList::GetServersAndCheckActivityL
       
  2426 // Gets mediaservers and removes not active servers
       
  2427 // --------------------------------------------------------------------------
       
  2428 //
       
  2429 void CMSFillRuleEditList::GetServersAndCheckActivityL()
       
  2430     {
       
  2431     iServers = iAppUi->MSEngine()->GetMediaServersL();
       
  2432 
       
  2433     for ( TInt i = 0; i < iServers->Count() ; i++ )
       
  2434         {
       
  2435         CCmMediaServerFull* server = (*iServers)[i];
       
  2436         // remove server if it is not tagged as fill server
       
  2437         if ( !server->FillUsage() )
       
  2438             {
       
  2439             delete server;
       
  2440             iServers->Remove(i);
       
  2441             i--;
       
  2442             }
       
  2443         }
       
  2444     iServers->Compress();
       
  2445     }
       
  2446 
       
  2447 // ---------------------------------------------------------------------------
       
  2448 // CMSFillRuleEditList::GetHelpContext
       
  2449 // ---------------------------------------------------------------------------
       
  2450 //
       
  2451 void CMSFillRuleEditList::GetHelpContext( TCoeHelpContext& aContext ) const
       
  2452     {
       
  2453     LOG(_L("[MediaServant]\t CMSFillRuleEditList::GetHelpContext"));
       
  2454 
       
  2455     aContext.iMajor = TUid::Uid(KMediaServantUID3);
       
  2456     aContext.iContext = KMSERV_HLP_EDIT_RULES;
       
  2457     }
       
  2458 
       
  2459 // End of File
       
  2460