utilities/downloadmanager/inc/backgrounddownload.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 BACKGROUNDDOWNLOAD_H
hgs
parents:
diff changeset
    18
#define BACKGROUNDDOWNLOAD_H
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "download.h"
hgs
parents:
diff changeset
    21
#include "dmcommon.h"
hgs
parents:
diff changeset
    22
#include "dmpimpl.h"
hgs
parents:
diff changeset
    23
#include <QObject>
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
class DownloadManager;
hgs
parents:
diff changeset
    26
class BackgroundDownloadManager;
hgs
parents:
diff changeset
    27
class BackgroundDownloadPrivate;
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
typedef QList<QObject*> EventReceiverList;
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
// class declaration
hgs
parents:
diff changeset
    32
class BackgroundDownload : public Download
hgs
parents:
diff changeset
    33
{
hgs
parents:
diff changeset
    34
    Q_OBJECT
hgs
parents:
diff changeset
    35
    DM_DECLARE_PRIVATE(BackgroundDownload);
hgs
parents:
diff changeset
    36
public:
hgs
parents:
diff changeset
    37
    BackgroundDownload(DownloadManager* mgr, const QString& url, int dlId);
hgs
parents:
diff changeset
    38
    virtual ~BackgroundDownload();
hgs
parents:
diff changeset
    39
hgs
parents:
diff changeset
    40
    // starts the download
hgs
parents:
diff changeset
    41
    int start();
hgs
parents:
diff changeset
    42
    // id of the download
hgs
parents:
diff changeset
    43
    int id();
hgs
parents:
diff changeset
    44
    // sets the attributes for the download
hgs
parents:
diff changeset
    45
    int setAttribute(DownloadAttribute attr, const QVariant& value);
hgs
parents:
diff changeset
    46
    // fetches the attributes of download
hgs
parents:
diff changeset
    47
    QVariant getAttribute(DownloadAttribute attr);
hgs
parents:
diff changeset
    48
    // pauses the download
hgs
parents:
diff changeset
    49
    int pause();
hgs
parents:
diff changeset
    50
    // resumes the download
hgs
parents:
diff changeset
    51
    int resume();
hgs
parents:
diff changeset
    52
    // cancels the download
hgs
parents:
diff changeset
    53
    int cancel();
hgs
parents:
diff changeset
    54
    // registers the event listener
hgs
parents:
diff changeset
    55
    void registerEventReceiver(QObject *receiver);
hgs
parents:
diff changeset
    56
    // unregisters the event listener
hgs
parents:
diff changeset
    57
    void unregisterEventReceiver(QObject *receiver);
hgs
parents:
diff changeset
    58
    // returns the download manager
hgs
parents:
diff changeset
    59
    DownloadManager* downloadManager();
hgs
parents:
diff changeset
    60
    // returns the list of child downloads
hgs
parents:
diff changeset
    61
    void getChildren(QList<Download*>& list);
hgs
parents:
diff changeset
    62
    // posts the event to recievers event loop
hgs
parents:
diff changeset
    63
    void postEvent(DEventType type, DlEventAttributeMap* attrMap);
hgs
parents:
diff changeset
    64
    // remove info of this download
hgs
parents:
diff changeset
    65
    void removeDownloadInfo();
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
private: // copy constructor and assaignment operator
hgs
parents:
diff changeset
    68
    BackgroundDownload(const BackgroundDownload &);
hgs
parents:
diff changeset
    69
    BackgroundDownload &operator=(const BackgroundDownload &);
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
    // returns the event listeners
hgs
parents:
diff changeset
    72
    EventReceiverList& eventReceivers();
hgs
parents:
diff changeset
    73
};
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
#endif