diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index e65647124..afdcd6ff3 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -31,6 +31,8 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE +// ----------------------------------------------------------------------------- + list ContentManager::multipartToContentList (const Content &content) { belle_sip_multipart_body_handler_t *mpbh = belle_sip_multipart_body_handler_new_from_buffer( (void *)content.getBodyAsString().c_str(), diff --git a/src/content/content-manager.h b/src/content/content-manager.h index f91adc2ab..a7b2b97b0 100644 --- a/src/content/content-manager.h +++ b/src/content/content-manager.h @@ -33,7 +33,7 @@ class Content; namespace ContentManager { std::list multipartToContentList (const Content &content); Content contentListToMultipart (const std::list &contents); -}; +} LINPHONE_END_NAMESPACE diff --git a/src/content/content-p.h b/src/content/content-p.h index b3045b429..c5685c297 100644 --- a/src/content/content-p.h +++ b/src/content/content-p.h @@ -22,20 +22,21 @@ #include -#include "object/clonable-object-p.h" -#include "object/object-p.h" #include "content-type.h" #include "content.h" +#include "object/clonable-object-p.h" // ============================================================================= LINPHONE_BEGIN_NAMESPACE class ContentPrivate : public ClonableObjectPrivate { -public: +private: std::vector body; ContentType contentType; std::string contentDisposition; + + L_DECLARE_PUBLIC(Content); }; LINPHONE_END_NAMESPACE diff --git a/src/content/content-type.cpp b/src/content/content-type.cpp index 4aeac8869..8c8d69859 100644 --- a/src/content/content-type.cpp +++ b/src/content/content-type.cpp @@ -19,9 +19,8 @@ #include "linphone/utils/utils.h" -#include "object/clonable-object-p.h" -#include "logger/logger.h" #include "content-type.h" +#include "object/clonable-object-p.h" // ============================================================================= @@ -29,6 +28,8 @@ using namespace std; LINPHONE_BEGIN_NAMESPACE +// ----------------------------------------------------------------------------- + class ContentTypePrivate : public ClonableObjectPrivate { public: string type; @@ -60,34 +61,32 @@ ContentType::ContentType (const string &contentType) : ClonableObject(*new Conte return; if (setType(contentType.substr(0, pos))) { - if (posParam != string::npos) { + if (posParam != string::npos) end = posParam; - } if (!setSubType(contentType.substr(pos + 1, end - (pos + 1)))) d->type.clear(); } - if (posParam != string::npos) { - setParameter(contentType.substr(posParam + 2)); // We remove the blankspace after the ; - } + if (posParam != string::npos) + setParameter(contentType.substr(posParam + 2)); // We remove the blankspace after the ;. } ContentType::ContentType (const string &type, const string &subType) : ClonableObject(*new ContentTypePrivate) { L_D(); - if (setType(type)) { - if (!setSubType(subType)) - d->type.clear(); - } + if (setType(type) && !setSubType(subType)) + d->type.clear(); } -ContentType::ContentType (const string &type, const string &subType, const string ¶meter) : ClonableObject(*new ContentTypePrivate) { +ContentType::ContentType ( + const string &type, + const string &subType, + const string ¶meter +) : ClonableObject(*new ContentTypePrivate) { L_D(); - if (setType(type)) { - if (!setSubType(subType)) - d->type.clear(); - } + if (setType(type) && !setSubType(subType)) + d->type.clear(); setParameter(parameter); } @@ -104,11 +103,13 @@ ContentType &ContentType::operator= (const ContentType &src) { } bool ContentType::operator== (const ContentType &contentType) const { - return getType() == contentType.getType() && getSubType() == contentType.getSubType() && getParameter() == contentType.getParameter(); + return getType() == contentType.getType() && + getSubType() == contentType.getSubType() && + getParameter() == contentType.getParameter(); } bool ContentType::operator!= (const ContentType &contentType) const { - return !operator==(contentType); + return !(*this == contentType); } const string &ContentType::getType () const { @@ -162,9 +163,8 @@ string ContentType::asString () const { L_D(); if (isValid()) { string asString = d->type + "/" + d->subType; - if (!d->parameter.empty()) { + if (!d->parameter.empty()) asString += "; " + d->parameter; - } return asString; } return ""; diff --git a/src/content/content.cpp b/src/content/content.cpp index 0bd2554d0..68d86e9fd 100644 --- a/src/content/content.cpp +++ b/src/content/content.cpp @@ -17,11 +17,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include "content-type.h" +// TODO: Remove me later. +#include "linphone/core.h" #include "content-p.h" -#include "content.h" -#include "linphone/core.h" +#include "content-type.h" // ============================================================================= @@ -151,14 +151,13 @@ bool Content::isEmpty () const { return getSize() == 0; } -bool Content::isValid() const { +bool Content::isValid () const { L_D(); return d->contentType.isValid() || d->body.empty(); } -LinphoneContent * Content::toLinphoneContent() const { - LinphoneContent* content; - content = linphone_core_create_content(NULL); +LinphoneContent *Content::toLinphoneContent () const { + LinphoneContent *content = linphone_core_create_content(nullptr); linphone_content_set_type(content, getContentType().getType().c_str()); linphone_content_set_subtype(content, getContentType().getSubType().c_str()); return content; diff --git a/src/content/content.h b/src/content/content.h index 23aa0446a..850bb7c50 100644 --- a/src/content/content.h +++ b/src/content/content.h @@ -62,12 +62,12 @@ public: size_t getSize () const; - bool isValid() const; + bool isValid () const; bool isEmpty () const; // TODO: Remove me later. - virtual LinphoneContent *toLinphoneContent() const; + virtual LinphoneContent *toLinphoneContent () const; protected: explicit Content (ContentPrivate &p);