internetradio2.0/uisrc/irdialoglauncher.cpp
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 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:  Implementation for a class showing dialogs and notes.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aknglobalnote.h>
       
    20 #include <aknlists.h>
       
    21 #include <aknnotewrappers.h>
       
    22 #include <aknsddata.h>
       
    23 #include <bldvariant.hrh>
       
    24 #include <etelpckt.h>
       
    25 #include <gsmerror.h>
       
    26 #include <stringloader.h>
       
    27 #include <textresolver.h>
       
    28 #include <aknquerydialog.h>
       
    29 #include <eikdialg.h>
       
    30 #include "irdialoglauncher.h"
       
    31 #include <internetradio.rsg>
       
    32 #include "irdebug.h"
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // C++ default constructor can NOT contain any code, that might leave.
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CIRDialogLauncher::CIRDialogLauncher()
       
    39     {
       
    40     IRLOG_DEBUG("CIRDialogLauncher::CIRDialogLauncher" );
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // EPOC default constructor can leave.
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void CIRDialogLauncher::ConstructL()
       
    49     {
       
    50     IRLOG_DEBUG("CIRDialogLauncher::ConstructL" );
       
    51 	return;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Two-phased constructor.
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CIRDialogLauncher* CIRDialogLauncher::NewL()
       
    59     {
       
    60     IRLOG_DEBUG("CIRDialogLauncher::NewL - Entering" );
       
    61     CIRDialogLauncher* self = new( ELeave ) CIRDialogLauncher();
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65     IRLOG_DEBUG("CIRDialogLauncher::NewL - Exiting" );
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // Destructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //            
       
    73 CIRDialogLauncher::~CIRDialogLauncher()
       
    74     { 
       
    75     IRLOG_DEBUG("CIRDialogLauncher::~CIRDialogLauncher" );
       
    76     }
       
    77             
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------------------------
       
    81 // CIRDialogLauncher::ShowConfirmationNoteL
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void CIRDialogLauncher::ShowConfirmationNoteL( TInt aTextResourceId, TBool aWaiting ) const
       
    85     {
       
    86     IRLOG_DEBUG("CIRDialogLauncher::ShowConfirmationNoteL - Entering" );
       
    87     HBufC* noteTxt = StringLoader::LoadLC( aTextResourceId );
       
    88     ShowConfirmationNoteL( *noteTxt, aWaiting );
       
    89     CleanupStack::PopAndDestroy( noteTxt );
       
    90     IRLOG_DEBUG("CIRDialogLauncher::ShowConfirmationNoteL - Exiting" );
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CIRDialogLauncher::ShowConfirmationNoteL
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 void CIRDialogLauncher::ShowConfirmationNoteL( const TDesC& aText, TBool aWaiting ) const
       
    98     {
       
    99     IRLOG_DEBUG("CIRDialogLauncher::ShowConfirmationNoteL - Entering" );
       
   100     CAknConfirmationNote* note = new( ELeave ) CAknConfirmationNote( aWaiting );
       
   101     note->ExecuteLD( aText );
       
   102     IRLOG_DEBUG("CIRDialogLauncher::ShowConfirmationNoteL - Exiting" );
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CIRDialogLauncher::ShowInformationNoteL
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CIRDialogLauncher::ShowInformationNoteL( TInt aTextResourceId,
       
   110                                               TBool aWaiting, TInt aDialogId ) const
       
   111     {
       
   112     IRLOG_DEBUG("CIRDialogLauncher::ShowInformationNoteL - Entering" );
       
   113     HBufC* noteTxt = StringLoader::LoadLC( aTextResourceId );
       
   114     CAknInformationNote* note = new( ELeave ) CAknInformationNote( aWaiting );
       
   115     CleanupStack::PushL(note);
       
   116     if ( aDialogId != KErrNotFound )
       
   117         {
       
   118         note->PublishDialogL( aDialogId );
       
   119         }
       
   120     note->ExecuteLD( *noteTxt );
       
   121     CleanupStack::Pop(note);
       
   122     CleanupStack::PopAndDestroy( noteTxt );
       
   123     IRLOG_DEBUG("CIRDialogLauncher::ShowInformationNoteL - Exiting" );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CIRDialogLauncher::ShowInformationNoteL
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CIRDialogLauncher::ShowInformationNoteL( TInt /*aErrorCode*/ ) const
       
   131     {
       
   132     IRLOG_DEBUG("CIRDialogLauncher::ShowInformationNoteL - Entering" );
       
   133 /*    HBufC* noteTxt= ResolveDefaultErrorTextLC( aErrorCode );
       
   134     
       
   135     CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
       
   136     note->ExecuteLD( *noteTxt );
       
   137     CleanupStack::PopAndDestroy( noteTxt );
       
   138 */    
       
   139     IRLOG_DEBUG("CIRDialogLauncher::ShowInformationNoteL - Exiting" );
       
   140 	return;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CIRDialogLauncher::ShowErrorNoteL
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 void CIRDialogLauncher::ShowErrorNoteL( TInt aTextResourceId, TBool aWaiting ) const
       
   148     {
       
   149     IRLOG_DEBUG("CIRDialogLauncher::ShowErrorNoteL - Entering" );
       
   150     HBufC* noteTxt = StringLoader::LoadLC( aTextResourceId );
       
   151     CAknErrorNote* note = new( ELeave ) CAknErrorNote( aWaiting );
       
   152     note->ExecuteLD( *noteTxt );
       
   153     CleanupStack::PopAndDestroy( noteTxt );
       
   154     IRLOG_DEBUG("CIRDialogLauncher::ShowErrorNoteL - Exiting" );
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // CIRDialogLauncher::ShowGlobalNoteL
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CIRDialogLauncher::ShowGlobalNoteL( TAknGlobalNoteType aType, TInt aTextResourceId ) const
       
   162     {
       
   163     IRLOG_DEBUG("CIRDialogLauncher::ShowGlobalNoteL - Entering" );
       
   164 	HBufC* noteTxt = StringLoader::LoadLC( aTextResourceId );
       
   165 	CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   166 	note->ShowNoteL( aType, *noteTxt );
       
   167 	CleanupStack::PopAndDestroy( 2, noteTxt );	// note, noteTxt
       
   168 	IRLOG_DEBUG("CIRDialogLauncher::ShowGlobalNoteL - Exiting" );
       
   169     }
       
   170 // ---------------------------------------------------------------------------
       
   171 // CIRDialogLauncher::ShowQueryDialogDeletionL
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 
       
   175 void CIRDialogLauncher::ShowQueryDialogDeletionL(const TDesC& aMessage,TInt& aValue)
       
   176 	{
       
   177 	IRLOG_DEBUG("CIRDialogLauncher::ShowQueryDialogDeletionL - Entering" );
       
   178 	CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   179 	aValue = dlg->ExecuteLD(R_QUERY_DELETION,aMessage);	
       
   180 	IRLOG_DEBUG("CIRDialogLauncher::ShowQueryDialogDeletionL - Exiting" );
       
   181 	}
       
   182 // ---------------------------------------------------------------------------
       
   183 // CIRDialogLauncher::ResolveDefaultErrorTextL
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 
       
   187 #ifdef __NOTREQUIRED__
       
   188 HBufC* CIRDialogLauncher::ResolveDefaultErrorTextLC( TInt aErrorCode ) const
       
   189     {
       
   190     VRDEBUG2( " *** S60VisualRadio -- CIRDialogLauncher::ResolveDefaultErrorTextL: error=%d", 
       
   191         aErrorCode );
       
   192    
       
   193     CTextResolver* textResolver = CTextResolver::NewLC();
       
   194 
       
   195 #ifdef RD_COMMON_ENGINE_API_CHANGE
       
   196     TPtrC ptr = textResolver->ResolveErrorString( aErrorCode, 
       
   197                                                   CTextResolver::ECtxNoCtxNoSeparator );
       
   198 #else
       
   199     TPtrC ptr = textResolver->ResolveError( aErrorCode, CTextResolver::ECtxNoCtxNoSeparator );
       
   200 #endif
       
   201 
       
   202     if( !(ptr.Length()) )    // Text resolver returned hidden
       
   203         {
       
   204         VRDEBUG( " *** S60VisualRadio -- CIRDialogLauncher::ResolveDefaultErrorTextL: TextResolver returned hidden" );
       
   205         // -4135 -> -4174
       
   206         if ( ( aErrorCode <= KErrGprsServicesNotAllowed ) && 
       
   207              ( aErrorCode >= KErrGprsPDPContextWithoutTFTAlreadyActivated ) )
       
   208             {
       
   209             VRDEBUG3( " *** S60VisualRadio -- Error note: %d - %d", 
       
   210                       KErrGprsServicesNotAllowed, 
       
   211                       KErrGprsPDPContextWithoutTFTAlreadyActivated );
       
   212 #ifdef RD_COMMON_ENGINE_API_CHANGE
       
   213             ptr.Set( textResolver->ResolveErrorString( KErrGprsMissingorUnknownAPN ) );
       
   214 #else
       
   215             ptr.Set( textResolver->ResolveError( KErrGprsMissingorUnknownAPN ) );
       
   216 #endif
       
   217             }
       
   218         // -8000 -> -8268 & -4000 -> -5124
       
   219         else if ( ( ( aErrorCode <= KErrPhoneSpecificGsmBase ) && 
       
   220                 ( aErrorCode >= KErrGsmOfflineOpNotAllowed ) )  ||
       
   221                 ( ( aErrorCode <= KErrEtelGsmBase ) &&
       
   222                 ( aErrorCode >= KErrGsm0707UnknownError ) ) )
       
   223             {
       
   224             VRDEBUG3( " *** S60VisualRadio -- Error note: %d - %d", 
       
   225                       KErrPhoneSpecificGsmBase, KErrGsmOfflineOpNotAllowed );
       
   226             VRDEBUG3( " *** S60VisualRadio -- Error note: %d - %d", 
       
   227                       KErrEtelGsmBase, KErrGsm0707UnknownError );
       
   228 #ifdef RD_COMMON_ENGINE_API_CHANGE
       
   229             ptr.Set( textResolver->ResolveErrorString( KErrNetUnreach ) );
       
   230 #else
       
   231             ptr.Set( textResolver->ResolveError( KErrNetUnreach ) );
       
   232 #endif
       
   233             }
       
   234         else
       
   235             {
       
   236             }
       
   237                     
       
   238         if( !(ptr.Length()) )    // If still no error text
       
   239             {
       
   240             VRDEBUG( " *** S60VisualRadio -- Error note, no text found" );
       
   241 #ifdef RD_COMMON_ENGINE_API_CHANGE
       
   242             ptr.Set( textResolver->ResolveErrorString( KErrGeneral ) );
       
   243 #else
       
   244             ptr.Set( textResolver->ResolveError( KErrGeneral ) );
       
   245 #endif
       
   246             }
       
   247         }
       
   248     // copy to errorText before deleting textResolver
       
   249     HBufC* errorText = ptr.AllocL();    
       
   250     CleanupStack::PopAndDestroy( textResolver );
       
   251     CleanupStack::PushL( errorText );
       
   252     
       
   253     return errorText;
       
   254     }
       
   255 #endif
       
   256 
       
   257 
       
   258 
       
   259 // -----------------------------------------------------------------------
       
   260 // CIRDialogLauncher::ShowQueryDialogL
       
   261 // -----------------------------------------------------------------------
       
   262 //
       
   263 
       
   264 void CIRDialogLauncher::ShowQueryDialogL( TInt aResourceId,TInt& aValue,
       
   265 									 TInt aDialogId ) const
       
   266     {
       
   267     IRLOG_DEBUG("CIRDialogLauncher::ShowQueryDialogL " );
       
   268     TInt dlgValue;
       
   269     ShowQueryDialogL( aResourceId, KNullDesC,dlgValue,aDialogId);
       
   270     aValue = dlgValue;
       
   271     }
       
   272     
       
   273   
       
   274     
       
   275 // -----------------------------------------------------------------------
       
   276 // CIRDialogLauncher::ShowQueryDialogL
       
   277 // -----------------------------------------------------------------------
       
   278 //
       
   279 
       
   280 void CIRDialogLauncher::ShowQueryDialogL( 
       
   281         TInt aResourceId, const TDesC& aPrompt, TInt& aValue ,TInt aDialogId ) const
       
   282     {
       
   283     IRLOG_DEBUG("CIRDialogLauncher::ShowQueryDialogL - Entering" );
       
   284     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   285     CleanupStack::PushL(dlg);
       
   286     dlg->PrepareLC( aResourceId );
       
   287     if ( aPrompt.Length() > 0 )
       
   288         {
       
   289         dlg->SetPromptL( aPrompt );
       
   290         }
       
   291     if ( aDialogId != KErrNotFound )
       
   292         {
       
   293         dlg->PublishDialogL( aDialogId );
       
   294         }
       
   295     aValue = dlg->RunLD();
       
   296     CleanupStack::Pop(dlg);
       
   297     IRLOG_DEBUG("CIRDialogLauncher::ShowQueryDialogL - Exiting" );
       
   298     }
       
   299  
       
   300     
       
   301 
       
   302   
       
   303 
       
   304