idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsapplist.cpp
branchRCL_3
changeset 118 8baec10861af
parent 114 a5a39a295112
child 122 6cadd6867c17
equal deleted inserted replaced
114:a5a39a295112 118:8baec10861af
    28 _LIT( KMenuAttrParameter, "param" );
    28 _LIT( KMenuAttrParameter, "param" );
    29 _LIT( KMenuAttrLocked, "locked" );
    29 _LIT( KMenuAttrLocked, "locked" );
    30 _LIT8( KItemLocked, "locked");
    30 _LIT8( KItemLocked, "locked");
    31 _LIT8( KProperValueFolder, "folder" );
    31 _LIT8( KProperValueFolder, "folder" );
    32 _LIT( KMenuAttrUndefUid, "0x99999991" );
    32 _LIT( KMenuAttrUndefUid, "0x99999991" );
       
    33 _LIT( KMenuAttrInvokeSettingsUid, "0x99999990" );
    33 _LIT( KMenuItemLongName, "long_name" );
    34 _LIT( KMenuItemLongName, "long_name" );
    34 
    35 
    35 #define KMCSCmailMtmUidValue 0x2001F406
    36 #define KMCSCmailMtmUidValue 0x2001F406
    36 
    37 
    37 // ======== MEMBER FUNCTIONS ========
    38 // ======== MEMBER FUNCTIONS ========
    52     {
    53     {
    53     iMsvSession = CMsvSession::OpenAsObserverL(*this);
    54     iMsvSession = CMsvSession::OpenAsObserverL(*this);
    54 
    55 
    55     iMenu.OpenL( KMyMenuData );
    56     iMenu.OpenL( KMyMenuData );
    56     
    57     
    57     // Get "Undefined" icon and text
    58     iUndefinedText = MenuItemTextL( KMenuAttrUndefUid );
    58     CMenuFilter* filter = CMenuFilter::NewL();
    59     iEmptyText = MenuItemTextL( KMenuAttrInvokeSettingsUid );
    59     CleanupStack::PushL( filter );
    60     }
    60 
    61 
    61     // 'Undefined' item
       
    62     filter->HaveAttributeL( KMenuAttrUid, KMenuAttrUndefUid );
       
    63 
       
    64     TMenuItem item;
       
    65     const TInt root = iMenu.RootFolderL();
       
    66     RArray<TMenuItem> items;
       
    67     CleanupClosePushL( items );
       
    68     iMenu.GetItemsL( items, root, filter, ETrue );
       
    69 
       
    70     if ( items.Count() > 0 )
       
    71         {
       
    72         iUndefinedItem = CMenuItem::OpenL( iMenu, items[ 0 ] );
       
    73         iUndefinedText = NULL;
       
    74 
       
    75         if ( iUndefinedItem )
       
    76             {
       
    77             TBool exists( KErrNotFound );//CleanupStack::PushL( undefinedItem );
       
    78             TPtrC undefined = iUndefinedItem->GetAttributeL( KMenuItemLongName, exists );
       
    79 
       
    80             if ( exists )
       
    81                 {
       
    82                 iUndefinedText = HBufC::NewMaxL( undefined.Length() );
       
    83                 iUndefinedText->Des().Copy( undefined );
       
    84                 }
       
    85             else
       
    86                 {
       
    87                 iUndefinedText = KNullDesC().Alloc();
       
    88                 }
       
    89             }
       
    90         }
       
    91 
       
    92     CleanupStack::PopAndDestroy( &items );
       
    93     CleanupStack::PopAndDestroy( filter );
       
    94     }
       
    95 
    62 
    96 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    97 // Two-phased constructor
    64 // Two-phased constructor
    98 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    99 //
    66 //
   116 
    83 
   117     iListItems.ResetAndDestroy();
    84     iListItems.ResetAndDestroy();
   118     iMenu.Close();
    85     iMenu.Close();
   119     
    86     
   120     delete iUndefinedText;
    87     delete iUndefinedText;
   121     delete iUndefinedItem;
    88     delete iEmptyText;
   122     }
    89     }
   123 
    90 
   124 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
   125 // From MDesCArray
    92 // From MDesCArray
   126 // Returns the number of descriptor elements in a descriptor array.
    93 // Returns the number of descriptor elements in a descriptor array.
   186 //
   153 //
   187 TSettingItem CMCSPluginSettingsAppList::FindItemL( 
   154 TSettingItem CMCSPluginSettingsAppList::FindItemL( 
   188         RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   155         RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties )
   189     {
   156     {
   190     TBool attrExists( EFalse );
   157     TBool attrExists( EFalse );
   191     TSettingItem settingItem = { KErrNotFound, EApplication, EFalse };
   158     TSettingItem settingItem = { KErrNotFound, EApplication, EFalse, EFalse };
   192     TBool isFolder = EFalse;
   159     TBool isFolder = EFalse;
   193 
   160 
   194     // check if the item is folder
   161     // check if the item is folder
   195     for ( TInt j = 0; j < aProperties.Count(); j++ )
   162     for ( TInt j = 0; j < aProperties.Count(); j++ )
   196         {
   163         {
   412     // append the item into iListItems lists
   379     // append the item into iListItems lists
   413     User::LeaveIfError( iListItems.InsertInOrderAllowRepeats( newItem, sortMethod ) );
   380     User::LeaveIfError( iListItems.InsertInOrderAllowRepeats( newItem, sortMethod ) );
   414     CleanupStack::Pop( newItem );
   381     CleanupStack::Pop( newItem );
   415     }
   382     }
   416 
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // Gets specified menu item text
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 HBufC* CMCSPluginSettingsAppList::MenuItemTextL( const TDesC& aUid )
       
   389     {
       
   390     HBufC* text = NULL;
       
   391 
       
   392     // Get specified icon and text
       
   393     CMenuFilter* filter = CMenuFilter::NewL();
       
   394     CleanupStack::PushL( filter );
       
   395     
       
   396     // Filter specified item
       
   397     filter->HaveAttributeL( KMenuAttrUid, aUid );
       
   398     
       
   399     const TInt root = iMenu.RootFolderL();
       
   400     RArray<TMenuItem> items;
       
   401     CleanupClosePushL( items );
       
   402     iMenu.GetItemsL( items, root, filter, ETrue );
       
   403     
       
   404     CMenuItem* item = NULL;
       
   405     
       
   406     if ( items.Count() > 0 )
       
   407         {
       
   408         item = CMenuItem::OpenL( iMenu, items[ 0 ] );
       
   409         
       
   410         if ( item )
       
   411             {
       
   412             TBool exists( KErrNotFound );
       
   413             TPtrC itemName = item->GetAttributeL( KMenuItemLongName, exists );
       
   414     
       
   415             if ( exists )
       
   416                 {
       
   417                 text = HBufC::NewMaxL( itemName.Length() );
       
   418                 text->Des().Copy( itemName );
       
   419                 }
       
   420             delete item;
       
   421             }
       
   422         }
       
   423 
       
   424     if( !text )
       
   425         {
       
   426         text = KNullDesC().Alloc();
       
   427         }    
       
   428 
       
   429     CleanupStack::PopAndDestroy( &items );
       
   430     CleanupStack::PopAndDestroy( filter );
       
   431     
       
   432     return text;
       
   433     }
       
   434 
       
   435 
   417 // End of File.
   436 // End of File.