homesync/contentmanager/mediaservant/src/msfillruleeditview.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:  CMSFillRuleEditView class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mediaservant.rsg>
       
    20 #include <hlplch.h>
       
    21 #include <StringLoader.h>
       
    22 #include <aknlistquerydialog.h>
       
    23 
       
    24 #include "msfillview.h"
       
    25 #include "msengine.h"
       
    26 #include "msfillruleeditlist.h"
       
    27 #include "msfillruleeditview.h"
       
    28 #include "msappui.h"
       
    29 #include "msconstants.h"
       
    30 #include "msdebug.h"
       
    31 
       
    32 
       
    33 // --------------------------------------------------------------------------
       
    34 // CMSFillRuleEditView::CMSFillRuleEditView()
       
    35 // --------------------------------------------------------------------------
       
    36 //
       
    37 CMSFillRuleEditView::CMSFillRuleEditView( CMSAppUi& aAppUi )
       
    38     {
       
    39     LOG(_L("[MediaServant]\t CMSFillRuleEditView::CMSFillRuleEditView"));
       
    40 
       
    41     iAppUi = &aAppUi;
       
    42     }
       
    43 
       
    44 // --------------------------------------------------------------------------
       
    45 // CMSFillRuleEditView::ConstructL()
       
    46 // --------------------------------------------------------------------------
       
    47 //
       
    48 void CMSFillRuleEditView::ConstructL()
       
    49     {
       
    50     LOG(_L("[MediaServant]\t CMSFillRuleEditView::ConstructL"));
       
    51 
       
    52     BaseConstructL( R_MS_FILL_EDIT_VIEW );
       
    53     }
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // CMSFillRuleEditView::~CMSFillRuleEditView()
       
    57 // --------------------------------------------------------------------------
       
    58 //
       
    59 CMSFillRuleEditView::~CMSFillRuleEditView()
       
    60     {
       
    61     LOG(_L("[MediaServant]\t CMSFillRuleEditView::~CMSFillRuleEditView"));
       
    62 
       
    63     DoDeactivate();
       
    64     }
       
    65 
       
    66 // --------------------------------------------------------------------------
       
    67 // TUid CMSFillRuleEditView::Id()
       
    68 // --------------------------------------------------------------------------
       
    69 //
       
    70 TUid CMSFillRuleEditView::Id() const
       
    71     {
       
    72     LOG(_L("[MediaServant]\t CMSFillRuleEditView::Id"));
       
    73 
       
    74     return KMSFillEditViewId;
       
    75     }
       
    76 
       
    77 
       
    78 // --------------------------------------------------------------------------
       
    79 // CMSFillRuleEditView::HandleCommandL(TInt aCommand)
       
    80 // --------------------------------------------------------------------------
       
    81 //
       
    82 void CMSFillRuleEditView::HandleCommandL( TInt aCommand )
       
    83     {
       
    84     LOG(_L("[MediaServant]\t CMSFillRuleEditView::HandleCommandL"));
       
    85 
       
    86     switch (aCommand)
       
    87         {
       
    88         case EAknCmdOpen:
       
    89             {
       
    90             iContainer->OpenSelectedListboxItemL();
       
    91             break;
       
    92             }
       
    93         case EAknSoftkeyDone:
       
    94             {
       
    95             iAppUi->MSEngine()->StopOperation();
       
    96             iAppUi->FillRuleController()->UpdateArrayL();
       
    97             iAppUi->ChangeViewL( KMSFillEditViewId, KMSFillViewId );
       
    98             break;
       
    99             }
       
   100         case EMSCmdRemoveRule:
       
   101             {
       
   102             iContainer->RemoveCurrentRuleL();
       
   103             break;
       
   104             }
       
   105         case EAknCmdHelp :
       
   106             {
       
   107             TRAP_IGNORE( HlpLauncher::LaunchHelpApplicationL(
       
   108                         iEikonEnv->WsSession(),
       
   109             iEikonEnv->EikAppUi()->AppHelpContextL() ));
       
   110             break;
       
   111             }
       
   112         default:
       
   113             {
       
   114             AppUi()->HandleCommandL(aCommand);
       
   115             }
       
   116         break;
       
   117 
       
   118         }
       
   119     }
       
   120 
       
   121 
       
   122 // --------------------------------------------------------------------------
       
   123 // CMSFillRuleEditView::DoActivateL()
       
   124 // --------------------------------------------------------------------------
       
   125 //
       
   126 void CMSFillRuleEditView::DoActivateL(
       
   127    const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   128    const TDesC8& /*aCustomMessage*/)
       
   129     {
       
   130     LOG(_L("[MediaServant]\t CMSFillRuleEditView::DoActivateL"));
       
   131 
       
   132     if ( !iContainer )
       
   133         {
       
   134         // create settings screen
       
   135         iContainer = CMSFillRuleEditList::NewL(*iAppUi,
       
   136                                                *this );
       
   137         iContainer->SetMopParent( this );
       
   138 
       
   139         // now control receives keyboard events
       
   140         iAppUi->AddToStackL( *this, iContainer );
       
   141         iContainer->ActivateL();
       
   142         }
       
   143 
       
   144     // Set title text
       
   145     HBufC* titleText = NULL;
       
   146 
       
   147     switch ( iContainer->ListMediaType() )
       
   148         {
       
   149         case ECmImage:
       
   150             {
       
   151             titleText = StringLoader::LoadLC(
       
   152                                         R_MS_EDIT_IMAGE_RULE_VIEW_TITLE );
       
   153             break;
       
   154             }
       
   155         case ECmVideo:
       
   156             {
       
   157             titleText = StringLoader::LoadLC(
       
   158                                         R_MS_EDIT_VIDEO_RULE_VIEW_TITLE );
       
   159             break;
       
   160             }
       
   161         case ECmAudio:
       
   162             {
       
   163             titleText = StringLoader::LoadLC(
       
   164                                         R_MS_EDIT_MUSIC_RULE_VIEW_TITLE );
       
   165             break;
       
   166             }
       
   167         default:
       
   168             {
       
   169             LOG(_L("[MediaServant]\t CMSFillRuleEditView::DoActivateL \
       
   170             list has no media type"));
       
   171             break;
       
   172             }
       
   173         }
       
   174 
       
   175     if ( titleText )
       
   176         {
       
   177         SetTitlePaneTextL( *titleText );
       
   178         CleanupStack::PopAndDestroy ( titleText );
       
   179         }
       
   180    }
       
   181 
       
   182 // --------------------------------------------------------------------------
       
   183 // CMSFillRuleEditView::DoDeactivate()
       
   184 // --------------------------------------------------------------------------
       
   185 //
       
   186 void CMSFillRuleEditView::DoDeactivate()
       
   187     {
       
   188     LOG(_L("[MediaServant]\t CMSFillRuleEditView::DoDeactivate"));
       
   189 
       
   190     ClearCurrentNaviPaneText();
       
   191 
       
   192     if ( iContainer )
       
   193         {
       
   194         AppUi()->RemoveFromStack( iContainer );
       
   195         }
       
   196 
       
   197     delete iContainer; // Deletes the container class object.
       
   198     iContainer = NULL;
       
   199     }
       
   200 
       
   201 
       
   202 // --------------------------------------------------------------------------
       
   203 // CMSFillRuleEditView:DynInitMenuPaneL
       
   204 // --------------------------------------------------------------------------
       
   205 //
       
   206 void CMSFillRuleEditView::DynInitMenuPaneL( TInt aResourceId,
       
   207                                             CEikMenuPane* aMenuPane )
       
   208     {
       
   209     LOG(_L("[MediaServant]\t CMSFillRuleEditView::DynInitMenuPaneL"));
       
   210     
       
   211     if ( aResourceId == R_MS_FILL_EDIT_MENU && iContainer )
       
   212         {
       
   213         // check if the list is empty
       
   214         if ( iContainer->IsCurrentRuleAdditional() == EFalse )
       
   215             {
       
   216             // Hide command
       
   217             aMenuPane->SetItemDimmed(EMSCmdRemoveRule, ETrue);
       
   218             }
       
   219         }
       
   220     }
       
   221 
       
   222 // --------------------------------------------------------------------------
       
   223 // CMSFillRuleEditView:ShowTemplateQueryL
       
   224 // --------------------------------------------------------------------------
       
   225 //
       
   226 TBool CMSFillRuleEditView::ShowTemplateQueryL( TInt aResourceId,
       
   227                                                TInt aQueryHeading,
       
   228                                                CDesCArray* aRuleNames,
       
   229                                                TInt &aSelected )
       
   230 	{
       
   231 	LOG(_L("[MediaServant]\t CMSFillRuleEditView::ShowTemplateQueryL"));
       
   232 	
       
   233 	TBool ret( EFalse );
       
   234 
       
   235     // construct and show template query
       
   236     CAknListQueryDialog* query =
       
   237                      new ( ELeave ) CAknListQueryDialog( &aSelected );
       
   238     query->PrepareLC( aResourceId );
       
   239 
       
   240     // read header text
       
   241     HBufC* header = StringLoader::LoadLC( aQueryHeading );
       
   242     query->SetHeaderTextL( header->Des() );
       
   243     
       
   244     // set item array
       
   245     query->SetItemTextArray( aRuleNames );
       
   246     query->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   247     CleanupStack::PopAndDestroy( header );
       
   248 
       
   249 	if ( query->RunLD() )
       
   250 		{
       
   251 		ret = ETrue;
       
   252 		}
       
   253 
       
   254     return ret;
       
   255 	}
       
   256 
       
   257 // --------------------------------------------------------------------------
       
   258 // CMSFillRuleEditView:ShowQueryL
       
   259 // --------------------------------------------------------------------------
       
   260 //
       
   261 TBool CMSFillRuleEditView::ShowQueryL( TInt aResourceId )
       
   262 	{
       
   263 	LOG(_L("[MediaServant]\t CMSFillRuleEditView::ShowQueryL"));
       
   264 	
       
   265 	TBool ret( EFalse );
       
   266 	CAknQueryDialog* query= CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
       
   267 	CleanupStack::PushL( query );
       
   268     if ( query->ExecuteLD( aResourceId ) )
       
   269         {
       
   270         ret = ETrue;
       
   271         }
       
   272     CleanupStack::Pop( query );
       
   273     return ret;
       
   274 	}
       
   275 
       
   276 // End of File