diff --git a/include/eepp/network/ftp.hpp b/include/eepp/network/ftp.hpp index 10879decb..569b4ab0b 100644 --- a/include/eepp/network/ftp.hpp +++ b/include/eepp/network/ftp.hpp @@ -108,17 +108,17 @@ public: ** equivalent to testing if the status code is < 400. ** ** @return True if the status is a success, false if it is a failure */ - bool IsOk() const; + bool isOk() const; /** @brief Get the status code of the response ** ** @return Status code */ - Status GetStatus() const; + Status getStatus() const; /** @brief Get the full message contained in the response ** @return The response message */ - const std::string& GetMessage() const; + const std::string& getMessage() const; private: // Member data Status mStatus; ///< Status code returned from the server @@ -135,7 +135,7 @@ public: /** @brief Get the directory returned in the response ** @return Directory name */ - const std::string& GetDirectory() const; + const std::string& getDirectory() const; private: // Member data std::string mDirectory; ///< Directory extracted from the response message @@ -155,7 +155,7 @@ public: /** @brief Return the array of directory/file names ** ** @return Array containing the requested listing */ - const std::vector& GetListing() const; + const std::vector& getListing() const; private: // Member data std::vector mListing; ///< Directory/file names extracted from the data @@ -181,19 +181,18 @@ public: ** @param timeout Maximum time to wait ** @return Server response to the request ** @see Disconnect */ - Response Connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero); + Response connect(const IpAddress& server, unsigned short port = 21, Time timeout = Time::Zero); /** @brief Close the connection with the server ** @return Server response to the request ** @see Connect */ - Response Disconnect(); + Response disconnect(); /** @brief Log in using an anonymous account ** Logging in is mandatory after connecting to the server. ** Users that are not logged in cannot perform any operation. ** @return Server response to the request */ - Response Login(); - + Response login(); /** @brief Log in using a username and a password ** Logging in is mandatory after connecting to the server. @@ -201,21 +200,21 @@ public: ** @param name User name ** @param password Password ** @return Server response to the request */ - Response Login(const std::string& name, const std::string& password); + Response login(const std::string& name, const std::string& password); /** @brief Send a null command to keep the connection alive ** This command is useful because the server may close the ** connection automatically if no command is sent. ** @return Server response to the request */ - Response KeepAlive(); + Response keepAlive(); /** @brief Get the current working directory ** The working directory is the root path for subsequent ** operations involving directories and/or filenames. ** @return Server response to the request ** @see GetDirectoryListing, ChangeDirectory, ParentDirectory */ - DirectoryResponse GetWorkingDirectory(); + DirectoryResponse getWorkingDirectory(); /** @brief Get the contents of the given directory ** This function retrieves the sub-directories and files @@ -225,20 +224,20 @@ public: ** @param directory Directory to list ** @return Server response to the request ** @see GetWorkingDirectory, ChangeDirectory, ParentDirectory */ - ListingResponse GetDirectoryListing(const std::string& directory = ""); + ListingResponse getDirectoryListing(const std::string& directory = ""); /** @brief Change the current working directory ** The new directory must be relative to the current one. ** @param directory New working directory ** @return Server response to the request ** @see GetWorkingDirectory, GetDirectoryListing, ParentDirectory */ - Response ChangeDirectory(const std::string& directory); + Response changeDirectory(const std::string& directory); /** @brief Go to the parent directory of the current one ** @return Server response to the request ** @see GetWorkingDirectory, GetDirectoryListing, ChangeDirectory */ - Response ParentDirectory(); + Response parentDirectory(); /** @brief Create a new directory ** The new directory is created as a child of the current @@ -246,8 +245,7 @@ public: ** @param name Name of the directory to create ** @return Server response to the request ** @see DeleteDirectory */ - Response CreateDirectory(const std::string& name); - + Response createDirectory(const std::string& name); /** @brief Remove an existing directory ** The directory to remove must be relative to the @@ -257,7 +255,7 @@ public: ** @param name Name of the directory to remove ** @return Server response to the request ** @see CreateDirectory */ - Response DeleteDirectory(const std::string& name); + Response deleteDirectory(const std::string& name); /** @brief Rename an existing file ** The filenames must be relative to the current working @@ -266,7 +264,7 @@ public: ** @param newName New name of the file ** @return Server response to the request ** @see DeleteFile */ - Response RenameFile(const std::string& file, const std::string& newName); + Response renameFile(const std::string& file, const std::string& newName); /** @brief Remove an existing file ** The file name must be relative to the current working @@ -276,7 +274,7 @@ public: ** @param name File to remove ** @return Server response to the request ** @see RenameFile */ - Response DeleteFile(const std::string& name); + Response deleteFile(const std::string& name); /** @brief Download a file from the server ** The filename of the distant file is relative to the @@ -291,7 +289,7 @@ public: ** @param mode Transfer mode ** @return Server response to the request ** @see Upload */ - Response Download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary); + Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary); /** @brief Upload a file to the server ** The name of the local file is relative to the current @@ -303,19 +301,19 @@ public: ** @param mode Transfer mode ** @return Server response to the request ** @see Download */ - Response Upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary); + Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary); private : /** @brief Send a command to the FTP server ** @param command Command to send ** @param parameter Command parameter ** @return Server response to the request */ - Response SendCommand(const std::string& command, const std::string& parameter = ""); + Response sendCommand(const std::string& command, const std::string& parameter = ""); /** @brief Receive a response from the server ** This function must be called after each call to ** SendCommand that expects a response. ** @return Server response to the request */ - Response GetResponse(); + Response getResponse(); /** @brief Utility class for exchanging datas with the server on the data channel */ class DataChannel; @@ -358,30 +356,30 @@ Ftp ftp; // Connect to the server Ftp::Response response = ftp.Connect("ftp://ftp.myserver.com"); -if (response.IsOk()) +if (response.isOk()) std::cout << "Connected" << std::endl; // Log in -response = ftp.Login("laurent", "dF6Zm89D"); -if (response.IsOk()) +response = ftp.login("laurent", "dF6Zm89D"); +if (response.isOk()) std::cout << "Logged in" << std::endl; // Print the working directory -Ftp::DirectoryResponse directory = ftp.GetWorkingDirectory(); -if (directory.IsOk()) - std::cout << "Working directory: " << directory.GetDirectory() << std::endl; +Ftp::DirectoryResponse directory = ftp.getWorkingDirectory(); +if (directory.isOk()) + std::cout << "Working directory: " << directory.getDirectory() << std::endl; // Create a new directory -response = ftp.CreateDirectory("files"); -if (response.IsOk()) +response = ftp.createDirectory("files"); +if (response.isOk()) std::cout << "Created new directory" << std::endl; // Upload a file to this new directory -response = ftp.Upload("local-path/file.txt", "files", Ftp::Ascii); -if (response.IsOk()) +response = ftp.upload("local-path/file.txt", "files", Ftp::Ascii); +if (response.isOk()) std::cout << "File uploaded" << std::endl; // Disconnect from the server (optional) -ftp.Disconnect(); +ftp.disconnect(); @endcode */ diff --git a/include/eepp/network/http.hpp b/include/eepp/network/http.hpp index 9ecbe742e..9350772f5 100644 --- a/include/eepp/network/http.hpp +++ b/include/eepp/network/http.hpp @@ -52,49 +52,49 @@ class EE_API Http : NonCopyable { ** sending the request). ** @param field Name of the field to set ** @param value Value of the field */ - void SetField(const std::string& field, const std::string& value); + void setField(const std::string& field, const std::string& value); /** @brief Set the request method ** See the Method enumeration for a complete list of all ** the availale methods. ** The method is Http::Request::Get by default. ** @param method Method to use for the request */ - void SetMethod(Method method); + void setMethod(Method method); /** @brief Set the requested URI ** The URI is the resource (usually a web page or a file) ** that you want to get or post. ** The URI is "/" (the root page) by default. ** @param uri URI to request, relative to the host */ - void SetUri(const std::string& uri); + void setUri(const std::string& uri); /** @brief Set the HTTP version for the request ** The HTTP version is 1.0 by default. ** @param major Major HTTP version number ** @param minor Minor HTTP version number */ - void SetHttpVersion(unsigned int major, unsigned int minor); + void setHttpVersion(unsigned int major, unsigned int minor); /** @brief Set the body of the request ** The body of a request is optional and only makes sense ** for POST requests. It is ignored for all other methods. ** The body is empty by default. ** @param body Content of the body */ - void SetBody(const std::string& body); + void setBody(const std::string& body); /** @return The request Uri */ - const std::string& GetUri() const; + const std::string& getUri() const; /** @return If SSL certificate validation is enabled */ - const bool& ValidateCertificate() const; + const bool& validateCertificate() const; /** Enable/disable SSL certificate validation */ - void ValidateCertificate( bool enable ); + void validateCertificate( bool enable ); /** @return If SSL hostname validation is enabled */ - const bool& ValidateHostname() const; + const bool& validateHostname() const; /** Enable/disable SSL hostname validation */ - void ValidateHostname( bool enable ); + void validateHostname( bool enable ); private: friend class Http; @@ -102,13 +102,13 @@ class EE_API Http : NonCopyable { ** This is used internally by Http before sending the ** request to the web server. ** @return String containing the request, ready to be sent */ - std::string Prepare() const; + std::string prepare() const; /** @brief Check if the request defines a field ** This function uses case-insensitive comparisons. ** @param field Name of the field to test ** @return True if the field exists, false otherwise */ - bool HasField(const std::string& field) const; + bool hasField(const std::string& field) const; // Types typedef std::map FieldTable; @@ -174,7 +174,7 @@ class EE_API Http : NonCopyable { ** case-insensitive comparisons. ** @param field Name of the field to get ** @return Value of the field, or empty string if not found */ - const std::string& GetField(const std::string& field) const; + const std::string& getField(const std::string& field) const; /** @brief Get the response status code ** The status code should be the first thing to be checked @@ -182,17 +182,17 @@ class EE_API Http : NonCopyable { ** success, a failure or anything else (see the Status ** enumeration). ** @return Status code of the response */ - Status GetStatus() const; + Status getStatus() const; /** @brief Get the major HTTP version number of the response ** @return Major HTTP version number ** @see GetMinorHttpVersion */ - unsigned int GetMajorHttpVersion() const; + unsigned int getMajorHttpVersion() const; /** @brief Get the minor HTTP version number of the response ** @return Minor HTTP version number ** @see GetMajorHttpVersion */ - unsigned int GetMinorHttpVersion() const; + unsigned int getMinorHttpVersion() const; /** @brief Get the body of the response ** The body of a response may contain: @@ -201,7 +201,7 @@ class EE_API Http : NonCopyable { ** @li nothing (for HEAD requests) ** @li an error message (in case of an error) ** @return The response body */ - const std::string& GetBody() const; + const std::string& getBody() const; private : friend class Http; @@ -209,13 +209,13 @@ class EE_API Http : NonCopyable { ** This function is used by Http to build the response ** of a request. ** @param data Content of the response to parse */ - void Parse(const std::string& data); + void parse(const std::string& data); /** @brief Read values passed in the answer header ** This function is used by Http to extract values passed ** in the response. ** @param in String stream containing the header values */ - void ParseFields(std::istream &in); + void parseFields(std::istream &in); // Types typedef std::map FieldTable; @@ -256,7 +256,7 @@ class EE_API Http : NonCopyable { ** @param host Web server to connect to ** @param port Port to use for connection ** @param useSSL force the SSL usage ( if compiled with the support of it ). If the host starts with https:// it will use it by default. */ - void SetHost(const std::string& host, unsigned short port = 0, bool useSSL = false); + void setHost(const std::string& host, unsigned short port = 0, bool useSSL = false); /** @brief Send a HTTP request and return the server's response. ** You must have a valid host before sending a request (see SetHost). @@ -270,7 +270,7 @@ class EE_API Http : NonCopyable { ** @param request Request to send ** @param timeout Maximum time to wait ** @return Server's response */ - Response SendRequest(const Request& request, Time timeout = Time::Zero); + Response sendRequest(const Request& request, Time timeout = Time::Zero); /** Definition of the async callback response */ typedef cb::Callback3 AsyncResponseCallback; @@ -278,16 +278,16 @@ class EE_API Http : NonCopyable { /** @brief Sends the request and creates a new thread, when got the response informs the result to the callback. ** This function does not lock the caller thread. ** @see SendRequest */ - void SendAsyncRequest( AsyncResponseCallback cb, const Http::Request& request, Time timeout = Time::Zero ); + void sendAsyncRequest( AsyncResponseCallback cb, const Http::Request& request, Time timeout = Time::Zero ); /** @return The host address */ - const IpAddress& GetHost() const; + const IpAddress& getHost() const; /** @return The host name */ - const std::string& GetHostName() const; + const std::string& getHostName() const; /** @return The host port */ - const unsigned short& GetPort() const; + const unsigned short& getPort() const; private: class AsyncRequest : public Thread { public: @@ -311,7 +311,7 @@ class EE_API Http : NonCopyable { Mutex mThreadsMutex; bool mIsSSL; - void RemoveOldThreads(); + void removeOldThreads(); }; }} @@ -349,19 +349,19 @@ Usage example: Http http; // We'll work on http://www.google.com -http.SetHost("http://www.google.com"); +http.setHost("http://www.google.com"); // Prepare a request to get the 'features.php' page Http::Request request("features.php"); // Send the request -Http::Response response = http.SendRequest(request); +Http::Response response = http.sendRequest(request); // Check the status code and display the result -Http::Response::Status status = response.GetStatus(); +Http::Response::Status status = response.getStatus(); if (status == Http::Response::Ok) { - std::cout << response.GetBody() << std::endl; + std::cout << response.getBody() << std::endl; } else { diff --git a/include/eepp/network/ipaddress.hpp b/include/eepp/network/ipaddress.hpp index 7e46592e0..a9625f163 100644 --- a/include/eepp/network/ipaddress.hpp +++ b/include/eepp/network/ipaddress.hpp @@ -59,7 +59,7 @@ class EE_API IpAddress ** from a host name. ** @return String representation of the address ** @see ToInteger */ - std::string ToString() const; + std::string toString() const; /** @brief Get an integer representation of the address ** The returned number is the internal representation of the @@ -69,7 +69,7 @@ class EE_API IpAddress ** back to a IpAddress with the proper constructor. ** @return 32-bits unsigned integer representation of the address ** @see ToString */ - Uint32 ToInteger() const; + Uint32 toInteger() const; /** @brief Get the computer's local address ** The local address is the address of the computer from the @@ -79,7 +79,7 @@ class EE_API IpAddress ** used safely anywhere. ** @return Local IP address of the computer ** @see GetPublicAddress */ - static IpAddress GetLocalAddress(); + static IpAddress getLocalAddress(); /** @brief Get the computer's public address ** The public address is the address of the computer from the @@ -96,7 +96,7 @@ class EE_API IpAddress ** @param timeout Maximum time to wait ** @return Public IP address of the computer ** @see GetLocalAddress */ - static IpAddress GetPublicAddress(Time timeout = Time::Zero); + static IpAddress getPublicAddress(Time timeout = Time::Zero); // Static member data static const IpAddress None; ///< Value representing an empty/invalid address @@ -177,8 +177,8 @@ IpAddress a4(192, 168, 1, 56); // a local address IpAddress a5("my_computer"); // a local address created from a network name IpAddress a6("89.54.1.169"); // a distant address IpAddress a7("www.google.com"); // a distant address created from a network name -IpAddress a8 = IpAddress::GetLocalAddress(); // my address on the local network -IpAddress a9 = IpAddress::GetPublicAddress(); // my address on the internet +IpAddress a8 = IpAddress::getLocalAddress(); // my address on the local network +IpAddress a9 = IpAddress::getPublicAddress(); // my address on the internet @endcode Note that IpAddress currently doesn't support IPv6 nor other types of network addresses. diff --git a/include/eepp/network/packet.hpp b/include/eepp/network/packet.hpp index c48d9ec87..9de19218f 100644 --- a/include/eepp/network/packet.hpp +++ b/include/eepp/network/packet.hpp @@ -27,12 +27,12 @@ class EE_API Packet { ** @param data Pointer to the sequence of bytes to append ** @param sizeInBytes Number of bytes to append ** @see Clear */ - void Append(const void* data, std::size_t sizeInBytes); + void append(const void* data, std::size_t sizeInBytes); /** @brief Clear the packet ** After calling Clear, the packet is empty. ** @see Append */ - void Clear(); + void clear(); /** @brief Get a pointer to the data contained in the packet ** Warning: the returned pointer may become invalid after @@ -41,14 +41,14 @@ class EE_API Packet { ** The return pointer is NULL if the packet is empty. ** @return Pointer to the data ** @see GetDataSize */ - const void* GetData() const; + const void* getData() const; /** @brief Get the size of the data contained in the packet ** This function returns the number of bytes pointed to by ** what GetData returns. ** @return Data size, in bytes ** @see GetData */ - std::size_t GetDataSize() const; + std::size_t getDataSize() const; /** @brief Tell if the reading position has reached the /// end of the packet @@ -56,7 +56,7 @@ class EE_API Packet { ** left to be read, without actually reading it. ** @return True if all data was read, false otherwise ** @see operator bool */ - bool EndOfPacket() const; + bool endOfPacket() const; /** @brief Test the validity of the packet, for reading ** This operator allows to test the packet as a boolean @@ -141,7 +141,7 @@ protected: ** @param size Variable to fill with the size of data to send ** @return Pointer to the array of bytes to send ** @see OnReceive */ - virtual const void* OnSend(std::size_t& size); + virtual const void* onSend(std::size_t& size); /** @brief Called after the packet is received over the network ** This function can be defined by derived classes to @@ -154,7 +154,7 @@ protected: ** @param data Pointer to the received bytes ** @param size Number of bytes ** @see OnSend */ - virtual void OnReceive(const void* data, std::size_t size); + virtual void onReceive(const void* data, std::size_t size); private: /** Disallow comparisons between packets */ bool operator ==(const Packet& right) const; @@ -164,7 +164,7 @@ private: ** This function updates accordingly the state of the packet. ** @param size Size to check ** @return True if @a size bytes can be read from the packet */ - bool CheckSize(std::size_t size); + bool checkSize(std::size_t size); // Member data std::vector mData; ///< Data stored in the packet @@ -210,13 +210,13 @@ Packet packet; packet << x << s << d; // Send it over the network (socket is a valid TcpSocket) -socket.Send(packet); +socket.send(packet); ----------------------------------------------------------------- // Receive the packet at the other end Packet packet; -socket.Receive(packet); +socket.receive(packet); // Extract the variables contained in the packet Uint32 x; @@ -269,15 +269,15 @@ Here is an example: @code class ZipPacket : public Packet { - virtual const void* OnSend(std::size_t& size) + virtual const void* onSend(std::size_t& size) { - const void* srcData = GetData(); - std::size_t srcSize = GetDataSize(); + const void* srcData = getData(); + std::size_t srcSize = getDataSize(); return MySuperZipFunction(srcData, srcSize, &size); } - virtual void OnReceive(const void* data, std::size_t size) + virtual void onReceive(const void* data, std::size_t size) { std::size_t dstSize; const void* dstData = MySuperUnzipFunction(data, size, &dstSize); diff --git a/include/eepp/network/socket.hpp b/include/eepp/network/socket.hpp index ef27d7cd2..23b16c85f 100644 --- a/include/eepp/network/socket.hpp +++ b/include/eepp/network/socket.hpp @@ -40,12 +40,12 @@ class EE_API Socket : NonCopyable { ** By default, all sockets are blocking. ** @param blocking True to set the socket as blocking, false for non-blocking ** @see IsBlocking */ - void SetBlocking(bool blocking); + void setBlocking(bool blocking); /** @brief Tell whether the socket is in blocking or non-blocking mode ** @return True if the socket is blocking, false otherwise ** @see SetBlocking */ - bool IsBlocking() const; + bool isBlocking() const; protected : /** @brief Types of protocols that the socket can use */ enum Type @@ -64,22 +64,22 @@ protected : ** was not created yet (or already destroyed). ** This function can only be accessed by derived classes. ** @return The internal (OS-specific) handle of the socket */ - SocketHandle GetHandle() const; + SocketHandle getHandle() const; /** @brief Create the internal representation of the socket /// ** This function can only be accessed by derived classes. */ - void Create(); + void create(); /** @brief Create the internal representation of the socket from a socket handle ** This function can only be accessed by derived classes. ** @param handle OS-specific handle of the socket to wrap */ - void Create(SocketHandle handle); + void create(SocketHandle handle); /** @brief Close the socket gracefully ** This function can only be accessed by derived classes. */ - void Close(); + void close(); protected : friend class SocketSelector; // Member data diff --git a/include/eepp/network/socketselector.hpp b/include/eepp/network/socketselector.hpp index b74a6ea56..d005a412f 100644 --- a/include/eepp/network/socketselector.hpp +++ b/include/eepp/network/socketselector.hpp @@ -30,21 +30,21 @@ class EE_API SocketSelector ** This function does nothing if the socket is not valid. ** @param socket Reference to the socket to add ** @see Remove, Clear */ - void Add(Socket& socket); + void add(Socket& socket); /** @brief Remove a socket from the selector ** This function doesn't destroy the socket, it simply ** removes the reference that the selector has to it. ** @param socket Reference to the socket to remove ** @see Add, Clear */ - void Remove(Socket& socket); + void remove(Socket& socket); /** @brief Remove all the sockets stored in the selector ** This function doesn't destroy any instance, it simply ** removes all the references that the selector has to ** external sockets. ** @see Add, Remove */ - void Clear(); + void clear(); /** @brief Wait until one or more sockets are ready to receive ** This function returns as soon as at least one socket has @@ -55,7 +55,7 @@ class EE_API SocketSelector ** @param timeout Maximum time to wait, (use Time::Zero for infinity) ** @return True if there are sockets ready, false otherwise ** @see IsReady */ - bool Wait(Time timeout = Time::Zero); + bool wait(Time timeout = Time::Zero); /** @brief Test a socket to know if it is ready to receive data ** This function must be used after a call to Wait, to know @@ -67,7 +67,7 @@ class EE_API SocketSelector ** @param socket Socket to test ** @return True if the socket is ready to read, false otherwise ** @see IsReady */ - bool IsReady(Socket& socket) const; + bool isReady(Socket& socket) const; /** @brief Overload of assignment operator ** @param right Instance to assign diff --git a/include/eepp/network/ssl/sslsocket.hpp b/include/eepp/network/ssl/sslsocket.hpp index b697c0a19..50fd8bab8 100644 --- a/include/eepp/network/ssl/sslsocket.hpp +++ b/include/eepp/network/ssl/sslsocket.hpp @@ -11,28 +11,28 @@ class EE_API SSLSocket : public TcpSocket { public: static std::string CertificatesPath; - static bool Init(); + static bool init(); - static bool End(); + static bool end(); /** @return True when the library was compiled with SSL support. */ - static bool IsSupported(); + static bool isSupported(); SSLSocket( std::string hostname, bool validateCertificate, bool validateHostname ); virtual ~SSLSocket(); - Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero); + Status connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero); - void Disconnect(); + void disconnect(); - Status Send(const void* data, std::size_t size); + Status send(const void* data, std::size_t size); - Status Receive(void* data, std::size_t size, std::size_t& received); + Status receive(void* data, std::size_t size, std::size_t& received); - Status Send(Packet& packet); + Status send(Packet& packet); - Status Receive(Packet& packet); + Status receive(Packet& packet); protected: friend class SSLSocketImpl; friend class OpenSSLSocket; @@ -42,9 +42,9 @@ class EE_API SSLSocket : public TcpSocket { bool mValidateCertificate; bool mValidateHostname; - Status TcpSend(const void* data, std::size_t size); + Status tcpSend(const void* data, std::size_t size); - Status TcpReceive(void* data, std::size_t size, std::size_t& received); + Status tcpReceive(void* data, std::size_t size, std::size_t& received); }; }}} diff --git a/include/eepp/network/tcplistener.hpp b/include/eepp/network/tcplistener.hpp index e9f13050e..e42d54310 100644 --- a/include/eepp/network/tcplistener.hpp +++ b/include/eepp/network/tcplistener.hpp @@ -20,7 +20,7 @@ public : ** returns 0. ** @return Port to which the socket is bound ** @see Listen */ - unsigned short GetLocalPort() const; + unsigned short getLocalPort() const; /** @brief Start listening for connections ** This functions makes the socket listen to the specified @@ -30,13 +30,13 @@ public : ** @param port Port to listen for new connections ** @return Status code ** @see Accept, Close */ - Status Listen(unsigned short port); + Status listen(unsigned short port); /** @brief Stop listening and close the socket ** This function gracefully stops the listener. If the ** socket is not listening, this function has no effect. ** @see Listen */ - void Close(); + void close(); /** @brief Accept a new connection ** If the socket is in blocking mode, this function will @@ -44,7 +44,7 @@ public : ** @param socket Socket that will hold the new connection ** @return Status code ** @see Listen */ - Status Accept(TcpSocket& socket); + Status accept(TcpSocket& socket); }; }} @@ -79,16 +79,16 @@ Usage example: // Create a listener socket and make it wait for new // connections on port 55001 TcpListener listener; -listener.Listen(55001); +listener.listen(55001); // Endless loop that waits for new connections while (running) { TcpSocket client; - if (listener.Accept(client) == Socket::Done) + if (listener.accept(client) == Socket::Done) { // A new client just connected! - std::cout << "New connection received from " << client.GetRemoteAddress() << std::endl; + std::cout << "New connection received from " << client.getRemoteAddress() << std::endl; doSomethingWith(client); } } diff --git a/include/eepp/network/tcpsocket.hpp b/include/eepp/network/tcpsocket.hpp index 08bf70457..21bc279dc 100644 --- a/include/eepp/network/tcpsocket.hpp +++ b/include/eepp/network/tcpsocket.hpp @@ -22,21 +22,21 @@ class EE_API TcpSocket : public Socket { ** If the socket is not connected, this function returns 0. ** @return Port to which the socket is bound ** @see Connect, GetRemotePort */ - unsigned short GetLocalPort() const; + unsigned short getLocalPort() const; /** @brief Get the address of the connected peer ** It the socket is not connected, this function returns ** IpAddress::None. ** @return Address of the remote peer ** @see GetRemotePort */ - IpAddress GetRemoteAddress() const; + IpAddress getRemoteAddress() const; /** @brief Get the port of the connected peer to which the socket is connected ** If the socket is not connected, this function returns 0. ** @return Remote port to which the socket is connected ** @see GetRemoteAddress */ - unsigned short GetRemotePort() const; + unsigned short getRemotePort() const; /** @brief Connect the socket to a remote peer ** In blocking mode, this function may take a while, especially @@ -48,13 +48,13 @@ class EE_API TcpSocket : public Socket { ** @param timeout Optional maximum time to wait ** @return Status code ** @see Disconnect */ - virtual Status Connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero); + virtual Status connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout = Time::Zero); /** @brief Disconnect the socket from its remote peer ** This function gracefully closes the connection. If the ** socket is not connected, this function has no effect. ** @see Connect */ - virtual void Disconnect(); + virtual void disconnect(); /** @brief Send raw data to the remote peer ** To be able to handle partial sends over non-blocking @@ -67,7 +67,7 @@ class EE_API TcpSocket : public Socket { ** @param size Number of bytes to send ** @return Status code ** @see Receive */ - virtual Status Send(const void* data, std::size_t size); + virtual Status send(const void* data, std::size_t size); /** @brief Send raw data to the remote peer ** This function will fail if the socket is not connected. @@ -76,7 +76,7 @@ class EE_API TcpSocket : public Socket { ** @param sent The number of bytes sent will be written here ** @return Status code ** @see receive */ - virtual Status Send(const void* data, std::size_t size, std::size_t& sent); + virtual Status send(const void* data, std::size_t size, std::size_t& sent); /** @brief Receive raw data from the remote peer ** In blocking mode, this function will wait until some @@ -87,7 +87,7 @@ class EE_API TcpSocket : public Socket { ** @param received This variable is filled with the actual number of bytes received ** @return Status code ** @see Send */ - virtual Status Receive(void* data, std::size_t size, std::size_t& received); + virtual Status receive(void* data, std::size_t size, std::size_t& received); /** @brief Send a formatted packet of data to the remote peer * @@ -100,7 +100,7 @@ class EE_API TcpSocket : public Socket { ** @param packet Packet to send ** @return Status code ** @see Receive */ - virtual Status Send(Packet& packet); + virtual Status send(Packet& packet); /** @brief Receive a formatted packet of data from the remote peer ** In blocking mode, this function will wait until the whole packet @@ -109,7 +109,7 @@ class EE_API TcpSocket : public Socket { ** @param packet Packet to fill with the received data ** @return Status code ** @see Send */ - virtual Status Receive(Packet& packet); + virtual Status receive(Packet& packet); private: @@ -172,38 +172,38 @@ Usage example: // Create a socket and connect it to 192.168.1.50 on port 55001 TcpSocket socket; -socket.Connect("192.168.1.50", 55001); +socket.connect("192.168.1.50", 55001); // Send a message to the connected host std::string message = "Hi, I am a client"; -socket.Send(message.c_str(), message.size() + 1); +socket.send(message.c_str(), message.size() + 1); // Receive an answer from the server char buffer[1024]; std::size_t received = 0; -socket.Receive(buffer, sizeof(buffer), received); +socket.receive(buffer, sizeof(buffer), received); std::cout << "The server said: " << buffer << std::endl; // ----- The server ----- // Create a listener to wait for incoming connections on port 55001 TcpListener listener; -listener.Listen(55001); +listener.listen(55001); // Wait for a connection TcpSocket socket; -listener.Accept(socket); -std::cout << "New client connected: " << socket.GetRemoteAddress() << std::endl; +listener.accept(socket); +std::cout << "New client connected: " << socket.getRemoteAddress() << std::endl; // Receive a message from the client char buffer[1024]; std::size_t received = 0; -socket.Receive(buffer, sizeof(buffer), received); +socket.receive(buffer, sizeof(buffer), received); std::cout << "The client said: " << buffer << std::endl; // Send an answer std::string message = "Welcome, client"; -socket.Send(message.c_str(), message.size() + 1); +socket.send(message.c_str(), message.size() + 1); @endcode @see Socket, UdpSocket, Packet diff --git a/include/eepp/network/udpsocket.hpp b/include/eepp/network/udpsocket.hpp index ac3c2a85d..706b4034c 100644 --- a/include/eepp/network/udpsocket.hpp +++ b/include/eepp/network/udpsocket.hpp @@ -26,7 +26,7 @@ class EE_API UdpSocket : public Socket { ** returns 0. ** @return Port to which the socket is bound ** @see Bind */ - unsigned short GetLocalPort() const; + unsigned short getLocalPort() const; /** @brief Bind the socket to a specific port ** Binding the socket to a port is necessary for being @@ -37,14 +37,14 @@ class EE_API UdpSocket : public Socket { ** @param port Port to Bind the socket to ** @return Status code ** @see Unbind, GetLocalPort */ - Status Bind(unsigned short port); + Status bind(unsigned short port); /** @brief Unbind the socket from the local port to which it is bound ** The port that the socket was previously using is immediately ** available after this function is called. If the ** socket is not bound to a port, this function has no effect. ** @see Bind */ - void Unbind(); + void unbind(); /** @brief Send raw data to a remote peer ** Make sure that @a size is not greater than @@ -56,7 +56,7 @@ class EE_API UdpSocket : public Socket { ** @param remotePort Port of the receiver to send the data to ** @return Status code ** @see Receive */ - Status Send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort); + Status send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort); /** @brief Receive raw data from a remote peer ** In blocking mode, this function will wait until some @@ -72,7 +72,7 @@ class EE_API UdpSocket : public Socket { ** @param remotePort Port of the peer that sent the data ** @return Status code ** @see Send */ - Status Receive(void* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort); + Status receive(void* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort); /** @brief Send a formatted packet of data to a remote peer ** Make sure that the packet size is not greater than @@ -83,7 +83,7 @@ class EE_API UdpSocket : public Socket { ** @param remotePort Port of the receiver to send the data to ** @return Status code ** @see Receive */ - Status Send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort); + Status send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort); /** @brief Receive a formatted packet of data from a remote peer ** In blocking mode, this function will wait until the whole packet @@ -93,7 +93,7 @@ class EE_API UdpSocket : public Socket { ** @param remotePort Port of the peer that sent the data ** @return Status code ** @see Send */ - Status Receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort); + Status receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort); private: // Member data std::vector mBuffer; ///< Temporary buffer holding the received data in Receive(Packet) @@ -157,7 +157,7 @@ UdpSocket socket; socket.Bind(55001); // Send a message to 192.168.1.50 on port 55002 -std::string message = "Hi, I am " + IpAddress::GetLocalAddress().ToString(); +std::string message = "Hi, I am " + IpAddress::getLocalAddress().toString(); socket.Send(message.c_str(), message.size() + 1, "192.168.1.50", 55002); // Receive an answer (most likely from 192.168.1.50, but could be anyone else) @@ -165,26 +165,26 @@ char buffer[1024]; std::size_t received = 0; IpAddress sender; unsigned short port; -socket.Receive(buffer, sizeof(buffer), received, sender, port); -std::cout << sender.ToString() << " said: " << buffer << std::endl; +socket.receive(buffer, sizeof(buffer), received, sender, port); +std::cout << sender.toString() << " said: " << buffer << std::endl; // ----- The server ----- // Create a socket and bind it to the port 55002 UdpSocket socket; -socket.Bind(55002); +socket.bind(55002); // Receive a message from anyone char buffer[1024]; std::size_t received = 0; IpAddress sender; unsigned short port; -socket.Receive(buffer, sizeof(buffer), received, sender, port); -std::cout << sender.ToString() << " said: " << buffer << std::endl; +socket.receive(buffer, sizeof(buffer), received, sender, port); +std::cout << sender.toString() << " said: " << buffer << std::endl; // Send an answer -std::string message = "Welcome " + sender.ToString(); -socket.Send(message.c_str(), message.size() + 1, sender, port); +std::string message = "Welcome " + sender.toString(); +socket.send(message.c_str(), message.size() + 1, sender, port); @endcode @see Socket, TcpSocket, Packet diff --git a/include/eepp/network/uri.hpp b/include/eepp/network/uri.hpp index d76a54382..9cce38f06 100644 --- a/include/eepp/network/uri.hpp +++ b/include/eepp/network/uri.hpp @@ -89,106 +89,106 @@ class EE_API URI { URI& operator = (const char* uri); /** Swaps the URI with another one. */ - void Swap(URI& uri); + void swap(URI& uri); /** Clears all parts of the URI. */ - void Clear(); + void clear(); /** @returns a string representation of the URI. * Characters in the path, query and fragment parts will be percent-encoded as necessary. */ - std::string ToString() const; + std::string toString() const; /** @returns the scheme part of the URI. */ - const std::string& GetScheme() const; + const std::string& getScheme() const; /** Sets the scheme part of the URI. The given scheme is converted to lower-case. * A list of registered URI schemes can be found at . */ - void SetScheme(const std::string& scheme); + void setScheme(const std::string& scheme); /** @returns the user-info part of the URI. */ - const std::string& GetUserInfo() const; + const std::string& getUserInfo() const; /** Sets the user-info part of the URI. */ - void SetUserInfo(const std::string& userInfo); + void setUserInfo(const std::string& userInfo); /** @returns the host part of the URI. */ - const std::string& GetHost() const; + const std::string& getHost() const; /** Sets the host part of the URI. */ - void SetHost(const std::string& host); + void getHost(const std::string& host); /** @returns the port number part of the URI. * If no port number (0) has been specified, the * well-known port number (e.g., 80 for http) for * the given scheme is returned if it is known. * Otherwise, 0 is returned. */ - unsigned short GetPort() const; + unsigned short getPort() const; /** Sets the port number part of the URI. */ - void SetPort(unsigned short port); + void getPort(unsigned short port); /** @returns the authority part (userInfo, host and port) of the URI. * If the port number is a well-known port * number for the given scheme (e.g., 80 for http), it * is not included in the authority. */ - std::string GetAuthority() const; + std::string getAuthority() const; /** Parses the given authority part for the URI and sets * the user-info, host, port components accordingly. */ - void SetAuthority(const std::string& authority); + void setAuthority(const std::string& authority); /** @returns The scheme and authority of the URI. */ - std::string GetSchemeAndAuthority(); + std::string getSchemeAndAuthority(); /** @returns The path part of the URI. */ - const std::string& GetPath() const; + const std::string& getPath() const; /** Sets the path part of the URI. */ - void SetPath(const std::string& path); + void getPath(const std::string& path); /** @returns the query part of the URI. */ - std::string GetQuery() const; + std::string getQuery() const; /** Sets the query part of the URI. */ - void SetQuery(const std::string& query); + void setQuery(const std::string& query); /** @returns the unencoded query part of the URI. */ - const std::string& GetRawQuery() const; + const std::string& getRawQuery() const; /** Sets the query part of the URI. */ - void SetRawQuery(const std::string& query); + void setRawQuery(const std::string& query); /** @returns the fragment part of the URI. */ - const std::string& GetFragment() const; + const std::string& getFragment() const; /** Sets the fragment part of the URI. */ - void GetFragment(const std::string& fragment); + void getFragment(const std::string& fragment); /** Sets the path, query and fragment parts of the URI. */ - void SetPathEtc(const std::string& pathEtc); + void setPathEtc(const std::string& pathEtc); /** @returns the path, query and fragment parts of the URI. */ - std::string GetPathEtc() const; + std::string getPathEtc() const; /** @returns the path and query parts of the URI. */ - std::string GetPathAndQuery() const; + std::string getPathAndQuery() const; /** Resolves the given relative URI against the base URI. * See section 5.2 of RFC 3986 for the algorithm used. */ - void Resolve(const std::string& relativeURI); + void resolve(const std::string& relativeURI); /** Resolves the given relative URI against the base URI. * See section 5.2 of RFC 3986 for the algorithm used. */ - void Resolve(const URI& relativeURI); + void resolve(const URI& relativeURI); /** @returns true if the URI is a relative reference, false otherwise. * A relative reference does not contain a scheme identifier. * Relative references are usually resolved against an absolute * base reference. */ - bool IsRelative() const; + bool isRelative() const; /** @returns true if the URI is empty, false otherwise. */ - bool Empty() const; + bool empty() const; /** @returns true if both URIs are identical, false otherwise. * Two URIs are identical if their scheme, authority, @@ -208,64 +208,64 @@ class EE_API URI { * If the first path segment in a relative path contains a colon (:), * such as in a Windows path containing a drive letter, a dot segment (./) * is prepended in accordance with section 3.3 of RFC 3986. */ - void Normalize(); + void normalize(); /** Places the single path segments (delimited by slashes) into the given vector. */ - void GetPathSegments(std::vector& segments); + void getPathSegments(std::vector& segments); /** URI-encodes the given string by escaping reserved and non-ASCII * characters. The encoded string is appended to encodedStr. */ - static void Encode(const std::string& str, const std::string& reserved, std::string& encodedStr); + static void encode(const std::string& str, const std::string& reserved, std::string& encodedStr); /** URI-decodes the given string by replacing percent-encoded * characters with the actual character. The decoded string * is appended to decodedStr. */ - static void Decode(const std::string& str, std::string& decodedStr); + static void decode(const std::string& str, std::string& decodedStr); protected: /** @returns true if both uri's are equivalent. */ - bool Equals(const URI& uri) const; + bool equals(const URI& uri) const; /** @returns true if the URI's port number is a well-known one * (for example, 80, if the scheme is http). */ - bool IsWellKnownPort() const; + bool isWellKnownPort() const; /** @returns the well-known port number for the URI's scheme, * or 0 if the port number is not known. */ - unsigned short GetWellKnownPort() const; + unsigned short getWellKnownPort() const; /** Parses and assigns an URI from the given string. Throws a * SyntaxException if the uri is not valid. */ - void Parse(const std::string& uri); + void parse(const std::string& uri); /** Parses and sets the user-info, host and port from the given data. */ - void ParseAuthority(std::string::const_iterator& it, const std::string::const_iterator& end); + void parseAuthority(std::string::const_iterator& it, const std::string::const_iterator& end); /** Parses and sets the host and port from the given data. */ - void ParseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end); + void parseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end); /** Parses and sets the path from the given data. */ - void ParsePath(std::string::const_iterator& it, const std::string::const_iterator& end); + void parsePath(std::string::const_iterator& it, const std::string::const_iterator& end); /** Parses and sets the path, query and fragment from the given data. */ - void ParsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end); + void parsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end); /** Parses and sets the query from the given data. */ - void ParseQuery(std::string::const_iterator& it, const std::string::const_iterator& end); + void parseQuery(std::string::const_iterator& it, const std::string::const_iterator& end); /** Parses and sets the fragment from the given data. */ - void ParseFragment(std::string::const_iterator& it, const std::string::const_iterator& end); + void parseFragment(std::string::const_iterator& it, const std::string::const_iterator& end); /** Appends a path to the URI's path. */ - void MergePath(const std::string& path); + void mergePath(const std::string& path); /** Removes all dot segments from the path. */ - void RemoveDotSegments(bool removeLeading = true); + void removeDotSegments(bool removeLeading = true); /** Places the single path segments (delimited by slashes) into the given vector. */ - static void GetPathSegments(const std::string& path, std::vector& segments); + static void getPathSegments(const std::string& path, std::vector& segments); /** Builds the path from the given segments. */ - void BuildPath(const std::vector& segments, bool leadingSlash, bool trailingSlash); + void buildPath(const std::vector& segments, bool leadingSlash, bool trailingSlash); static const std::string RESERVED_PATH; static const std::string RESERVED_QUERY; @@ -281,32 +281,32 @@ class EE_API URI { std::string mFragment; }; -inline const std::string& URI::GetScheme() const { +inline const std::string& URI::getScheme() const { return mScheme; } -inline const std::string& URI::GetUserInfo() const { +inline const std::string& URI::getUserInfo() const { return mUserInfo; } -inline const std::string& URI::GetHost() const { +inline const std::string& URI::getHost() const { return mHost; } -inline const std::string& URI::GetPath() const { +inline const std::string& URI::getPath() const { return mPath; } -inline const std::string& URI::GetRawQuery() const { +inline const std::string& URI::getRawQuery() const { return mQuery; } -inline const std::string& URI::GetFragment() const { +inline const std::string& URI::getFragment() const { return mFragment; } -inline void Swap(URI& u1, URI& u2) { - u1.Swap(u2); +inline void swap(URI& u1, URI& u2) { + u1.swap(u2); } }} diff --git a/src/eepp/network/ftp.cpp b/src/eepp/network/ftp.cpp index 56bbb417d..5ca602d38 100644 --- a/src/eepp/network/ftp.cpp +++ b/src/eepp/network/ftp.cpp @@ -29,37 +29,37 @@ Ftp::Response::Response(Status code, const std::string& message) : { } -bool Ftp::Response::IsOk() const { +bool Ftp::Response::isOk() const { return mStatus < 400; } -Ftp::Response::Status Ftp::Response::GetStatus() const { +Ftp::Response::Status Ftp::Response::getStatus() const { return mStatus; } -const std::string& Ftp::Response::GetMessage() const { +const std::string& Ftp::Response::getMessage() const { return mMessage; } Ftp::DirectoryResponse::DirectoryResponse(const Ftp::Response& response) : Ftp::Response(response) { - if ( IsOk() ) { + if ( isOk() ) { // Extract the directory from the server response - std::string::size_type begin = GetMessage().find('"', 0); - std::string::size_type end = GetMessage().find('"', begin + 1); - mDirectory = GetMessage().substr(begin + 1, end - begin - 1); + std::string::size_type begin = getMessage().find('"', 0); + std::string::size_type end = getMessage().find('"', begin + 1); + mDirectory = getMessage().substr(begin + 1, end - begin - 1); } } -const std::string& Ftp::DirectoryResponse::GetDirectory() const { +const std::string& Ftp::DirectoryResponse::getDirectory() const { return mDirectory; } Ftp::ListingResponse::ListingResponse(const Ftp::Response& response, const std::string& data) : Ftp::Response(response) { - if ( IsOk() ) { + if ( isOk() ) { // Fill the array of strings std::string::size_type lastPos = 0; for (std::string::size_type pos = data.find("\r\n"); pos != std::string::npos; pos = data.find("\r\n", lastPos)) { @@ -69,111 +69,111 @@ Ftp::ListingResponse::ListingResponse(const Ftp::Response& response, const std:: } } -const std::vector& Ftp::ListingResponse::GetListing() const { +const std::vector& Ftp::ListingResponse::getListing() const { return mListing; } Ftp::~Ftp() { - Disconnect(); + disconnect(); } -Ftp::Response Ftp::Connect(const IpAddress& server, unsigned short port, Time timeout) { +Ftp::Response Ftp::connect(const IpAddress& server, unsigned short port, Time timeout) { // Connect to the server - if (mCommandSocket.Connect(server, port, timeout) != Socket::Done) + if (mCommandSocket.connect(server, port, timeout) != Socket::Done) return Response(Response::ConnectionFailed); // Get the response to the connection - return GetResponse(); + return getResponse(); } -Ftp::Response Ftp::Login() { - return Login("anonymous", "user@eepp.com.ar"); +Ftp::Response Ftp::login() { + return login("anonymous", "user@eepp.com.ar"); } -Ftp::Response Ftp::Login(const std::string& name, const std::string& password) { - Response response = SendCommand("USER", name); - if (response.IsOk()) - response = SendCommand("PASS", password); +Ftp::Response Ftp::login(const std::string& name, const std::string& password) { + Response response = sendCommand("USER", name); + if (response.isOk()) + response = sendCommand("PASS", password); return response; } -Ftp::Response Ftp::Disconnect() { +Ftp::Response Ftp::disconnect() { // Send the exit command - Response response = SendCommand("QUIT"); - if (response.IsOk()) - mCommandSocket.Disconnect(); + Response response = sendCommand("QUIT"); + if (response.isOk()) + mCommandSocket.disconnect(); return response; } -Ftp::Response Ftp::KeepAlive() { - return SendCommand("NOOP"); +Ftp::Response Ftp::keepAlive() { + return sendCommand("NOOP"); } -Ftp::DirectoryResponse Ftp::GetWorkingDirectory() { - return DirectoryResponse(SendCommand("PWD")); +Ftp::DirectoryResponse Ftp::getWorkingDirectory() { + return DirectoryResponse(sendCommand("PWD")); } -Ftp::ListingResponse Ftp::GetDirectoryListing(const std::string& directory) { +Ftp::ListingResponse Ftp::getDirectoryListing(const std::string& directory) { // Open a data channel on default port (20) using ASCII transfer mode std::ostringstream directoryData; DataChannel data(*this); Response response = data.Open(Ascii); - if (response.IsOk()) { + if (response.isOk()) { // Tell the server to send us the listing - response = SendCommand("NLST", directory); - if (response.IsOk()) { + response = sendCommand("NLST", directory); + if (response.isOk()) { // Receive the listing data.Receive(directoryData); // Get the response from the server - response = GetResponse(); + response = getResponse(); } } return ListingResponse(response, directoryData.str()); } -Ftp::Response Ftp::ChangeDirectory(const std::string& directory) { - return SendCommand("CWD", directory); +Ftp::Response Ftp::changeDirectory(const std::string& directory) { + return sendCommand("CWD", directory); } -Ftp::Response Ftp::ParentDirectory() { - return SendCommand("CDUP"); +Ftp::Response Ftp::parentDirectory() { + return sendCommand("CDUP"); } -Ftp::Response Ftp::CreateDirectory(const std::string& name) { - return SendCommand("MKD", name); +Ftp::Response Ftp::createDirectory(const std::string& name) { + return sendCommand("MKD", name); } -Ftp::Response Ftp::DeleteDirectory(const std::string& name) { - return SendCommand("RMD", name); +Ftp::Response Ftp::deleteDirectory(const std::string& name) { + return sendCommand("RMD", name); } -Ftp::Response Ftp::RenameFile(const std::string& file, const std::string& newName) { - Response response = SendCommand("RNFR", file); - if (response.IsOk()) - response = SendCommand("RNTO", newName); +Ftp::Response Ftp::renameFile(const std::string& file, const std::string& newName) { + Response response = sendCommand("RNFR", file); + if (response.isOk()) + response = sendCommand("RNTO", newName); return response; } -Ftp::Response Ftp::DeleteFile(const std::string& name) { - return SendCommand("DELE", name); +Ftp::Response Ftp::deleteFile(const std::string& name) { + return sendCommand("DELE", name); } -Ftp::Response Ftp::Download(const std::string& remoteFile, const std::string& localPath, TransferMode mode) { +Ftp::Response Ftp::download(const std::string& remoteFile, const std::string& localPath, TransferMode mode) { // Open a data channel using the given transfer mode DataChannel data(*this); Response response = data.Open(mode); - if ( response.IsOk() ) { + if ( response.isOk() ) { // Tell the server to start the transfer - response = SendCommand("RETR", remoteFile); + response = sendCommand("RETR", remoteFile); - if ( response.IsOk() ) + if ( response.isOk() ) { // Extract the filename from the file path std::string filename = remoteFile; @@ -198,10 +198,10 @@ Ftp::Response Ftp::Download(const std::string& remoteFile, const std::string& lo file.close(); // Get the response from the server - response = GetResponse(); + response = getResponse(); // If the download was unsuccessful, delete the partial file - if (!response.IsOk()) + if (!response.isOk()) std::remove((path + filename).c_str()); } } @@ -209,7 +209,7 @@ Ftp::Response Ftp::Download(const std::string& remoteFile, const std::string& lo return response; } -Ftp::Response Ftp::Upload(const std::string& localFile, const std::string& remotePath, TransferMode mode) { +Ftp::Response Ftp::upload(const std::string& localFile, const std::string& remotePath, TransferMode mode) { // Get the contents of the file to send std::ifstream file(localFile.c_str(), std::ios_base::binary); if (!file) @@ -229,22 +229,22 @@ Ftp::Response Ftp::Upload(const std::string& localFile, const std::string& remot // Open a data channel using the given transfer mode DataChannel data(*this); Response response = data.Open(mode); - if (response.IsOk()) { + if (response.isOk()) { // Tell the server to start the transfer - response = SendCommand("STOR", path + filename); - if (response.IsOk()) { + response = sendCommand("STOR", path + filename); + if (response.isOk()) { // Send the file data data.Send(file); // Get the response from the server - response = GetResponse(); + response = getResponse(); } } return response; } -Ftp::Response Ftp::SendCommand(const std::string& command, const std::string& parameter) { +Ftp::Response Ftp::sendCommand(const std::string& command, const std::string& parameter) { // Build the command string std::string commandStr; if (parameter != "") @@ -253,14 +253,14 @@ Ftp::Response Ftp::SendCommand(const std::string& command, const std::string& pa commandStr = command + "\r\n"; // Send it to the server - if (mCommandSocket.Send(commandStr.c_str(), commandStr.length()) != Socket::Done) + if (mCommandSocket.send(commandStr.c_str(), commandStr.length()) != Socket::Done) return Response(Response::ConnectionClosed); // Get the response - return GetResponse(); + return getResponse(); } -Ftp::Response Ftp::GetResponse() { +Ftp::Response Ftp::getResponse() { // We'll use a variable to keep track of the last valid code. // It is useful in case of multi-lines responses, because the end of such a response // will start by the same code @@ -272,7 +272,7 @@ Ftp::Response Ftp::GetResponse() { // Receive the response from the server char buffer[1024]; std::size_t length; - if (mCommandSocket.Receive(buffer, sizeof(buffer), length) != Socket::Done) + if (mCommandSocket.receive(buffer, sizeof(buffer), length) != Socket::Done) return Response(Response::ConnectionClosed); // There can be several lines inside the received buffer, extract them all @@ -376,15 +376,15 @@ Ftp::DataChannel::DataChannel(Ftp& owner) : Ftp::Response Ftp::DataChannel::Open(Ftp::TransferMode mode) { // Open a data connection in active mode (we connect to the server) - Ftp::Response response = mFtp.SendCommand("PASV"); + Ftp::Response response = mFtp.sendCommand("PASV"); - if (response.IsOk()) { + if (response.isOk()) { // Extract the connection address and port from the response - std::string::size_type begin = response.GetMessage().find_first_of("0123456789"); + std::string::size_type begin = response.getMessage().find_first_of("0123456789"); if (begin != std::string::npos) { Uint8 data[6] = {0, 0, 0, 0, 0, 0}; - std::string str = response.GetMessage().substr(begin); + std::string str = response.getMessage().substr(begin); std::size_t index = 0; std::locale loc; @@ -407,7 +407,7 @@ Ftp::Response Ftp::DataChannel::Open(Ftp::TransferMode mode) { static_cast(data[3])); // Connect the data channel to the server - if (mDataSocket.Connect(address, port) == Socket::Done) { + if (mDataSocket.connect(address, port) == Socket::Done) { // Translate the transfer mode to the corresponding FTP parameter std::string modeStr; switch (mode) { @@ -417,7 +417,7 @@ Ftp::Response Ftp::DataChannel::Open(Ftp::TransferMode mode) { } // Set the transfer mode - response = mFtp.SendCommand("TYPE", modeStr); + response = mFtp.sendCommand("TYPE", modeStr); } else { // Failed to connect to the server response = Ftp::Response(Ftp::Response::ConnectionFailed); @@ -433,7 +433,7 @@ void Ftp::DataChannel::Receive(std::ostream& stream) { char buffer[1024]; std::size_t received; - while (mDataSocket.Receive(buffer, sizeof(buffer), received) == Socket::Done) { + while (mDataSocket.receive(buffer, sizeof(buffer), received) == Socket::Done) { stream.write(buffer, static_cast(received)); if (!stream.good()) { @@ -443,7 +443,7 @@ void Ftp::DataChannel::Receive(std::ostream& stream) { } // Close the data socket - mDataSocket.Disconnect(); + mDataSocket.disconnect(); } void Ftp::DataChannel::Send( std::istream& stream ) { @@ -464,7 +464,7 @@ void Ftp::DataChannel::Send( std::istream& stream ) { if (count > 0) { // we could read more data from the stream: send them - if (mDataSocket.Send(buffer, count) != Socket::Done) + if (mDataSocket.send(buffer, count) != Socket::Done) break; } else { // no more data: exit the loop @@ -473,7 +473,7 @@ void Ftp::DataChannel::Send( std::istream& stream ) { } // Close the data socket - mDataSocket.Disconnect(); + mDataSocket.disconnect(); } }} diff --git a/src/eepp/network/http.cpp b/src/eepp/network/http.cpp index 18ed08065..4c48330eb 100644 --- a/src/eepp/network/http.cpp +++ b/src/eepp/network/http.cpp @@ -14,21 +14,21 @@ Http::Request::Request(const std::string& uri, Method method, const std::string& mValidateCertificate( validateCertificate ), mValidateHostname( validateHostname ) { - SetMethod(method); - SetUri(uri); - SetHttpVersion(1, 0); - SetBody(body); + setMethod(method); + setUri(uri); + setHttpVersion(1, 0); + setBody(body); } -void Http::Request::SetField(const std::string& field, const std::string& value) { +void Http::Request::setField(const std::string& field, const std::string& value) { mFields[String::toLower(field)] = value; } -void Http::Request::SetMethod(Http::Request::Method method) { +void Http::Request::setMethod(Http::Request::Method method) { mMethod = method; } -void Http::Request::SetUri(const std::string& uri) { +void Http::Request::setUri(const std::string& uri) { mUri = uri; // Make sure it starts with a '/' @@ -36,36 +36,36 @@ void Http::Request::SetUri(const std::string& uri) { mUri.insert(0, "/"); } -void Http::Request::SetHttpVersion(unsigned int major, unsigned int minor) { +void Http::Request::setHttpVersion(unsigned int major, unsigned int minor) { mMajorVersion = major; mMinorVersion = minor; } -void Http::Request::SetBody(const std::string& body) { +void Http::Request::setBody(const std::string& body) { mBody = body; } -const std::string &Http::Request::GetUri() const { +const std::string &Http::Request::getUri() const { return mUri; } -const bool& Http::Request::ValidateCertificate() const { +const bool& Http::Request::validateCertificate() const { return mValidateCertificate; } -void Http::Request::ValidateCertificate(bool enable) { +void Http::Request::validateCertificate(bool enable) { mValidateCertificate = enable; } -const bool &Http::Request::ValidateHostname() const { +const bool &Http::Request::validateHostname() const { return mValidateHostname; } -void Http::Request::ValidateHostname(bool enable) { +void Http::Request::validateHostname(bool enable) { mValidateHostname = enable; } -std::string Http::Request::Prepare() const { +std::string Http::Request::prepare() const { std::ostringstream out; // Convert the method to its string representation @@ -97,7 +97,7 @@ std::string Http::Request::Prepare() const { return out.str(); } -bool Http::Request::HasField(const std::string& field) const { +bool Http::Request::hasField(const std::string& field) const { return mFields.find(String::toLower(field)) != mFields.end(); } @@ -108,7 +108,7 @@ Http::Response::Response() : { } -const std::string& Http::Response::GetField(const std::string& field) const { +const std::string& Http::Response::getField(const std::string& field) const { FieldTable::const_iterator it = mFields.find(String::toLower(field)); if (it != mFields.end()) { return it->second; @@ -118,23 +118,23 @@ const std::string& Http::Response::GetField(const std::string& field) const { } } -Http::Response::Status Http::Response::GetStatus() const { +Http::Response::Status Http::Response::getStatus() const { return mStatus; } -unsigned int Http::Response::GetMajorHttpVersion() const { +unsigned int Http::Response::getMajorHttpVersion() const { return mMajorVersion; } -unsigned int Http::Response::GetMinorHttpVersion() const { +unsigned int Http::Response::getMinorHttpVersion() const { return mMinorVersion; } -const std::string& Http::Response::GetBody() const { +const std::string& Http::Response::getBody() const { return mBody; } -void Http::Response::Parse(const std::string& data) { +void Http::Response::parse(const std::string& data) { std::istringstream in(data); // Extract the HTTP version from the first line @@ -169,13 +169,13 @@ void Http::Response::Parse(const std::string& data) { in.ignore(std::numeric_limits::max(), '\n'); // Parse the other lines, which contain fields, one by one - ParseFields(in); + parseFields(in); // Finally extract the body mBody.clear(); // Determine whether the transfer is chunked - if (String::toLower(GetField("transfer-encoding")) != "chunked") { + if (String::toLower(getField("transfer-encoding")) != "chunked") { // Not chunked - everything at once std::copy(std::istreambuf_iterator(in), std::istreambuf_iterator(), std::back_inserter(mBody)); } else { @@ -197,11 +197,11 @@ void Http::Response::Parse(const std::string& data) { in.ignore(std::numeric_limits::max(), '\n'); // Read all trailers (if present) - ParseFields(in); + parseFields(in); } } -void Http::Response::ParseFields(std::istream &in) { +void Http::Response::parseFields(std::istream &in) { std::string line; while (std::getline(in, line) && (line.size() > 2)) { std::string::size_type pos = line.find(": "); @@ -233,7 +233,7 @@ Http::Http(const std::string& host, unsigned short port, bool useSSL) : mConnection( NULL ), mIsSSL( false ) { - SetHost(host, port, useSSL); + setHost(host, port, useSSL); } Http::~Http() { @@ -254,7 +254,7 @@ Http::~Http() { eeSAFE_DELETE( tcp ); } -void Http::SetHost(const std::string& host, unsigned short port, bool useSSL) { +void Http::setHost(const std::string& host, unsigned short port, bool useSSL) { // Check the protocol if (String::toLower(host.substr(0, 7)) == "http://") { // HTTP protocol @@ -288,72 +288,72 @@ void Http::SetHost(const std::string& host, unsigned short port, bool useSSL) { mHost = IpAddress(mHostName); } -Http::Response Http::SendRequest(const Http::Request& request, Time timeout) { - if ( 0 == mHost.ToInteger() ) { +Http::Response Http::sendRequest(const Http::Request& request, Time timeout) { + if ( 0 == mHost.toInteger() ) { return Response(); } if ( NULL == mConnection ) { - TcpSocket * Conn = mIsSSL ? eeNew( SSLSocket, ( mHostName, request.ValidateCertificate(), request.ValidateHostname() ) ) : eeNew( TcpSocket, () ); + TcpSocket * Conn = mIsSSL ? eeNew( SSLSocket, ( mHostName, request.validateCertificate(), request.validateHostname() ) ) : eeNew( TcpSocket, () ); mConnection = Conn; } // First make sure that the request is valid -- add missing mandatory fields Request toSend(request); - if (!toSend.HasField("From")) { - toSend.SetField("From", "user@eepp.com.ar"); + if (!toSend.hasField("From")) { + toSend.setField("From", "user@eepp.com.ar"); } - if (!toSend.HasField("User-Agent")) { - toSend.SetField("User-Agent", "eepp-network"); + if (!toSend.hasField("User-Agent")) { + toSend.setField("User-Agent", "eepp-network"); } - if (!toSend.HasField("Host")) { - toSend.SetField("Host", mHostName); + if (!toSend.hasField("Host")) { + toSend.setField("Host", mHostName); } - if (!toSend.HasField("Content-Length")) { + if (!toSend.hasField("Content-Length")) { std::ostringstream out; out << toSend.mBody.size(); - toSend.SetField("Content-Length", out.str()); + toSend.setField("Content-Length", out.str()); } - if ((toSend.mMethod == Request::Post) && !toSend.HasField("Content-Type")) { - toSend.SetField("Content-Type", "application/x-www-form-urlencoded"); + if ((toSend.mMethod == Request::Post) && !toSend.hasField("Content-Type")) { + toSend.setField("Content-Type", "application/x-www-form-urlencoded"); } - if ((toSend.mMajorVersion * 10 + toSend.mMinorVersion >= 11) && !toSend.HasField("Connection")) { - toSend.SetField("Connection", "close"); + if ((toSend.mMajorVersion * 10 + toSend.mMinorVersion >= 11) && !toSend.hasField("Connection")) { + toSend.setField("Connection", "close"); } // Prepare the response Response received; // Connect the socket to the host - if (mConnection->Connect(mHost, mPort, timeout) == Socket::Done) { + if (mConnection->connect(mHost, mPort, timeout) == Socket::Done) { // Convert the request to string and send it through the connected socket - std::string requestStr = toSend.Prepare(); + std::string requestStr = toSend.prepare(); if (!requestStr.empty()) { // Send it through the socket - if (mConnection->Send(requestStr.c_str(), requestStr.size()) == Socket::Done) { + if (mConnection->send(requestStr.c_str(), requestStr.size()) == Socket::Done) { // Wait for the server's response std::string receivedStr; std::size_t size = 0; char buffer[1024]; - while (mConnection->Receive(buffer, sizeof(buffer), size) == Socket::Done) { + while (mConnection->receive(buffer, sizeof(buffer), size) == Socket::Done) { receivedStr.append(buffer, buffer + size); } // Build the Response object from the received data - received.Parse(receivedStr); + received.parse(receivedStr); } } // Close the connection - mConnection->Disconnect(); + mConnection->disconnect(); } return received; @@ -369,7 +369,7 @@ Http::AsyncRequest::AsyncRequest(Http *http, AsyncResponseCallback cb, Http::Req } void Http::AsyncRequest::run() { - Http::Response response = mHttp->SendRequest( mRequest, mTimeout ); + Http::Response response = mHttp->sendRequest( mRequest, mTimeout ); mCb( *mHttp, mRequest, response ); @@ -381,7 +381,7 @@ void Http::AsyncRequest::run() { mRunning = false; } -void Http::RemoveOldThreads() { +void Http::removeOldThreads() { std::list remove; std::list::iterator it = mThreads.begin(); @@ -404,7 +404,7 @@ void Http::RemoveOldThreads() { } } -void Http::SendAsyncRequest( AsyncResponseCallback cb, const Http::Request& request, Time timeout ) { +void Http::sendAsyncRequest( AsyncResponseCallback cb, const Http::Request& request, Time timeout ) { AsyncRequest * thread = eeNew( AsyncRequest, ( this, cb, request, timeout ) ); thread->launch(); @@ -412,20 +412,20 @@ void Http::SendAsyncRequest( AsyncResponseCallback cb, const Http::Request& requ // Clean old threads Lock l( mThreadsMutex ); - RemoveOldThreads(); + removeOldThreads(); mThreads.push_back( thread ); } -const IpAddress &Http::GetHost() const { +const IpAddress &Http::getHost() const { return mHost; } -const std::string &Http::GetHostName() const { +const std::string &Http::getHostName() const { return mHostName; } -const unsigned short& Http::GetPort() const { +const unsigned short& Http::getPort() const { return mPort; } diff --git a/src/eepp/network/ipaddress.cpp b/src/eepp/network/ipaddress.cpp index 4c71aefdd..cfb46c897 100644 --- a/src/eepp/network/ipaddress.cpp +++ b/src/eepp/network/ipaddress.cpp @@ -69,7 +69,7 @@ IpAddress::IpAddress(Uint32 address) : { } -std::string IpAddress::ToString() const { +std::string IpAddress::toString() const { in_addr address; address.s_addr = mAddress; @@ -77,11 +77,11 @@ std::string IpAddress::ToString() const { } -Uint32 IpAddress::ToInteger() const { +Uint32 IpAddress::toInteger() const { return ntohl(mAddress); } -IpAddress IpAddress::GetLocalAddress() { +IpAddress IpAddress::getLocalAddress() { // The method here is to connect a UDP socket to anyone (here to localhost), // and get the local socket address with the getsockname function. // UDP connection will not send anything to the network, so this function won't cause any overhead. @@ -116,7 +116,7 @@ IpAddress IpAddress::GetLocalAddress() { return localAddress; } -IpAddress IpAddress::GetPublicAddress(Time timeout) { +IpAddress IpAddress::getPublicAddress(Time timeout) { // The trick here is more complicated, because the only way // to get our public IP address is to get it from a distant computer. // Here we get the web page from http://www.sfml-dev.org/ip-provider.php @@ -124,16 +124,16 @@ IpAddress IpAddress::GetPublicAddress(Time timeout) { // (not very hard: the web page contains only our IP address). Http server("www.sfml-dev.org"); Http::Request request("/ip-provider.php", Http::Request::Get); - Http::Response page = server.SendRequest(request, timeout); - if (page.GetStatus() == Http::Response::Ok) - return IpAddress(page.GetBody()); + Http::Response page = server.sendRequest(request, timeout); + if (page.getStatus() == Http::Response::Ok) + return IpAddress(page.getBody()); // Something failed: return an invalid address return IpAddress(); } bool operator ==(const IpAddress& left, const IpAddress& right) { - return left.ToInteger() == right.ToInteger(); + return left.toInteger() == right.toInteger(); } bool operator !=(const IpAddress& left, const IpAddress& right) { @@ -141,7 +141,7 @@ bool operator !=(const IpAddress& left, const IpAddress& right) { } bool operator <(const IpAddress& left, const IpAddress& right) { - return left.ToInteger() < right.ToInteger(); + return left.toInteger() < right.toInteger(); } bool operator >(const IpAddress& left, const IpAddress& right) { @@ -165,7 +165,7 @@ std::istream& operator >>(std::istream& stream, IpAddress& address) { } std::ostream& operator <<(std::ostream& stream, const IpAddress& address) { - return stream << address.ToString(); + return stream << address.toString(); } }} diff --git a/src/eepp/network/packet.cpp b/src/eepp/network/packet.cpp index 412978528..d911cabba 100644 --- a/src/eepp/network/packet.cpp +++ b/src/eepp/network/packet.cpp @@ -19,7 +19,7 @@ Packet::~Packet() { } -void Packet::Append(const void* data, std::size_t sizeInBytes) { +void Packet::append(const void* data, std::size_t sizeInBytes) { if (data && (sizeInBytes > 0)) { std::size_t start = mData.size(); mData.resize(start + sizeInBytes); @@ -27,26 +27,26 @@ void Packet::Append(const void* data, std::size_t sizeInBytes) { } } -void Packet::Clear() { +void Packet::clear() { mData.clear(); mReadPos = 0; mIsValid = true; } -const void* Packet::GetData() const { +const void* Packet::getData() const { return !mData.empty() ? &mData[0] : NULL; } -std::size_t Packet::GetDataSize() const { +std::size_t Packet::getDataSize() const { return mData.size(); } -bool Packet::EndOfPacket() const { +bool Packet::endOfPacket() const { return mReadPos >= mData.size(); } Packet::operator BoolType() const { - return mIsValid ? &Packet::CheckSize : NULL; + return mIsValid ? &Packet::checkSize : NULL; } Packet& Packet::operator >>(bool& data) { @@ -58,7 +58,7 @@ Packet& Packet::operator >>(bool& data) { } Packet& Packet::operator >>(Int8& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = *reinterpret_cast(&mData[mReadPos]); mReadPos += sizeof(data); } @@ -67,7 +67,7 @@ Packet& Packet::operator >>(Int8& data) { } Packet& Packet::operator >>(Uint8& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = *reinterpret_cast(&mData[mReadPos]); mReadPos += sizeof(data); } @@ -76,7 +76,7 @@ Packet& Packet::operator >>(Uint8& data) { } Packet& Packet::operator >>(Int16& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = ntohs(*reinterpret_cast(&mData[mReadPos])); mReadPos += sizeof(data); } @@ -85,7 +85,7 @@ Packet& Packet::operator >>(Int16& data) { } Packet& Packet::operator >>(Uint16& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = ntohs(*reinterpret_cast(&mData[mReadPos])); mReadPos += sizeof(data); } @@ -95,7 +95,7 @@ Packet& Packet::operator >>(Uint16& data) { Packet& Packet::operator >>(Int32& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = ntohl(*reinterpret_cast(&mData[mReadPos])); mReadPos += sizeof(data); } @@ -104,7 +104,7 @@ Packet& Packet::operator >>(Int32& data) { } Packet& Packet::operator >>(Uint32& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = ntohl(*reinterpret_cast(&mData[mReadPos])); mReadPos += sizeof(data); } @@ -113,7 +113,7 @@ Packet& Packet::operator >>(Uint32& data) { } Packet& Packet::operator >>(float& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = *reinterpret_cast(&mData[mReadPos]); mReadPos += sizeof(data); } @@ -122,7 +122,7 @@ Packet& Packet::operator >>(float& data) { } Packet& Packet::operator >>(double& data) { - if (CheckSize(sizeof(data))) { + if (checkSize(sizeof(data))) { data = *reinterpret_cast(&mData[mReadPos]); mReadPos += sizeof(data); } @@ -135,7 +135,7 @@ Packet& Packet::operator >>(char* data) { Uint32 length = 0; *this >> length; - if ((length > 0) && CheckSize(length)) { + if ((length > 0) && checkSize(length)) { // Then extract characters std::memcpy(data, &mData[mReadPos], length); data[length] = '\0'; @@ -153,7 +153,7 @@ Packet& Packet::operator >>(std::string& data) { *this >> length; data.clear(); - if ((length > 0) && CheckSize(length)) + if ((length > 0) && checkSize(length)) { // Then extract characters data.assign(&mData[mReadPos], length); @@ -171,7 +171,7 @@ Packet& Packet::operator >>(wchar_t* data) { Uint32 length = 0; *this >> length; - if ((length > 0) && CheckSize(length * sizeof(Uint32))) { + if ((length > 0) && checkSize(length * sizeof(Uint32))) { // Then extract characters for (Uint32 i = 0; i < length; ++i) { Uint32 character = 0; @@ -191,7 +191,7 @@ Packet& Packet::operator >>(std::wstring& data) { *this >> length; data.clear(); - if ((length > 0) && CheckSize(length * sizeof(Uint32))) { + if ((length > 0) && checkSize(length * sizeof(Uint32))) { // Then extract characters for (Uint32 i = 0; i < length; ++i) { Uint32 character = 0; @@ -210,7 +210,7 @@ Packet& Packet::operator >>(String& data) { *this >> length; data.clear(); - if ((length > 0) && CheckSize(length * sizeof(Uint32))) { + if ((length > 0) && checkSize(length * sizeof(Uint32))) { // Then extract characters for (Uint32 i = 0; i < length; ++i) { Uint32 character = 0; @@ -228,46 +228,46 @@ Packet& Packet::operator <<(bool data) { } Packet& Packet::operator <<(Int8 data) { - Append(&data, sizeof(data)); + append(&data, sizeof(data)); return *this; } Packet& Packet::operator <<(Uint8 data) { - Append(&data, sizeof(data)); + append(&data, sizeof(data)); return *this; } Packet& Packet::operator <<(Int16 data) { Int16 toWrite = htons(data); - Append(&toWrite, sizeof(toWrite)); + append(&toWrite, sizeof(toWrite)); return *this; } Packet& Packet::operator <<(Uint16 data) { Uint16 toWrite = htons(data); - Append(&toWrite, sizeof(toWrite)); + append(&toWrite, sizeof(toWrite)); return *this; } Packet& Packet::operator <<(Int32 data) { Int32 toWrite = htonl(data); - Append(&toWrite, sizeof(toWrite)); + append(&toWrite, sizeof(toWrite)); return *this; } Packet& Packet::operator <<(Uint32 data) { Uint32 toWrite = htonl(data); - Append(&toWrite, sizeof(toWrite)); + append(&toWrite, sizeof(toWrite)); return *this; } Packet& Packet::operator <<(float data) { - Append(&data, sizeof(data)); + append(&data, sizeof(data)); return *this; } Packet& Packet::operator <<(double data) { - Append(&data, sizeof(data)); + append(&data, sizeof(data)); return *this; } @@ -277,7 +277,7 @@ Packet& Packet::operator <<(const char* data) { *this << length; // Then insert characters - Append(data, length * sizeof(char)); + append(data, length * sizeof(char)); return *this; } @@ -289,7 +289,7 @@ Packet& Packet::operator <<(const std::string& data) { // Then insert characters if (length > 0) - Append(data.c_str(), length * sizeof(std::string::value_type)); + append(data.c_str(), length * sizeof(std::string::value_type)); return *this; } @@ -336,18 +336,18 @@ Packet& Packet::operator <<(const String& data) { return *this; } -bool Packet::CheckSize(std::size_t size) { +bool Packet::checkSize(std::size_t size) { mIsValid = mIsValid && (mReadPos + size <= mData.size()); return mIsValid; } -const void* Packet::OnSend(std::size_t& size) { - size = GetDataSize(); - return GetData(); +const void* Packet::onSend(std::size_t& size) { + size = getDataSize(); + return getData(); } -void Packet::OnReceive(const void* data, std::size_t size) { - Append(data, size); +void Packet::onReceive(const void* data, std::size_t size) { + append(data, size); } }} diff --git a/src/eepp/network/socket.cpp b/src/eepp/network/socket.cpp index b46edee97..a02adb004 100644 --- a/src/eepp/network/socket.cpp +++ b/src/eepp/network/socket.cpp @@ -12,10 +12,10 @@ Socket::Socket(Type type) : Socket::~Socket() { // Close the socket before it gets destructed - Close(); + close(); } -void Socket::SetBlocking(bool blocking) { +void Socket::setBlocking(bool blocking) { // Apply if the socket is already created if (mSocket != Private::SocketImpl::InvalidSocket()) Private::SocketImpl::SetBlocking(mSocket, blocking); @@ -23,30 +23,30 @@ void Socket::SetBlocking(bool blocking) { mIsBlocking = blocking; } -bool Socket::IsBlocking() const { +bool Socket::isBlocking() const { return mIsBlocking; } -SocketHandle Socket::GetHandle() const { +SocketHandle Socket::getHandle() const { return mSocket; } -void Socket::Create() { +void Socket::create() { // Don't create the socket if it already exists if (mSocket == Private::SocketImpl::InvalidSocket()) { SocketHandle handle = socket(PF_INET, mType == Tcp ? SOCK_STREAM : SOCK_DGRAM, 0); - Create(handle); + create(handle); } } -void Socket::Create(SocketHandle handle) { +void Socket::create(SocketHandle handle) { // Don't create the socket if it already exists if (mSocket == Private::SocketImpl::InvalidSocket()) { // Assign the new handle mSocket = handle; // Set the current blocking state - SetBlocking(mIsBlocking); + setBlocking(mIsBlocking); if (mType == Tcp) { // Disable the Nagle algorithm (ie. removes buffering of TCP packets) @@ -73,7 +73,7 @@ void Socket::Create(SocketHandle handle) { } } -void Socket::Close() { +void Socket::close() { // Close the socket if (mSocket != Private::SocketImpl::InvalidSocket()) { Private::SocketImpl::Close(mSocket); diff --git a/src/eepp/network/socketselector.cpp b/src/eepp/network/socketselector.cpp index c0dd1c45a..21c36a07d 100644 --- a/src/eepp/network/socketselector.cpp +++ b/src/eepp/network/socketselector.cpp @@ -20,7 +20,7 @@ struct SocketSelector::SocketSelectorImpl { SocketSelector::SocketSelector() : mImpl( eeNew( SocketSelectorImpl, () ) ) { - Clear(); + clear(); } SocketSelector::SocketSelector(const SocketSelector& copy) : @@ -32,8 +32,8 @@ SocketSelector::~SocketSelector() { eeSAFE_DELETE( mImpl ); } -void SocketSelector::Add(Socket& socket) { - SocketHandle handle = socket.GetHandle(); +void SocketSelector::add(Socket& socket) { + SocketHandle handle = socket.getHandle(); if (handle != Private::SocketImpl::InvalidSocket()) { #if EE_PLATFORM == EE_PLATFORM_WIN @@ -64,8 +64,8 @@ void SocketSelector::Add(Socket& socket) { } } -void SocketSelector::Remove(Socket& socket) { - SocketHandle handle = socket.GetHandle(); +void SocketSelector::remove(Socket& socket) { + SocketHandle handle = socket.getHandle(); if (handle != Private::SocketImpl::InvalidSocket()) { #if EE_PLATFORM == EE_PLATFORM_WIN @@ -83,7 +83,7 @@ void SocketSelector::Remove(Socket& socket) { } } -void SocketSelector::Clear() { +void SocketSelector::clear() { FD_ZERO(&mImpl->AllSockets); FD_ZERO(&mImpl->SocketsReady); @@ -91,7 +91,7 @@ void SocketSelector::Clear() { mImpl->SocketCount = 0; } -bool SocketSelector::Wait(Time timeout) { +bool SocketSelector::wait(Time timeout) { // Setup the timeout timeval time; time.tv_sec = static_cast(timeout.asMicroseconds() / 1000000); @@ -107,8 +107,8 @@ bool SocketSelector::Wait(Time timeout) { return count > 0; } -bool SocketSelector::IsReady(Socket& socket) const { - SocketHandle handle = socket.GetHandle(); +bool SocketSelector::isReady(Socket& socket) const { + SocketHandle handle = socket.getHandle(); if (handle != Private::SocketImpl::InvalidSocket()) { #if EE_PLATFORM == EE_PLATFORM_WIN diff --git a/src/eepp/network/ssl/sslsocket.cpp b/src/eepp/network/ssl/sslsocket.cpp index 15df260ba..139fd88c4 100644 --- a/src/eepp/network/ssl/sslsocket.cpp +++ b/src/eepp/network/ssl/sslsocket.cpp @@ -17,7 +17,7 @@ static bool ssl_initialized = false; std::string SSLSocket::CertificatesPath = ""; static Mutex sMutex; -bool SSLSocket::Init() { +bool SSLSocket::init() { Lock l( sMutex ); bool ret = false; @@ -63,7 +63,7 @@ bool SSLSocket::Init() { return ret; } -bool SSLSocket::End() { +bool SSLSocket::end() { Lock l( sMutex ); bool ret = false; @@ -79,7 +79,7 @@ bool SSLSocket::End() { return ret; } -bool SSLSocket::IsSupported() { +bool SSLSocket::isSupported() { #ifdef EE_SSL_SUPPORT return true; #else @@ -97,50 +97,50 @@ SSLSocket::SSLSocket( std::string hostname , bool validateCertificate, bool vali mValidateCertificate( validateCertificate ), mValidateHostname( validateHostname ) { - Init(); + init(); } SSLSocket::~SSLSocket() { eeSAFE_DELETE( mImpl ); } -Socket::Status SSLSocket::Connect( const IpAddress& remoteAddress, unsigned short remotePort, Time timeout ) { +Socket::Status SSLSocket::connect( const IpAddress& remoteAddress, unsigned short remotePort, Time timeout ) { Status status = Socket::Disconnected; - if ( ( status = TcpSocket::Connect( remoteAddress, remotePort, timeout ) ) == Socket::Done ) { + if ( ( status = TcpSocket::connect( remoteAddress, remotePort, timeout ) ) == Socket::Done ) { status = mImpl->Connect( remoteAddress, remotePort, timeout ); } return status; } -void SSLSocket::Disconnect() { +void SSLSocket::disconnect() { mImpl->Disconnect(); - TcpSocket::Disconnect(); + TcpSocket::disconnect(); } -Socket::Status SSLSocket::Send(const void* data, std::size_t size) { +Socket::Status SSLSocket::send(const void* data, std::size_t size) { return mImpl->Send( data, size ); } -Socket::Status SSLSocket::Receive(void* data, std::size_t size, std::size_t& received) { +Socket::Status SSLSocket::receive(void* data, std::size_t size, std::size_t& received) { return mImpl->Receive( data, size, received ); } -Socket::Status SSLSocket::Send(Packet& packet) { - return TcpSocket::Send( packet ); +Socket::Status SSLSocket::send(Packet& packet) { + return TcpSocket::send( packet ); } -Socket::Status SSLSocket::Receive(Packet& packet) { - return TcpSocket::Receive( packet ); +Socket::Status SSLSocket::receive(Packet& packet) { + return TcpSocket::receive( packet ); } -Socket::Status SSLSocket::TcpSend(const void* data, std::size_t size) { - return TcpSocket::Send( data, size ); +Socket::Status SSLSocket::tcpSend(const void* data, std::size_t size) { + return TcpSocket::send( data, size ); } -Socket::Status SSLSocket::TcpReceive(void* data, std::size_t size, std::size_t& received) { - return TcpSocket::Receive( data, size, received ); +Socket::Status SSLSocket::tcpReceive(void* data, std::size_t size, std::size_t& received) { + return TcpSocket::receive( data, size, received ); } }}} diff --git a/src/eepp/network/tcplistener.cpp b/src/eepp/network/tcplistener.cpp index 789818578..cfe83ccb9 100644 --- a/src/eepp/network/tcplistener.cpp +++ b/src/eepp/network/tcplistener.cpp @@ -9,13 +9,13 @@ TcpListener::TcpListener() : { } -unsigned short TcpListener::GetLocalPort() const { - if (GetHandle() != Private::SocketImpl::InvalidSocket()) { +unsigned short TcpListener::getLocalPort() const { + if (getHandle() != Private::SocketImpl::InvalidSocket()) { // Retrieve informations about the local end of the socket sockaddr_in address; Private::SocketImpl::AddrLength size = sizeof(address); - if (getsockname(GetHandle(), reinterpret_cast(&address), &size) != -1) { + if (getsockname(getHandle(), reinterpret_cast(&address), &size) != -1) { return ntohs(address.sin_port); } } @@ -24,20 +24,20 @@ unsigned short TcpListener::GetLocalPort() const { return 0; } -Socket::Status TcpListener::Listen(unsigned short port) { +Socket::Status TcpListener::listen(unsigned short port) { // Create the internal socket if it doesn't exist - Create(); + create(); // Bind the socket to the specified port sockaddr_in address = Private::SocketImpl::CreateAddress(INADDR_ANY, port); - if (bind(GetHandle(), reinterpret_cast(&address), sizeof(address)) == -1) { + if (bind(getHandle(), reinterpret_cast(&address), sizeof(address)) == -1) { // Not likely to happen, but... eePRINTL( "Failed to bind listener socket to port %d", port ); return Error; } // Listen to the bound port - if (::listen(GetHandle(), 0) == -1) { + if (::listen(getHandle(), 0) == -1) { // Oops, socket is deaf eePRINTL( "Failed to Listen to port %d", port ); return Error; @@ -46,14 +46,14 @@ Socket::Status TcpListener::Listen(unsigned short port) { return Done; } -void TcpListener::Close() { +void TcpListener::close() { // Simply close the socket - Socket::Close(); + Socket::close(); } -Socket::Status TcpListener::Accept(TcpSocket& socket) { +Socket::Status TcpListener::accept(TcpSocket& socket) { // Make sure that we're listening - if (GetHandle() == Private::SocketImpl::InvalidSocket()) { + if (getHandle() == Private::SocketImpl::InvalidSocket()) { eePRINTL( "Failed to accept a new connection, the socket is not listening" ); return Error; } @@ -61,15 +61,15 @@ Socket::Status TcpListener::Accept(TcpSocket& socket) { // Accept a new connection sockaddr_in address; Private::SocketImpl::AddrLength length = sizeof(address); - SocketHandle remote = ::accept(GetHandle(), reinterpret_cast(&address), &length); + SocketHandle remote = ::accept(getHandle(), reinterpret_cast(&address), &length); // Check for errors if (remote == Private::SocketImpl::InvalidSocket()) return Private::SocketImpl::GetErrorStatus(); // Initialize the new connected socket - socket.Close(); - socket.Create(remote); + socket.close(); + socket.create(remote); return Done; } diff --git a/src/eepp/network/tcpsocket.cpp b/src/eepp/network/tcpsocket.cpp index ae30261bc..29a0bc8a0 100644 --- a/src/eepp/network/tcpsocket.cpp +++ b/src/eepp/network/tcpsocket.cpp @@ -26,12 +26,12 @@ TcpSocket::TcpSocket() : { } -unsigned short TcpSocket::GetLocalPort() const { - if (GetHandle() != Private::SocketImpl::InvalidSocket()) { +unsigned short TcpSocket::getLocalPort() const { + if (getHandle() != Private::SocketImpl::InvalidSocket()) { // Retrieve informations about the local end of the socket sockaddr_in address; Private::SocketImpl::AddrLength size = sizeof(address); - if (getsockname(GetHandle(), reinterpret_cast(&address), &size) != -1) { + if (getsockname(getHandle(), reinterpret_cast(&address), &size) != -1) { return ntohs(address.sin_port); } } @@ -40,12 +40,12 @@ unsigned short TcpSocket::GetLocalPort() const { return 0; } -IpAddress TcpSocket::GetRemoteAddress() const { - if (GetHandle() != Private::SocketImpl::InvalidSocket()) { +IpAddress TcpSocket::getRemoteAddress() const { + if (getHandle() != Private::SocketImpl::InvalidSocket()) { // Retrieve informations about the remote end of the socket sockaddr_in address; Private::SocketImpl::AddrLength size = sizeof(address); - if (getpeername(GetHandle(), reinterpret_cast(&address), &size) != -1) { + if (getpeername(getHandle(), reinterpret_cast(&address), &size) != -1) { return IpAddress(ntohl(address.sin_addr.s_addr)); } } @@ -54,12 +54,12 @@ IpAddress TcpSocket::GetRemoteAddress() const { return IpAddress::None; } -unsigned short TcpSocket::GetRemotePort() const { - if (GetHandle() != Private::SocketImpl::InvalidSocket()) { +unsigned short TcpSocket::getRemotePort() const { + if (getHandle() != Private::SocketImpl::InvalidSocket()) { // Retrieve informations about the remote end of the socket sockaddr_in address; Private::SocketImpl::AddrLength size = sizeof(address); - if (getpeername(GetHandle(), reinterpret_cast(&address), &size) != -1) { + if (getpeername(getHandle(), reinterpret_cast(&address), &size) != -1) { return ntohs(address.sin_port); } } @@ -68,18 +68,18 @@ unsigned short TcpSocket::GetRemotePort() const { return 0; } -Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout) { +Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short remotePort, Time timeout) { // Create the internal socket if it doesn't exist - Create(); + create(); // Create the remote address - sockaddr_in address = Private::SocketImpl::CreateAddress(remoteAddress.ToInteger(), remotePort); + sockaddr_in address = Private::SocketImpl::CreateAddress(remoteAddress.toInteger(), remotePort); if (timeout <= Time::Zero) { // ----- We're not using a timeout: just try to connect ----- // Connect the socket - if (::connect(GetHandle(), reinterpret_cast(&address), sizeof(address)) == -1) + if (::connect(getHandle(), reinterpret_cast(&address), sizeof(address)) == -1) return Private::SocketImpl::GetErrorStatus(); // Connection succeeded @@ -88,16 +88,16 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short // ----- We're using a timeout: we'll need a few tricks to make it work ----- // Save the previous blocking state - bool blocking = IsBlocking(); + bool blocking = isBlocking(); // Switch to non-blocking to enable our connection timeout if (blocking) - SetBlocking(false); + setBlocking(false); // Try to connect to the remote address - if (::connect(GetHandle(), reinterpret_cast(&address), sizeof(address)) >= 0) { + if (::connect(getHandle(), reinterpret_cast(&address), sizeof(address)) >= 0) { // We got instantly connected! (it may no happen a lot...) - SetBlocking(blocking); + setBlocking(blocking); return Done; } @@ -113,7 +113,7 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short // Setup the selector fd_set selector; FD_ZERO(&selector); - FD_SET(GetHandle(), &selector); + FD_SET(getHandle(), &selector); // Setup the timeout timeval time; @@ -121,10 +121,10 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short time.tv_usec = static_cast(timeout.asMicroseconds() % 1000000); // Wait for something to write on our socket (which means that the connection request has returned) - if (select(static_cast(GetHandle() + 1), NULL, &selector, NULL, &time) > 0) { + if (select(static_cast(getHandle() + 1), NULL, &selector, NULL, &time) > 0) { // At this point the connection may have been either accepted or refused. // To know whether it's a success or a failure, we must check the address of the connected peer - if (GetRemoteAddress() != IpAddress::None) { + if (getRemoteAddress() != IpAddress::None) { // Connection accepted status = Done; } else { @@ -138,30 +138,30 @@ Socket::Status TcpSocket::Connect(const IpAddress& remoteAddress, unsigned short } // Switch back to blocking mode - SetBlocking(true); + setBlocking(true); return status; } } -void TcpSocket::Disconnect() { +void TcpSocket::disconnect() { // Close the socket - Close(); + close(); // Reset the pending packet data mPendingPacket = PendingPacket(); } -Socket::Status TcpSocket::Send(const void* data, std::size_t size) { - if ( !IsBlocking() ) +Socket::Status TcpSocket::send(const void* data, std::size_t size) { + if ( !isBlocking() ) eePRINTL( "Warning: Partial sends might not be handled properly." ); std::size_t sent; - return Send(data, size, sent); + return send(data, size, sent); } -Socket::Status TcpSocket::Send(const void* data, std::size_t size, std::size_t& sent) { +Socket::Status TcpSocket::send(const void* data, std::size_t size, std::size_t& sent) { // Check the parameters if (!data || (size == 0)) { eePRINTL( "Cannot send data over the network (no data to send)" ); @@ -172,7 +172,7 @@ Socket::Status TcpSocket::Send(const void* data, std::size_t size, std::size_t& int result = 0; for (sent = 0; sent < size; sent += result) { // Send a chunk of data - result = ::send(GetHandle(), static_cast(data) + sent, size - sent, flags); + result = ::send(getHandle(), static_cast(data) + sent, size - sent, flags); // Check for errors if (result < 0) { @@ -189,7 +189,7 @@ Socket::Status TcpSocket::Send(const void* data, std::size_t size, std::size_t& return Done; } -Socket::Status TcpSocket::Receive(void* data, std::size_t size, std::size_t& received) { +Socket::Status TcpSocket::receive(void* data, std::size_t size, std::size_t& received) { // First clear the variables to fill received = 0; @@ -200,7 +200,7 @@ Socket::Status TcpSocket::Receive(void* data, std::size_t size, std::size_t& rec } // Receive a chunk of bytes - int sizeReceived = recv(GetHandle(), static_cast(data), static_cast(size), flags); + int sizeReceived = recv(getHandle(), static_cast(data), static_cast(size), flags); // Check the number of bytes received if (sizeReceived > 0) { @@ -213,7 +213,7 @@ Socket::Status TcpSocket::Receive(void* data, std::size_t size, std::size_t& rec } } -Socket::Status TcpSocket::Send(Packet& packet) { +Socket::Status TcpSocket::send(Packet& packet) { // TCP is a stream protocol, it doesn't preserve messages boundaries. // This means that we have to send the packet size first, so that the // receiver knows the actual end of the packet in the data stream. @@ -225,7 +225,7 @@ Socket::Status TcpSocket::Send(Packet& packet) { // Get the data to send from the packet std::size_t size = 0; - const void* data = packet.OnSend(size); + const void* data = packet.onSend(size); // First convert the packet size to network byte order Uint32 packetSize = htonl(static_cast(size)); @@ -240,7 +240,7 @@ Socket::Status TcpSocket::Send(Packet& packet) { // Send the data block std::size_t sent; - Status status = Send(&blockToSend[0] + packet.mSendPos, blockToSend.size() - packet.mSendPos, sent ); + Status status = send(&blockToSend[0] + packet.mSendPos, blockToSend.size() - packet.mSendPos, sent ); // In the case of a partial send, record the location to resume from if (status == Partial) { @@ -252,9 +252,9 @@ Socket::Status TcpSocket::Send(Packet& packet) { return status; } -Socket::Status TcpSocket::Receive(Packet& packet) { +Socket::Status TcpSocket::receive(Packet& packet) { // First clear the variables to fill - packet.Clear(); + packet.clear(); // We start by getting the size of the incoming packet Uint32 packetSize = 0; @@ -264,7 +264,7 @@ Socket::Status TcpSocket::Receive(Packet& packet) { // (even a 4 byte variable may be received in more than one call) while (mPendingPacket.SizeReceived < sizeof(mPendingPacket.Size)) { char* data = reinterpret_cast(&mPendingPacket.Size) + mPendingPacket.SizeReceived; - Status status = Receive(data, sizeof(mPendingPacket.Size) - mPendingPacket.SizeReceived, received); + Status status = receive(data, sizeof(mPendingPacket.Size) - mPendingPacket.SizeReceived, received); mPendingPacket.SizeReceived += received; if (status != Done) @@ -283,7 +283,7 @@ Socket::Status TcpSocket::Receive(Packet& packet) { while (mPendingPacket.Data.size() < packetSize) { // Receive a chunk of data std::size_t sizeToGet = eemin(static_cast(packetSize - mPendingPacket.Data.size()), sizeof(buffer)); - Status status = Receive(buffer, sizeToGet, received); + Status status = receive(buffer, sizeToGet, received); if (status != Done) return status; @@ -297,7 +297,7 @@ Socket::Status TcpSocket::Receive(Packet& packet) { // We have received all the packet data: we can copy it to the user packet if (!mPendingPacket.Data.empty()) - packet.OnReceive(&mPendingPacket.Data[0], mPendingPacket.Data.size()); + packet.onReceive(&mPendingPacket.Data[0], mPendingPacket.Data.size()); // Clear the pending packet data mPendingPacket = PendingPacket(); diff --git a/src/eepp/network/udpsocket.cpp b/src/eepp/network/udpsocket.cpp index 000e802d1..2d3265382 100644 --- a/src/eepp/network/udpsocket.cpp +++ b/src/eepp/network/udpsocket.cpp @@ -12,12 +12,12 @@ UdpSocket::UdpSocket() : { } -unsigned short UdpSocket::GetLocalPort() const { - if (GetHandle() != Private::SocketImpl::InvalidSocket()) { +unsigned short UdpSocket::getLocalPort() const { + if (getHandle() != Private::SocketImpl::InvalidSocket()) { // Retrieve informations about the local end of the socket sockaddr_in address; Private::SocketImpl::AddrLength size = sizeof(address); - if (getsockname(GetHandle(), reinterpret_cast(&address), &size) != -1) { + if (getsockname(getHandle(), reinterpret_cast(&address), &size) != -1) { return ntohs(address.sin_port); } } @@ -26,13 +26,13 @@ unsigned short UdpSocket::GetLocalPort() const { return 0; } -Socket::Status UdpSocket::Bind(unsigned short port) { +Socket::Status UdpSocket::bind(unsigned short port) { // Create the internal socket if it doesn't exist - Create(); + create(); // Bind the socket sockaddr_in address = Private::SocketImpl::CreateAddress(INADDR_ANY, port); - if (::bind(GetHandle(), reinterpret_cast(&address), sizeof(address)) == -1) { + if (::bind(getHandle(), reinterpret_cast(&address), sizeof(address)) == -1) { eePRINTL( "Failed to bind socket to port %d", port ); return Error; } @@ -40,14 +40,14 @@ Socket::Status UdpSocket::Bind(unsigned short port) { return Done; } -void UdpSocket::Unbind() { +void UdpSocket::unbind() { // Simply close the socket - Close(); + close(); } -Socket::Status UdpSocket::Send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort) { +Socket::Status UdpSocket::send(const void* data, std::size_t size, const IpAddress& remoteAddress, unsigned short remotePort) { // Create the internal socket if it doesn't exist - Create(); + create(); // Make sure that all the data will fit in one datagram if (size > MaxDatagramSize) @@ -57,10 +57,10 @@ Socket::Status UdpSocket::Send(const void* data, std::size_t size, const IpAddre } // Build the target address - sockaddr_in address = Private::SocketImpl::CreateAddress(remoteAddress.ToInteger(), remotePort); + sockaddr_in address = Private::SocketImpl::CreateAddress(remoteAddress.toInteger(), remotePort); // Send the data (unlike TCP, all the data is always sent in one call) - int sent = sendto(GetHandle(), static_cast(data), static_cast(size), 0, reinterpret_cast(&address), sizeof(address)); + int sent = sendto(getHandle(), static_cast(data), static_cast(size), 0, reinterpret_cast(&address), sizeof(address)); // Check for errors if (sent < 0) @@ -69,7 +69,7 @@ Socket::Status UdpSocket::Send(const void* data, std::size_t size, const IpAddre return Done; } -Socket::Status UdpSocket::Receive(void* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort) { +Socket::Status UdpSocket::receive(void* data, std::size_t size, std::size_t& received, IpAddress& remoteAddress, unsigned short& remotePort) { // First clear the variables to fill received = 0; remoteAddress = IpAddress(); @@ -86,7 +86,7 @@ Socket::Status UdpSocket::Receive(void* data, std::size_t size, std::size_t& rec // Receive a chunk of bytes Private::SocketImpl::AddrLength addressSize = sizeof(address); - int sizeReceived = recvfrom(GetHandle(), static_cast(data), static_cast(size), 0, reinterpret_cast(&address), &addressSize); + int sizeReceived = recvfrom(getHandle(), static_cast(data), static_cast(size), 0, reinterpret_cast(&address), &addressSize); // Check for errors if (sizeReceived < 0) @@ -100,7 +100,7 @@ Socket::Status UdpSocket::Receive(void* data, std::size_t size, std::size_t& rec return Done; } -Socket::Status UdpSocket::Send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort) { +Socket::Status UdpSocket::send(Packet& packet, const IpAddress& remoteAddress, unsigned short remotePort) { // UDP is a datagram-oriented protocol (as opposed to TCP which is a stream protocol). // Sending one datagram is almost safe: it may be lost but if it's received, then its data // is guaranteed to be ok. However, splitting a packet into multiple datagrams would be highly @@ -111,23 +111,23 @@ Socket::Status UdpSocket::Send(Packet& packet, const IpAddress& remoteAddress, u // Get the data to send from the packet std::size_t size = 0; - const void* data = packet.OnSend(size); + const void* data = packet.onSend(size); // Send it - return Send(data, size, remoteAddress, remotePort); + return send(data, size, remoteAddress, remotePort); } -Socket::Status UdpSocket::Receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort) { +Socket::Status UdpSocket::receive(Packet& packet, IpAddress& remoteAddress, unsigned short& remotePort) { // See the detailed comment in Send(Packet) above. // Receive the datagram std::size_t received = 0; - Status status = Receive(&mBuffer[0], mBuffer.size(), received, remoteAddress, remotePort); + Status status = receive(&mBuffer[0], mBuffer.size(), received, remoteAddress, remotePort); // If we received valid data, we can copy it to the user packet - packet.Clear(); + packet.clear(); if ((status == Done) && (received > 0)) - packet.OnReceive(&mBuffer[0], received); + packet.onReceive(&mBuffer[0], received); return status; } diff --git a/src/eepp/network/uri.cpp b/src/eepp/network/uri.cpp index bf645ec4f..f816d2e99 100644 --- a/src/eepp/network/uri.cpp +++ b/src/eepp/network/uri.cpp @@ -31,13 +31,13 @@ URI::URI(): URI::URI(const std::string& uri): mPort(0) { - Parse(uri); + parse(uri); } URI::URI(const char* uri): mPort(0) { - Parse(std::string(uri)); + parse(std::string(uri)); } URI::URI(const std::string& scheme, const std::string& pathEtc): @@ -45,10 +45,10 @@ URI::URI(const std::string& scheme, const std::string& pathEtc): mPort(0) { String::toLowerInPlace(mScheme); - mPort = GetWellKnownPort(); + mPort = getWellKnownPort(); std::string::const_iterator beg = pathEtc.begin(); std::string::const_iterator end = pathEtc.end(); - ParsePathEtc(beg, end); + parsePathEtc(beg, end); } URI::URI(const std::string& scheme, const std::string& authority, const std::string& pathEtc): @@ -57,10 +57,10 @@ URI::URI(const std::string& scheme, const std::string& authority, const std::str String::toLowerInPlace(mScheme); std::string::const_iterator beg = authority.begin(); std::string::const_iterator end = authority.end(); - ParseAuthority(beg, end); + parseAuthority(beg, end); beg = pathEtc.begin(); end = pathEtc.end(); - ParsePathEtc(beg, end); + parsePathEtc(beg, end); } URI::URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query): @@ -71,7 +71,7 @@ URI::URI(const std::string& scheme, const std::string& authority, const std::str String::toLowerInPlace(mScheme); std::string::const_iterator beg = authority.begin(); std::string::const_iterator end = authority.end(); - ParseAuthority(beg, end); + parseAuthority(beg, end); } URI::URI(const std::string& scheme, const std::string& authority, const std::string& path, const std::string& query, const std::string& fragment): @@ -83,7 +83,7 @@ URI::URI(const std::string& scheme, const std::string& authority, const std::str String::toLowerInPlace(mScheme); std::string::const_iterator beg = authority.begin(); std::string::const_iterator end = authority.end(); - ParseAuthority(beg, end); + parseAuthority(beg, end); } URI::URI(const URI& uri): @@ -106,7 +106,7 @@ URI::URI(const URI& baseURI, const std::string& relativeURI): mQuery(baseURI.mQuery), mFragment(baseURI.mFragment) { - Resolve(relativeURI); + resolve(relativeURI); } URI::~URI() @@ -130,19 +130,19 @@ URI& URI::operator = (const URI& uri) URI& URI::operator = (const std::string& uri) { - Clear(); - Parse(uri); + clear(); + parse(uri); return *this; } URI& URI::operator = (const char* uri) { - Clear(); - Parse(std::string(uri)); + clear(); + parse(std::string(uri)); return *this; } -void URI::Swap(URI& uri) +void URI::swap(URI& uri) { std::swap(mScheme, uri.mScheme); std::swap(mUserInfo, uri.mUserInfo); @@ -153,7 +153,7 @@ void URI::Swap(URI& uri) std::swap(mFragment, uri.mFragment); } -void URI::Clear() +void URI::clear() { mScheme.clear(); mUserInfo.clear(); @@ -164,18 +164,18 @@ void URI::Clear() mFragment.clear(); } -std::string URI::ToString() const +std::string URI::toString() const { std::string uri; - if (IsRelative()) + if (isRelative()) { - Encode(mPath, RESERVED_PATH, uri); + encode(mPath, RESERVED_PATH, uri); } else { uri = mScheme; uri += ':'; - std::string auth = GetAuthority(); + std::string auth = getAuthority(); if (!auth.empty() || mScheme == "file") { uri.append("//"); @@ -185,7 +185,7 @@ std::string URI::ToString() const { if (!auth.empty() && mPath[0] != '/') uri += '/'; - Encode(mPath, RESERVED_PATH, uri); + encode(mPath, RESERVED_PATH, uri); } else if (!mQuery.empty() || !mFragment.empty()) { @@ -200,45 +200,45 @@ std::string URI::ToString() const if (!mFragment.empty()) { uri += '#'; - Encode(mFragment, RESERVED_FRAGMENT, uri); + encode(mFragment, RESERVED_FRAGMENT, uri); } return uri; } -void URI::SetScheme(const std::string& scheme) +void URI::setScheme(const std::string& scheme) { mScheme = scheme; String::toLowerInPlace(mScheme); if (mPort == 0) - mPort = GetWellKnownPort(); + mPort = getWellKnownPort(); } -void URI::SetUserInfo(const std::string& userInfo) +void URI::setUserInfo(const std::string& userInfo) { mUserInfo.clear(); - Decode(userInfo, mUserInfo); + decode(userInfo, mUserInfo); } -void URI::SetHost(const std::string& host) +void URI::getHost(const std::string& host) { mHost = host; } -unsigned short URI::GetPort() const +unsigned short URI::getPort() const { if (mPort == 0) - return GetWellKnownPort(); + return getWellKnownPort(); else return mPort; } -void URI::SetPort(unsigned short port) +void URI::getPort(unsigned short port) { mPort = port; } -std::string URI::GetAuthority() const +std::string URI::getAuthority() const { std::string auth; if (!mUserInfo.empty()) @@ -253,7 +253,7 @@ std::string URI::GetAuthority() const auth += ']'; } else auth.append(mHost); - if (mPort && !IsWellKnownPort()) + if (mPort && !isWellKnownPort()) { auth += ':'; auth += String::toStr( mPort ); @@ -261,65 +261,65 @@ std::string URI::GetAuthority() const return auth; } -void URI::SetAuthority(const std::string& authority) +void URI::setAuthority(const std::string& authority) { mUserInfo.clear(); mHost.clear(); mPort = 0; std::string::const_iterator beg = authority.begin(); std::string::const_iterator end = authority.end(); - ParseAuthority(beg, end); + parseAuthority(beg, end); } -std::string URI::GetSchemeAndAuthority() +std::string URI::getSchemeAndAuthority() { - return GetScheme() + GetAuthority(); + return getScheme() + getAuthority(); } -void URI::SetPath(const std::string& path) +void URI::getPath(const std::string& path) { mPath.clear(); - Decode(path, mPath); + decode(path, mPath); } -void URI::SetRawQuery(const std::string& query) +void URI::setRawQuery(const std::string& query) { mQuery = query; } -void URI::SetQuery(const std::string& query) +void URI::setQuery(const std::string& query) { mQuery.clear(); - Encode(query, RESERVED_QUERY, mQuery); + encode(query, RESERVED_QUERY, mQuery); } -std::string URI::GetQuery() const +std::string URI::getQuery() const { std::string query; - Decode(mQuery, query); + decode(mQuery, query); return query; } -void URI::GetFragment(const std::string& fragment) +void URI::getFragment(const std::string& fragment) { mFragment.clear(); - Decode(fragment, mFragment); + decode(fragment, mFragment); } -void URI::SetPathEtc(const std::string& pathEtc) +void URI::setPathEtc(const std::string& pathEtc) { mPath.clear(); mQuery.clear(); mFragment.clear(); std::string::const_iterator beg = pathEtc.begin(); std::string::const_iterator end = pathEtc.end(); - ParsePathEtc(beg, end); + parsePathEtc(beg, end); } -std::string URI::GetPathEtc() const +std::string URI::getPathEtc() const { std::string pathEtc; - Encode(mPath, RESERVED_PATH, pathEtc); + encode(mPath, RESERVED_PATH, pathEtc); if (!mQuery.empty()) { pathEtc += '?'; @@ -328,15 +328,15 @@ std::string URI::GetPathEtc() const if (!mFragment.empty()) { pathEtc += '#'; - Encode(mFragment, RESERVED_FRAGMENT, pathEtc); + encode(mFragment, RESERVED_FRAGMENT, pathEtc); } return pathEtc; } -std::string URI::GetPathAndQuery() const +std::string URI::getPathAndQuery() const { std::string pathAndQuery; - Encode(mPath, RESERVED_PATH, pathAndQuery); + encode(mPath, RESERVED_PATH, pathAndQuery); if (!mQuery.empty()) { pathAndQuery += '?'; @@ -345,13 +345,13 @@ std::string URI::GetPathAndQuery() const return pathAndQuery; } -void URI::Resolve(const std::string& relativeURI) +void URI::resolve(const std::string& relativeURI) { URI ParsedURI(relativeURI); - Resolve(ParsedURI); + resolve(ParsedURI); } -void URI::Resolve(const URI& relativeURI) +void URI::resolve(const URI& relativeURI) { if (!relativeURI.mScheme.empty()) { @@ -361,7 +361,7 @@ void URI::Resolve(const URI& relativeURI) mPort = relativeURI.mPort; mPath = relativeURI.mPath; mQuery = relativeURI.mQuery; - RemoveDotSegments(); + removeDotSegments(); } else { @@ -372,7 +372,7 @@ void URI::Resolve(const URI& relativeURI) mPort = relativeURI.mPort; mPath = relativeURI.mPath; mQuery = relativeURI.mQuery; - RemoveDotSegments(); + removeDotSegments(); } else { @@ -386,11 +386,11 @@ void URI::Resolve(const URI& relativeURI) if (relativeURI.mPath[0] == '/') { mPath = relativeURI.mPath; - RemoveDotSegments(); + removeDotSegments(); } else { - MergePath(relativeURI.mPath); + mergePath(relativeURI.mPath); } mQuery = relativeURI.mQuery; } @@ -399,55 +399,55 @@ void URI::Resolve(const URI& relativeURI) mFragment = relativeURI.mFragment; } -bool URI::IsRelative() const +bool URI::isRelative() const { return mScheme.empty(); } -bool URI::Empty() const +bool URI::empty() const { return mScheme.empty() && mHost.empty() && mPath.empty() && mQuery.empty() && mFragment.empty(); } bool URI::operator == (const URI& uri) const { - return Equals(uri); + return equals(uri); } bool URI::operator == (const std::string& uri) const { URI ParsedURI(uri); - return Equals(ParsedURI); + return equals(ParsedURI); } bool URI::operator != (const URI& uri) const { - return !Equals(uri); + return !equals(uri); } bool URI::operator != (const std::string& uri) const { URI ParsedURI(uri); - return !Equals(ParsedURI); + return !equals(ParsedURI); } -bool URI::Equals(const URI& uri) const +bool URI::equals(const URI& uri) const { return mScheme == uri.mScheme && mUserInfo == uri.mUserInfo && mHost == uri.mHost - && GetPort() == uri.GetPort() + && getPort() == uri.getPort() && mPath == uri.mPath && mQuery == uri.mQuery && mFragment == uri.mFragment; } -void URI::Normalize() +void URI::normalize() { - RemoveDotSegments(!IsRelative()); + removeDotSegments(!isRelative()); } -void URI::RemoveDotSegments(bool removeLeading) +void URI::removeDotSegments(bool removeLeading) { if (mPath.empty()) return; @@ -455,7 +455,7 @@ void URI::RemoveDotSegments(bool removeLeading) bool trailingSlash = *(mPath.rbegin()) == '/'; std::vector segments; std::vector NormalizedSegments; - GetPathSegments(segments); + getPathSegments(segments); for (std::vector::const_iterator it = segments.begin(); it != segments.end(); ++it) { if (*it == "..") @@ -477,15 +477,15 @@ void URI::RemoveDotSegments(bool removeLeading) NormalizedSegments.push_back(*it); } } - BuildPath(NormalizedSegments, leadingSlash, trailingSlash); + buildPath(NormalizedSegments, leadingSlash, trailingSlash); } -void URI::GetPathSegments(std::vector& segments) +void URI::getPathSegments(std::vector& segments) { - GetPathSegments(mPath, segments); + getPathSegments(mPath, segments); } -void URI::GetPathSegments(const std::string& path, std::vector& segments) +void URI::getPathSegments(const std::string& path, std::vector& segments) { std::string::const_iterator it = path.begin(); std::string::const_iterator end = path.end(); @@ -507,7 +507,7 @@ void URI::GetPathSegments(const std::string& path, std::vector& seg segments.push_back(seg); } -void URI::Encode(const std::string& str, const std::string& reserved, std::string& encodedStr) +void URI::encode(const std::string& str, const std::string& reserved, std::string& encodedStr) { for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { @@ -529,7 +529,7 @@ void URI::Encode(const std::string& str, const std::string& reserved, std::strin } } -void URI::Decode(const std::string& str, std::string& decodedStr) +void URI::decode(const std::string& str, std::string& decodedStr) { std::string::const_iterator it = str.begin(); std::string::const_iterator end = str.end(); @@ -572,12 +572,12 @@ void URI::Decode(const std::string& str, std::string& decodedStr) } } -bool URI::IsWellKnownPort() const +bool URI::isWellKnownPort() const { - return mPort == GetWellKnownPort(); + return mPort == getWellKnownPort(); } -unsigned short URI::GetWellKnownPort() const +unsigned short URI::getWellKnownPort() const { if (mScheme == "ftp") return 21; @@ -605,7 +605,7 @@ unsigned short URI::GetWellKnownPort() const return 0; } -void URI::Parse(const std::string& uri) +void URI::parse(const std::string& uri) { std::string::const_iterator it = uri.begin(); std::string::const_iterator end = uri.end(); @@ -620,29 +620,29 @@ void URI::Parse(const std::string& uri) if (it == end) { return; //throw SyntaxException("URI scheme must be followed by authority or path", uri); } - SetScheme(scheme); + setScheme(scheme); if (*it == '/') { ++it; if (it != end && *it == '/') { ++it; - ParseAuthority(it, end); + parseAuthority(it, end); } else --it; } - ParsePathEtc(it, end); + parsePathEtc(it, end); } else { it = uri.begin(); - ParsePathEtc(it, end); + parsePathEtc(it, end); } } - else ParsePathEtc(it, end); + else parsePathEtc(it, end); } -void URI::ParseAuthority(std::string::const_iterator& it, const std::string::const_iterator& end) +void URI::parseAuthority(std::string::const_iterator& it, const std::string::const_iterator& end) { std::string userInfo; std::string part; @@ -658,11 +658,11 @@ void URI::ParseAuthority(std::string::const_iterator& it, const std::string::con } std::string::const_iterator pbeg = part.begin(); std::string::const_iterator pend = part.end(); - ParseHostAndPort(pbeg, pend); + parseHostAndPort(pbeg, pend); mUserInfo = userInfo; } -void URI::ParseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end) +void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::const_iterator& end) { if (it == end) return; std::string host; @@ -695,64 +695,64 @@ void URI::ParseHostAndPort(std::string::const_iterator& it, const std::string::c return; //throw SyntaxException("bad or invalid port number", port); } } - else mPort = GetWellKnownPort(); + else mPort = getWellKnownPort(); } - else mPort = GetWellKnownPort(); + else mPort = getWellKnownPort(); mHost = host; String::toLowerInPlace(mHost); } -void URI::ParsePath(std::string::const_iterator& it, const std::string::const_iterator& end) +void URI::parsePath(std::string::const_iterator& it, const std::string::const_iterator& end) { std::string path; while (it != end && *it != '?' && *it != '#') path += *it++; - Decode(path, mPath); + decode(path, mPath); } -void URI::ParsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end) +void URI::parsePathEtc(std::string::const_iterator& it, const std::string::const_iterator& end) { if (it == end) return; if (*it != '?' && *it != '#') - ParsePath(it, end); + parsePath(it, end); if (it != end && *it == '?') { ++it; - ParseQuery(it, end); + parseQuery(it, end); } if (it != end && *it == '#') { ++it; - ParseFragment(it, end); + parseFragment(it, end); } } -void URI::ParseQuery(std::string::const_iterator& it, const std::string::const_iterator& end) +void URI::parseQuery(std::string::const_iterator& it, const std::string::const_iterator& end) { mQuery.clear(); while (it != end && *it != '#') mQuery += *it++; } -void URI::ParseFragment(std::string::const_iterator& it, const std::string::const_iterator& end) +void URI::parseFragment(std::string::const_iterator& it, const std::string::const_iterator& end) { std::string fragment; while (it != end) fragment += *it++; - Decode(fragment, mFragment); + decode(fragment, mFragment); } -void URI::MergePath(const std::string& path) +void URI::mergePath(const std::string& path) { std::vector segments; std::vector NormalizedSegments; bool addLeadingSlash = false; if (!mPath.empty()) { - GetPathSegments(segments); + getPathSegments(segments); bool endsWithSlash = *(mPath.rbegin()) == '/'; if (!endsWithSlash && !segments.empty()) segments.pop_back(); addLeadingSlash = mPath[0] == '/'; } - GetPathSegments(path, segments); + getPathSegments(path, segments); addLeadingSlash = addLeadingSlash || (!path.empty() && path[0] == '/'); bool hasTrailingSlash = (!path.empty() && *(path.rbegin()) == '/'); bool addTrailingSlash = false; @@ -771,10 +771,10 @@ void URI::MergePath(const std::string& path) } else addTrailingSlash = true; } - BuildPath(NormalizedSegments, addLeadingSlash, hasTrailingSlash || addTrailingSlash); + buildPath(NormalizedSegments, addLeadingSlash, hasTrailingSlash || addTrailingSlash); } -void URI::BuildPath(const std::vector& segments, bool leadingSlash, bool trailingSlash) +void URI::buildPath(const std::vector& segments, bool leadingSlash, bool trailingSlash) { mPath.clear(); bool first = true; diff --git a/src/eepp/window/engine.cpp b/src/eepp/window/engine.cpp index 39256e1fd..1ed8f8900 100755 --- a/src/eepp/window/engine.cpp +++ b/src/eepp/window/engine.cpp @@ -76,7 +76,7 @@ Engine::~Engine() { HaikuTTF::hkFontManager::destroySingleton(); #ifdef EE_SSL_SUPPORT - Network::SSL::SSLSocket::End(); + Network::SSL::SSLSocket::end(); #endif Destroy(); diff --git a/src/examples/http_request/http_request.cpp b/src/examples/http_request/http_request.cpp index 0e9cada61..e62638c83 100644 --- a/src/examples/http_request/http_request.cpp +++ b/src/examples/http_request/http_request.cpp @@ -1,12 +1,12 @@ #include void AsyncRequestCallback( const Http& http, Http::Request& request, Http::Response& response ) { - std::cout << "Got response from request: " << http.GetHostName() << request.GetUri() << std::endl; + std::cout << "Got response from request: " << http.getHostName() << request.getUri() << std::endl; - if ( response.GetStatus() == Http::Response::Ok ) { - std::cout << response.GetBody() << std::endl; + if ( response.getStatus() == Http::Response::Ok ) { + std::cout << response.getBody() << std::endl; } else { - std::cout << "Error " << response.GetStatus() << std::endl; + std::cout << "Error " << response.getStatus() << std::endl; } } @@ -18,38 +18,38 @@ EE_MAIN_FUNC int main (int argc, char * argv []) { if ( argc < 2 ) { // We'll work on http://en.wikipedia.org - if ( SSLSocket::IsSupported() ) { - http.SetHost("https://en.wikipedia.org"); + if ( SSLSocket::isSupported() ) { + http.setHost("https://en.wikipedia.org"); } else { - http.SetHost("http://en.wikipedia.org"); + http.setHost("http://en.wikipedia.org"); } // Prepare a request to get the wikipedia main page - request.SetUri("/wiki/Main_Page"); + request.setUri("/wiki/Main_Page"); // Creates an async http request Http::Request asyncRequest( "/wiki/" + Version::getCodename() ); - http.SendAsyncRequest( cb::Make3( AsyncRequestCallback ), asyncRequest, Seconds( 5 ) ); + http.sendAsyncRequest( cb::Make3( AsyncRequestCallback ), asyncRequest, Seconds( 5 ) ); } else { // If the user provided the URI, creates an instance of URI to parse it. URI uri( argv[1] ); // Set the host and port from the URI - http.SetHost( uri.GetHost(), uri.GetPort() ); + http.setHost( uri.getHost(), uri.getPort() ); // Set the path and query parts for the request - request.SetUri( uri.GetPathAndQuery() ); + request.setUri( uri.getPathAndQuery() ); } // Send the request - Http::Response response = http.SendRequest(request); + Http::Response response = http.sendRequest(request); // Check the status code and display the result - Http::Response::Status status = response.GetStatus(); + Http::Response::Status status = response.getStatus(); if ( status == Http::Response::Ok ) { - std::cout << response.GetBody() << std::endl; + std::cout << response.getBody() << std::endl; } else { std::cout << "Error " << status << std::endl; }