utilities/downloadmanager/inc/downloadmanager.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 DOWNLOADMANAGER_H
hgs
parents:
diff changeset
    18
#define DOWNLOADMANAGER_H
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "dmcommon.h"
hgs
parents:
diff changeset
    21
#include "dmpimpl.h"
hgs
parents:
diff changeset
    22
#include "downloadevent.h"
hgs
parents:
diff changeset
    23
#include <QObject>
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
#ifndef DOWNLOAD_MGR_EXPORT
hgs
parents:
diff changeset
    26
# ifdef BUILD_DOWNLOAD_MGR_LIB
hgs
parents:
diff changeset
    27
#  define DOWNLOAD_MGR_EXPORT Q_DECL_EXPORT
hgs
parents:
diff changeset
    28
# else
hgs
parents:
diff changeset
    29
#  define DOWNLOAD_MGR_EXPORT Q_DECL_IMPORT
hgs
parents:
diff changeset
    30
# endif
hgs
parents:
diff changeset
    31
#endif
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
// forward declarations
hgs
parents:
diff changeset
    34
class Download;
hgs
parents:
diff changeset
    35
class QNetworkReply; 
hgs
parents:
diff changeset
    36
class QNetworkProxy;
hgs
parents:
diff changeset
    37
class DownloadInfo;
hgs
parents:
diff changeset
    38
class DownloadCoreManager;
hgs
parents:
diff changeset
    39
class BackgroundDownloadManager;
hgs
parents:
diff changeset
    40
class DownloadManagerPrivate;
hgs
parents:
diff changeset
    41
class SequentialDownloadManager;
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
// class declaration
hgs
parents:
diff changeset
    44
class DownloadManager
hgs
parents:
diff changeset
    45
{
hgs
parents:
diff changeset
    46
    DM_DECLARE_PRIVATE(DownloadManager); // private implementation
hgs
parents:
diff changeset
    47
public:
hgs
parents:
diff changeset
    48
    DOWNLOAD_MGR_EXPORT DownloadManager(const QString& clientName);
hgs
parents:
diff changeset
    49
    DOWNLOAD_MGR_EXPORT virtual ~DownloadManager();
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
    // to initialise all the downloads which belongs to last
hgs
parents:
diff changeset
    52
    // download manager session
hgs
parents:
diff changeset
    53
    DOWNLOAD_MGR_EXPORT void init();
hgs
parents:
diff changeset
    54
    // creates new download by passing url
hgs
parents:
diff changeset
    55
    DOWNLOAD_MGR_EXPORT Download* createDownload(const QString& url, DownloadType type = Parallel, DownloadScope scope = Normal);
hgs
parents:
diff changeset
    56
    // creates a download by passing network reply
hgs
parents:
diff changeset
    57
    DOWNLOAD_MGR_EXPORT Download* createDownload(QNetworkReply *reply);    
hgs
parents:
diff changeset
    58
    // sets the proxy
hgs
parents:
diff changeset
    59
    DOWNLOAD_MGR_EXPORT void setProxy(const QString& proxyServer, int port);
hgs
parents:
diff changeset
    60
    // registers event listener
hgs
parents:
diff changeset
    61
    DOWNLOAD_MGR_EXPORT void registerEventReceiver(QObject *receiver);
hgs
parents:
diff changeset
    62
    // unregister event listener
hgs
parents:
diff changeset
    63
    DOWNLOAD_MGR_EXPORT void unregisterEventReceiver(QObject *receiver);
hgs
parents:
diff changeset
    64
    // sets download manager attributes
hgs
parents:
diff changeset
    65
    DOWNLOAD_MGR_EXPORT int setAttribute(DownloadManagerAttribute attr, const QVariant& value);
hgs
parents:
diff changeset
    66
    // fetches download manager attributes
hgs
parents:
diff changeset
    67
    DOWNLOAD_MGR_EXPORT QVariant getAttribute(DownloadManagerAttribute attr);
hgs
parents:
diff changeset
    68
    // returns all the current downloads
hgs
parents:
diff changeset
    69
    DOWNLOAD_MGR_EXPORT QList<Download *>& currentDownloads();
hgs
parents:
diff changeset
    70
    // finds a download provided id if exists
hgs
parents:
diff changeset
    71
    DOWNLOAD_MGR_EXPORT Download* findDownload(int dlId);
hgs
parents:
diff changeset
    72
    // cancels all the downloads and removes from the list
hgs
parents:
diff changeset
    73
    DOWNLOAD_MGR_EXPORT void removeAll();
hgs
parents:
diff changeset
    74
    // cancels and removes the download from list
hgs
parents:
diff changeset
    75
    DOWNLOAD_MGR_EXPORT void removeOne(Download *dl);
hgs
parents:
diff changeset
    76
    // pauses all the downloads which are in progress
hgs
parents:
diff changeset
    77
    DOWNLOAD_MGR_EXPORT void pauseAll();
hgs
parents:
diff changeset
    78
    // resumes all the downloads which are paused
hgs
parents:
diff changeset
    79
    DOWNLOAD_MGR_EXPORT void resumeAll();
hgs
parents:
diff changeset
    80
    // returns the network proxy
hgs
parents:
diff changeset
    81
    DOWNLOAD_MGR_EXPORT QNetworkProxy* proxy();
hgs
parents:
diff changeset
    82
    
hgs
parents:
diff changeset
    83
    // returns downloadinfo object
hgs
parents:
diff changeset
    84
    DownloadInfo* downloadInfo();
hgs
parents:
diff changeset
    85
    // returns downloadcoremanager object
hgs
parents:
diff changeset
    86
    DownloadCoreManager* downloadCoreManager();
hgs
parents:
diff changeset
    87
    // returns sequentialmanager object
hgs
parents:
diff changeset
    88
    SequentialDownloadManager* sequentialManager();
hgs
parents:
diff changeset
    89
    // returns background download manager object
hgs
parents:
diff changeset
    90
    BackgroundDownloadManager* backgroundManager();
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
    // post the events
hgs
parents:
diff changeset
    93
    void postEvent(DEventType type, DlManagerEventAttributeMap* attrMap);
hgs
parents:
diff changeset
    94
hgs
parents:
diff changeset
    95
private:
hgs
parents:
diff changeset
    96
    // creates download by passing id
hgs
parents:
diff changeset
    97
    // used while loading the saved downloads
hgs
parents:
diff changeset
    98
    Download* createDownload(int dlId, DownloadScope scope);
hgs
parents:
diff changeset
    99
    // loads the saved downloads
hgs
parents:
diff changeset
   100
    void loadAllDownloads();
hgs
parents:
diff changeset
   101
    // generated unique id for download
hgs
parents:
diff changeset
   102
    long generateDlId();
hgs
parents:
diff changeset
   103
};
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
#endif