Skip to content

Commit

Permalink
Move all remaining member to private classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dantti committed Nov 8, 2015
1 parent 424c699 commit f7d761d
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 82 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set(simplemailqt_SRC
mimepart.cpp
mimepart_p.h
mimetext.cpp
mimetext_p.h
quotedprintable.cpp
sender.cpp
sender_p.h
Expand Down
2 changes: 1 addition & 1 deletion src/mimeattachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SMTP_EXPORT MimeAttachment : public MimeFile
~MimeAttachment();

protected:
virtual void prepare();
virtual void prepare() Q_DECL_OVERRIDE;
};

#endif // MIMEATTACHMENT_H
11 changes: 5 additions & 6 deletions src/mimefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
MimeFile::MimeFile(QFile *file)
{
Q_D(MimePart);
this->file = file;
d->contentFile = file;
d->cType = QStringLiteral("application/octet-stream");
d->cName = QFileInfo(*file).fileName();
d->cEncoding = Base64;
Expand All @@ -40,17 +40,16 @@ MimeFile::MimeFile(const QByteArray &stream, const QString &fileName)

MimeFile::~MimeFile()
{
delete file;
}

void MimeFile::prepare()
{
Q_D(MimePart);

if (this->file) {
file->open(QIODevice::ReadOnly);
d->content = file->readAll();
file->close();
if (d->contentFile) {
d->contentFile->open(QIODevice::ReadOnly);
d->content = d->contentFile->readAll();
d->contentFile->close();
}

/* !!! IMPORTANT !!!! */
Expand Down
4 changes: 1 addition & 3 deletions src/mimefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class SMTP_EXPORT MimeFile : public MimePart
~MimeFile();

protected:
QFile* file = nullptr;

virtual void prepare();
virtual void prepare() Q_DECL_OVERRIDE;
};

#endif // MIMEFILE_H
8 changes: 5 additions & 3 deletions src/mimehtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "mimehtml.h"
#include "mimepart_p.h"
#include "mimetext_p.h"

MimeHtml::MimeHtml(const QString &html) : MimeText(html)
{
Expand All @@ -32,12 +32,14 @@ MimeHtml::~MimeHtml()

void MimeHtml::setHtml(const QString &html)
{
this->m_text = html;
Q_D(MimePart);
static_cast<MimeTextPrivate*>(d)->text = html;
}

QString MimeHtml::html() const
{
return m_text;
Q_D(const MimePart);
return static_cast<const MimeTextPrivate*>(d)->text;
}

void MimeHtml::prepare()
Expand Down
3 changes: 1 addition & 2 deletions src/mimehtml.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ class SMTP_EXPORT MimeHtml : public MimeText
~MimeHtml();

void setHtml(const QString &html);

QString html() const;

protected:
virtual void prepare();
virtual void prepare() Q_DECL_OVERRIDE;
};

#endif // MIMEHTML_H
14 changes: 3 additions & 11 deletions src/mimeinlinefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@
#include "mimeinlinefile.h"
#include "mimepart_p.h"

MimeInlineFile::MimeInlineFile(QFile *f)
: MimeFile(f)
MimeInlineFile::MimeInlineFile(QFile *f) : MimeFile(f)
{
Q_D(MimePart);
d->header.append(QStringLiteral("Content-Disposition: inline\r\n"));
}

MimeInlineFile::~MimeInlineFile()
{

}

void MimeInlineFile::prepare()
{
Q_D(MimePart);
d->header.append(QStringLiteral("Content-Disposition: inline\r\n"));

/* !!! IMPORTANT !!! */
MimeFile::prepare();
}
3 changes: 0 additions & 3 deletions src/mimeinlinefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class SMTP_EXPORT MimeInlineFile : public MimeFile
public:
MimeInlineFile(QFile *f);
~MimeInlineFile();

protected:
virtual void prepare();
};

#endif // MIMEINLINEFILE_H
4 changes: 2 additions & 2 deletions src/mimemessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ QString MimeMessage::subject() const
return d->subject;
}

QList<MimePart*> MimeMessage::getParts() const
QList<MimePart*> MimeMessage::parts() const
{
Q_D(const MimeMessage);
if (typeid(*d->content) == typeid(MimeMultiPart)) {
return ((MimeMultiPart*) d->content)->getParts();
return ((MimeMultiPart*) d->content)->parts();
} else {
QList<MimePart*> *res = new QList<MimePart*>();
res->append(d->content);
Expand Down
2 changes: 1 addition & 1 deletion src/mimemessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SMTP_EXPORT MimeMessage
EmailAddress sender() const;
QList<EmailAddress> getRecipients(RecipientType type = To) const;
QString subject() const;
QList<MimePart *> getParts() const;
QList<MimePart *> parts() const;

MimePart& getContent();
void setContent(MimePart *content);
Expand Down
2 changes: 1 addition & 1 deletion src/mimemultipart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void MimeMultiPart::addPart(MimePart *part)
static_cast<MimeMultiPartPrivate*>(d)->parts.append(part);
}

QList<MimePart*> MimeMultiPart::getParts() const
QList<MimePart*> MimeMultiPart::parts() const
{
Q_D(const MimePart);
return static_cast<const MimeMultiPartPrivate*>(d)->parts;
Expand Down
6 changes: 3 additions & 3 deletions src/mimemultipart.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class SMTP_EXPORT MimeMultiPart : public MimePart
void setMimeType(const MultiPartType type);
MultiPartType mimeType() const;

QList<MimePart *> getParts() const;

QList<MimePart *> parts() const;
void addPart(MimePart *part);

virtual void prepare();
protected:
virtual void prepare() Q_DECL_OVERRIDE;
};

#endif // MIMEMULTIPART_H
2 changes: 2 additions & 0 deletions src/mimepart_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@

#include "mimepart.h"

class QFile;
class MimePartPrivate : public QSharedData
{
public:
QString header;
QByteArray content;
QFile *contentFile = nullptr;

QString cId;
QString cName;
Expand Down
15 changes: 8 additions & 7 deletions src/mimetext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
See the LICENSE file for more details.
*/

#include "mimetext.h"
#include "mimepart_p.h"
#include "mimetext_p.h"

MimeText::MimeText(const QString &txt)
MimeText::MimeText(const QString &txt) : MimePart(new MimeTextPrivate)
{
Q_D(MimePart);
this->m_text = txt;
static_cast<MimeTextPrivate*>(d)->text = txt;
d->cType = QStringLiteral("text/plain");
d->cCharset = QStringLiteral("utf-8");
d->cEncoding = _8Bit;
Expand All @@ -35,18 +34,20 @@ MimeText::~MimeText()

void MimeText::setText(const QString &text)
{
this->m_text = text;
Q_D(MimePart);
static_cast<MimeTextPrivate*>(d)->text = text;
}

QString MimeText::text() const
{
return m_text;
Q_D(const MimePart);
return static_cast<const MimeTextPrivate*>(d)->text;
}

void MimeText::prepare()
{
Q_D(MimePart);
d->content = m_text.toUtf8();
d->content = static_cast<MimeTextPrivate*>(d)-> text.toUtf8();

/* !!! IMPORTANT !!! */
MimePart::prepare();
Expand Down
5 changes: 1 addition & 4 deletions src/mimetext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ class SMTP_EXPORT MimeText : public MimePart
QString text() const;

protected:
QString m_text;

void prepare();

virtual void prepare() Q_DECL_OVERRIDE;
};

#endif // MIMETEXT_H
33 changes: 33 additions & 0 deletions src/mimetext_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2015 Daniel Nicoletti <dantti12@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

#ifndef MIMETEXT_P_H
#define MIMETEXT_P_H

#include "mimetext.h"
#include "mimepart_p.h"

class MimeTextPrivate : public MimePartPrivate
{
public:
QString text;
};

#endif // MIMETEXT_P_H

Loading

0 comments on commit f7d761d

Please sign in to comment.