utilities/downloadmanager/inc/oma2downloadbackend.h
author hgs
Fri, 15 Oct 2010 17:30:59 -0400
changeset 16 3c88a81ff781
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16
hgs
parents:
diff changeset
     1
/**
hgs
parents:
diff changeset
     2
   This file is part of CWRT package **
hgs
parents:
diff changeset
     3
hgs
parents:
diff changeset
     4
   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
hgs
parents:
diff changeset
     5
hgs
parents:
diff changeset
     6
   This program is free software: you can redistribute it and/or modify
hgs
parents:
diff changeset
     7
   it under the terms of the GNU (Lesser) General Public License as 
hgs
parents:
diff changeset
     8
   published by the Free Software Foundation, version 2.1 of the License. 
hgs
parents:
diff changeset
     9
   This program is distributed in the hope that it will be useful, but
hgs
parents:
diff changeset
    10
   WITHOUT ANY WARRANTY; without even the implied warranty of 
hgs
parents:
diff changeset
    11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
hgs
parents:
diff changeset
    12
   (Lesser) General Public License for more details. You should have 
hgs
parents:
diff changeset
    13
   received a copy of the GNU (Lesser) General Public License along 
hgs
parents:
diff changeset
    14
   with this program. If not, see <http://www.gnu.org/licenses/>.
hgs
parents:
diff changeset
    15
*/
hgs
parents:
diff changeset
    16
hgs
parents:
diff changeset
    17
#ifndef OMA2DOWNLOADBACKEND_H
hgs
parents:
diff changeset
    18
#define OMA2DOWNLOADBACKEND_H
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "dmcommon.h"
hgs
parents:
diff changeset
    21
#include "dmcommoninternal.h"
hgs
parents:
diff changeset
    22
#include "dmpimpl.h"
hgs
parents:
diff changeset
    23
#include "downloadbackend.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
// forward declarations
hgs
parents:
diff changeset
    26
class OMA2DownloadBackendPrivate;
hgs
parents:
diff changeset
    27
class DownloadCore;
hgs
parents:
diff changeset
    28
class ClientDownload;
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
typedef QList<ClientDownload*> MediaDownloadList;
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
// class declaration
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
// concrete download implementation for OMA2 downloads
hgs
parents:
diff changeset
    35
class OMA2DownloadBackend : public DownloadBackend
hgs
parents:
diff changeset
    36
{
hgs
parents:
diff changeset
    37
    Q_OBJECT
hgs
parents:
diff changeset
    38
    DM_DECLARE_PRIVATE(OMA2DownloadBackend); // private implementation
hgs
parents:
diff changeset
    39
public:
hgs
parents:
diff changeset
    40
    OMA2DownloadBackend(DownloadCore *dlCore, ClientDownload *dl);
hgs
parents:
diff changeset
    41
    ~OMA2DownloadBackend();
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
    // fetches the oma2 download attributes
hgs
parents:
diff changeset
    44
    QVariant getAttribute(DownloadAttribute attr);
hgs
parents:
diff changeset
    45
    // sets the oma2 download specific attributes
hgs
parents:
diff changeset
    46
    int setAttribute(DownloadAttribute attr, const QVariant& value);
hgs
parents:
diff changeset
    47
    // overloaded function for pausing the download
hgs
parents:
diff changeset
    48
    int pause();
hgs
parents:
diff changeset
    49
    // overloaded function for resuming paused download
hgs
parents:
diff changeset
    50
    int resume();
hgs
parents:
diff changeset
    51
    // overloaded function for cancelling the download
hgs
parents:
diff changeset
    52
    int cancel();
hgs
parents:
diff changeset
    53
    // overloaded function for getting child downloads
hgs
parents:
diff changeset
    54
    void getChildren(QList<Download*>& list);
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
    // stores the data in storage
hgs
parents:
diff changeset
    57
    void store(QByteArray data, bool lastChunk=false);
hgs
parents:
diff changeset
    58
    // deletes the storage
hgs
parents:
diff changeset
    59
    void deleteStore();
hgs
parents:
diff changeset
    60
    // returns the size of stored data
hgs
parents:
diff changeset
    61
    qint64 storedDataSize();
hgs
parents:
diff changeset
    62
    // re-constructing all the values as part of persistent storage
hgs
parents:
diff changeset
    63
    void init();
hgs
parents:
diff changeset
    64
hgs
parents:
diff changeset
    65
hgs
parents:
diff changeset
    66
private slots:
hgs
parents:
diff changeset
    67
    void bytesRecieved(qint64 bytesRecieved, qint64 bytesTotal);
hgs
parents:
diff changeset
    68
    void handleFinished();    
hgs
parents:
diff changeset
    69
    void bytesUploaded(qint64, qint64); 
hgs
parents:
diff changeset
    70
private:
hgs
parents:
diff changeset
    71
    // parses download descriptor
hgs
parents:
diff changeset
    72
    bool parseDownloadDescriptor();
hgs
parents:
diff changeset
    73
    // does the capability check on receiving DD
hgs
parents:
diff changeset
    74
    bool checkDownloadDescriptor();
hgs
parents:
diff changeset
    75
    // event handler
hgs
parents:
diff changeset
    76
    bool event(QEvent *event);
hgs
parents:
diff changeset
    77
    // suppress user confirmation
hgs
parents:
diff changeset
    78
    bool suppressUserConfirmation();
hgs
parents:
diff changeset
    79
    // handle status code
hgs
parents:
diff changeset
    80
    void handleStatusCode(const int& statusCode);
hgs
parents:
diff changeset
    81
    // handle precondition failed
hgs
parents:
diff changeset
    82
    void handlePreconditionFailed();
hgs
parents:
diff changeset
    83
    // adds the downloads to downloadList
hgs
parents:
diff changeset
    84
    void addtoDownloadList(ClientDownload *dl);
hgs
parents:
diff changeset
    85
    // finds the download for the given id
hgs
parents:
diff changeset
    86
    ClientDownload* findDownload(int id);
hgs
parents:
diff changeset
    87
    // posting the install notify event to the web server
hgs
parents:
diff changeset
    88
    void postInstallNotifyEvent(const char* statusMessage);
hgs
parents:
diff changeset
    89
    // verifying downloads by going through the MediaObject map and setting OMA2'S state at the end.
hgs
parents:
diff changeset
    90
    void verifyDownloads();
hgs
parents:
diff changeset
    91
    // returns current MediaObject index
hgs
parents:
diff changeset
    92
    int currentIndex();
hgs
parents:
diff changeset
    93
    // setting values in QSettings for persistent storage
hgs
parents:
diff changeset
    94
    void serializeData(ClientDownload* dl, int index);
hgs
parents:
diff changeset
    95
};
hgs
parents:
diff changeset
    96
hgs
parents:
diff changeset
    97
#endif