Skip to content

Commit

Permalink
[libcommhistory] Don't leak DBus in headers.
Browse files Browse the repository at this point in the history
Don't export serialisation in QDBusArgument in
headers.
  • Loading branch information
dcaliste committed May 29, 2024
1 parent 58de1d0 commit 207114a
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 30 deletions.
2 changes: 2 additions & 0 deletions src/adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "messagepart.h"
#include "recipient.h"

#include "dbus_p.h"

using namespace CommHistory;

Adaptor::Adaptor(QObject *parent)
Expand Down
51 changes: 51 additions & 0 deletions src/dbus_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/******************************************************************************
**
** This file is part of libcommhistory.
**
** Copyright (C) 2024 Jolla Ltd.
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the GNU Lesser General Public License version 2.1 as
** published by the Free Software Foundation.
**
** 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 Lesser General Public
** License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this library; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
**
******************************************************************************/

#ifndef DBUS_P_H
#define DBUS_P_H

#include <QDBusArgument>

#include "recipient.h"
#include "event.h"
#include "messagepart.h"
#include "group.h"

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Recipient &recipient);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Recipient &recipient);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::RecipientList &recipients);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::RecipientList &recipients);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Event &event);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Event &event);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Event::Contact &contact);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Event::Contact &contact);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::MessagePart &part);
const QDBusArgument &operator>>(const QDBusArgument &argument,
CommHistory::MessagePart &part);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Group &group);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Group &group);

#endif
1 change: 1 addition & 0 deletions src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "event.h"
#include "messagepart.h"
#include "constants.h"
#include "dbus_p.h"

#include <QStringBuilder>

Expand Down
8 changes: 0 additions & 8 deletions src/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include "recipient.h"
#include "libcommhistoryexport.h"

class QDBusArgument;

namespace CommHistory {

class EventPrivate;
Expand Down Expand Up @@ -395,12 +393,6 @@ class LIBCOMMHISTORY_EXPORT Event

}

LIBCOMMHISTORY_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Event &event);
LIBCOMMHISTORY_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Event &event);

LIBCOMMHISTORY_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Event::Contact &contact);
LIBCOMMHISTORY_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Event::Contact &contact);

LIBCOMMHISTORY_EXPORT QDataStream &operator<<(QDataStream &stream, const CommHistory::Event &event);
LIBCOMMHISTORY_EXPORT QDataStream &operator>>(QDataStream &stream, CommHistory::Event &event);

Expand Down
1 change: 1 addition & 0 deletions src/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "group.h"
#include "event.h"
#include "dbus_p.h"

namespace CommHistory {

Expand Down
5 changes: 0 additions & 5 deletions src/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include "recipient.h"
#include "libcommhistoryexport.h"

class QDBusArgument;

namespace CommHistory {

class GroupPrivate;
Expand Down Expand Up @@ -264,9 +262,6 @@ class LIBCOMMHISTORY_EXPORT Group

}

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Group &group);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Group &group);

LIBCOMMHISTORY_EXPORT QDataStream &operator<<(QDataStream &stream, const CommHistory::Group &group);
LIBCOMMHISTORY_EXPORT QDataStream &operator>>(QDataStream &stream, CommHistory::Group &group);

Expand Down
2 changes: 0 additions & 2 deletions src/groupobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include "group.h"
#include "libcommhistoryexport.h"

class QDBusArgument;

namespace CommHistory {

class GroupManager;
Expand Down
8 changes: 7 additions & 1 deletion src/messagepart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ QDBusArgument &operator<<(QDBusArgument &argument, const MessagePart &part)

const QDBusArgument &operator>>(const QDBusArgument &argument, MessagePart &part)
{
int id;
QString contentId, contentType, path;
argument.beginStructure();
argument >> part.d->id >> part.d->contentId >> part.d->contentType >> part.d->path;
argument >> id >> contentId >> contentType >> path;
argument.endStructure();
part.setId(id);
part.setContentId(contentId);
part.setContentType(contentType);
part.setPath(path);
return argument;
}

Expand Down
7 changes: 0 additions & 7 deletions src/messagepart.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@

#include "libcommhistoryexport.h"

class QDBusArgument;

namespace CommHistory {
class MessagePart;
}

LIBCOMMHISTORY_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::MessagePart &part);
LIBCOMMHISTORY_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument,
CommHistory::MessagePart &part);

LIBCOMMHISTORY_EXPORT QDataStream &operator<<(QDataStream &stream, const CommHistory::MessagePart &part);
LIBCOMMHISTORY_EXPORT QDataStream &operator>>(QDataStream &stream, CommHistory::MessagePart &part);

Expand Down Expand Up @@ -102,7 +96,6 @@ class LIBCOMMHISTORY_EXPORT MessagePart
private:
QSharedDataPointer<MessagePartPrivate> d;

friend const QDBusArgument &::operator>>(const QDBusArgument &argument, CommHistory::MessagePart &part);
friend QDataStream &::operator>>(QDataStream &stream, CommHistory::MessagePart &part);
};

Expand Down
1 change: 1 addition & 0 deletions src/recipient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "commonutils.h"
#include <QSet>
#include <QHash>
#include <QDBusArgument>
#include <QDebug>

#include <phonenumbers/phonenumberutil.h>
Expand Down
7 changes: 0 additions & 7 deletions src/recipient.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <seasidecache.h>

#include <QObject>
#include <QDBusArgument>
#include <QSharedPointer>
#include <QHash>
#include <QDebug>
Expand Down Expand Up @@ -266,12 +265,6 @@ inline uint qHash(const CommHistory::Recipient &value, uint seed = 0)
LIBCOMMHISTORY_EXPORT QDebug &operator<<(QDebug &debug, const CommHistory::Recipient &recipient);
LIBCOMMHISTORY_EXPORT QDebug &operator<<(QDebug &debug, const CommHistory::RecipientList &recipientList);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::Recipient &recipient);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::Recipient &recipient);

QDBusArgument &operator<<(QDBusArgument &argument, const CommHistory::RecipientList &recipients);
const QDBusArgument &operator>>(const QDBusArgument &argument, CommHistory::RecipientList &recipients);

Q_DECLARE_METATYPE(CommHistory::Recipient)
Q_DECLARE_METATYPE(CommHistory::RecipientList)

Expand Down
1 change: 1 addition & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ PUBLIC_HEADERS += \
HEADERS += \
$$PUBLIC_HEADERS \
commhistorydatabase.h \
dbus_p.h \
debug.h \
eventmodel_p.h \
eventtreeitem.h \
Expand Down

0 comments on commit 207114a

Please sign in to comment.