VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/networking/UINetworkRequestManager.h

Last change on this file was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: UINetworkRequestManager.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UINetworkRequestManager stuff declaration.
4 */
5
6/*
7 * Copyright (C) 2011-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_networking_UINetworkRequestManager_h
29#define FEQT_INCLUDED_SRC_networking_UINetworkRequestManager_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36#include <QUuid>
37
38/* GUI inludes: */
39#include "UILibraryDefs.h"
40#include "UINetworkDefs.h"
41
42/* Forward declarations: */
43class QUrl;
44class UINetworkCustomer;
45class UINetworkRequest;
46
47/** QObject class extension.
48 * Providing network access for VirtualBox application purposes. */
49class SHARED_LIBRARY_STUFF UINetworkRequestManager : public QObject
50{
51 Q_OBJECT;
52
53public:
54
55 /** Creates singleton instance. */
56 static void create();
57 /** Destroys singleton instance. */
58 static void destroy();
59 /** Returns the singleton instance. */
60 static UINetworkRequestManager *instance();
61
62 /** Creates network-request returning request ID.
63 * @param enmType Brings request type.
64 * @param urls Brings request urls, there can be few of them.
65 * @param strTarget Brings request target path.
66 * @param requestHeaders Brings request headers in dictionary form.
67 * @param pCustomer Brings customer this request being ordered by. */
68 QUuid createNetworkRequest(UINetworkRequestType enmType,
69 const QList<QUrl> &urls,
70 const QString &strTarget,
71 const UserDictionary &requestHeaders,
72 UINetworkCustomer *pCustomer);
73
74 /** Aborts network-request. */
75 void cancelNetworkRequest(const QUuid &uId);
76
77protected:
78
79 /** Constructs network manager. */
80 UINetworkRequestManager();
81 /** Destructs network manager. */
82 virtual ~UINetworkRequestManager() RT_OVERRIDE RT_FINAL;
83
84private slots:
85
86 /** Handles progress for @a iReceived amount of bytes among @a iTotal. */
87 void sltHandleNetworkRequestProgress(qint64 iReceived, qint64 iTotal);
88 /** Handles request @a strError. */
89 void sltHandleNetworkRequestFailure(const QString &strError);
90 /** Handles request canceling. */
91 void sltHandleNetworkRequestCancel();
92 /** Handles request finishing. */
93 void sltHandleNetworkRequestFinish();
94
95 /** Handles signal about @a pNetworkCustomer being destroyed. */
96 void sltHandleNetworkCustomerBeingDestroyed(UINetworkCustomer *pNetworkCustomer);
97
98private:
99
100 /** Prepares all. */
101 void prepare();
102 /** Cleanups network-request with passed @a uId. */
103 void cleanupNetworkRequest(const QUuid &uId);
104 /** Cleanups all network-requests. */
105 void cleanupNetworkRequests();
106 /** Cleanups all. */
107 void cleanup();
108
109 /** Holds the singleton instance. */
110 static UINetworkRequestManager *s_pInstance;
111
112 /** Holds the map of current requests. */
113 QMap<QUuid, UINetworkRequest*> m_requests;
114 /** Holds the map of current customers. */
115 QMap<QUuid, UINetworkCustomer*> m_customers;
116};
117
118/** Singleton Network Manager 'official' name. */
119#define gNetworkManager UINetworkRequestManager::instance()
120
121#endif /* !FEQT_INCLUDED_SRC_networking_UINetworkRequestManager_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette