applicationmanagement/server/inc/appmgmtdownloadmgr.h
author hgs
Tue, 13 Jul 2010 04:01:20 +0530
changeset 47 d316aecb87fd
child 52 6e38e48ee756
permissions -rw-r--r--
201025_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     1
/*
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     8
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    11
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    12
 * Contributors:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    13
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    14
 * Description: Implementation of applicationmanagement components
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    15
 *
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    16
 */
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    17
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    18
#include <QObject>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    19
#include <qtimeline.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    20
#include <QTimer>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    21
#include <QWidget>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    22
#include <hbcombobox.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    23
#include <downloadevent.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    24
#include <downloadmanager.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    25
#include <hbdocumentloader.h>
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    26
#include "appmgmtprogdialog.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    27
#include "AMDeploymentComponent.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    28
#include "appmgmtnotifier.h"
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    29
#define  KOmaDMAppUid   0x101F6DE5
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    30
const TReal KSizeDivisor = 1024.0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    31
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    32
const TUint32 KDownloadActive = 0x0000008;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    33
enum TDriveSize
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    34
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    35
    EKb = -1,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    36
    EMb = 0,
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    37
    EGb = 1
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    38
    };
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    39
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    40
using namespace WRT;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    41
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    42
namespace NApplicationManagement
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    43
    {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    44
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    45
    class MDownloadMgrQTCallback
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    46
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    47
    public:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    48
        virtual void DownloadCompleted()=0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    49
        virtual void DownloadFailed(TInt aDownloaderr)=0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    50
        virtual void SetStatus(TInt aStatus)=0;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    51
        };
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    52
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    53
    class CDialogWait : public CActive
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    54
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    55
    public:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    56
        static CDialogWait* NewL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    57
        CDialogWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    58
        void ConstructL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    59
        ~CDialogWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    60
        void StartWait();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    61
        void Stop();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    62
    protected:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    63
        void DoCancel();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    64
        void RunL();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    65
        TInt RunError(TInt aError);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    66
    private:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    67
        CActiveSchedulerWait* iWait;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    68
        };
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    69
    
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    70
    class appmgmtdownloadmgr : public QWidget
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    71
        {
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    72
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    73
    Q_OBJECT
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    74
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    75
    public:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    76
        appmgmtdownloadmgr(QWidget* parent, MDownloadMgrQTCallback& wrapper, TRequestStatus& aStatus);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    77
        ~appmgmtdownloadmgr();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    78
        
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    79
        void startDownload(CDeploymentComponent *aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    80
        void showDialog(CDeploymentComponent *aComponent);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    81
        void showUninstallDialog(const CDeploymentComponent &aCompo, TRequestStatus &s);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    82
        void updateProgress(TInt32 aDownloadedSize, TInt32 aContentSize);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    83
        void closeProgress();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    84
        void setUri();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    85
        void getUri();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    86
        void setState();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    87
        void getState();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    88
        void MimeType(QString& aMimeType);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    89
        void FileName(QString& afilename);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    90
	  void SetMimeType();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    91
        void sendSrvToBg();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    92
        QString convertSize();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    93
        int currDwnldStatForGenericAlert(int dwnldstatus);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    94
        
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    95
    public slots:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    96
        bool downloadMgrEventRecieved(DownloadManagerEvent *event);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    97
        bool downloadEventRecieved(DownloadEvent *event);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    98
        void dialogSlot(HbAction*);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
    99
        void defaultDriveChanged(int);
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   100
    private:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   101
        void getAvailableDrives();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   102
        void showInstalltoDialog();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   103
        void showDownloadDialog();
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   104
    private:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   105
        QStringList m_drivList;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   106
        QString m_appName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   107
        HbAction* mOkButton;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   108
        HbAction* mCancel;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   109
        QString mSize;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   110
        QString mSizeFormat;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   111
        QString mNotifierdata, mDialogData;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   112
        QString m_sizeStr;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   113
        QString m_mimetype;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   114
        HbComboBox* mDriveBox;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   115
        HbDialog* mDialog;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   116
    public:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   117
        // Functions from base classes
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   118
        TBuf<256> drilist;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   119
        DownloadManager* iDownloadManager;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   120
        Download* iDl;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   121
        int m_inProgress;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   122
        int m_currentDownloadedSize;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   123
        int m_totalSize;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   124
        CDialogWait* iWait;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   125
        TUint32 iProgStarted;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   126
        TUint32 iSetFinalValue;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   127
		int m_downloadStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   128
        AppMgmtProgDialog *iProgressNote;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   129
        TDownloadTarget iOperationType;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   130
    private:
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   131
        // Data
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   132
        MDownloadMgrQTCallback& m_callback;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   133
        CDeploymentComponent* iComp;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   134
        HBufC *iFileName;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   135
        HBufC8 *iContentType;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   136
        HBufC8 *iURI;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   137
        TBool iProgressCancelled;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   138
        TBool iDialogAccepted;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   139
        TRequestStatus& iStatus;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   140
        AppMgmtNotifier* mNote;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   141
        int mEndReported;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   142
        int mNetworkLoss;
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   143
        };
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   144
d316aecb87fd 201025_02
hgs
parents:
diff changeset
   145
    }