Commit a0e40432 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Some cleaning in CPIM parser.

parent daddec29
......@@ -75,7 +75,11 @@ void Cpim::ContactHeader::setFormalName (const string &formalName) {
string Cpim::ContactHeader::getValue () const {
L_D();
return "\"" + d->formalName + "\"" + "<" + d->uri + ">";
string result;
if (!d->formalName.empty())
result += "\"" + d->formalName + "\"";
result += "<" + d->uri + ">";
return result;
}
string Cpim::ContactHeader::asString () const {
......@@ -84,37 +88,6 @@ string Cpim::ContactHeader::asString () const {
// -----------------------------------------------------------------------------
class Cpim::MessageIdHeaderPrivate : public HeaderPrivate {
public:
string token;
};
Cpim::MessageIdHeader::MessageIdHeader () : Header(*new MessageIdHeaderPrivate) {}
Cpim::MessageIdHeader::MessageIdHeader (const string &token) : MessageIdHeader() {
setToken(token);
}
string Cpim::MessageIdHeader::getToken () const {
L_D();
return d->token;
}
void Cpim::MessageIdHeader::setToken (string token) {
L_D();
d->token = token;
}
string Cpim::MessageIdHeader::getValue () const {
return getToken();
}
string Cpim::MessageIdHeader::asString () const {
return getName() + ": " + getValue() + "\r\n";
}
// -----------------------------------------------------------------------------
class Cpim::DateTimeHeaderPrivate : public HeaderPrivate {
public:
tm dateTime;
......
......@@ -77,34 +77,6 @@ namespace Cpim {
MAKE_CONTACT_HEADER(To, "To");
MAKE_CONTACT_HEADER(Cc, "cc");
// -------------------------------------------------------------------------
// Specific MessageId declaration.
// -------------------------------------------------------------------------
class MessageIdHeaderPrivate;
class LINPHONE_PUBLIC MessageIdHeader : public Header {
public:
MessageIdHeader ();
MessageIdHeader (const std::string &token);
inline std::string getName() const override {
return "Message-ID";
}
std::string getToken () const;
void setToken (std::string token);
std::string getValue () const override;
std::string asString () const override;
private:
L_DECLARE_PRIVATE(MessageIdHeader);
L_DISABLE_COPY(MessageIdHeader);
};
// -------------------------------------------------------------------------
// Specific DateTime declaration.
// -------------------------------------------------------------------------
......
......@@ -77,7 +77,7 @@ void Cpim::Message::removeMessageHeader (const Header &messageHeader, const stri
});
}
shared_ptr<const Cpim::Header> Cpim::Message::getMessageHeader (const string &name, const string &ns) {
shared_ptr<const Cpim::Header> Cpim::Message::getMessageHeader (const string &name, const string &ns) const {
L_D();
if (d->messageHeaders.find(ns) == d->messageHeaders.end())
......@@ -111,7 +111,7 @@ void Cpim::Message::removeContentHeader (const Header &contentHeader) {
});
}
shared_ptr<const Cpim::Header> Cpim::Message::getContentHeader(const string &name) {
shared_ptr<const Cpim::Header> Cpim::Message::getContentHeader(const string &name) const {
L_D();
for (const auto &contentHeader : *d->contentHeaders) {
......
......@@ -39,12 +39,12 @@ namespace Cpim {
HeaderList getMessageHeaders (const std::string &ns = "") const;
void addMessageHeader (const Header &messageHeader, const std::string &ns = "");
void removeMessageHeader (const Header &messageHeader, const std::string &ns = "");
std::shared_ptr<const Cpim::Header> getMessageHeader (const std::string &name, const std::string &ns = "");
std::shared_ptr<const Cpim::Header> getMessageHeader (const std::string &name, const std::string &ns = "") const;
HeaderList getContentHeaders () const;
void addContentHeader (const Header &contentHeader);
void removeContentHeader (const Header &contentHeader);
std::shared_ptr<const Cpim::Header> getContentHeader (const std::string &name);
std::shared_ptr<const Cpim::Header> getContentHeader (const std::string &name) const;
std::string getContent () const;
bool setContent (const std::string &content);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment