piprofilerui/ui/avkon/inc/profiler_gui_model.h
changeset 51 b048e15729d6
parent 44 5db69f4c3d06
child 52 36d60d12b4af
equal deleted inserted replaced
44:5db69f4c3d06 51:b048e15729d6
     1 /*
       
     2 * Copyright (c) 2009 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef PROFILER_GUI_MODEL_H
       
    21 #define PROFILER_GUI_MODEL_H
       
    22 
       
    23 // SYSTEM INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include <apgcli.h>
       
    27 #include <gdi.h>
       
    28 #include <utf.h>
       
    29 #include <e32property.h>    // RProperty
       
    30 
       
    31 // LOCAL INCLUDES
       
    32 #include "profiler_gui_mainview.h"
       
    33 #include "profiler_gui.hrh"
       
    34 
       
    35 // COMMON INCLUDES
       
    36 #include <piprofiler/ProfilerConfig.h>
       
    37 #include <piprofiler/ProfilerAttributes.h>
       
    38 #include <piprofiler/ProfilerEngineStatusChecker.h>
       
    39 
       
    40 // setting keys (do not change uids of existing keys to maintain compatibility to older versions!)
       
    41 const TUid KPSettingPluginNameMode                         = { 0x00 };
       
    42 const TUid KPSettingPluginSaveFileDrive                    = { 0x01 };
       
    43 const TUid KPSettingPluginTraceOutput                      = { 0x02 };
       
    44 const TUid KPSettingPluginSaveFilePrefix                   = { 0x03 };
       
    45 const TUid KPSettingPluginTraceMode                        = { 0x04 };
       
    46 
       
    47 
       
    48 // FORWARD DECLARATIONS
       
    49 class CProfilerGuiMainView;
       
    50 class CProfilerGuiMainContainer;
       
    51 class CEikonEnv;
       
    52 class TSamplerAttributes;
       
    53 class CProfilerEngineStatusChecker;
       
    54 class MProfilerStatusObserver;
       
    55 
       
    56 
       
    57 typedef CArrayFixSeg<TSamplerAttributes> CSamplerItemList;
       
    58 
       
    59 
       
    60 
       
    61 class CProfilerGuiModel : public CActive, MProfilerStatusObserver
       
    62 	{
       
    63 private:
       
    64     enum TContainerDrawState
       
    65     	{
       
    66     	EDrawStateInvalid = -1,
       
    67     	EDrawStateMain
       
    68     	};
       
    69  public:
       
    70 	static CProfilerGuiModel* NewL();
       
    71 	~CProfilerGuiModel();
       
    72 	void ActivateModelL();
       
    73 	void DeActivateModelL();
       
    74 	void SetMainView(CProfilerGuiMainView* aMainView);
       
    75 	void UpdateState(TInt aState);
       
    76 	TBool GetSelectedItemHasSettings();
       
    77     TBool GetSelectedItemEnabled();
       
    78     TBool GetSelectedItemHidden();
       
    79     TInt EditSelectedSamplerL(TInt index);
       
    80     void SelectedSamplerInfoL(TInt index);
       
    81     void TerminateProfilerL();
       
    82     TBool CheckTraceLocationSanityL(TGeneralAttributes& aAttr, TBool aQuietCheck);
       
    83  private:
       
    84     void RunL();
       
    85 	void DoCancel();
       
    86 	void LoadPluginsL();	
       
    87     TInt EditSamplerL(TSamplerAttributes& aItem);
       
    88     void SamplerInfoL(TSamplerAttributes& aItem);
       
    89 private:
       
    90 	CProfilerGuiModel();
       
    91 	void ConstructL();
       
    92     TInt LoadGeneralSettingsL();
       
    93 
       
    94     void AppendToSamplerItemListL(TSamplerAttributes& aItem);
       
    95     void DisableOrEnableFromSamplerItemListL(TInt aIndex);
       
    96     void DeleteAllSamplerItems();
       
    97     void RefreshViewL(TBool aClearSelection=ETrue);
       
    98     void LaunchProfilerEngineL();
       
    99     void UpdateUIRunningStateL();
       
   100     TInt FindProcessL(RProcess& aProc);
       
   101     
       
   102 public:
       
   103     
       
   104     enum TProfilingMode
       
   105         {
       
   106         EProfilingModeNormal = 0,
       
   107         EProfilingModeTimed
       
   108         };
       
   109     
       
   110  	void StartAllSamplerItemsL(TProfilingMode aProfilingMode = EProfilingModeNormal);
       
   111     void StopAllSamplerItemsL();
       
   112     void DeleteAllSamplerItemsL();
       
   113     void DisableAllSamplerItemsL();
       
   114     void EnableAllSamplerItemsL();
       
   115             
       
   116     TInt SamplerItemCount() const;
       
   117     void ShowItemActionMenuL();
       
   118     void StopSelectedOrHighlightedItemsL();
       
   119     void DisableOrEnableSelectedOrHighlightedItemsL();
       
   120 
       
   121     CDesCArray* GenerateListBoxItemTextArrayL();
       
   122 	void StartNewSamplerL(TInt aCommand);
       
   123     void AddNewSamplersL(CArrayFixFlat<TSamplerAttributes>& iSamplerAttributes);
       
   124 
       
   125     void SaveGeneralSettingsL();
       
   126     void SetMainContainer(CProfilerGuiMainContainer* aContainer);
       
   127     TInt LaunchSettingsDialogL();
       
   128     inline CEikonEnv* EikonEnv() { return iEnv; }
       
   129     inline CProfilerGuiMainContainer* MainContainer() { return iMainContainer; }
       
   130     inline TBool SamplerItemsExists() { return iSamplerItemList->Count() > 0; } 
       
   131     inline TGeneralAttributes const& GeneralSettings() const { return iGeneralAttributes; }
       
   132     
       
   133     TPtrC GetWriterInfoNoteL(const TDesC& aNote);
       
   134     void AttachClient();
       
   135     void RemoveClient();
       
   136 
       
   137 public:
       
   138     // from MProfilerStatusObserver
       
   139     void NotifyContainerReadyL();
       
   140     void HandleProfilerStatusChange( KProfilerStatus aStatus );
       
   141     void HandleProfilerErrorL( TInt aError );
       
   142         
       
   143 private:
       
   144 	static const TInt                   iSamplerNameMode = ESamplerNameLong;
       
   145     CProfilerGuiMainContainer*          iMainContainer;
       
   146     CEikonEnv*                          iEnv;
       
   147     TInt                                iDrawState;
       
   148     CSamplerItemList*                   iSamplerItemList;
       
   149     TInt                                iReferenceNumber;
       
   150     CArrayFixFlat<TSamplerAttributes>*	iSamplerAttributes;
       
   151     TGeneralAttributes                  iGeneralAttributes;
       
   152     TBool                               iProfilerStatus;   // Status of Engine before it was launched by this application
       
   153     CProfilerGuiMainView*               iMainView;
       
   154 
       
   155     // checkers
       
   156     CProfilerEngineStatusChecker*       iStatusChecker;
       
   157 public:
       
   158     TInt							     iState;
       
   159     };
       
   160 
       
   161 #endif