iaupdate/IAD/ui/src/iaupdatestatusdialog.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 30 398876c4ffa7
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
     1 /*
       
     2 * Copyright (c) 2007-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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "iaupdatestatusdialog.h"
       
    23 #include "iaupdatedialogutil.h"
       
    24 #include "iaupdatedebug.h"
       
    25 
       
    26 #include <iaupdate.rsg>
       
    27 #include <aknmessagequerydialog.h>      // CAknMessageQueryDialog
       
    28 #include <StringLoader.h>
       
    29 #include <AknUtils.h>
       
    30 
       
    31 
       
    32 
       
    33 /*******************************************************************************
       
    34  * class CIAUpdateStatusDialog
       
    35  *******************************************************************************/
       
    36 
       
    37 /*
       
    38 A message query can contain a link text which can be highlighted and opened.
       
    39 When a query is opened and it has a link text in the beginning (visible without
       
    40 scrolling the query) the link is not highlighted. When a link becomes visible by
       
    41 scrolling the query, the link is highlighted.
       
    42 There can be multiple link texts in the query. It is highly recommended, not to
       
    43 use more than 3 link texts in one query.
       
    44 A link text can open for example a help view or another message query.
       
    45 The default softkeys are:
       
    46 SK1 OK text.softkey.ok
       
    47 
       
    48 SK1 changes to View text.softkey.view when a link text is highlighted.
       
    49 SK2 does not have a default text.
       
    50 */
       
    51 
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CIAUpdateStatusDialog::ShowDialogL
       
    55 // 
       
    56 // -----------------------------------------------------------------------------
       
    57 TInt CIAUpdateStatusDialog::ShowDialogL( TIAUpdateDialogParam* aParam )
       
    58 	{
       
    59 	CIAUpdateStatusDialog* dialog = CIAUpdateStatusDialog::NewL( aParam );
       
    60 	CleanupStack::PushL( dialog );
       
    61 
       
    62 	TInt ret = dialog->ShowDialogL();
       
    63 
       
    64 	CleanupStack::PopAndDestroy( dialog );
       
    65     
       
    66     return ret;
       
    67 	}
       
    68 
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CIAUpdateStatusDialog::NewL
       
    72 //
       
    73 // -----------------------------------------------------------------------------
       
    74 CIAUpdateStatusDialog* CIAUpdateStatusDialog::NewL( TIAUpdateDialogParam* aParam )
       
    75     {
       
    76     CIAUpdateStatusDialog* self = new ( ELeave ) CIAUpdateStatusDialog( aParam );
       
    77     CleanupStack::PushL( self );
       
    78     self->ConstructL();
       
    79     CleanupStack::Pop( self );
       
    80 
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CIAUpdateStatusDialog::CIAUpdateStatusDialog
       
    87 // 
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CIAUpdateStatusDialog::CIAUpdateStatusDialog( TIAUpdateDialogParam* aParam )
       
    91 	{
       
    92 	iParam = aParam;
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CIAUpdateStatusDialog::ConstructL
       
    98 //
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CIAUpdateStatusDialog::ConstructL()
       
   102     {
       
   103     } 
       
   104 
       
   105 
       
   106 // ----------------------------------------------------------------------------
       
   107 // Destructor
       
   108 //
       
   109 // ----------------------------------------------------------------------------
       
   110 //
       
   111 CIAUpdateStatusDialog::~CIAUpdateStatusDialog()
       
   112     {
       
   113     delete iBuf;
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CIAUpdateStatusDialog::ConstructTextL
       
   119 //
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CIAUpdateStatusDialog::ConstructTextL()
       
   123     {
       
   124     _LIT(KNewLine, "\n");
       
   125     
       
   126     const TInt KBufSize = 1024;
       
   127 
       
   128     delete iBuf;
       
   129     iBuf = NULL;
       
   130     iBuf = HBufC::NewL( KBufSize );
       
   131     TPtr ptr = iBuf->Des();
       
   132     
       
   133     HBufC* hBuf = NULL;
       
   134 
       
   135     
       
   136     if ( iParam->iCountSuccessfull == 0 && iParam->iCountCancelled == 0 &&
       
   137          iParam->iCountFailed == 0 )
       
   138         {
       
   139         hBuf = StringLoader::LoadLC( 
       
   140         R_IAUPDATE_STATUS_DIALOG_SUCCESSFUL, iParam->iCountSuccessfull );
       
   141         
       
   142         ptr.Append( *hBuf );
       
   143         ptr.Append( KNewLine );
       
   144         CleanupStack::PopAndDestroy( hBuf );
       
   145 
       
   146         hBuf = StringLoader::LoadLC( R_IAUPDATE_STATUS_DIALOG_TEXT_LINK );
       
   147         ptr.Append( KOpeningLinkTag );
       
   148         ptr.Append( *hBuf );
       
   149         ptr.Append( KClosingLinkTag );
       
   150         CleanupStack::PopAndDestroy( hBuf );
       
   151         return;
       
   152         }
       
   153     
       
   154     
       
   155         
       
   156     if ( iParam->iCountSuccessfull != 0 )
       
   157         {
       
   158         if ( iParam->iCountSuccessfull == 1 )
       
   159             {
       
   160             hBuf = StringLoader::LoadLC( R_IAUPDATE_STATUS_DIALOG_SUCCESSFUL_ONE );
       
   161             }
       
   162         else
       
   163             {
       
   164             hBuf = StringLoader::LoadLC( 
       
   165             R_IAUPDATE_STATUS_DIALOG_SUCCESSFUL, iParam->iCountSuccessfull );
       
   166             }
       
   167         ptr.Append( *hBuf );
       
   168         ptr.Append( KNewLine );
       
   169         CleanupStack::PopAndDestroy( hBuf );
       
   170         }
       
   171     
       
   172     if ( iParam->iCountCancelled != 0 )
       
   173         {
       
   174         if ( iParam->iCountCancelled == 1 )
       
   175             {
       
   176             hBuf = StringLoader::LoadLC( R_IAUPDATE_STATUS_DIALOG_CANCELLED_ONE );
       
   177             }
       
   178         else
       
   179             {
       
   180             hBuf = StringLoader::LoadLC( 
       
   181             R_IAUPDATE_STATUS_DIALOG_CANCELLED, iParam->iCountCancelled  );
       
   182             }
       
   183         ptr.Append( *hBuf );
       
   184         ptr.Append( KNewLine );
       
   185         CleanupStack::PopAndDestroy( hBuf );
       
   186         }
       
   187 
       
   188     if ( iParam->iCountFailed != 0 )
       
   189         {
       
   190         if ( iParam->iCountFailed == 1 )
       
   191             {
       
   192             hBuf = StringLoader::LoadLC( R_IAUPDATE_STATUS_DIALOG_FAILED_ONE );
       
   193             }
       
   194         else
       
   195             {
       
   196             hBuf = StringLoader::LoadLC( 
       
   197             R_IAUPDATE_STATUS_DIALOG_FAILED, iParam->iCountFailed );
       
   198             }
       
   199     
       
   200         ptr.Append( *hBuf );
       
   201         ptr.Append( KNewLine );
       
   202         CleanupStack::PopAndDestroy( hBuf );
       
   203         }
       
   204     
       
   205     if ( iParam->iShowCloseAllText )
       
   206         {
       
   207     	hBuf = StringLoader::LoadLC( R_IAUPDATE_CLOSE_ALL );
       
   208     	ptr.Append( *hBuf );
       
   209     	ptr.Append( KNewLine );
       
   210         CleanupStack::PopAndDestroy( hBuf );
       
   211         }
       
   212 
       
   213 
       
   214     hBuf = StringLoader::LoadLC( R_IAUPDATE_STATUS_DIALOG_TEXT_LINK );
       
   215     ptr.Append( KOpeningLinkTag );
       
   216     ptr.Append( *hBuf );
       
   217     ptr.Append( KClosingLinkTag );
       
   218     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
       
   219     CleanupStack::PopAndDestroy( hBuf );
       
   220     } 
       
   221 
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CIAUpdateStatusDialog::ShowDialogL
       
   225 // 
       
   226 // -----------------------------------------------------------------------------
       
   227 TInt CIAUpdateStatusDialog::ShowDialogL()
       
   228 	{
       
   229 	ConstructTextL();
       
   230 	
       
   231 	CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *iBuf );
       
   232 	dlg->PrepareLC( R_IAUPDATE_MESSAGE_QUERY );
       
   233 
       
   234 	HBufC* title = StringLoader::LoadLC( R_IAUPDATE_STATUS_DIALOG_TITLE );
       
   235 	CAknPopupHeadingPane* headingPane = dlg->Heading();
       
   236 	headingPane->SetTextL( *title );
       
   237 	CleanupStack::PopAndDestroy( title );
       
   238 
       
   239 	TCallBack LinkCallback( HandleLink, this );
       
   240 	dlg->SetLink( LinkCallback );
       
   241 	
       
   242 	return ( dlg->RunLD() );
       
   243 	}
       
   244 
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CIAUpdateStatusDialog::HandleLink
       
   248 //
       
   249 // Used as a callback function in message query.
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 TInt CIAUpdateStatusDialog::HandleLink( TAny* aPtr )
       
   253     {
       
   254     TInt err = KErrNone;
       
   255         
       
   256     CIAUpdateStatusDialog* self = static_cast<CIAUpdateStatusDialog*>(aPtr);
       
   257     
       
   258     TRAP( err, self->HandleLinkL() );
       
   259     return err;    
       
   260     }
       
   261 
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CIAUpdateStatusDialog::HandleLink
       
   265 //
       
   266 // Used as a callback function in message query.
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CIAUpdateStatusDialog::HandleLinkL()
       
   270     {
       
   271     if ( iParam->iLinkObserver )
       
   272         {
       
   273         iParam->iLinkObserver->TextLinkL( 0 );
       
   274         }
       
   275     }
       
   276 
       
   277     
       
   278 //  End of File