Verified Commit 1db40364 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Move Pop3ResourceAttribute and NewMailNotifierAttribute to akonadi-mime

Those are email-specific attributes, so their place is in akonadi-mie
rather than the type-agnostic Akonadi repository.
parent 3a182781
......@@ -48,8 +48,6 @@ add_akonadi_test(collectionutilstest.cpp)
add_akonadi_test(collectioncolorattributetest.cpp)
add_akonadi_test(entitydisplayattributetest.cpp)
add_akonadi_test(proxymodelstest.cpp)
add_akonadi_test(newmailnotifierattributetest.cpp)
add_akonadi_test(pop3resourceattributetest.cpp)
add_akonadi_test_widgets(actionstatemanagertest.cpp)
add_akonadi_test_widgets(conflictresolvedialogtest.cpp)
add_akonadi_test(tagmodeltest.cpp)
......
/*
Copyright (c) 2014-2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "newmailnotifierattributetest.h"
#include "newmailnotifierattribute.h"
#include <QTest>
using namespace Akonadi;
NewMailNotifierAttributeTest::NewMailNotifierAttributeTest(QObject *parent)
: QObject(parent)
{
}
void NewMailNotifierAttributeTest::shouldHaveDefaultValue()
{
NewMailNotifierAttribute attr;
QVERIFY(!attr.ignoreNewMail());
}
void NewMailNotifierAttributeTest::shouldSetIgnoreNotification()
{
NewMailNotifierAttribute attr;
bool ignore = false;
attr.setIgnoreNewMail(ignore);
QCOMPARE(attr.ignoreNewMail(), ignore);
ignore = true;
attr.setIgnoreNewMail(ignore);
QCOMPARE(attr.ignoreNewMail(), ignore);
}
void NewMailNotifierAttributeTest::shouldSerializedData()
{
NewMailNotifierAttribute attr;
attr.setIgnoreNewMail(true);
QByteArray ba = attr.serialized();
NewMailNotifierAttribute result;
result.deserialize(ba);
QVERIFY(attr == result);
}
void NewMailNotifierAttributeTest::shouldCloneAttribute()
{
NewMailNotifierAttribute attr;
attr.setIgnoreNewMail(true);
NewMailNotifierAttribute *result = attr.clone();
QVERIFY(attr == *result);
delete result;
}
void NewMailNotifierAttributeTest::shouldHaveType()
{
NewMailNotifierAttribute attr;
QCOMPARE(attr.type(), QByteArray("newmailnotifierattribute"));
}
QTEST_MAIN(NewMailNotifierAttributeTest)
/*
Copyright (c) 2014-2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef NEWMAILNOTIFIERATTRIBUTETEST_H
#define NEWMAILNOTIFIERATTRIBUTETEST_H
#include <QObject>
class NewMailNotifierAttributeTest : public QObject
{
Q_OBJECT
public:
explicit NewMailNotifierAttributeTest(QObject *parent = nullptr);
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldSetIgnoreNotification();
void shouldSerializedData();
void shouldCloneAttribute();
void shouldHaveType();
};
#endif // NEWMAILNOTIFIERATTRIBUTETEST_H
/*
Copyright (c) 2014-2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "pop3resourceattributetest.h"
#include "pop3resourceattribute.h"
#include <QTest>
Pop3ResourceAttributeTest::Pop3ResourceAttributeTest(QObject *parent)
: QObject(parent)
{
}
void Pop3ResourceAttributeTest::shouldHaveDefaultValue()
{
Akonadi::Pop3ResourceAttribute attr;
QVERIFY(attr.pop3AccountName().isEmpty());
}
void Pop3ResourceAttributeTest::shouldAssignValue()
{
Akonadi::Pop3ResourceAttribute attr;
QString accountName;
attr.setPop3AccountName(accountName);
QCOMPARE(attr.pop3AccountName(), accountName);
accountName = QStringLiteral("foo");
attr.setPop3AccountName(accountName);
QCOMPARE(attr.pop3AccountName(), accountName);
accountName.clear();
attr.setPop3AccountName(accountName);
QCOMPARE(attr.pop3AccountName(), accountName);
}
void Pop3ResourceAttributeTest::shouldDeserializeValue()
{
Akonadi::Pop3ResourceAttribute attr;
QString accountName = QStringLiteral("foo");
attr.setPop3AccountName(accountName);
const QByteArray ba = attr.serialized();
Akonadi::Pop3ResourceAttribute result;
result.deserialize(ba);
QVERIFY(attr == result);
}
void Pop3ResourceAttributeTest::shouldCloneAttribute()
{
Akonadi::Pop3ResourceAttribute attr;
QString accountName = QStringLiteral("foo");
attr.setPop3AccountName(accountName);
Akonadi::Pop3ResourceAttribute *result = attr.clone();
QVERIFY(attr == *result);
delete result;
}
QTEST_MAIN(Pop3ResourceAttributeTest)
/*
Copyright (c) 2014-2020 Laurent Montel <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef POP3RESOURCEATTRIBUTETEST_H
#define POP3RESOURCEATTRIBUTETEST_H
#include <QObject>
class Pop3ResourceAttributeTest : public QObject
{
Q_OBJECT
public:
explicit Pop3ResourceAttributeTest(QObject *parent = nullptr);
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldAssignValue();
void shouldDeserializeValue();
void shouldCloneAttribute();
};
#endif // POP3RESOURCEATTRIBUTETEST_H
......@@ -53,14 +53,12 @@ set(akonadicore_base_SRCS
mimetypechecker.cpp
monitor.cpp
monitor_p.cpp
newmailnotifierattribute.cpp
notificationsource_p.cpp
notificationsubscriber.cpp
partfetcher.cpp
pastehelper.cpp
persistentsearchattribute.cpp
pluginloader.cpp
pop3resourceattribute.cpp
protocolhelper.cpp
remotelog.cpp
relation.cpp
......@@ -115,12 +113,10 @@ ecm_generate_headers(AkonadiCore_base_HEADERS
ItemSerializerPlugin
ItemSync
MimeTypeChecker
NewMailNotifierAttribute
NotificationSubscriber
Monitor
PartFetcher
PersistentSearchAttribute
Pop3ResourceAttribute
Relation
SearchQuery
ServerManager
......
/*
Copyright (c) 2013-2020 Laurent Montel <montel@kde.org>
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.
*/
#include "newmailnotifierattribute.h"
#include <QByteArray>
#include <QIODevice>
#include <QDataStream>
namespace Akonadi
{
class NewMailNotifierAttributePrivate
{
public:
NewMailNotifierAttributePrivate()
: ignoreNewMail(false)
{
}
bool ignoreNewMail;
};
NewMailNotifierAttribute::NewMailNotifierAttribute()
: d(new NewMailNotifierAttributePrivate)
{
}
NewMailNotifierAttribute::~NewMailNotifierAttribute()
{
delete d;
}
NewMailNotifierAttribute *NewMailNotifierAttribute::clone() const
{
NewMailNotifierAttribute *attr = new NewMailNotifierAttribute();
attr->setIgnoreNewMail(ignoreNewMail());
return attr;
}
QByteArray NewMailNotifierAttribute::type() const
{
static const QByteArray sType("newmailnotifierattribute");
return sType;
}
QByteArray NewMailNotifierAttribute::serialized() const
{
QByteArray result;
QDataStream s(&result, QIODevice::WriteOnly);
s << ignoreNewMail();
return result;
}
void NewMailNotifierAttribute::deserialize(const QByteArray &data)
{
QDataStream s(data);
s >> d->ignoreNewMail;
}
bool NewMailNotifierAttribute::ignoreNewMail() const
{
return d->ignoreNewMail;
}
void NewMailNotifierAttribute::setIgnoreNewMail(bool b)
{
d->ignoreNewMail = b;
}
bool NewMailNotifierAttribute::operator==(const NewMailNotifierAttribute &other) const
{
return d->ignoreNewMail == other.ignoreNewMail();
}
}
/*
Copyright (c) 2013-2020 Laurent Montel <montel@kde.org>
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 NEWMAILNOTIFIERATTRIBUTE_H
#define NEWMAILNOTIFIERATTRIBUTE_H
#include "akonadicore_export.h"
#include <attribute.h>
namespace Akonadi
{
class NewMailNotifierAttributePrivate;
class AKONADICORE_EXPORT NewMailNotifierAttribute : public Akonadi::Attribute
{
public:
NewMailNotifierAttribute();
~NewMailNotifierAttribute() override;
/* reimpl */
NewMailNotifierAttribute *clone() const override;
QByteArray type() const override;
QByteArray serialized() const override;
void deserialize(const QByteArray &data) override;
bool ignoreNewMail() const;
void setIgnoreNewMail(bool b);
bool operator==(const NewMailNotifierAttribute &other) const;
private:
friend class NewMailNotifierAttributePrivate;
NewMailNotifierAttributePrivate *const d;
};
}
#endif // NEWMAILNOTIFIERATTRIBUTE_H
/*
Copyright (c) 2013-2020 Laurent Montel <montel@kde.org>
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.
*/
#include "pop3resourceattribute.h"
#include <QByteArray>
#include <QIODevice>
#include <QDataStream>
namespace Akonadi
{
class Pop3ResourceAttributePrivate
{
public:
Pop3ResourceAttributePrivate()
{
}
QString accountName;
};
Pop3ResourceAttribute::Pop3ResourceAttribute()
: d(new Pop3ResourceAttributePrivate)
{
}
Pop3ResourceAttribute::~Pop3ResourceAttribute()
{
delete d;
}
Pop3ResourceAttribute *Pop3ResourceAttribute::clone() const
{
Pop3ResourceAttribute *attr = new Pop3ResourceAttribute();
attr->setPop3AccountName(pop3AccountName());
return attr;
}
QByteArray Pop3ResourceAttribute::type() const
{
static const QByteArray sType("pop3resourceattribute");
return sType;
}
QByteArray Pop3ResourceAttribute::serialized() const
{
QByteArray result;
QDataStream s(&result, QIODevice::WriteOnly);
s << pop3AccountName();
return result;
}
void Pop3ResourceAttribute::deserialize(const QByteArray &data)
{
QDataStream s(data);
QString value;
s >> value;
d->accountName = value;
}
QString Pop3ResourceAttribute::pop3AccountName() const
{
return d->accountName;
}
void Pop3ResourceAttribute::setPop3AccountName(const QString &accountName)
{
d->accountName = accountName;
}
bool Pop3ResourceAttribute::operator==(const Pop3ResourceAttribute &other) const
{
return d->accountName == other.pop3AccountName();
}
}
/*
Copyright (c) 2013-2020 Laurent Montel <montel@kde.org>
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 AKONADICORE_POP3RESOURCEATTRIBUTE_H
#define AKONADICORE_POP3RESOURCEATTRIBUTE_H
#include <attribute.h>
#include "akonadicore_export.h"
namespace Akonadi
{
class Pop3ResourceAttributePrivate;
class AKONADICORE_EXPORT Pop3ResourceAttribute : public Akonadi::Attribute
{
public:
Pop3ResourceAttribute();
~Pop3ResourceAttribute() override;
/* reimpl */
Pop3ResourceAttribute *clone() const override;
QByteArray type() const override;
QByteArray serialized() const override;
void deserialize(const QByteArray &data) override;
QString pop3AccountName() const;
void setPop3AccountName(const QString &accountName);
bool operator==(const Pop3ResourceAttribute &other) const;
private:
friend class Pop3ResourceAttributePrivate;
Pop3ResourceAttributePrivate *const d;
};
}
#endif // AKONADICORE_POP3RESOURCEATTRIBUTE_H
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