iaupdate/IAD/ui/src/iaupdatedialogutil.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   This module contains the implementation of IAUpdateDialogUtil class 
    14 * Description:    
    15 *                member functions.
       
    16 *
    15 *
    17 */
    16 */
    18 #include <hblabel.h>
       
    19 #include <hbmessagebox.h>
       
    20 
       
    21 #include "iaupdatedialogutil.h"
       
    22 #include "iaupdatedialogobserver.h"
       
    23 #include "iaupdatedebug.h"
       
    24 
    17 
    25 
    18 
    26 
    19 
    27 IAUpdateDialogUtil::IAUpdateDialogUtil(QObject *parent, IAUpdateDialogObserver *observer)
    20 // INCLUDE FILES
    28 : QObject(parent),
       
    29   mObserver(observer)
       
    30 {
       
    31     IAUPDATE_TRACE("[IAUPDATE] IAUpdateDialogUtil::IAUpdateDialogUtil()");
       
    32 }
       
    33 
    21 
    34 IAUpdateDialogUtil::~IAUpdateDialogUtil()
    22 #include "iaupdatedialogutil.h"
    35 {
    23 #include "iaupdatedebug.h"
    36     IAUPDATE_TRACE("[IAUPDATE] IAUpdateDialogUtil::~IAUpdateDialogUtil()");
    24 #include <iaupdate.rsg>
    37 }
    25 
       
    26 #include <aknmessagequerydialog.h>      // CAknMessageQueryDialog
       
    27 #include <aknnotewrappers.h>    // CAknInformationNote
       
    28 #include <StringLoader.h>
    38 
    29 
    39 
    30 
    40 void IAUpdateDialogUtil::showInformation(const QString &text, HbAction *primaryAction)
    31 /*******************************************************************************
    41 {    
    32  * class TIAUpdateDialogParam
    42     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation); 
    33  *******************************************************************************/
    43     messageBox->setText(text);
       
    44     int actionCount = messageBox->actions().count();
       
    45     for (int i=actionCount-1; i >= 0; i--)
       
    46     { 
       
    47         messageBox->removeAction(messageBox->actions().at(i));
       
    48     }
       
    49     if (primaryAction)
       
    50     {    
       
    51         messageBox->addAction(primaryAction);
       
    52     }  
       
    53     messageBox->setTimeout(HbPopup::NoTimeout); 
       
    54     messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
    55     messageBox->open(this,SLOT(finished(HbAction*)));
       
    56 }
       
    57 
    34 
    58 
    35 
    59 void IAUpdateDialogUtil::showQuestion(const QString &text, HbAction *primaryAction, HbAction *secondaryAction)
    36 // -------------------------------------------------------------------------------
    60 {
    37 // TIAUpdateDialogParam::TIAUpdateDialogParam
    61     HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); 
    38 //
    62     messageBox->setIconVisible(false);
    39 // -------------------------------------------------------------------------------
    63     messageBox->setText(text);
    40 //
    64     int actionCount = messageBox->actions().count();
    41 TIAUpdateDialogParam::TIAUpdateDialogParam()
    65     for (int i=actionCount-1; i >= 0; i--)
    42  : iCountSuccessfull( KErrNotFound ), iCountCancelled( KErrNotFound ),
    66     { 
    43    iCountFailed( KErrNotFound ), iResourceId( KErrNotFound ), iNode( NULL ), 
    67         messageBox->removeAction(messageBox->actions().at(i));
    44    iLinkObserver( NULL )
       
    45     {
    68     }
    46     }
    69     if (primaryAction)
       
    70     {    
       
    71         messageBox->addAction(primaryAction);
       
    72     }
       
    73     if (secondaryAction)
       
    74     {    
       
    75         messageBox->addAction(secondaryAction);
       
    76     } 
       
    77     messageBox->setTimeout(HbPopup::NoTimeout); 
       
    78     messageBox->setAttribute(Qt::WA_DeleteOnClose);
       
    79     messageBox->open(this,SLOT(finished(HbAction*)));
       
    80 }
       
    81 
    47 
    82 
    48 
    83 void IAUpdateDialogUtil::showAgreement(HbAction *primaryAction, HbAction *secondaryAction)
    49 /*******************************************************************************
    84 {
    50  * class IAUpdateDialogUtil
    85     HbMessageBox *agreementDialog = new HbMessageBox(HbMessageBox::MessageTypeQuestion); 
    51  *******************************************************************************/
    86     HbLabel *label = new HbLabel(agreementDialog);
       
    87     label->setHtml(QString("Disclaimer"));
       
    88     agreementDialog->setHeadingWidget(label);
       
    89     agreementDialog->setIconVisible(false);
       
    90     agreementDialog->setText("This application allows you to download and use applications and services provided by Nokia or third parties. Service Terms and Privacy Policy will apply. Nokia will not assume any liability or responsibility for the availability or third party applications or services. Before using the third party application or service, read the applicable terms of use.<br /><br />Use of this application involves transmission of data. Contact your network service provider for information about data transmission charges.<br /><br />(c) 2007-2010 Nokia. All rights reserved.");
       
    91 
       
    92     int actionCount = agreementDialog->actions().count();
       
    93     for (int i=actionCount-1; i >= 0; i--)
       
    94     { 
       
    95         agreementDialog->removeAction(agreementDialog->actions().at(i));
       
    96     }
       
    97     if (primaryAction)
       
    98     {    
       
    99         agreementDialog->addAction(primaryAction);
       
   100     }    
       
   101     if (secondaryAction)
       
   102     {
       
   103         agreementDialog->addAction(secondaryAction);
       
   104     }
       
   105     agreementDialog->setTimeout(HbPopup::NoTimeout);
       
   106     agreementDialog->setAttribute(Qt::WA_DeleteOnClose);
       
   107     agreementDialog->open(this,SLOT(finished(HbAction*)));
       
   108 }
       
   109 
    52 
   110 
    53 
       
    54 //------------------------------------------------------------------------------
       
    55 // IAUpdateDialogUtil::ShowMessageQueryL
       
    56 //
       
    57 //------------------------------------------------------------------------------
       
    58 //
       
    59 void IAUpdateDialogUtil::ShowMessageQueryL(const TDesC& aTitle, const TDesC& aText)
       
    60 	{
       
    61 	TPtrC ptr = aText;
       
    62 	CAknMessageQueryDialog* query = CAknMessageQueryDialog::NewL( ptr );
       
    63 	query->PrepareLC( R_IAUPDATE_MESSAGE_QUERY );
   111 
    64 
   112 void IAUpdateDialogUtil::finished(HbAction *action)
    65 	if ( aTitle.Length() != 0 )
   113 {
    66 		{
   114     if (mObserver)
    67 		CAknPopupHeadingPane* headingPane = query->Heading();
   115     {
    68 		headingPane->SetTextL( aTitle );
   116         mObserver->dialogFinished(action);
    69 		}
   117     }
    70 	query->RunLD();
   118 }
    71 	}
       
    72 
       
    73 
       
    74 //------------------------------------------------------------------------------
       
    75 // IAUpdateDialogUtil::ShowMessageQueryL
       
    76 //
       
    77 //------------------------------------------------------------------------------
       
    78 //
       
    79 void IAUpdateDialogUtil::ShowMessageQueryL( const TDesC& aTitle, TInt aResource )
       
    80 	{
       
    81 	HBufC* hBuf = StringLoader::LoadLC( aResource );
       
    82 	ShowMessageQueryL( aTitle, hBuf->Des() );
       
    83 	CleanupStack::PopAndDestroy( hBuf );
       
    84 	}
       
    85 
       
    86 
       
    87 //------------------------------------------------------------------------------
       
    88 // IAUpdateDialogUtil::ShowInformationQueryL
       
    89 //
       
    90 //------------------------------------------------------------------------------
       
    91 //
       
    92 void IAUpdateDialogUtil::ShowInformationQueryL(const TDesC& aText)
       
    93 	{
       
    94 	CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog;
       
    95 	queryDialog->ExecuteLD(R_IAUPDATE_INFORMATION_QUERY, aText);
       
    96 	}
       
    97 
       
    98 
       
    99 //------------------------------------------------------------------------------
       
   100 // IAUpdateDialogUtil::ShowInformationQueryL
       
   101 //
       
   102 //------------------------------------------------------------------------------
       
   103 //
       
   104 void IAUpdateDialogUtil::ShowInformationQueryL(TInt aResource)
       
   105 	{
       
   106 	HBufC* hBuf = StringLoader::LoadLC(aResource);
       
   107 	ShowInformationQueryL( hBuf->Des() );
       
   108 	CleanupStack::PopAndDestroy( hBuf );
       
   109 	}
       
   110 
       
   111 //------------------------------------------------------------------------------
       
   112 // IAUpdateDialogUtil::ShowConfirmationQueryL
       
   113 //
       
   114 //------------------------------------------------------------------------------
       
   115 //
       
   116 TInt IAUpdateDialogUtil::ShowConfirmationQueryL( const TDesC& aText, 
       
   117                                           TInt aSoftkeyResourceId )
       
   118 	{
       
   119 	CAknQueryDialog* queryDialog = CAknQueryDialog::NewL( 
       
   120 	                               CAknQueryDialog::EConfirmationTone );
       
   121 
       
   122     queryDialog->PrepareLC( R_IAUPDATE_CONFIRMATION_QUERY );
       
   123     queryDialog->SetPromptL( aText );
       
   124     queryDialog->ButtonGroupContainer().SetCommandSetL( aSoftkeyResourceId );
       
   125     return ( queryDialog->RunLD() );
       
   126 	}
       
   127 
       
   128 //------------------------------------------------------------------------------
       
   129 // IAUpdateDialogUtil::ShowConfirmationQueryL
       
   130 //
       
   131 //------------------------------------------------------------------------------
       
   132 //
       
   133 TInt IAUpdateDialogUtil::ShowConfirmationQueryL( TInt aResource, 
       
   134                                           TInt aSoftkeyResourceId )
       
   135 	{
       
   136 	HBufC* hBuf = StringLoader::LoadLC( aResource) ;
       
   137 	TInt ret = ShowConfirmationQueryL( *hBuf, aSoftkeyResourceId );
       
   138 	CleanupStack::PopAndDestroy( hBuf );
       
   139 	return ret;
       
   140 	}
   119 
   141 
   120 
   142 
   121 
   143 
   122 
   144 
   123 
   145 // -----------------------------------------------------------------------------
   124 
   146 // IAUpdateDialogUtil::Panic
       
   147 //
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void IAUpdateDialogUtil::Panic( TInt aReason ) 
       
   151     {
       
   152 	_LIT(KPanicCategory, "IAUpdateDialogUtil");
       
   153 	
       
   154 	User::Panic(KPanicCategory, aReason); 
       
   155     }
       
   156     
       
   157 //  End of File