From e69cc3226406d76888620ec2c21dff6a3504dc0d Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 30 Aug 2017 15:48:48 +0200 Subject: [PATCH] feat(core): add cpp Address interface --- src/CMakeLists.txt | 3 + src/address/address.cpp | 182 ++++++++++++++++++++++++++++++++++++++++ src/address/address.h | 91 ++++++++++++++++++++ src/enums.h | 37 ++++++++ 4 files changed, 313 insertions(+) create mode 100644 src/address/address.cpp create mode 100644 src/address/address.h create mode 100644 src/enums.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1aa5947d..afefefd42 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,7 @@ ############################################################################ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES + address/address.h c-wrapper/api/c-event-log.h c-wrapper/c-tools.h c-wrapper/c-types.h @@ -43,6 +44,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES db/provider/db-session-p.h db/provider/db-session-provider.h db/provider/db-session.h + enums.h event-log/call-event.h event-log/conference-event-p.h event-log/conference-event.h @@ -66,6 +68,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES ) set(LINPHONE_CXX_OBJECTS_SOURCE_FILES + address/address.cpp c-wrapper/api/c-event-log.cpp chat/chat-room.cpp content/content.cpp diff --git a/src/address/address.cpp b/src/address/address.cpp new file mode 100644 index 000000000..38291beb4 --- /dev/null +++ b/src/address/address.cpp @@ -0,0 +1,182 @@ +/* + * address.cpp + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY {} without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "object/clonable-object-p.h" + +#include "address.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +class AddressPrivate : public ClonableObjectPrivate { + // TODO. +}; + +// ----------------------------------------------------------------------------- + +Address::Address (const string &address) : ClonableObject(*new AddressPrivate) { + // TODO. +} + +Address::Address (const Address &src) : ClonableObject(*new AddressPrivate) { + // TODO. +} + +Address &Address::operator= (const Address &src) { + // TODO. + return *this; +} + +Address::operator bool () const { + // TODO. + return false; +} + +bool Address::operator== (const Address &address) const { + // TODO. + return false; +} + +string Address::getScheme () const { + // TODO. + return ""; +} + +string Address::getDisplayName () const { + // TODO. + return ""; +} + +bool setDisplayName (const string &displayName) { + // TODO. + return false; +} + +string Address::getUsername () const { + // TODO. + return ""; +} + +bool setUsername (const string &username) { + // TODO. + return false; +} + +string Address::getDomain () const { + // TODO. + return ""; +} + +bool setDomain (const string &host) { + // TODO. + return false; +} + +int Address::getPort () const { + // TODO. + return 0; +} + +bool Address::setPort (int port) { + // TODO. + return false; +} + +Transport Address::getTransport () const { + // TODO. + return Transport::Dtls; +} + +bool setTransport (Transport transport) { + // TODO. + return false; +} + +bool Address::getSecure () const { + // TODO. + return false; +} + +void Address::setSecure (bool enabled) { + // TODO. +} + +bool Address::isSip () const { + // TODO. + return false; +} + +string Address::getMethodParam () const { + // TODO. + return ""; +} + +void Address::setMethodParam (const string &method) { + // TODO. +} + +string Address::getPassword () const { + // TODO. + return ""; +} + +void Address::setPassword (const string &passwd) { + // TODO. +} + +void clean () { + // TODO. +} + +string Address::asString () const { + // TODO. + return ""; +} + +string Address::asStringUriOnly () const { + // TODO. + return ""; +} + +bool Address::equal (const shared_ptr &address) const { + // TODO. + return false; +} + +bool Address::weakEqual (const shared_ptr &a2) const { + // TODO. + return false; +} + +string Address::getHeaderValue (const string &headerName) const { + // TODO. + return ""; +} + +void addHeader (const string &headerName, const string &headerValue) { + // TODO. +} + +void removeHeader (const string &headerName) { + // TODO. +} + +LINPHONE_END_NAMESPACE diff --git a/src/address/address.h b/src/address/address.h new file mode 100644 index 000000000..e18949814 --- /dev/null +++ b/src/address/address.h @@ -0,0 +1,91 @@ +/* + * address.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _ADDRESS_H_ +#define _ADDRESS_H_ + +#include +#include + +#include "enums.h" +#include "object/clonable-object.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class AddressPrivate; + +class LINPHONE_PUBLIC Address : public ClonableObject { +public: + Address (const std::string &address); + Address (const Address &src); + + Address &operator= (const Address &src); + + operator bool () const; + + bool operator== (const Address &address) const; + + std::string getScheme () const; + + std::string getDisplayName () const; + bool setDisplayName (const std::string &displayName); + + std::string getUsername () const; + bool setUsername (const std::string &username); + + std::string getDomain () const; + bool setDomain (const std::string &host); + + int getPort () const; + bool setPort (int port); + + Transport getTransport () const; + bool setTransport (Transport transport); + + bool getSecure () const; + void setSecure (bool enabled); + + bool isSip () const; + + std::string getMethodParam () const; + void setMethodParam (const std::string &method); + + std::string getPassword () const; + void setPassword (const std::string &passwd); + + void clean (); + + std::string asString () const; + std::string asStringUriOnly () const; + + bool equal (const std::shared_ptr &address) const; + bool weakEqual (const std::shared_ptr &a2) const; + + std::string getHeaderValue (const std::string &headerName) const; + void addHeader (const std::string &headerName, const std::string &headerValue); + void removeHeader (const std::string &headerName); + +private: + L_DECLARE_PRIVATE(Address); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _ADDRESS_H_ diff --git a/src/enums.h b/src/enums.h new file mode 100644 index 000000000..945e43995 --- /dev/null +++ b/src/enums.h @@ -0,0 +1,37 @@ +/* + * enums.h + * Copyright (C) 2017 Belledonne Communications SARL + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _ENUMS_H_ +#define _ENUMS_H_ + +#include "utils/general.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +enum class Transport { + Udp, + Tcp, + Tls, + Dtls +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _ENUMS_H_