idlefw/plugins/mcsplugin/settings/src/mcspluginsettingsapplist.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 1 844b978f8d5e
child 51 15e4dd19031c
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
    41 _LIT( KMailboxUid, "0x100058c5" );
    41 _LIT( KMailboxUid, "0x100058c5" );
    42 _LIT( KInitialRefCount, "1" );
    42 _LIT( KInitialRefCount, "1" );
    43 _LIT( KMCSFolder, "mcsplugin_folder" );
    43 _LIT( KMCSFolder, "mcsplugin_folder" );
    44 _LIT8( KItemLocked, "locked");
    44 _LIT8( KItemLocked, "locked");
    45 _LIT8( KProperValueFolder, "folder" );
    45 _LIT8( KProperValueFolder, "folder" );
       
    46 _LIT( KMenuAttrUndefUid, "0x99999991" );
       
    47 _LIT( KMenuItemLongName, "long_name" );
       
    48 
       
    49 #define KMCSCmailMtmUidValue 0x2001F406
    46 
    50 
    47 // ======== MEMBER FUNCTIONS ========
    51 // ======== MEMBER FUNCTIONS ========
    48 
    52 
    49 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    50 // First-phase construction
    54 // First-phase construction
    65 
    69 
    66     iMenu.OpenL( KMyMenuData );
    70     iMenu.OpenL( KMyMenuData );
    67     iSaveWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation );
    71     iSaveWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation );
    68     iUpdateWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation );
    72     iUpdateWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation );
    69     iRemoveWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation );
    73     iRemoveWatcher = CMCSPluginWatcher::NewL( CMCSPluginWatcher::EOperation );
       
    74     
       
    75     // Get "Undefined" icon and text
       
    76     CMenuFilter* filter = CMenuFilter::NewL();
       
    77     CleanupStack::PushL( filter );
       
    78 
       
    79     // 'Undefined' item
       
    80     filter->HaveAttributeL( KMenuAttrUid, KMenuAttrUndefUid );
       
    81 
       
    82     TMenuItem item;
       
    83     const TInt root = iMenu.RootFolderL();
       
    84     RArray<TMenuItem> items;
       
    85     CleanupClosePushL( items );
       
    86     iMenu.GetItemsL( items, root, filter, ETrue );
       
    87     TMenuItem undefItem;
       
    88 
       
    89     if ( items.Count() > 0 )
       
    90         {
       
    91         undefItem = items[ 0 ];
       
    92         CMenuItem* undefinedItem = CMenuItem::OpenL( iMenu, undefItem );
       
    93         iUndefinedText = NULL;
       
    94 
       
    95         if ( undefinedItem )
       
    96             {
       
    97             TBool exists( KErrNotFound );
       
    98             CleanupStack::PushL( undefinedItem );
       
    99             TPtrC undefined = undefinedItem->GetAttributeL( KMenuItemLongName, exists );
       
   100 
       
   101             if ( exists )
       
   102                 {
       
   103                 iUndefinedText = HBufC::NewMaxL( undefined.Length() );
       
   104                 iUndefinedText->Des().Copy( undefined );
       
   105                 }
       
   106             else
       
   107                 {
       
   108                 iUndefinedText = KNullDesC().Alloc();
       
   109                 }
       
   110             CleanupStack::PopAndDestroy( undefinedItem );
       
   111             }
       
   112         }
       
   113 
       
   114     CleanupStack::PopAndDestroy( &items );
       
   115     CleanupStack::PopAndDestroy( filter );
    70     }
   116     }
    71 
   117 
    72 // ---------------------------------------------------------------------------
   118 // ---------------------------------------------------------------------------
    73 // Two-phased constructor
   119 // Two-phased constructor
    74 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
    94     iMenu.Close();
   140     iMenu.Close();
    95     delete iSaveWatcher;
   141     delete iSaveWatcher;
    96     delete iUpdateWatcher;
   142     delete iUpdateWatcher;
    97     delete iRemoveWatcher;
   143     delete iRemoveWatcher;
    98     
   144     
       
   145     if ( iUndefinedText )
       
   146         {
       
   147         delete iUndefinedText;
       
   148         iUndefinedText = NULL;
       
   149         }
    99     }
   150     }
   100 
   151 
   101 // ---------------------------------------------------------------------------
   152 // ---------------------------------------------------------------------------
   102 // From MDesCArray
   153 // From MDesCArray
   103 // Returns the number of descriptor elements in a descriptor array.
   154 // Returns the number of descriptor elements in a descriptor array.
   113 // Indexes into a descriptor array.
   164 // Indexes into a descriptor array.
   114 // ---------------------------------------------------------------------------
   165 // ---------------------------------------------------------------------------
   115 //
   166 //
   116 TPtrC CMCSPluginSettingsAppList::MdcaPoint( TInt aIndex ) const
   167 TPtrC CMCSPluginSettingsAppList::MdcaPoint( TInt aIndex ) const
   117     {
   168     {
   118     if (aIndex < 0 || aIndex >= iListItems.Count())
   169     if ( aIndex < 0 || aIndex >= iListItems.Count() )
   119         {
   170         {
   120         TPtrC ret(KNullDesC);
   171         TPtrC ret( KNullDesC );
   121         return ret;
   172         return ret;
   122         }
   173         }
   123     CMenuItem* item = iListItems[aIndex];
   174     CMenuItem* item = iListItems[ aIndex ];
       
   175 
   124     TBool attrExists;
   176     TBool attrExists;
   125     TPtrC itm; 
   177     TPtrC itm;
   126     TRAP_IGNORE( 
   178     TRAP_IGNORE( 
   127         itm.Set( item->GetAttributeL( KMenuAttrLongName, attrExists ) );
   179         itm.Set( item->GetAttributeL( KMenuAttrLongName, attrExists ) );
   128         )
   180         )
   129     return itm;
   181     return itm;
   130     }
   182     }
   364     for ( TInt i = 0; i < count; i++ )
   416     for ( TInt i = 0; i < count; i++ )
   365         {
   417         {
   366         TPtrC type = itemArray[ i ].Type();
   418         TPtrC type = itemArray[ i ].Type();
   367         
   419         
   368         // we add applications, shortcuts and folders to the list
   420         // we add applications, shortcuts and folders to the list
   369         if ( type == KMenuTypeApp || type == KMenuTypeShortcut || 
   421         if ( type == KMenuTypeApp || 
       
   422              type == KMenuTypeShortcut || 
   370              type == KMenuTypeFolder )
   423              type == KMenuTypeFolder )
   371             {
   424             {
   372             CMenuItem* menuItem = CMenuItem::OpenL( iMenu, itemArray[ i ] );
   425             CMenuItem* menuItem = CMenuItem::OpenL( iMenu, itemArray[ i ] );
   373             CleanupStack::PushL( menuItem );
   426             CleanupStack::PushL( menuItem );
   374 
   427 
   375             // only non-hidden and non-missing items should be offered to the user
   428             // only non-hidden and non-missing items should be offered to the user
   376             if ( ( menuItem->Flags() & TMenuItem::EHidden ) == EFalse &&
   429             if ( ( menuItem->Flags() & TMenuItem::EHidden ) == 0 &&
   377                  ( menuItem->Flags() & TMenuItem::EMissing ) == EFalse )
   430                  ( menuItem->Flags() & TMenuItem::EMissing ) == 0 )
   378                 {
   431                 {
   379                 User::LeaveIfError( iListItems.InsertInOrderAllowRepeats( menuItem, sortMethod ) );
   432                 User::LeaveIfError( iListItems.InsertInOrderAllowRepeats( menuItem, sortMethod ) );
   380                 CleanupStack::Pop( menuItem );
   433                 CleanupStack::Pop( menuItem );
   381                 }
   434                 }
   382             else 
   435             else 
   396 // Returns the root entry containing mailboxes.
   449 // Returns the root entry containing mailboxes.
   397 // ---------------------------------------------------------------------------
   450 // ---------------------------------------------------------------------------
   398 //
   451 //
   399 CMsvEntry* CMCSPluginSettingsAppList::GetRootEntryL()
   452 CMsvEntry* CMCSPluginSettingsAppList::GetRootEntryL()
   400     {
   453     {
   401     return iMsvSession->GetEntryL(KMsvRootIndexEntryIdValue);
   454     return iMsvSession->GetEntryL( KMsvRootIndexEntryIdValue );
   402     }
   455     }
   403 
   456 
   404 // ---------------------------------------------------------------------------
   457 // ---------------------------------------------------------------------------
   405 // Adds remote mailboxes to the application list.
   458 // Adds remote mailboxes to the application list.
   406 // ---------------------------------------------------------------------------
   459 // ---------------------------------------------------------------------------
   411     iListItems.ResetAndDestroy();
   464     iListItems.ResetAndDestroy();
   412     CMsvEntry* rootEntry = GetRootEntryL();
   465     CMsvEntry* rootEntry = GetRootEntryL();
   413     CleanupStack::PushL(rootEntry);
   466     CleanupStack::PushL(rootEntry);
   414     TBuf<255> mailboxId;
   467     TBuf<255> mailboxId;
   415     
   468     
   416     for ( TInt i = rootEntry->Count() - 1; i >= 0; --i )
   469     TInt cnt = rootEntry->Count();
   417         {
   470     if ( cnt > 0 )
   418         const TMsvEntry& tentry = (*rootEntry)[i];
   471         {
   419 
   472         rootEntry->SetSortTypeL( TMsvSelectionOrdering( 
   420         if (tentry.iMtm == KSenduiMtmImap4Uid || tentry.iMtm == KSenduiMtmPop3Uid)
   473             KMsvGroupByType | KMsvGroupByStandardFolders, 
   421             {
   474             EMsvSortByDetailsReverse, ETrue ) );
   422             mailboxId.Num( tentry.Id() );  
   475     
   423             AddMailboxL( tentry.iDetails, mailboxId );
   476         for ( TInt i = rootEntry->Count(); --i >= 0; )
       
   477             {
       
   478             const TMsvEntry& tentry = (*rootEntry)[i];
       
   479     
       
   480             if (tentry.iMtm.iUid == KMCSCmailMtmUidValue )
       
   481                 {
       
   482                 mailboxId.Num( tentry.Id() );  
       
   483                 AddMailboxL( tentry.iDetails, mailboxId );
       
   484                 }
   424             }
   485             }
   425         }
   486         }
   426     CleanupStack::PopAndDestroy(rootEntry);
   487     CleanupStack::PopAndDestroy(rootEntry);
   427     }
   488     }
   428 
   489