menucontentsrv/srvsrc/mcssatmonitor.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Used for receive SIM Application name, icon or 
       
    15 *                visibility information.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include <e32property.h>
       
    24 
       
    25 #include "mcsdef.h"
       
    26 #include "menueng.h"
       
    27 #include "menusrvengutils.h"
       
    28 #include "mcsmenunotifier.h"
       
    29 #include "mcssatmonitor.h"
       
    30 #include "mcsmenuitem.h"
       
    31 
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 // -----------------------------------------------------------------------------
       
    35 // CMcsSatHandler::NewL
       
    36 // Two-phased constructor.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C CMcsSatMonitor* CMcsSatMonitor::NewL( CMenuEng& aEng )
       
    40     {
       
    41     CMcsSatMonitor* self = new( ELeave ) CMcsSatMonitor( aEng );
       
    42     CleanupStack::PushL( self );
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop( self );
       
    45     return self;
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------    
       
    49 // Destructor
       
    50 // -----------------------------------------------------------------------------
       
    51 CMcsSatMonitor::~CMcsSatMonitor()
       
    52     {
       
    53     iEng.DequeueOperation( *this );
       
    54     delete iMcsSatNotifier2;
       
    55     delete iMcsSatNotifier1;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CMcsSatHandler::CMcsSatHandler
       
    60 // C++ default constructor can NOT contain any code, that
       
    61 // might leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CMcsSatMonitor::CMcsSatMonitor( CMenuEng& aEng ):
       
    65     iEng(aEng)
       
    66     {
       
    67     iOpStatus = EFalse;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CMcsSatHandler::ConstructL
       
    72 // Symbian 2nd phase constructor can leave.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 void CMcsSatMonitor::ConstructL()
       
    76     {
       
    77     iMcsSatNotifier1 = CMcsSatNotifier::NewL( this, KCRUidMenu, 
       
    78                                              KMenuSatUIName );                                      
       
    79     iMcsSatNotifier2 = CMcsSatNotifier::NewL( this, KCRUidMenu, 
       
    80                                              KMenuSatUIIconId  );   
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------
       
    84 // CMcsSatMonitor::RunMenuEngOperationL
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 void CMcsSatMonitor::RunMenuEngOperationL()
       
    88     {
       
    89     TInt root;
       
    90     iEng.RootFolderL( root ); 
       
    91     TInt parentId(0); 
       
    92     TInt id = GetIdL( KSatUid );
       
    93     if (id != KErrNotFound)
       
    94         {
       
    95         do
       
    96             {
       
    97             iEng.ParentFolderL( id, parentId );
       
    98             id = parentId;
       
    99             iEng.AppendNotifyL( id, 
       
   100                         RMenuNotifier::EItemAttributeChanged );
       
   101             }
       
   102         while ( id != root );
       
   103         }
       
   104     iOpStatus = EFalse;
       
   105     } 
       
   106 
       
   107 // ---------------------------------------------------------
       
   108 // CMcsSatMonitor::CompletedMenuEngOperation
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 void CMcsSatMonitor::CompletedMenuEngOperation( TInt /*aErr*/ )
       
   112     {
       
   113     // If there was error, ignore it (what else could we do?).
       
   114     // When next AppArc update occurs, we will run again.
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CMcsSatHandler::SATChangeL
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CMcsSatMonitor::SATChangeL()
       
   122     {
       
   123     
       
   124     // AppArc app scan complete, we have the app list.
       
   125     // Now queue this operation to be executed by the Engine.
       
   126     if ( !iOpStatus ) 
       
   127     	{
       
   128     	iOpStatus = ETrue;
       
   129     	iEng.QueueOperationL( *this );
       
   130     	}
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------
       
   134 // CMcsSatHandler::GetParentIdL
       
   135 // ---------------------------------------------------------
       
   136 //
       
   137 TInt CMcsSatMonitor::GetIdL( TUid aAppUid )
       
   138     {
       
   139     TInt result(KErrNotFound);
       
   140     RArray<TMenuItem> array;
       
   141     CleanupClosePushL(array);
       
   142     TInt root;
       
   143     iEng.RootFolderL( root );
       
   144     TMenuSrvTypeAttrFilter appFilter;
       
   145     appFilter.SetType( KMenuTypeApp() );
       
   146     TBuf<KUidChars> uidString;
       
   147     TInt appuid( aAppUid.iUid );
       
   148     MenuSrvUtil::UidToStringL( appuid, uidString, EFalse, EHex );
       
   149     appFilter.SetAttr( KMenuAttrUid(), uidString );
       
   150     iEng.GetItemsL( array, root, &appFilter, ETrue );
       
   151     if (array.Count())
       
   152         {
       
   153         if( array[0].Flags() != TMenuItem::EHidden )
       
   154             {
       
   155             result = array[0].Id();
       
   156             }
       
   157         }
       
   158     CleanupStack::PopAndDestroy(&array);
       
   159     return result;
       
   160     }   
       
   161 
       
   162 //  End of File