From Adrien Destugues <pulkomandy@xxxxxxxxx>:
Adrien Destugues has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/2961 ;)
Change subject: IPP: remove custom URL implemenation.
......................................................................
IPP: remove custom URL implemenation.
Use BUrl.
---
M src/add-ons/print/transports/ipp/HttpURLConnection.cpp
M src/add-ons/print/transports/ipp/HttpURLConnection.h
M src/add-ons/print/transports/ipp/IppSetupDlg.cpp
M src/add-ons/print/transports/ipp/IppTransport.cpp
M src/add-ons/print/transports/ipp/IppURLConnection.cpp
M src/add-ons/print/transports/ipp/IppURLConnection.h
M src/add-ons/print/transports/ipp/Jamfile
D src/add-ons/print/transports/ipp/URL.cpp
D src/add-ons/print/transports/ipp/URL.h
9 files changed, 20 insertions(+), 192 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/61/2961/1
diff --git a/src/add-ons/print/transports/ipp/HttpURLConnection.cpp
b/src/add-ons/print/transports/ipp/HttpURLConnection.cpp
index 729ac59..eb68393 100644
--- a/src/add-ons/print/transports/ipp/HttpURLConnection.cpp
+++ b/src/add-ons/print/transports/ipp/HttpURLConnection.cpp
@@ -47,7 +47,7 @@
return (key == o.key) && (value == o.value);
}
-HttpURLConnection::HttpURLConnection(const URL &Url)
+HttpURLConnection::HttpURLConnection(const BUrl &Url)
: connected(false), doInput(true), doOutput(false), url(Url)
{
__sock = NULL;
@@ -130,9 +130,9 @@
void HttpURLConnection::connect()
{
if (!connected) {
- int port = url.getPort();
+ int port = url.Port();
if (port < 0) {
- const char *protocol = url.getProtocol();
+ const char *protocol = url.Protocol();
if (!stricmp(protocol, "http")) {
port = DEFAULT_PORT;
} else if (!stricmp(protocol, "ipp")) {
@@ -141,7 +141,7 @@
port = DEFAULT_PORT;
}
}
- __sock = new Socket(url.getHost(), port);
+ __sock = new Socket(url.Host(), port);
if (__sock->fail()) {
__error_msg = __sock->getLastError();
} else {
@@ -213,9 +213,9 @@
void HttpURLConnection::setRequest()
{
if (connected) {
- setRequestProperty("Host", url.getHost());
+ setRequestProperty("Host", url.Host());
ostream &os = getOutputStream();
- os << __method << ' ' << url.getFile() << " HTTP/1.1" << '\r'
<< '\n';
+ os << __method << ' ' << url.Path() << " HTTP/1.1" << '\r' <<
'\n';
for (Fields::iterator it = __request->begin(); it !=
__request->end(); it++) {
os << (*it).key << ": " << (*it).value << '\r' << '\n';
}
@@ -287,7 +287,7 @@
{
const char *p =
getHeaderField("Location");
if (p) {
- URL trueUrl(p);
+ BUrl trueUrl(p);
url = trueUrl;
delete __response;
__response = NULL;
diff --git a/src/add-ons/print/transports/ipp/HttpURLConnection.h
b/src/add-ons/print/transports/ipp/HttpURLConnection.h
index 84bcdf8..bd806ea 100644
--- a/src/add-ons/print/transports/ipp/HttpURLConnection.h
+++ b/src/add-ons/print/transports/ipp/HttpURLConnection.h
@@ -9,7 +9,7 @@
#include <list>
#include <string>
-#include "URL.h"
+#include <Url.h>
using namespace std;
@@ -76,7 +76,7 @@
class HttpURLConnection {
public:
- HttpURLConnection(const URL &url);
+ HttpURLConnection(const BUrl &url);
virtual ~HttpURLConnection();
virtual void connect();
@@ -92,7 +92,7 @@
long getDate();
const char *getHeaderField(int n);
const char *getHeaderField(const char *);
- const URL &getURL() const;
+ const BUrl &getURL() const;
HTTP_RESPONSECODE getResponseCode();
const char *getResponseMessage();
@@ -111,7 +111,7 @@
bool connected;
bool doInput;
bool doOutput;
- URL url;
+ BUrl url;
virtual void action();
virtual void setRequest();
diff --git a/src/add-ons/print/transports/ipp/IppSetupDlg.cpp
b/src/add-ons/print/transports/ipp/IppSetupDlg.cpp
index e59e517..fb0046a 100644
--- a/src/add-ons/print/transports/ipp/IppSetupDlg.cpp
+++ b/src/add-ons/print/transports/ipp/IppSetupDlg.cpp
@@ -4,14 +4,14 @@
#include <string.h>
#include <strings.h>
+#include <Alert.h>
#include <Button.h>
+#include <Directory.h>
#include <Rect.h>
#include <TextControl.h>
#include <View.h>
-#include <Directory.h>
-#include <Alert.h>
+#include <Url.h>
-#include "URL.h"
#include "IppContent.h"
#include "IppURLConnection.h"
#include "IppSetupDlg.h"
@@ -114,7 +114,7 @@
request->setURI("printer-uri", url->Text());
request->setDelimiter(IPP_END_OF_ATTRIBUTES_TAG);
- IppURLConnection conn(URL(url->Text()));
+ IppURLConnection conn(BUrl(url->Text()));
conn.setIppRequest(request);
conn.setRequestProperty("Connection", "close");
diff --git a/src/add-ons/print/transports/ipp/IppTransport.cpp
b/src/add-ons/print/transports/ipp/IppTransport.cpp
index 522eebd..53494c2 100644
--- a/src/add-ons/print/transports/ipp/IppTransport.cpp
+++ b/src/add-ons/print/transports/ipp/IppTransport.cpp
@@ -3,8 +3,9 @@
#include <Alert.h>
#include <DataIO.h>
-#include <Message.h>
#include <Directory.h>
+#include <Message.h>
+#include <Url.h>
#include <pwd.h>
#include <stdio.h>
@@ -12,7 +13,6 @@
#include <strings.h>
#include <unistd.h>
-#include "URL.h"
#include "IppContent.h"
#include "IppURLConnection.h"
#include "IppSetupDlg.h"
@@ -97,7 +97,7 @@
__fs.seekg(0, ios::beg);
request->setRawData(__fs, fssize);
- URL url(__url);
+ BUrl url(__url);
IppURLConnection conn(url);
conn.setIppRequest(request);
conn.setRequestProperty("Connection", "close");
diff --git a/src/add-ons/print/transports/ipp/IppURLConnection.cpp
b/src/add-ons/print/transports/ipp/IppURLConnection.cpp
index 482bea1..c6cfe3e 100644
--- a/src/add-ons/print/transports/ipp/IppURLConnection.cpp
+++ b/src/add-ons/print/transports/ipp/IppURLConnection.cpp
@@ -21,7 +21,7 @@
#include "IppURLConnection.h"
#include "IppContent.h"
-IppURLConnection::IppURLConnection(const URL &Url)
+IppURLConnection::IppURLConnection(const BUrl &Url)
: HttpURLConnection(Url)
{
__ippRequest = NULL;
diff --git a/src/add-ons/print/transports/ipp/IppURLConnection.h
b/src/add-ons/print/transports/ipp/IppURLConnection.h
index 73e4497..5a6fc41 100644
--- a/src/add-ons/print/transports/ipp/IppURLConnection.h
+++ b/src/add-ons/print/transports/ipp/IppURLConnection.h
@@ -10,7 +10,7 @@
class IppURLConnection : public HttpURLConnection {
public:
- IppURLConnection(const URL &url);
+ IppURLConnection(const BUrl &url);
~IppURLConnection();
void setIppRequest(IppContent *);
diff --git a/src/add-ons/print/transports/ipp/Jamfile
b/src/add-ons/print/transports/ipp/Jamfile
index 3bdbe8d..d7ea334 100644
--- a/src/add-ons/print/transports/ipp/Jamfile
+++ b/src/add-ons/print/transports/ipp/Jamfile
@@ -13,7 +13,6 @@
HttpURLConnection.cpp
IppContent.cpp
IppURLConnection.cpp
- URL.cpp
Socket.o
SocketStream.o
DbgMsg.o
diff --git a/src/add-ons/print/transports/ipp/URL.cpp
b/src/add-ons/print/transports/ipp/URL.cpp
deleted file mode 100644
index a01c22c..0000000
--- a/src/add-ons/print/transports/ipp/URL.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-// Sun, 18 Jun 2000
-// Y.Takagi
-
-#include <cstring>
-#include <stdlib.h>
-#include "URL.h"
-
-URL::URL(const char *spec)
-{
-// __protocol = "http";
-// __host = "localhost";
-// __file = "/";
- __port = -1;
-
- if (spec) {
- char *temp_spec = new char[strlen(spec) + 1];
- strcpy(temp_spec, spec);
-
- char *p1;
- char *p2;
- char *p3;
- char *p4;
-
- p1 = strstr(temp_spec, "//");
- if (p1) {
- *p1 = '\0';
- p1 += 2;
- __protocol = temp_spec;
- } else {
- p1 = temp_spec;
- }
-
- p3 = strstr(p1, "/");
- if (p3) {
- p4 = strstr(p3, "#");
- if (p4) {
- __ref = p4 + 1;
- *p4 = '\0';
- }
- __file = p3;
- *p3 = '\0';
- } else {
- __file = "/";
- }
-
- p2 = strstr(p1, ":");
- if (p2) {
- __port = atoi(p2 + 1);
- *p2 = '\0';
- }
-
- __host = p1;
- delete [] temp_spec;
- }
-
-// if (__port == -1) {
-// if (__protocol == "http") {
-// __port = 80;
-// } else if (__protocol == "ipp") {
-// __port = 631;
-// }
-// }
-}
-
-URL::URL(const char *protocol, const char *host, int port, const char *file)
-{
- __protocol = protocol;
- __host = host;
- __file = file;
- __port = port;
-}
-
-URL::URL(const char *protocol, const char *host, const char *file)
-{
- __protocol = protocol;
- __host = host;
- __file = file;
-}
-
-URL::URL(const URL &url)
-{
- __protocol = url.__protocol;
- __host = url.__host;
- __file = url.__file;
- __ref = url.__ref;
- __port = url.__port;
-}
-
-URL &URL::operator = (const URL &url)
-{
- __protocol = url.__protocol;
- __host = url.__host;
- __file = url.__file;
- __ref = url.__ref;
- __port = url.__port;
- return *this;
-}
-
-bool URL::operator == (const URL &url)
-{
- return (__protocol == url.__protocol) && (__host == url.__host) &&
(__file == url.__file) &&
- (__ref == url.__ref) && (__port == url.__port);
-}
diff --git a/src/add-ons/print/transports/ipp/URL.h
b/src/add-ons/print/transports/ipp/URL.h
deleted file mode 100644
index 86f4ab2..0000000
--- a/src/add-ons/print/transports/ipp/URL.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Sun, 18 Jun 2000
-// Y.Takagi
-
-#ifndef __URL_H
-#define __URL_H
-
-#include <string>
-
-#if (!__MWERKS__)
-using namespace std;
-#else
-#define std
-#endif
-
-class URL {
-public:
- URL(const char *spec);
- URL(const char *protocol, const char *host, int port, const char *file);
- URL(const char *protocol, const char *host, const char *file);
-// URL(URL &, const char *spec);
-
- int getPort() const;
- const char *getProtocol() const;
- const char *getHost() const;
- const char *getFile() const;
- const char *getRef() const;
-
- URL(const URL &);
- URL &operator = (const URL &);
- bool operator == (const URL &);
-
-protected:
-// void set(const char *protocol, const char *host, int port, const char
*file, const char *ref);
-
-private:
- string __protocol;
- string __host;
- string __file;
- string __ref;
- int __port;
-};
-
-inline int URL::getPort() const
-{
- return __port;
-}
-
-inline const char *URL::getProtocol() const
-{
- return __protocol.c_str();
-}
-
-inline const char *URL::getHost() const
-{
- return __host.c_str();
-}
-
-inline const char *URL::getFile() const
-{
- return __file.c_str();
-}
-
-inline const char *URL::getRef() const
-{
- return __ref.c_str();
-}
-
-#endif // __URL_H
--
To view, visit https://review.haiku-os.org/c/haiku/+/2961
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I40ce72fc34b2ba4f5980eee3cc81cba58c74a43a
Gerrit-Change-Number: 2961
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange