uifw/AvKon/src/AknTextSettingPage.cpp
branchRCL_3
changeset 15 08e69e956a8c
parent 10 9f56a4e1b8ab
child 29 a8834a2e9a96
equal deleted inserted replaced
10:9f56a4e1b8ab 15:08e69e956a8c
    32 #include <AknsControlContext.h>
    32 #include <AknsControlContext.h>
    33 #include <AknsFrameBackgroundControlContext.h>
    33 #include <AknsFrameBackgroundControlContext.h>
    34 #include <eikedwob.h>
    34 #include <eikedwob.h>
    35 
    35 
    36 #include <AknTasHook.h>
    36 #include <AknTasHook.h>
    37 
    37 #include <AknFepInternalPSKeys.h>
       
    38 #include <e32property.h>
       
    39 #include <AknDef.h>
       
    40 
       
    41 static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy );
       
    42 static _LIT_SECURITY_POLICY_C1( KPowerMgmtPolicy, ECapabilityPowerMgmt );
       
    43 
       
    44 /*
       
    45  * this class is a fixing for bug ESLM-8395MP 
       
    46  * Settingpage will keep watch the RProperty(set by Fep) to hide it self 
       
    47  */
       
    48 class CAknFepSettingDialogStatusWatcher : public CActive
       
    49 	{
       
    50 public:
       
    51 
       
    52     static CAknFepSettingDialogStatusWatcher* NewL( CAknTextSettingPage* aControl )
       
    53         {
       
    54         CAknFepSettingDialogStatusWatcher* watcher = new (ELeave) CAknFepSettingDialogStatusWatcher( aControl );
       
    55         CleanupStack::PushL( watcher );
       
    56         watcher->ConstructL();
       
    57         CleanupStack::Pop(watcher);
       
    58         return watcher;
       
    59         }
       
    60     
       
    61 	CAknFepSettingDialogStatusWatcher( CAknTextSettingPage* aControl )
       
    62 	    : CActive( EPriorityNormal )
       
    63 		, iControl( aControl ) 
       
    64 	    {
       
    65 	    CActiveScheduler::Add( this );
       
    66 	    }
       
    67 	
       
    68 	~CAknFepSettingDialogStatusWatcher()
       
    69         {
       
    70         StopWatching();
       
    71         iFepSettingDialogStatusProperty.Close();
       
    72 	    }
       
    73 	
       
    74 	void StartWatchingL()
       
    75 	    {
       
    76 	    if ( !IsActive() )
       
    77             {
       
    78             iFepSettingDialogStatusProperty.Subscribe( iStatus );
       
    79             SetActive();
       
    80             }
       
    81 	    }
       
    82 		
       
    83     void StopWatching()
       
    84 	    {
       
    85 	    Cancel();
       
    86 	    }
       
    87 	
       
    88 private:    
       
    89     
       
    90     void ConstructL()
       
    91         {
       
    92         // Define PS Key
       
    93         TInt err = RProperty::Define(
       
    94             KPSUidAknFep, 
       
    95             KAknFepSettingDialogState, 
       
    96             RProperty::EInt, 
       
    97             KAllowAllPolicy,  // None
       
    98             KPowerMgmtPolicy ); 
       
    99             
       
   100         if (err != KErrAlreadyExists)
       
   101             {
       
   102             User::LeaveIfError( err );
       
   103             }
       
   104         User::LeaveIfError( iFepSettingDialogStatusProperty.Attach( KPSUidAknFep
       
   105                                           , KAknFepSettingDialogState, EOwnerThread ) );
       
   106         }
       
   107 	
       
   108 	void HandleAknFepSettingDialogStatusChangeNotificationL()
       
   109 	    {
       
   110 	    TInt isOpen = 0;
       
   111 	    TInt ret = iFepSettingDialogStatusProperty.Get( isOpen );
       
   112         if ( ret!=KErrOverflow )
       
   113             {
       
   114             User::LeaveIfError( ret );
       
   115             }
       
   116 	
       
   117         if ( !iControl )
       
   118             {
       
   119             return;
       
   120             }
       
   121 
       
   122 	    if ( isOpen )
       
   123 	        {
       
   124 	        iControl->MakeVisible( EFalse );
       
   125 	        }
       
   126 	    else
       
   127 	        {
       
   128 	        iControl->MakeVisible( ETrue );
       
   129 	        }
       
   130 	    }
       
   131 	
       
   132 private: // from CActive
       
   133 
       
   134     void RunL()
       
   135 	    {
       
   136 	    if ( iStatus.Int() == KErrNone )
       
   137             {
       
   138             HandleAknFepSettingDialogStatusChangeNotificationL();
       
   139             StartWatchingL();
       
   140             }
       
   141 	    }
       
   142 
       
   143     void DoCancel()
       
   144 	    {
       
   145 	    iFepSettingDialogStatusProperty.Cancel();
       
   146 	    }
       
   147 	
       
   148 private:
       
   149     //
       
   150     // not owned
       
   151     //
       
   152     CAknTextSettingPage* iControl;
       
   153 
       
   154     RProperty  iFepSettingDialogStatusProperty;
       
   155     };
       
   156 
       
   157 
       
   158 // ============================================================================
       
   159 //  text settingpage private extented class 
       
   160 //
       
   161 // ============================================================================
       
   162 //
    38 class CAknTextSettingPageExtension : public CBase
   163 class CAknTextSettingPageExtension : public CBase
    39 								   , public MEikEdwinObserver
   164 								   , public MEikEdwinObserver
    40     {
   165     {
    41 public:
   166 public:
    42     static CAknTextSettingPageExtension* NewL(CAknTextSettingPage* aExtensionOwner )
   167     static CAknTextSettingPageExtension* NewL(CAknTextSettingPage* aExtensionOwner )
    49         }
   174         }
    50         
   175         
    51     ~CAknTextSettingPageExtension()
   176     ~CAknTextSettingPageExtension()
    52         {
   177         {
    53         iExtensionOwner = 0;
   178         iExtensionOwner = 0;
       
   179 		
       
   180 		if( iAknFepSettingDialogStatusWatcher )
       
   181 		    {
       
   182 		    iAknFepSettingDialogStatusWatcher->StopWatching();
       
   183             }			
       
   184 		delete iAknFepSettingDialogStatusWatcher;
    54         }
   185         }
    55         
   186         
    56     TInt PreviousCba()
   187     TInt PreviousCba()
    57         {
   188         {
    58         return iPreviousCba;
   189         return iPreviousCba;
    59         };
   190         };
       
   191 		
    60     void SetPreviousCba(TInt aCbaId)
   192     void SetPreviousCba(TInt aCbaId)
    61         {
   193         {
    62         iPreviousCba = aCbaId;
   194         iPreviousCba = aCbaId;
    63         }
   195         }
       
   196 		
    64 	TBool PopupState()
   197 	TBool PopupState()
    65 	 	{
   198 	 	{
    66 		return iPopupState;
   199 		return iPopupState;
    67 		}
   200 		}
    68 
   201 
    80 		}
   213 		}
    81     
   214     
    82 private:
   215 private:
    83     void ConstructL()
   216     void ConstructL()
    84         {
   217         {
       
   218 		iAknFepSettingDialogStatusWatcher = CAknFepSettingDialogStatusWatcher::NewL( iExtensionOwner );
       
   219 		iAknFepSettingDialogStatusWatcher->StartWatchingL();
    85         }
   220         }
    86         
   221         
    87     CAknTextSettingPageExtension(CAknTextSettingPage*  aExtensionOwner )
   222     CAknTextSettingPageExtension(CAknTextSettingPage*  aExtensionOwner )
    88         : iPreviousCba( 0 ), iExtensionOwner( aExtensionOwner )
   223         : iPreviousCba( 0 )
       
   224         , iExtensionOwner( aExtensionOwner )
    89         , iPopupState( EFalse )
   225         , iPopupState( EFalse )
    90         {
   226         {
    91         }
   227         }
    92         
   228         
    93 private:
   229 private:
    94     TInt iPreviousCba;
   230     TInt iPreviousCba;
    95     CAknTextSettingPage* iExtensionOwner;
   231     CAknTextSettingPage* iExtensionOwner;
    96     TBool iPopupState;  // when open the popup set popup state flag  to 1
   232     TBool iPopupState;  // when open the popup set popup state flag  to 1
       
   233 
       
   234 	//
       
   235 	// active object keep watching Fep's property (Owned)
       
   236 	//
       
   237 	CAknFepSettingDialogStatusWatcher* iAknFepSettingDialogStatusWatcher;
    97     };
   238     };
    98 
   239 
    99 /**
   240 /**
   100  * Exported in case others want to derive from this class
   241  * Exported in case others want to derive from this class
   101  *
   242  *