uifw/EikStd/srvuisrc/EIKNFYUI.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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:  Alert dialog implementation for EIKON Server.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    20 #include <uikon/eiknotifyalert.h>
       
    21 #endif
       
    22 #include <coemain.h>
       
    23 #include <eikbtgpc.h>
       
    24 #include <aknmessagequerycontrol.h>
       
    25 #include <eiksrvui.rsg>
       
    26 
       
    27 #include "EIKNFYUI.H"
       
    28 #include "EIKSRV.HRH"
       
    29 
       
    30 //
       
    31 // CEikServNotifyAlert
       
    32 //
       
    33 
       
    34 const TInt KSomethingDefinetelyDifferentFromEEikBidCancel( ~( EEikBidCancel ) );
       
    35 
       
    36 // ======== LOCAL FUNCTIONS ========
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CallDisplayNextNote
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 TInt CallDisplayNextNote( TAny* aThis )
       
    43     {
       
    44     TRAPD( err, ( static_cast<CEikServNotifyAlert*>( aThis )->DisplayNextNoteL() ) ); 
       
    45     return err;
       
    46     }
       
    47 
       
    48 // ======== MEMBER FUNCTIONS ========
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CEikServNotifyAlert::CEikServNotifyAlert
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CEikServNotifyAlert::CEikServNotifyAlert() : CAknMessageQueryDialog( ENoTone )
       
    55     {
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CEikServNotifyAlert::~CEikServNotifyAlert
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CEikServNotifyAlert::~CEikServNotifyAlert()
       
    64     {
       
    65     Reset();
       
    66     }
       
    67 
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CEikServNotifyAlert::ConstructL
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CEikServNotifyAlert::ConstructL()
       
    74     {
       
    75     SetGloballyCapturing( ETrue );
       
    76 
       
    77     // Constructs with two labels & two buttons.
       
    78     // Normal priority for CBA's is just ok.
       
    79     ConstructSleepingDialogL( R_EIKSERV_NOTIFIER_DIALOG2 );
       
    80 
       
    81     TCallBack callback( CallDisplayNextNote, this );
       
    82     iDisplayCallback = new (ELeave) CAsyncCallBack( callback,
       
    83                                                     CActive::EPriorityHigh );
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // CEikServNotifyAlert::Release
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CEikServNotifyAlert::Release()
       
    92     {
       
    93     if ( iObserver )
       
    94         {
       
    95         iObserver->HandleAlertCompletion(
       
    96             KSomethingDefinetelyDifferentFromEEikBidCancel );
       
    97         }
       
    98 
       
    99     delete this;
       
   100     }
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CEikServNotifyAlert::Reset
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CEikServNotifyAlert::Reset()
       
   108     {
       
   109     delete iTitle;
       
   110     delete iLabel;
       
   111     delete iBut1;
       
   112     delete iBut2;
       
   113 
       
   114     iTitle = NULL;
       
   115     iLabel = NULL;
       
   116     iBut1  = NULL;
       
   117     iBut2  = NULL;
       
   118     }
       
   119 
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CEikServNotifyAlert::DoLeavingSettingsL
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CEikServNotifyAlert::DoLeavingSettingsL( const TDesC& aTitle,
       
   126                                               const TDesC& aLabel, 
       
   127                                               const TDesC& aBut1,
       
   128                                               const TDesC& aBut2 )
       
   129     {
       
   130     TInt bufferSize = aTitle.Length() + aLabel.Length() + 1;
       
   131     HBufC* textBuffer = HBufC::NewLC( bufferSize );
       
   132     TPtr ptr( textBuffer->Des() );
       
   133 
       
   134     if ( aTitle.Length() )
       
   135         {
       
   136         ptr.Append( aTitle );
       
   137         _LIT( KFormFeed, "\f" );
       
   138         ptr.Append( KFormFeed );
       
   139         }
       
   140         
       
   141     if ( aLabel.Length() )
       
   142         {
       
   143         ptr.Append( aLabel );
       
   144         }
       
   145     
       
   146     if ( ptr.Length() )
       
   147         {
       
   148         static_cast<CAknMessageQueryControl*>(
       
   149             Control( EAknMessageQueryContentId ) )->SetMessageTextL( &ptr );
       
   150         CleanupStack::Pop( textBuffer );
       
   151         }
       
   152     else
       
   153         {
       
   154         // Ownership not transferred.
       
   155         CleanupStack::PopAndDestroy( textBuffer );
       
   156         }
       
   157 
       
   158     CEikButtonGroupContainer& bgc = ButtonGroupContainer();
       
   159     bgc.SetCommandL( EAknAlertWinButton1, aBut1 );    
       
   160     bgc.SetCommandL( EAknAlertWinButton2, aBut2 );    
       
   161     }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CEikServNotifyAlert::DisplayNotifier
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 void CEikServNotifyAlert::DisplayNotifier(
       
   169     const TDesC& aTitle,
       
   170     const TDesC& aLabel, 
       
   171     const TDesC& aBut1,
       
   172     const TDesC& aBut2,
       
   173     MEikNotifyAlertCompletionObserver* aObserver )
       
   174     {
       
   175     // Previous notify still not handled.
       
   176     if ( iObserver && aObserver )
       
   177         {
       
   178         aObserver->HandleAlertCompletion(
       
   179             KSomethingDefinetelyDifferentFromEEikBidCancel );
       
   180         return;
       
   181         }
       
   182 
       
   183     TRAPD( err,
       
   184         {
       
   185         iTitle = aTitle.AllocL();
       
   186         iLabel = aLabel.AllocL();
       
   187         iBut1  = aBut1.AllocL();
       
   188         iBut2  = aBut2.AllocL();
       
   189         }
       
   190         )
       
   191 
       
   192     if ( err )
       
   193         {
       
   194         Reset();
       
   195         }
       
   196     else
       
   197         {
       
   198         iObserver = aObserver;
       
   199         iDisplayCallback->CallBack();
       
   200         }
       
   201     }
       
   202 
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // CEikServNotifyAlert::DisplayNextNoteL
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 void CEikServNotifyAlert::DisplayNextNoteL()
       
   209     {
       
   210     TRAPD( err, DoLeavingSettingsL( iTitle->Des(),
       
   211                                     iLabel->Des(),
       
   212                                     iBut1->Des(),
       
   213                                     iBut2->Des() ) );
       
   214 
       
   215     // Ownership was transferred.
       
   216     Reset();
       
   217 
       
   218     if ( err )
       
   219         {
       
   220         // Just make sure that observer will be completed correctly.
       
   221         OkToExitL( KSomethingDefinetelyDifferentFromEEikBidCancel ); 
       
   222         return;
       
   223         }
       
   224 
       
   225 #ifdef RD_SCALABLE_UI_V2
       
   226     if ( AknLayoutUtils::PenEnabled() )
       
   227         {
       
   228         SetGloballyCapturing( ETrue ); 
       
   229         SetPointerCapture( ETrue ); 
       
   230         }
       
   231 #endif
       
   232  
       
   233     RouseSleepingDialog();
       
   234     }
       
   235 
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // CEikServNotifyAlert::OkToExitL
       
   239 // ---------------------------------------------------------------------------
       
   240 //
       
   241 TBool CEikServNotifyAlert::OkToExitL( TInt aButtonId )
       
   242     {
       
   243 #ifdef RD_SCALABLE_UI_V2
       
   244     if ( AknLayoutUtils::PenEnabled() )
       
   245         {
       
   246         SetGloballyCapturing( EFalse ); 
       
   247         SetPointerCapture( EFalse ); 
       
   248         }
       
   249 #endif
       
   250 
       
   251     if ( iObserver )
       
   252         {
       
   253         iObserver->HandleAlertCompletion( aButtonId );
       
   254         }
       
   255 
       
   256     // To make sure that HandleAlertCompletion() will be
       
   257     // called only once per DisplayNotifier.
       
   258     iObserver = NULL;
       
   259 
       
   260     // always exit
       
   261     return ETrue;
       
   262     }
       
   263 
       
   264 // End of file