idlefw/plugins/shortcutplugin/inc/caiscutsettingsapplist.h
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Application list for settings listbox.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAISCUTSETTINGSAPPLIST_H
       
    20 #define CAISCUTSETTINGSAPPLIST_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <bamdesca.h>   // For MDesCArray
       
    24 #include <apgcli.h>     // For RApaLsSession
       
    25 #include <msvapi.h>     // For MMsvSessionObserver
       
    26 #include <apgnotif.h>   // For MApaAppListServObserver
       
    27 #include "aiscutsettings.hrh" // For TAiScutSettingType
       
    28 
       
    29 class CAiScutSettingsItem;
       
    30 class CCoeEnv;
       
    31 
       
    32 /**
       
    33  * Shortcut definition parameter for theme change shortcut.
       
    34  */
       
    35 _LIT( KScutParamChangeTheme,     "view=0x102750A7" );
       
    36 
       
    37 /**
       
    38  * Shortcut definition parameter for messaging. New message
       
    39  */
       
    40 _LIT( KScutParamNewMsg,          "new=msg" );
       
    41 
       
    42 /**
       
    43  * Shortcut definition parameter for messaging. New email
       
    44  */
       
    45 _LIT( KScutParamNewEmail,        "new=email" );
       
    46 
       
    47 /**
       
    48  * Shortcut definition parameter for messaging. New syncml mail
       
    49  */
       
    50 _LIT( KScutParamNewSyncMLMail,   "new=syncmlmail" );
       
    51 
       
    52 /**
       
    53  * Shortcut definition parameter for messaging. New postcard
       
    54  */
       
    55 _LIT( KScutParamNewPostcard,     "new=postcard" );
       
    56 
       
    57 /**
       
    58  * Shortcut definition parameter for messaging. New audio message
       
    59  */
       
    60 _LIT( KScutParamNewAudioMsg,     "new=audiomsg" );
       
    61 
       
    62 /**
       
    63  * Shortcut definition parameter for messaging. Select message type
       
    64  */
       
    65 _LIT( KScutParamSelectMsgType,   "new" );
       
    66 
       
    67 /**
       
    68  * Shortcut definition parameter for messaging. Remote mailbox
       
    69  */
       
    70 _LIT( KScutParamMailbox,         "mailbox=" );
       
    71 
       
    72 /**
       
    73  * Shortcut definition parameter for general settings. Connectivity view
       
    74  */
       
    75 _LIT( KScutParamConnectivityView,     "view=0x10207250" );
       
    76 
       
    77 /**
       
    78  * Shortcut definition parameter for general settings. Installations view
       
    79  */
       
    80 _LIT( KScutParamInstallationsView,     "view=0x10283321" );
       
    81 
       
    82 
       
    83 /**
       
    84  * Observer interface for application list events
       
    85  *
       
    86  * @since S60 v3.2
       
    87  */
       
    88 class MAiScutListObserver
       
    89 {
       
    90 public:
       
    91 
       
    92     /**
       
    93      * AppList event codes
       
    94      */
       
    95     enum TScutListEvent
       
    96     {
       
    97         EAppListReady,
       
    98         EAppListUpdated,
       
    99         EBkmListUpdated
       
   100     };
       
   101 
       
   102     /**
       
   103      * Callback for application list events
       
   104      *
       
   105      * @since S60 v3.2
       
   106      * @param aEvent AppList event code
       
   107      * @param aAdded ETrue if applications were added, EFalse if removed
       
   108      */
       
   109     virtual void HandleScutListEventL( TScutListEvent aEvent, TBool aAdded ) = 0;
       
   110 
       
   111     virtual TBool IsHidden(const TUid& aAppUid) const = 0;
       
   112 
       
   113 };
       
   114 
       
   115 
       
   116 /**
       
   117  * Application list for settings listbox
       
   118  *
       
   119  * @since S60 v3.2
       
   120  */
       
   121 class CAiScutSettingsAppList : public CActive
       
   122                              , public MDesCArray
       
   123                              , public MMsvSessionObserver
       
   124                              , public MApaAppListServObserver
       
   125 {
       
   126 
       
   127 public:
       
   128 
       
   129     static CAiScutSettingsAppList* NewL( CCoeEnv* aEnv, MAiScutListObserver& aObserver );
       
   130 
       
   131     virtual ~CAiScutSettingsAppList();
       
   132 
       
   133     // from base class MDesCArray
       
   134 
       
   135     /**
       
   136      * From MDesCArray
       
   137      * Returns the number of descriptor elements in a descriptor array.
       
   138      *
       
   139      * @since S60 v3.2
       
   140      * @return The number of descriptor elements in a descriptor array.
       
   141      */
       
   142     TInt MdcaCount() const;
       
   143 
       
   144     /**
       
   145      * From MDesCArray
       
   146      * Indexes into a descriptor array.
       
   147      *
       
   148      * @since S60 v3.2
       
   149      * @param aIndex The position of the descriptor element within a descriptor array.
       
   150      * @return A 16 bit non-modifiable pointer descriptor representing the descriptor
       
   151      *         element located at position aIndex within a descriptor array.
       
   152      */
       
   153     TPtrC MdcaPoint( TInt aIndex ) const;
       
   154 
       
   155     // from base class MMsvSessionObserver
       
   156 
       
   157     /**
       
   158      * Handles an event from the message server.
       
   159      * Not used, but must be defined to be able to use the messaging server.
       
   160      *
       
   161      * @since S60 v3.2
       
   162      * @param aEvent Indicates the event type.
       
   163      * @param aArg1 Event type-specific argument value
       
   164      * @param aArg2 Event type-specific argument value
       
   165      * @param aArg3 Event type-specific argument value
       
   166      */
       
   167     void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 );
       
   168 
       
   169     // from base class MApaAppListServObserver
       
   170 
       
   171     /**
       
   172      * From MApaAppListServObserver
       
   173      * Handles a change in the application list
       
   174      *
       
   175      * @since S60 v3.2
       
   176      * @param aEvent Event id
       
   177      */
       
   178     void HandleAppListEvent( TInt aEvent );
       
   179 
       
   180     /**
       
   181      * Starts the asynchronous appliation list initialization
       
   182      *
       
   183      * @since S60 v3.2
       
   184      */
       
   185     void StartL();
       
   186 
       
   187     /**
       
   188      * Checks if the application list is ready to be shown
       
   189      *
       
   190      * @since S60 v3.2
       
   191      * @return ETrue if ready, EFalse if not
       
   192      */
       
   193     TBool IsReady() const;
       
   194 
       
   195     /**
       
   196      * Tells the application list to start or stop observing for changes
       
   197      *
       
   198      * @since S60 v3.2
       
   199      * @param aObserving ETrue if changes should be observed, EFalse if not
       
   200      */
       
   201     void SetObservingL( TBool aObserving );
       
   202 
       
   203     /**
       
   204      * Finds the index of the given settings item in the application list
       
   205      *
       
   206      * @since S60 v3.2
       
   207      * @param aItem Setting item to find
       
   208      * @return Index of the setting item in the application list
       
   209      */
       
   210     TInt FindIndex( CAiScutSettingsItem& aItem );
       
   211 
       
   212     /**
       
   213      * Returns target application data from the given index
       
   214      *
       
   215      * @since S60 v3.2
       
   216      * @param aIndex Index of the application in the list
       
   217      * @param aUid On return, the application uid
       
   218      * @param aParams On return, the application parameters
       
   219      * @param aCaption On return, the application caption
       
   220      * @param aType On return, the application type (app or url)
       
   221      * @return KErrNotFound if the application cannot be found, KErrNone otherwise
       
   222      */
       
   223     TInt GetDataByIndex( TInt aIndex, TUid& aUid, TPtrC& aParams, TPtrC& aCaption, TAiScutSettingType& aType ) const;
       
   224 
       
   225     /**
       
   226      * Adds extra list items to the application list.
       
   227      * For example "No Effect" item is added here.
       
   228      *
       
   229      * @since S60 v3.2
       
   230      */
       
   231     void AddExtraItemsL();
       
   232 
       
   233     /**
       
   234      * Removes extra list items from the application list.
       
   235      *
       
   236      * @since S60 v3.2
       
   237      */
       
   238     void RemoveExtraItemsL();
       
   239 
       
   240 protected:
       
   241 
       
   242 private:
       
   243 
       
   244     CAiScutSettingsAppList( CCoeEnv* aEnv, MAiScutListObserver& aObserver );
       
   245 
       
   246     void ConstructL();
       
   247 
       
   248     // from base class CActive
       
   249 
       
   250     /**
       
   251      * From CActive
       
   252      * Implements cancellation of an outstanding request.
       
   253      *
       
   254      * @since S60 v3.2
       
   255      */
       
   256     void DoCancel();
       
   257 
       
   258     /**
       
   259      * From CActive
       
   260      * Performs one step of the app list initialization
       
   261      *
       
   262      * @since S60 v3.2
       
   263      */
       
   264     void RunL();
       
   265 
       
   266     /**
       
   267      * From CActive
       
   268      * Handles an error situation
       
   269      *
       
   270      * @since S60 v3.2
       
   271      * @param aError Error code received from system
       
   272      * @return Error code after error handling
       
   273      */
       
   274     TInt RunError( TInt aError );
       
   275 
       
   276     /**
       
   277      * Completes own request status to make sure active scheduler
       
   278      * calls RunL again.
       
   279      *
       
   280      * @since S60 v3.2
       
   281      */
       
   282     void CompleteSelf();
       
   283 
       
   284     /**
       
   285      * Adds an application to the list
       
   286      *
       
   287      * @since S60 v3.2
       
   288      * @param aAppInfo Application information object
       
   289      */
       
   290     void AddApplicationL( TApaAppInfo& aAppInfo );
       
   291 
       
   292     /**
       
   293      * Adds the static list items to the application list.
       
   294      * For example "New Message" and "New Email" items are added here.
       
   295      *
       
   296      * @since S60 v3.2
       
   297      */
       
   298     void AddStaticItemsL();
       
   299 
       
   300     /**
       
   301      * Finds all mailboxes defined in the device
       
   302      */
       
   303     CMsvEntry* GetRootEntryL();
       
   304 
       
   305     /**
       
   306      * Adds remote mailboxes to the application list.
       
   307      *
       
   308      * @since S60 v3.2
       
   309      */
       
   310     void AddMailboxesL();
       
   311 
       
   312     /**
       
   313      * Adds a mailbox to the list
       
   314      *
       
   315      * @since S60 v3.2
       
   316      * @param aMailbox Name of the mailbox to add
       
   317      */
       
   318     void AddMailboxL( const TDesC& aMailbox, const TDesC& aMailboxId );
       
   319 
       
   320     /**
       
   321      * Removes a mailbox from the list
       
   322      *
       
   323      * @since S60 v3.2
       
   324      * @param aMailboxParam Parameter string of the mailbox to remove
       
   325      */
       
   326     void RemoveMailboxL( const TDesC& aMailboxParam );
       
   327 
       
   328     /**
       
   329      * Adds extra application to applist from central repository
       
   330      * 
       
   331      * @since S60 v3.2
       
   332      */
       
   333     void AddExtraItemsFromCRL();
       
   334 
       
   335     TBool IsBannedUid(TUid aUid);
       
   336 
       
   337     /**
       
   338      * Gets the next valid application from application architecture server.
       
   339      * Valid applications are non-hidden ones
       
   340      *
       
   341      * @since S60 v3.2
       
   342      * @param aAppInfo Application information of the next valid application
       
   343      * @return Error code from RApaLsSession or one of system wide errors
       
   344      */
       
   345     TInt GetNextValidApp( TApaAppInfo& aAppInfo );
       
   346 
       
   347     /**
       
   348      * Updates the application list
       
   349      *
       
   350      * @since S60 v3.2
       
   351      */
       
   352     void UpdateAppListL();
       
   353 
       
   354     /**
       
   355      * Figures out which application is missing from the list and adds it
       
   356      *
       
   357      * @since S60 v3.2
       
   358      * @param aCount Amount of applications to add
       
   359      */
       
   360     void AddInstalledAppToListL( TInt aCount );
       
   361 
       
   362     /**
       
   363      * Figures out which application should not be in the list and removes it
       
   364      *
       
   365      * @since S60 v3.2
       
   366      * @param aCount Amount of applications to remove
       
   367      */
       
   368     void RemoveUninstalledAppFromListL( TInt aCount );
       
   369     
       
   370     /**
       
   371      * Checks if application is midlet.
       
   372      * @param aUid Application uid
       
   373      * @since S60 v3.2
       
   374      */
       
   375     TBool IsNonNative(const TUid& aUid);
       
   376     
       
   377     /**
       
   378      * Checks if application is located in ROM.
       
   379      * @param aUid Application uid
       
   380      * @since S60 v5.0 
       
   381      */
       
   382     TBool IsInRom( const TUid& aUid );
       
   383 
       
   384 
       
   385 private:
       
   386 
       
   387     /**
       
   388      * Nested class to store individual application list items
       
   389      *
       
   390      * @since S60 v3.2
       
   391      */
       
   392     class CAppListItem : public CBase
       
   393     {
       
   394     public:
       
   395 
       
   396         static CAppListItem* NewLC( TUid aUid, const TDesC& aCaption );
       
   397 
       
   398         ~CAppListItem();
       
   399 
       
   400         /**
       
   401          * Compare method used to add the items to the list in sorted order
       
   402          *
       
   403          * @since S60 v3.2
       
   404          * @param aFirst The first item to be compared
       
   405          * @param aSecond The second item to be compared
       
   406          * @return Negative if first comes before second, zero if equal and
       
   407          *         positive if first comes after second
       
   408          */
       
   409         static TInt CompareCaption( const CAppListItem& aFirst,
       
   410             const CAppListItem& aSecond );
       
   411 
       
   412         /**
       
   413          * Returns the item target application uid
       
   414          *
       
   415          * @since S60 v3.2
       
   416          * @return Target application uid
       
   417          */
       
   418         TUid Uid() const;
       
   419 
       
   420         /**
       
   421          * Returns the item target application caption
       
   422          *
       
   423          * @since S60 v3.2
       
   424          * @return Target application caption
       
   425          */
       
   426         TPtrC Caption() const;
       
   427 
       
   428         /**
       
   429          * Returns the possible parameters for item target
       
   430          *
       
   431          * @since S60 v3.2
       
   432          * @return Item target parameters
       
   433          */
       
   434         TPtrC Params() const;
       
   435 
       
   436         /**
       
   437          * Sets the parameters for the item target
       
   438          *
       
   439          * @since S60 v3.2
       
   440          * @param aParams Parameters for item target
       
   441          */
       
   442         void SetParamsL( const TDesC& aParams );
       
   443 
       
   444         /**
       
   445          * Sets the type for the item target
       
   446          * 
       
   447          * @since S60 v3.2
       
   448          * @param aType The item target type
       
   449          */
       
   450         void SetType( TAiScutSettingType aType );
       
   451         
       
   452         /**
       
   453          * Returns the type of this item target
       
   454          * 
       
   455          * @since S60 v3.2
       
   456          * @return Item type
       
   457          */
       
   458         TAiScutSettingType Type() const;
       
   459     private:
       
   460 
       
   461         CAppListItem( TUid aUid );
       
   462 
       
   463         void ConstructL( const TDesC& aCaption );
       
   464 
       
   465     private:  // data
       
   466 
       
   467         /**
       
   468          * Target application uid
       
   469          */
       
   470         TUid iUid;
       
   471 
       
   472         /**
       
   473          * Target application caption
       
   474          */
       
   475         HBufC* iCaption;
       
   476 
       
   477         /**
       
   478          * Target application parameters
       
   479          */
       
   480         HBufC* iParams;
       
   481         /**
       
   482          * Is this setting a application or URL. 
       
   483          * Needed for URLs added from cenrep
       
   484          */
       
   485         TAiScutSettingType iType;
       
   486 
       
   487     };
       
   488 
       
   489 private:  // data
       
   490 
       
   491     /**
       
   492      * List of application items
       
   493      * Own.
       
   494      */
       
   495     RPointerArray<CAppListItem> iListItems;
       
   496 
       
   497     /**
       
   498      * Application architecture server session
       
   499      * Own.
       
   500      */
       
   501     RApaLsSession               iApaSession;
       
   502 
       
   503     /**
       
   504      * Message server session
       
   505      * Own.
       
   506      */
       
   507     CMsvSession*                iMsvSession;
       
   508 
       
   509     /**
       
   510      * Notifier for changes in the application list
       
   511      * ( installations / uninstallations )
       
   512      * Own.
       
   513      */
       
   514     CApaAppListNotifier*        iAppNotifier;
       
   515 
       
   516     /**
       
   517      * Amount of all applications in the device
       
   518      */
       
   519     TInt                        iTotalAppCount;
       
   520 
       
   521     /**
       
   522      * List of mailbox items. Points to iListItems.
       
   523      * DO NOT DELETE THROUGH THIS!
       
   524      * Own.
       
   525      */
       
   526     RPointerArray<CAppListItem> iMailboxes;
       
   527 
       
   528     /**
       
   529      * Flag indicating if the asynchronous application list generation is ready
       
   530      */
       
   531     TBool                       iReady;
       
   532 
       
   533     /**
       
   534      * Pointer to the control environment
       
   535      * Not own.
       
   536      */
       
   537     CCoeEnv*                    iEnv;
       
   538 
       
   539     /**
       
   540      * Registered observer for application list events
       
   541      */
       
   542     MAiScutListObserver&        iObserver;
       
   543 
       
   544     /**
       
   545      * A flag indicating if the app list should observe changes
       
   546      */
       
   547     TBool                       iObserving;
       
   548 
       
   549 };
       
   550 
       
   551 #endif // CAISCUTSETTINGSAPPLIST_H
       
   552 
       
   553 // End of File.