connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/wlanpowersavetestnotif.cpp
changeset 0 5a93021fdf25
child 41 bbb64eb3bdee
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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:  Notier part for WLAN Power Save Testing notification dialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "wlanpowersavetestnotif.h"
       
    22 #include "wlanpowersavetest.h"
       
    23 #include "ConnectionUiUtilitiesCommon.h"
       
    24 #include "ConnUiUtilsNotif.h"
       
    25 #include "ConnectionDialogsLogger.h"
       
    26 
       
    27 #include <ConnUiUtilsNotif.rsg>
       
    28 #include <StringLoader.h>
       
    29 
       
    30 #include <ConnectionUiUtilities.h>
       
    31 
       
    32 
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 
       
    36 // ---------------------------------------------------------
       
    37 // CWlanPowerSaveQueryNotif::CWlanPowerSaveQueryNotif()
       
    38 // ---------------------------------------------------------
       
    39 //
       
    40 CWlanPowerSaveQueryNotif::CWlanPowerSaveQueryNotif()
       
    41     :
       
    42     iDisable( EFalse )
       
    43     {
       
    44     }
       
    45 
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CWlanPowerSaveQueryNotif* CWlanPowerSaveQueryNotif::NewL()
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 CWlanPowerSaveQueryNotif* CWlanPowerSaveQueryNotif::NewL( 
       
    52                                         const TBool aResourceFileResponsible )
       
    53     {
       
    54     CWlanPowerSaveQueryNotif* self = new ( ELeave ) CWlanPowerSaveQueryNotif();
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
    57     CleanupStack::Pop();
       
    58 
       
    59     return self;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CWlanPowerSaveQueryNotif::~CWlanPowerSaveQueryNotif()
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 CWlanPowerSaveQueryNotif::~CWlanPowerSaveQueryNotif()
       
    67     {   
       
    68     if ( iExitAsync )
       
    69         {
       
    70     	delete iExitAsync;
       
    71     	iExitAsync = NULL;
       
    72         }
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // CWlanPowerSaveQueryNotif::RegisterL()
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 CWlanPowerSaveQueryNotif::TNotifierInfo CWlanPowerSaveQueryNotif::RegisterL()
       
    80     {
       
    81     iInfo.iUid      = KUidWlanPowerSaveTestNote;
       
    82     iInfo.iPriority = ENotifierPriorityHigh;
       
    83     iInfo.iChannel  = KUidWlanPowerSaveTestNote;
       
    84 
       
    85     return iInfo;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------
       
    89 // void CWlanPowerSaveQueryNotif::StartL
       
    90 // ---------------------------------------------------------
       
    91 //
       
    92 void CWlanPowerSaveQueryNotif::StartL( const TDesC8& /*aBuffer*/, 
       
    93                                        TInt aReplySlot,
       
    94                                        const RMessagePtr2& aMessage )
       
    95     {
       
    96     if ( iDialog )
       
    97         {
       
    98         // Dialog is already on the display
       
    99         aMessage.Complete( KErrServerBusy );
       
   100         return;
       
   101         }
       
   102             
       
   103     iReplySlot = aReplySlot;
       
   104     iMessage   = aMessage;
       
   105     iCancelled = EFalse;    
       
   106 
       
   107     iDialog = new ( ELeave ) CWlanPowerSaveQuery( this );
       
   108     iDialog->PrepareLC( R_POWERSAVE_QUERY );
       
   109     
       
   110     HBufC* heading  = NULL;
       
   111     HBufC* message  = NULL;
       
   112     TInt resourceId = 0;
       
   113     
       
   114     resourceId = R_QTN_WLAN_POWER_SAVE_TEST_DLG_TEXT;
       
   115     heading    = StringLoader::LoadLC( 
       
   116                      R_QTN_WLAN_POWER_SAVE_TEST_DLG_TITLE );
       
   117     
       
   118     CDesCArrayFlat* strings = new( ELeave ) CDesCArrayFlat( 2 );
       
   119     CleanupStack::PushL( strings );
       
   120     
       
   121     HBufC* messageBase = StringLoader::LoadL( resourceId, *strings );
       
   122 
       
   123     CleanupStack::PopAndDestroy( strings );
       
   124 
       
   125     CleanupStack::PushL( messageBase );
       
   126 
       
   127     _LIT( KLinkStartTag, "\n<AknMessageQuery Link>" );
       
   128     _LIT( KLinkEndTag, "</AknMessageQuery Link>" );
       
   129 
       
   130     HBufC* linkString1 = StringLoader::LoadLC( 
       
   131                             R_QTN_WLAN_POWER_SAVE_TEST_DLG_LINK );
       
   132 
       
   133     TInt lenMsg = messageBase->Des().Length()+
       
   134                   linkString1->Des().Length()+
       
   135                   KLinkStartTag().Length()+
       
   136                   KLinkEndTag().Length();
       
   137 
       
   138 
       
   139     message = HBufC::NewL( lenMsg );
       
   140     TPtr messagePtr = message->Des();
       
   141 
       
   142     messagePtr.Append( messageBase->Des() ); 
       
   143 
       
   144     messagePtr.Append( KLinkStartTag ); 
       
   145     messagePtr.Append( linkString1->Des() );
       
   146     messagePtr.Append( KLinkEndTag );
       
   147 
       
   148     CleanupStack::PopAndDestroy( linkString1 );
       
   149     CleanupStack::PopAndDestroy( messageBase );
       
   150 
       
   151     CleanupStack::PushL( message );
       
   152 
       
   153     iDialog->SetMessageTextL( *message );
       
   154     CleanupStack::PopAndDestroy( message );
       
   155 
       
   156     iDialog->QueryHeading()->SetTextL( *heading );
       
   157     CleanupStack::PopAndDestroy( heading );
       
   158 
       
   159     // Set callback for the link
       
   160     TCallBack callBackFirstLink( DisableTestLinkL, this );
       
   161     iDialog->SetLink( callBackFirstLink );
       
   162 
       
   163     iDialog->RunLD();
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------
       
   167 // void CWlanPowerSaveQueryNotif::Cancel()
       
   168 // ---------------------------------------------------------
       
   169 //
       
   170 void CWlanPowerSaveQueryNotif::Cancel()
       
   171     {
       
   172     CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::Cancel" );
       
   173     if ( !iCancelled )
       
   174         {
       
   175         iCancelled = ETrue;
       
   176         if ( !iMessage.IsNull() )
       
   177             {
       
   178             iMessage.Complete( KErrCancel );
       
   179             }
       
   180         
       
   181         delete iDialog;
       
   182         iDialog = NULL;
       
   183         }
       
   184             
       
   185     CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::Cancel" );
       
   186     }
       
   187 
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // void CWlanPowerSaveQueryNotif::CompleteL( TInt aStatus )
       
   191 // ---------------------------------------------------------
       
   192 //
       
   193 void CWlanPowerSaveQueryNotif::CompleteL( TInt aStatus )
       
   194     {  
       
   195     CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::CompleteL" );
       
   196     if ( !iMessage.IsNull() )
       
   197         {        
       
   198         iMessage.WriteL( iReplySlot, TPckg< TBool >( iDisable ) );
       
   199         iMessage.Complete( aStatus );
       
   200         }
       
   201     
       
   202     iCancelled = ETrue;
       
   203     iDialog    = NULL; //deleted by AVKON when OkToExitL completes
       
   204     
       
   205     CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::CompleteL" );
       
   206     }
       
   207 
       
   208 
       
   209 // ---------------------------------------------------------
       
   210 // TInt CWlanPowerSaveQueryNotif::DisableTestLinkL()
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 TInt CWlanPowerSaveQueryNotif::DisableTestLinkL( TAny* aObject )
       
   214     {
       
   215     CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::DisableTestLinkL" );
       
   216     CWlanPowerSaveQueryNotif* myself =
       
   217                             static_cast<CWlanPowerSaveQueryNotif*>( aObject );
       
   218     
       
   219     if ( !myself->iExitAsync )
       
   220         {
       
   221         // Can't exit now. This call could be triggered by a pointer
       
   222         // event. AVKON would crash if exit is done now.
       
   223         // Trigger a one shot active object to delay exit. 
       
   224         TCallBack cb( myself->DisableTestLinkL, myself );
       
   225 	    myself->iExitAsync = new( ELeave ) CAsyncCallBack( cb, CActive::EPriorityHigh );
       
   226 	    myself->iExitAsync->CallBack();
       
   227 	    
       
   228 	    CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::DisableTestLinkL" );
       
   229 	    return 1;
       
   230         }
       
   231     else
       
   232         {
       
   233         // We can exit now. Called by one shot active object.
       
   234         myself->DoDisableTestLinkL();
       
   235         
       
   236         CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::DisableTestLinkL" );
       
   237         return 0;	
       
   238         }
       
   239     }
       
   240 
       
   241 
       
   242 // ---------------------------------------------------------
       
   243 // void CWlanPowerSaveQueryNotif::DoDisableTestLinkL()
       
   244 // ---------------------------------------------------------
       
   245 //
       
   246 void CWlanPowerSaveQueryNotif::DoDisableTestLinkL()
       
   247     {
       
   248     CLOG_ENTERFN( "CWlanPowerSaveQueryNotif::DoDisableTestLinkL" );
       
   249 
       
   250     iDisable = ETrue;
       
   251     
       
   252     iDialog->TryExitL( EAknSoftkeySelect );
       
   253     
       
   254     CLOG_LEAVEFN( "CWlanPowerSaveQueryNotif::DoDisableTestLinkL" );
       
   255     }
       
   256 
       
   257 // End of File