applicationmanagement/server/src/appmgmtprogdialog.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 downloading progress note
       
    15  *
       
    16  */
       
    17 
       
    18 #include <hblabel.h>
       
    19 #include <hbaction.h>
       
    20 #include <e32property.h>
       
    21 #include <qapplication.h>
       
    22 #include <apgtask.h>
       
    23 #include <e32base.h>
       
    24 #include <eikenv.h>
       
    25 #include <dmindicatorconsts.h>
       
    26 #include "appmgmtdownloadmgr.h"
       
    27 #include "ApplicationManagementUtility.h"
       
    28 
       
    29 using namespace NApplicationManagement;
       
    30 
       
    31 // ------------------------------------------------------------------------------------------------
       
    32 // AppMgmtProgDialog::AppMgmtProgDialog
       
    33 // ------------------------------------------------------------------------------------------------ 
       
    34 AppMgmtProgDialog::AppMgmtProgDialog(QString aAppData, Download &mdl,int &aUserCancelled)
       
    35 :m_Dlg(0)
       
    36     {   
       
    37     m_Data=aAppData;
       
    38     iDl=&mdl;
       
    39     mUsrCancel = aUserCancelled;
       
    40     m_Indi = 0;
       
    41     }
       
    42 
       
    43 // ------------------------------------------------------------------------------------------------
       
    44 // AppMgmtProgDialog::~AppMgmtProgDialog()
       
    45 // ------------------------------------------------------------------------------------------------ 
       
    46 AppMgmtProgDialog::~AppMgmtProgDialog()
       
    47     {
       
    48     if(m_Dlg)
       
    49         {
       
    50         delete m_Dlg;
       
    51         m_Dlg=NULL;
       
    52         }
       
    53     }
       
    54 
       
    55 // ------------------------------------------------------------------------------------------------
       
    56 // AppMgmtProgDialog::sendServerToBackground()
       
    57 // ------------------------------------------------------------------------------------------------ 
       
    58 void AppMgmtProgDialog::sendServerToBackground()
       
    59     {
       
    60     CCoeEnv* coe = CCoeEnv::Static();
       
    61     TApaTaskList taskList(coe->WsSession());
       
    62     TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
       
    63     if(task.Exists())
       
    64         {
       
    65         task.SendToBackground();
       
    66         }
       
    67     }
       
    68 
       
    69 // ------------------------------------------------------------------------------------------------
       
    70 // AppMgmtProgDialog::startDialog
       
    71 // ------------------------------------------------------------------------------------------------ 
       
    72 void AppMgmtProgDialog::startDialog(int aContentSize,int aDownloaded)
       
    73     {
       
    74     if (m_Dlg == NULL)
       
    75         {
       
    76         m_Dlg = new HbProgressDialog(HbProgressDialog::ProgressDialog);
       
    77         CApplicationManagementUtility::mCurrDlg = m_Dlg;
       
    78         QStringList strList = m_Data.split(",");
       
    79         m_Name = strList[0];
       
    80         m_SizeStr = strList[1];
       
    81         }
       
    82     m_Dlg->setMinimum(0);
       
    83     m_Dlg->setMaximum(aContentSize);
       
    84 
       
    85     m_Dlg->setAutoClose(true);
       
    86     m_Dlg->setProgressValue(aDownloaded);
       
    87 
       
    88     QString val = hbTrId("txt_device_update_title_downloading");
       
    89     m_Dlg->setHeadingWidget(new HbLabel(val));
       
    90 
       
    91     val = hbTrId("txt_deviceupdate_info_file_1_2").arg(m_Name);
       
    92     val.append("\n");
       
    93     val.append(m_SizeStr);
       
    94 
       
    95     m_Dlg->setText(val);
       
    96     val = hbTrId("txt_common_button_hide");
       
    97     HbAction* hide = new HbAction();
       
    98     hide->setText(val);
       
    99     m_Dlg->clearActions();
       
   100     m_Dlg->addAction(hide);
       
   101     val = hbTrId("txt_common_button_cancel");
       
   102     HbAction* cancel = new HbAction();
       
   103     cancel->setText(val);
       
   104     m_Dlg->addAction(cancel);
       
   105     QObject::connect(hide, SIGNAL(triggered()), this,
       
   106             SLOT(hideAMProgDialog()));
       
   107     QObject::connect(cancel, SIGNAL(triggered()), this, SLOT(cancelDialog()));
       
   108     m_Dlg->show();
       
   109     }
       
   110 
       
   111 // ------------------------------------------------------------------------------------------------
       
   112 // AppMgmtProgDialog::closeAMProgDialog()
       
   113 // ------------------------------------------------------------------------------------------------ 
       
   114 void AppMgmtProgDialog::closeAMProgDialog()
       
   115     {    
       
   116     CApplicationManagementUtility::mCurrDlg=0;
       
   117     if(m_Dlg)
       
   118         {
       
   119         m_Dlg->close();
       
   120         }
       
   121     if(CApplicationManagementUtility::mHidden==0)
       
   122         {
       
   123         sendServerToBackground();
       
   124         }
       
   125     else
       
   126         {
       
   127         m_Indi->deactivate(KScomoProgressIndicatorType);   
       
   128         }
       
   129     }
       
   130 
       
   131 // ------------------------------------------------------------------------------------------------
       
   132 // AppMgmtProgDialog::cancelDialog()
       
   133 // ------------------------------------------------------------------------------------------------ 
       
   134 void AppMgmtProgDialog::cancelDialog()
       
   135     {
       
   136     mUsrCancel = 1;
       
   137     iDl->cancel();
       
   138     if(m_Dlg)
       
   139         {
       
   140         m_Dlg->close();
       
   141         }
       
   142     sendServerToBackground();
       
   143     CApplicationManagementUtility::mCurrDlg=0;
       
   144     }
       
   145 
       
   146 // ------------------------------------------------------------------------------------------------
       
   147 // AppMgmtProgDialog::hideAMProgDialog()
       
   148 // ------------------------------------------------------------------------------------------------ 
       
   149 void AppMgmtProgDialog::hideAMProgDialog()
       
   150     {
       
   151     sendServerToBackground();
       
   152     
       
   153     QString str = hbTrId("txt_device_update_dblist_product_code_val_download").arg(m_Name);
       
   154     CApplicationManagementUtility::mHidden=1;
       
   155     m_Indi = new HbIndicator();
       
   156     m_Indi->activate(KScomoProgressIndicatorType,str);
       
   157     }
       
   158 
       
   159 // ------------------------------------------------------------------------------------------------
       
   160 // AppMgmtProgDialog::updateProgress
       
   161 // ------------------------------------------------------------------------------------------------ 
       
   162 void AppMgmtProgDialog::updateProgress(int aProgress)
       
   163     {
       
   164     if(m_Dlg)
       
   165         {
       
   166         m_Dlg->setProgressValue(aProgress);       
       
   167         }
       
   168     }
       
   169