utilities/downloadmanager/inc/downloadmanagerclient.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
#ifndef DOWNLOADMANAGERCLIENT_H
hgs
parents:
diff changeset
    17
#define DOWNLOADMANAGERCLIENT_H
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
#include <QObject>
hgs
parents:
diff changeset
    20
#include "downloadmanager.h"
hgs
parents:
diff changeset
    21
#include "dmcommoninternal.h"
hgs
parents:
diff changeset
    22
#include "dmpimpl.h"
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
class DownloadManagerClientPrivate;
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
class DownloadManagerClient : public QObject
hgs
parents:
diff changeset
    27
{
hgs
parents:
diff changeset
    28
    Q_OBJECT
hgs
parents:
diff changeset
    29
    DM_DECLARE_PRIVATE(DownloadManagerClient);
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
public:
hgs
parents:
diff changeset
    32
    DownloadManagerClient(DownloadManager* downloadManager);
hgs
parents:
diff changeset
    33
    ~DownloadManagerClient();
hgs
parents:
diff changeset
    34
    
hgs
parents:
diff changeset
    35
    // low-level implementation of functions present in BackgroundDownloadManager class
hgs
parents:
diff changeset
    36
    void setStartupInfo();
hgs
parents:
diff changeset
    37
    void setProxy(const QString& proxyServer, const int port);
hgs
parents:
diff changeset
    38
    int createDownload(const QString& url, DownloadType type);
hgs
parents:
diff changeset
    39
    bool attachToDownload(int dlId);
hgs
parents:
diff changeset
    40
    void removeDownload(int downloadId);
hgs
parents:
diff changeset
    41
    void pauseAll();
hgs
parents:
diff changeset
    42
    void resumeAll();
hgs
parents:
diff changeset
    43
    void removeAll();
hgs
parents:
diff changeset
    44
    QVariant getDownloadManagerAttribute(DownloadManagerAttribute attr);
hgs
parents:
diff changeset
    45
    int setDownloadManagerAttribute(DownloadManagerAttribute attr, const QVariant& value);
hgs
parents:
diff changeset
    46
hgs
parents:
diff changeset
    47
    // low-level implementation of functions present in BackgroundDownload class
hgs
parents:
diff changeset
    48
    int startDownload(int dlId);
hgs
parents:
diff changeset
    49
    int pauseDownload(int dlId);
hgs
parents:
diff changeset
    50
    int resumeDownload(int dlId);
hgs
parents:
diff changeset
    51
    int cancelDownload(int dlId);
hgs
parents:
diff changeset
    52
    QVariant getDownloadAttribute(int dlId, DownloadAttribute attr);
hgs
parents:
diff changeset
    53
    int setDownloadAttribute(int dlId, DownloadAttribute attr, const QVariant& value);
hgs
parents:
diff changeset
    54
hgs
parents:
diff changeset
    55
    // server error functions
hgs
parents:
diff changeset
    56
    int serverError();
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
private:
hgs
parents:
diff changeset
    59
    // start server if required and connect to it; set proxy info in server
hgs
parents:
diff changeset
    60
    bool initServer();
hgs
parents:
diff changeset
    61
    // connect to download manager server
hgs
parents:
diff changeset
    62
    bool connectToServer();
hgs
parents:
diff changeset
    63
    // process Download and DownloadManager events
hgs
parents:
diff changeset
    64
    void processEvents(QString eventMsg);
hgs
parents:
diff changeset
    65
    // encodes the strings (client name, url, etc) so that it does not contain
hgs
parents:
diff changeset
    66
    // message delimiter (DM_DELIMITER)
hgs
parents:
diff changeset
    67
    QString encodeString(const QString& inputString);
hgs
parents:
diff changeset
    68
hgs
parents:
diff changeset
    69
private slots:
hgs
parents:
diff changeset
    70
    // poll server for events
hgs
parents:
diff changeset
    71
    void getEvents();
hgs
parents:
diff changeset
    72
    // set server IPC error
hgs
parents:
diff changeset
    73
    void setServerError(int );
hgs
parents:
diff changeset
    74
};
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
#endif