applicationmanagement/server/src/AppMgmtProgDialog.cpp
branchRCL_3
changeset 58 5b858729772b
parent 57 6757f1e2efd2
equal deleted inserted replaced
57:6757f1e2efd2 58:5b858729772b
     1 /*
     1 /*
     2  * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
     8  *
    13  *
     9  * Initial Contributors:
    14  * Description:  Implementation of applicationmanagement components
    10  * Nokia Corporation - initial contribution.
       
    11  *
    15  *
    12  * Contributors:
    16 */
    13  *
    17 #include "AppMgmtProgDialog.h"
    14  * Description: Implementation of downloading progress note
    18 #include <avkon.rsg>
    15  *
    19 #include <applicationmanagement.rsg>
    16  */
    20 #include <eikenv.h>
       
    21 #include <aknnotewrappers.h>
       
    22 #include <avkon.hrh>
    17 
    23 
    18 #include <hblabel.h>
    24 CAppMgmtProgDialog::CAppMgmtProgDialog(MDLProgressDlgObserver *iCallback) :
    19 #include <hbaction.h>
    25     iDlgObserver(iCallback)
    20 #include <e32property.h>
    26     {
    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 
    27 
    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     }
    28     }
    42 
    29 
    43 // ------------------------------------------------------------------------------------------------
    30 CAppMgmtProgDialog::~CAppMgmtProgDialog()
    44 // AppMgmtProgDialog::~AppMgmtProgDialog()
       
    45 // ------------------------------------------------------------------------------------------------ 
       
    46 AppMgmtProgDialog::~AppMgmtProgDialog()
       
    47     {
    31     {
    48     if(m_Dlg)
    32     if (iProgressDialog)
    49         {
    33         {
    50         delete m_Dlg;
    34         delete iProgressDialog;
    51         m_Dlg=NULL;
    35         }
       
    36 
       
    37     }
       
    38 
       
    39 void CAppMgmtProgDialog::StartProgressNoteL()
       
    40     {
       
    41     iProgressDialog = new (ELeave) CAknProgressDialog(
       
    42             (REINTERPRET_CAST(CEikDialog**, &iProgressDialog)),
       
    43             ETrue);
       
    44     iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
       
    45     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
    46     iProgressDialog->SetCallback(this);
       
    47     iProgressDialog->RunLD();
       
    48     iProgressInfo->SetFinalValue(500);
       
    49 
       
    50     }
       
    51 
       
    52 void CAppMgmtProgDialog::UpdateProcessL(TInt aProgress)
       
    53     {
       
    54     if (iProgressInfo)
       
    55         {
       
    56         iProgressInfo->SetAndDraw(aProgress);
    52         }
    57         }
    53     }
    58     }
    54 
    59 
    55 // ------------------------------------------------------------------------------------------------
    60 void CAppMgmtProgDialog::ProgressCompletedL()
    56 // AppMgmtProgDialog::sendServerToBackground()
       
    57 // ------------------------------------------------------------------------------------------------ 
       
    58 void AppMgmtProgDialog::sendServerToBackground()
       
    59     {
    61     {
    60     CCoeEnv* coe = CCoeEnv::Static();
    62     if (iProgressDialog)
    61     TApaTaskList taskList(coe->WsSession());
       
    62     TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
       
    63     if(task.Exists())
       
    64         {
    63         {
    65         task.SendToBackground();
    64         iProgressDialog->ProcessFinishedL();
       
    65         }
       
    66 
       
    67     }
       
    68 
       
    69 void CAppMgmtProgDialog::SetFinalValueL(TInt32 aFinalValue)
       
    70     {
       
    71     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
    72     iProgressInfo-> SetFinalValue(aFinalValue);
       
    73     }
       
    74 
       
    75 void CAppMgmtProgDialog::DialogDismissedL(TInt aButtonId)
       
    76     {
       
    77 
       
    78     //|| aButtonId == EAknSoftkeyEmpty
       
    79     if (aButtonId == EAknSoftkeyCancel)
       
    80         {
       
    81 
       
    82         iDlgObserver->HandleDLProgressDialogExitL(aButtonId);
       
    83 
    66         }
    84         }
    67     }
    85     }
    68 
    86 
    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