applicationmanagement/server/src/amwaitprogdialog.cpp
changeset 42 aa33c2cb9a50
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
       
     1 /*
       
     2  * Copyright (c) 2000 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 of applicationmanagement components
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #include <apgtask.h>
       
    20 #include <hbaction.h>
       
    21 #include <eikenv.h>
       
    22 #include <hblabel.h>
       
    23 #include <dmindicatorconsts.h>
       
    24 #include "amwaitprogdialog.h"
       
    25 #include "ApplicationManagementServer.h"
       
    26 
       
    27 using namespace NApplicationManagement;
       
    28 
       
    29 // ------------------------------------------------------------------------------------------------
       
    30 // AMWaitProgDialog::AMWaitProgDialog()
       
    31 // ------------------------------------------------------------------------------------------------
       
    32 AMWaitProgDialog::AMWaitProgDialog(QString aAppName, MInstallerCallBack& aCallback)
       
    33 :mDlg(0),m_callback(aCallback)
       
    34     {
       
    35     mIndi = 0;
       
    36     m_appname = aAppName;
       
    37     }
       
    38 // ------------------------------------------------------------------------------------------------
       
    39 // AMWaitProgDialog::~AMWaitProgDialog
       
    40 // ------------------------------------------------------------------------------------------------
       
    41 AMWaitProgDialog::~AMWaitProgDialog()
       
    42     {
       
    43     if(mDlg)
       
    44         {
       
    45         delete mDlg;
       
    46         mDlg=NULL;
       
    47         }
       
    48     if(mIndi)
       
    49         {
       
    50         delete mIndi;
       
    51         mIndi = NULL;
       
    52         }
       
    53     }
       
    54 // ------------------------------------------------------------------------------------------------
       
    55 // AMWaitProgDialog::createWaitDialog
       
    56 // ------------------------------------------------------------------------------------------------
       
    57 void AMWaitProgDialog::createWaitDialog(TInt aType)
       
    58     {
       
    59     mType = aType;
       
    60     if(mDlg==NULL)
       
    61         {
       
    62         mDlg = new HbProgressDialog(HbProgressDialog::WaitDialog);
       
    63         CApplicationManagementUtility::mCurrDlg=mDlg;
       
    64         }
       
    65     if (aType == EInstallWaitDlg)
       
    66         {
       
    67         //installing wait dialog
       
    68         mDlg->setHeadingWidget(new HbLabel(hbTrId(
       
    69                 "txt_device_update_title_installing")));
       
    70         mDlg->setText(hbTrId("txt_deviceupdate_info_file_1_2").arg(m_appname));
       
    71         QString val = hbTrId("txt_common_button_hide");
       
    72         HbAction* hide = new HbAction(mDlg);
       
    73         hide->setText(val);
       
    74         mDlg->clearActions();
       
    75         mDlg->addAction(hide);
       
    76         val = hbTrId("txt_common_button_cancel");
       
    77         HbAction* cancel = new HbAction(mDlg);
       
    78         cancel->setText(val);
       
    79         mDlg->addAction(cancel);
       
    80         QObject::connect(hide, SIGNAL(triggered()), this,
       
    81                 SLOT(hideAMWaitDialog()));
       
    82         QObject::connect(cancel, SIGNAL(triggered()), this,
       
    83                 SLOT(cancelWaitDialog()));
       
    84         
       
    85         mDlg->show();
       
    86         }
       
    87     else
       
    88         {
       
    89         //uninstalling wait dialog
       
    90     mDlg->setHeadingWidget(new HbLabel(hbTrId(
       
    91                 "txt_device_update_title_removing")));
       
    92     mDlg->setText(hbTrId("txt_deviceupdate_info_application_1").arg(m_appname));
       
    93         QString val = hbTrId("txt_common_button_hide");
       
    94         HbAction* hide = new HbAction();
       
    95         hide->setText(val);
       
    96         mDlg->clearActions();
       
    97         mDlg->addAction(hide);
       
    98         val = hbTrId("txt_common_button_cancel");
       
    99         QObject::connect(hide, SIGNAL(triggered()), this,
       
   100                 SLOT(hideAMWaitDialog()));
       
   101         mDlg->setAttribute(Qt::WA_DeleteOnClose, true);
       
   102         mDlg->show();
       
   103         }
       
   104     }
       
   105 
       
   106 // ------------------------------------------------------------------------------------------------
       
   107 // AMWaitProgDialog::startIndicator()
       
   108 // ------------------------------------------------------------------------------------------------
       
   109 void AMWaitProgDialog::startIndicator()
       
   110         {
       
   111     CApplicationManagementUtility::mHidden = 1;
       
   112     mIndi = new HbIndicator();
       
   113     if (mType == EInstallWaitDlg)
       
   114         {
       
   115         QString str(hbTrId("txt_device_update_title_installing"));
       
   116         mIndi->activate(KScomoProgressIndicatorType, str);
       
   117         }
       
   118     else
       
   119         {
       
   120         QString str(hbTrId("txt_device_update_title_removing"));
       
   121         mIndi->activate(KScomoProgressIndicatorType, str);
       
   122         }
       
   123     }
       
   124 
       
   125 // ------------------------------------------------------------------------------------------------
       
   126 // AMWaitProgDialog::closeAMWaitDialog()
       
   127 // ------------------------------------------------------------------------------------------------
       
   128 void AMWaitProgDialog::closeAMWaitDialog()
       
   129     {
       
   130     CApplicationManagementUtility::mCurrDlg=0;
       
   131     if(mDlg)
       
   132         {
       
   133     mDlg->close();       
       
   134         }
       
   135     if(mIndi)
       
   136         {
       
   137         mIndi->deactivate(KScomoProgressIndicatorType);
       
   138         }
       
   139     }
       
   140 
       
   141 // ------------------------------------------------------------------------------------------------
       
   142 // AMWaitProgDialog::hideAMWaitDialog()
       
   143 // ------------------------------------------------------------------------------------------------
       
   144 void AMWaitProgDialog::hideAMWaitDialog()
       
   145     {
       
   146     CCoeEnv* coe = CCoeEnv::Static();
       
   147     TApaTaskList taskList(coe->WsSession());
       
   148         TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
       
   149         if(task.Exists())
       
   150             {
       
   151             task.SendToBackground();
       
   152             }
       
   153         startIndicator();
       
   154     }
       
   155 
       
   156 // ------------------------------------------------------------------------------------------------
       
   157 // AMWaitProgDialog::cancelDialog()
       
   158 // ------------------------------------------------------------------------------------------------
       
   159 void AMWaitProgDialog::cancelWaitDialog()
       
   160     {
       
   161     //mInstaller.CancelOperation();
       
   162     m_callback.InstallationCancelled();
       
   163     closeAMWaitDialog();
       
   164     CCoeEnv* coe = CCoeEnv::Static();
       
   165     TApaTaskList taskList(coe->WsSession());
       
   166     TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));  
       
   167     if(task.Exists())
       
   168         {
       
   169         task.SendToBackground();
       
   170         }
       
   171     CApplicationManagementUtility::mCurrDlg=0;
       
   172     }
       
   173 
       
   174 // ------------------------------------------------------------------------------------------------
       
   175 // AMWaitProgDialog::registerInstallRequest
       
   176 // ------------------------------------------------------------------------------------------------
       
   177 void AMWaitProgDialog::registerInstallRequest(TRequestStatus &stat)
       
   178     {
       
   179     //mInstaller = aInstaller;
       
   180     m_Stat = &stat;
       
   181     }