VirtualBox

Ignore:
Timestamp:
Oct 14, 2015 3:39:48 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Networking cleanup/rework (part 10): Get rid of Qt networking stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/net
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkDefs.h

    r58242 r58249  
    55
    66/*
    7  * Copyright (C) 2011-2012 Oracle Corporation
     7 * Copyright (C) 2011-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UINetworkDefs_h__
    19 #define __UINetworkDefs_h__
     18#ifndef ___UINetworkDefs_h___
     19#define ___UINetworkDefs_h___
    2020
    21 /* Network-request types: */
     21/** Network request types. */
    2222enum UINetworkRequestType
    2323{
    24     UINetworkRequestType_HEAD,
    2524    UINetworkRequestType_HEAD_Our,
    26     UINetworkRequestType_GET,
    2725    UINetworkRequestType_GET_Our
    2826};
    2927
    30 /* Network-reply types: */
    31 enum UINetworkReplyType
    32 {
    33     UINetworkReplyType_Qt,
    34     UINetworkReplyType_Our
    35 };
     28#endif /* !___UINetworkDefs_h___ */
    3629
    37 #endif // __UINetworkDefs_h__
    38 
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp

    r58247 r58249  
    879879
    880880    /* API: Abort reply: */
    881     void abort()
    882     {
    883         m_pThread->abort();
    884     }
     881    void abort() { m_pThread->abort(); }
    885882
    886883    /* API: Error-code getter: */
     
    908905
    909906    /* API: Reply getter: */
    910     QByteArray readAll() { return m_pThread->readAll(); }
     907    QByteArray readAll() const { return m_pThread->readAll(); }
    911908
    912909    /** Returns value for the cached reply header of the passed @a type. */
     
    915912    /** Returns URL of the reply. */
    916913    QUrl url() const { return m_pThread->url(); }
     914
     915    /** Returns value for the cached reply attribute of the passed @a code. */
     916    QVariant attribute(QNetworkRequest::Attribute code) const { /** @todo r=dsen: Fix that. */ Q_UNUSED(code); return QVariant(); }
    917917
    918918private slots:
     
    956956
    957957UINetworkReply::UINetworkReply(const QNetworkRequest &request, UINetworkRequestType requestType)
    958     : m_replyType(UINetworkReplyType_Qt)
    959     , m_pReply(0)
    960 {
    961     /* Create network-reply object: */
    962     switch (requestType)
    963     {
    964         /* Prepare Qt network-reply (HEAD): */
    965         case UINetworkRequestType_HEAD:
    966             m_replyType = UINetworkReplyType_Qt;
    967             m_pReply = gNetworkManager->head(request);
    968             break;
    969         /* Prepare our network-reply (HEAD): */
    970         case UINetworkRequestType_HEAD_Our:
    971             m_replyType = UINetworkReplyType_Our;
    972             m_pReply = new UINetworkReplyPrivate(request, UINetworkRequestType_HEAD_Our);
    973             break;
    974         /* Prepare Qt network-reply (GET): */
    975         case UINetworkRequestType_GET:
    976             m_replyType = UINetworkReplyType_Qt;
    977             m_pReply = gNetworkManager->get(request);
    978             break;
    979         /* Prepare our network-reply (GET): */
    980         case UINetworkRequestType_GET_Our:
    981             m_replyType = UINetworkReplyType_Our;
    982             m_pReply = new UINetworkReplyPrivate(request, UINetworkRequestType_GET_Our);
    983             break;
    984     }
    985 
     958    : m_pReply(new UINetworkReplyPrivate(request, requestType))
     959{
    986960    /* Prepare network-reply object connections: */
    987961    connect(m_pReply, SIGNAL(downloadProgress(qint64, qint64)), this, SIGNAL(downloadProgress(qint64, qint64)));
     
    1001975QVariant UINetworkReply::header(QNetworkRequest::KnownHeaders header) const
    1002976{
    1003     QVariant result;
    1004     switch (m_replyType)
    1005     {
    1006         case UINetworkReplyType_Qt: result = qobject_cast<QNetworkReply*>(m_pReply)->header(header); break;
    1007         case UINetworkReplyType_Our: result = qobject_cast<UINetworkReplyPrivate*>(m_pReply)->header(header); break;
    1008     }
    1009     return result;
     977    return m_pReply->header(header);
    1010978}
    1011979
    1012980QVariant UINetworkReply::attribute(QNetworkRequest::Attribute code) const
    1013981{
    1014     QVariant result;
    1015     switch (m_replyType)
    1016     {
    1017         case UINetworkReplyType_Qt: result = qobject_cast<QNetworkReply*>(m_pReply)->attribute(code); break;
    1018         case UINetworkReplyType_Our: /* TODO: attribute() */ break;
    1019     }
    1020     return result;
     982    return m_pReply->attribute(code);
    1021983}
    1022984
    1023985void UINetworkReply::abort()
    1024986{
    1025     switch (m_replyType)
    1026     {
    1027         case UINetworkReplyType_Qt: qobject_cast<QNetworkReply*>(m_pReply)->abort(); break;
    1028         case UINetworkReplyType_Our: qobject_cast<UINetworkReplyPrivate*>(m_pReply)->abort(); break;
    1029     }
     987    return m_pReply->abort();
    1030988}
    1031989
    1032990QNetworkReply::NetworkError UINetworkReply::error() const
    1033991{
    1034     QNetworkReply::NetworkError result = QNetworkReply::NoError;
    1035     switch (m_replyType)
    1036     {
    1037         case UINetworkReplyType_Qt: result = qobject_cast<QNetworkReply*>(m_pReply)->error(); break;
    1038         case UINetworkReplyType_Our: result = qobject_cast<UINetworkReplyPrivate*>(m_pReply)->error(); break;
    1039     }
    1040     return result;
     992    return m_pReply->error();
    1041993}
    1042994
    1043995QString UINetworkReply::errorString() const
    1044996{
    1045     QString strResult;
    1046     switch (m_replyType)
    1047     {
    1048         case UINetworkReplyType_Qt: strResult = qobject_cast<QNetworkReply*>(m_pReply)->errorString(); break;
    1049         case UINetworkReplyType_Our: strResult = qobject_cast<UINetworkReplyPrivate*>(m_pReply)->errorString(); break;
    1050     }
    1051     return strResult;
    1052 }
    1053 
    1054 QByteArray UINetworkReply::readAll()
    1055 {
    1056     QByteArray result;
    1057     switch (m_replyType)
    1058     {
    1059         case UINetworkReplyType_Qt: result = qobject_cast<QNetworkReply*>(m_pReply)->readAll(); break;
    1060         case UINetworkReplyType_Our: result = qobject_cast<UINetworkReplyPrivate*>(m_pReply)->readAll(); break;
    1061     }
    1062     return result;
     997    return m_pReply->errorString();
     998}
     999
     1000QByteArray UINetworkReply::readAll() const
     1001{
     1002    return m_pReply->readAll();
    10631003}
    10641004
    10651005QUrl UINetworkReply::url() const
    10661006{
    1067     QUrl result;
    1068     switch (m_replyType)
    1069     {
    1070         case UINetworkReplyType_Qt: result = qobject_cast<QNetworkReply*>(m_pReply)->url(); break;
    1071         case UINetworkReplyType_Our: result = qobject_cast<UINetworkReplyPrivate*>(m_pReply)->url(); break;
    1072     }
    1073     return result;
     1007    return m_pReply->url();
    10741008}
    10751009
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.h

    r55401 r58249  
    2626#include "UINetworkDefs.h"
    2727
     28/* Forward declarations: */
     29class UINetworkReplyPrivate;
     30
    2831/* Network-reply interface: */
    2932class UINetworkReply : public QObject
     
    4952    QNetworkReply::NetworkError error() const;
    5053    QString errorString() const;
    51     QByteArray readAll();
     54    QByteArray readAll() const;
    5255    QUrl url() const;
    5356
    5457private:
    5558
    56     /* Variables: */
    57     UINetworkReplyType m_replyType;
    58     QPointer<QObject> m_pReply;
     59    /** Holds the network reply private instance. */
     60    UINetworkReplyPrivate *m_pReply;
    5961};
    6062
Note: See TracChangeset for help on using the changeset viewer.

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