~ubuntu-branches/ubuntu/trusty/virtualbox-lts-xenial/trusty-updates

« back to all changes in this revision

Viewing changes to src/VBox/Frontends/VirtualBox/src/net/UIDownloader.h

  • Committer: Package Import Robot
  • Author(s): Gianfranco Costamagna
  • Date: 2016-02-23 14:28:26 UTC
  • Revision ID: package-import@ubuntu.com-20160223142826-bdu69el2z6wa2a44
Tags: upstream-4.3.36-dfsg
ImportĀ upstreamĀ versionĀ 4.3.36-dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 *
 
3
 * VBox frontends: Qt GUI ("VirtualBox"):
 
4
 * UIDownloader class declaration
 
5
 */
 
6
 
 
7
/*
 
8
 * Copyright (C) 2006-2012 Oracle Corporation
 
9
 *
 
10
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
11
 * available from http://www.virtualbox.org. This file is free software;
 
12
 * you can redistribute it and/or modify it under the terms of the GNU
 
13
 * General Public License (GPL) as published by the Free Software
 
14
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
15
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
16
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
17
 */
 
18
 
 
19
#ifndef __UIDownloader_h__
 
20
#define __UIDownloader_h__
 
21
 
 
22
/* Global includes: */
 
23
#include <QUrl>
 
24
#include <QList>
 
25
 
 
26
/* Local includes: */
 
27
#include "UINetworkDefs.h"
 
28
#include "UINetworkCustomer.h"
 
29
 
 
30
/* Forward declarations: */
 
31
class UINetworkReply;
 
32
 
 
33
/* Downloader interface.
 
34
 * UINetworkCustomer class extension which allows background http downloading. */
 
35
class UIDownloader : public UINetworkCustomer
 
36
{
 
37
    Q_OBJECT;
 
38
 
 
39
signals:
 
40
 
 
41
    /* Signal to start acknowledging: */
 
42
    void sigToStartAcknowledging();
 
43
    /* Signal to start downloading: */
 
44
    void sigToStartDownloading();
 
45
 
 
46
public:
 
47
 
 
48
    /* Starting routine: */
 
49
    void start();
 
50
 
 
51
protected slots:
 
52
 
 
53
    /* Acknowledging part: */
 
54
    void sltStartAcknowledging();
 
55
    /* Downloading part: */
 
56
    void sltStartDownloading();
 
57
 
 
58
protected:
 
59
 
 
60
    /* UIDownloader states: */
 
61
    enum UIDownloaderState
 
62
    {
 
63
        UIDownloaderState_Null,
 
64
        UIDownloaderState_Acknowledging,
 
65
        UIDownloaderState_Downloading
 
66
    };
 
67
 
 
68
    /* Constructor: */
 
69
    UIDownloader();
 
70
 
 
71
    /* Source stuff,
 
72
     * allows to set/get one or more sources to try to download from: */
 
73
    void addSource(const QString &strSource) { m_sources << QUrl(strSource); }
 
74
    void setSource(const QString &strSource) { m_sources.clear(); addSource(strSource); }
 
75
    const QList<QUrl>& sources() const { return m_sources; }
 
76
    const QUrl& source() const { return m_source; }
 
77
 
 
78
    /* Target stuff,
 
79
     * allows to set/get downloaded file destination: */
 
80
    void setTarget(const QString &strTarget) { m_strTarget = strTarget; }
 
81
    const QString& target() const { return m_strTarget; }
 
82
 
 
83
    /* Description stuff,
 
84
     * allows to set/get Network Customer description for Network Access Manager: */
 
85
    void setDescription(const QString &strDescription) { m_strDescription = strDescription; }
 
86
 
 
87
    /* Start delayed acknowledging: */
 
88
    void startDelayedAcknowledging() { emit sigToStartAcknowledging(); }
 
89
    /* Start delayed downloading: */
 
90
    void startDelayedDownloading() { emit sigToStartDownloading(); }
 
91
 
 
92
    /* Network-reply progress handler: */
 
93
    void processNetworkReplyProgress(qint64 iReceived, qint64 iTotal);
 
94
    /* Network-reply cancel handler: */
 
95
    void processNetworkReplyCanceled(UINetworkReply *pNetworkReply);
 
96
    /* Network-reply finish handler: */
 
97
    void processNetworkReplyFinished(UINetworkReply *pNetworkReply);
 
98
 
 
99
    /* Handle acknowledging result: */
 
100
    virtual void handleAcknowledgingResult(UINetworkReply *pNetworkReply);
 
101
    /* Handle downloading result: */
 
102
    virtual void handleDownloadingResult(UINetworkReply *pNetworkReply);
 
103
 
 
104
    /* Pure virtual function to ask user about downloading confirmation: */
 
105
    virtual bool askForDownloadingConfirmation(UINetworkReply *pNetworkReply) = 0;
 
106
    /* Pure virtual function to handle downloaded object: */
 
107
    virtual void handleDownloadedObject(UINetworkReply *pNetworkReply) = 0;
 
108
 
 
109
private:
 
110
 
 
111
    /* Private variables: */
 
112
    UIDownloaderState m_state;
 
113
    QList<QUrl> m_sources;
 
114
    QUrl m_source;
 
115
    QString m_strTarget;
 
116
    QString m_strDescription;
 
117
};
 
118
 
 
119
#endif // __UIDownloader_h__
 
120