utilities/downloadmanager/inc/sequentialdownloadmanager.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 SEQUENTIALDOWNLOADMANAGER_H
hgs
parents:
diff changeset
    18
#define SEQUENTIALDOWNLOADMANAGER_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
#include <QQueue>
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
// forward declarations
hgs
parents:
diff changeset
    27
class ClientDownload;
hgs
parents:
diff changeset
    28
class QNetworkReply; 
hgs
parents:
diff changeset
    29
class SequentialDownloadManagerPrivate;
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
// class declaration
hgs
parents:
diff changeset
    32
class SequentialDownloadManager : public QObject
hgs
parents:
diff changeset
    33
{
hgs
parents:
diff changeset
    34
    DM_DECLARE_PRIVATE(SequentialDownloadManager); // private implementation
hgs
parents:
diff changeset
    35
public:
hgs
parents:
diff changeset
    36
    SequentialDownloadManager();
hgs
parents:
diff changeset
    37
    virtual ~SequentialDownloadManager();
hgs
parents:
diff changeset
    38
    
hgs
parents:
diff changeset
    39
    // returns all the current downloads
hgs
parents:
diff changeset
    40
    QList<Download *>& currentDownloads();
hgs
parents:
diff changeset
    41
    // finds a download provided id if exists
hgs
parents:
diff changeset
    42
    Download* findDownload(int dlId);
hgs
parents:
diff changeset
    43
    // cancels all the downloads and removes from the list
hgs
parents:
diff changeset
    44
    void removeAll();
hgs
parents:
diff changeset
    45
    // cancels and removes the download from list
hgs
parents:
diff changeset
    46
    void removeOne(Download *dl);
hgs
parents:
diff changeset
    47
    // pauses all the downloads which are in progress
hgs
parents:
diff changeset
    48
    void pauseAll();
hgs
parents:
diff changeset
    49
    // resumes all the downloads which are paused
hgs
parents:
diff changeset
    50
    void resumeAll();
hgs
parents:
diff changeset
    51
    // Adds to the download list
hgs
parents:
diff changeset
    52
    void addToSequentialDownload(Download* dl);
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
private:
hgs
parents:
diff changeset
    55
    // removes adownload from created download list to download queue for downloading
hgs
parents:
diff changeset
    56
    void addToDownloadQueue(Download* dl);
hgs
parents:
diff changeset
    57
    // adds downloads to completed list of downloads
hgs
parents:
diff changeset
    58
    void addToCompletedList(Download* dl);
hgs
parents:
diff changeset
    59
    // processes a download when download start fired
hgs
parents:
diff changeset
    60
    void process(int dlId);
hgs
parents:
diff changeset
    61
    // event handler
hgs
parents:
diff changeset
    62
    bool event(QEvent *event);
hgs
parents:
diff changeset
    63
    // starts the next download in downloadQueue
hgs
parents:
diff changeset
    64
    void startNext();
hgs
parents:
diff changeset
    65
    // pauses the download if it is the first one in the queue
hgs
parents:
diff changeset
    66
    void pauseDownload(int dlId);
hgs
parents:
diff changeset
    67
    // resumes the download if it is the first one in the queue
hgs
parents:
diff changeset
    68
    void resumeDownload(int dlId);
hgs
parents:
diff changeset
    69
    // cancels the download if it is the first one in the queue
hgs
parents:
diff changeset
    70
    void cancelDownload(int dlId);
hgs
parents:
diff changeset
    71
hgs
parents:
diff changeset
    72
    friend class ClientDownload;
hgs
parents:
diff changeset
    73
};
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
#endif