Changeset 58249 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 14, 2015 3:39:48 PM (9 years ago)
- 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 5 5 6 6 /* 7 * Copyright (C) 2011-201 2Oracle Corporation7 * Copyright (C) 2011-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UINetworkDefs_h__19 #define __ UINetworkDefs_h__18 #ifndef ___UINetworkDefs_h___ 19 #define ___UINetworkDefs_h___ 20 20 21 /* Network-request types:*/21 /** Network request types. */ 22 22 enum UINetworkRequestType 23 23 { 24 UINetworkRequestType_HEAD,25 24 UINetworkRequestType_HEAD_Our, 26 UINetworkRequestType_GET,27 25 UINetworkRequestType_GET_Our 28 26 }; 29 27 30 /* Network-reply types: */ 31 enum UINetworkReplyType 32 { 33 UINetworkReplyType_Qt, 34 UINetworkReplyType_Our 35 }; 28 #endif /* !___UINetworkDefs_h___ */ 36 29 37 #endif // __UINetworkDefs_h__38 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp
r58247 r58249 879 879 880 880 /* API: Abort reply: */ 881 void abort() 882 { 883 m_pThread->abort(); 884 } 881 void abort() { m_pThread->abort(); } 885 882 886 883 /* API: Error-code getter: */ … … 908 905 909 906 /* API: Reply getter: */ 910 QByteArray readAll() { return m_pThread->readAll(); }907 QByteArray readAll() const { return m_pThread->readAll(); } 911 908 912 909 /** Returns value for the cached reply header of the passed @a type. */ … … 915 912 /** Returns URL of the reply. */ 916 913 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(); } 917 917 918 918 private slots: … … 956 956 957 957 UINetworkReply::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 { 986 960 /* Prepare network-reply object connections: */ 987 961 connect(m_pReply, SIGNAL(downloadProgress(qint64, qint64)), this, SIGNAL(downloadProgress(qint64, qint64))); … … 1001 975 QVariant UINetworkReply::header(QNetworkRequest::KnownHeaders header) const 1002 976 { 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); 1010 978 } 1011 979 1012 980 QVariant UINetworkReply::attribute(QNetworkRequest::Attribute code) const 1013 981 { 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); 1021 983 } 1022 984 1023 985 void UINetworkReply::abort() 1024 986 { 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(); 1030 988 } 1031 989 1032 990 QNetworkReply::NetworkError UINetworkReply::error() const 1033 991 { 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(); 1041 993 } 1042 994 1043 995 QString UINetworkReply::errorString() const 1044 996 { 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 1000 QByteArray UINetworkReply::readAll() const 1001 { 1002 return m_pReply->readAll(); 1063 1003 } 1064 1004 1065 1005 QUrl UINetworkReply::url() const 1066 1006 { 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(); 1074 1008 } 1075 1009 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.h
r55401 r58249 26 26 #include "UINetworkDefs.h" 27 27 28 /* Forward declarations: */ 29 class UINetworkReplyPrivate; 30 28 31 /* Network-reply interface: */ 29 32 class UINetworkReply : public QObject … … 49 52 QNetworkReply::NetworkError error() const; 50 53 QString errorString() const; 51 QByteArray readAll() ;54 QByteArray readAll() const; 52 55 QUrl url() const; 53 56 54 57 private: 55 58 56 /* Variables: */ 57 UINetworkReplyType m_replyType; 58 QPointer<QObject> m_pReply; 59 /** Holds the network reply private instance. */ 60 UINetworkReplyPrivate *m_pReply; 59 61 }; 60 62
Note:
See TracChangeset
for help on using the changeset viewer.