Skip to content

Commit

Permalink
Allow build for qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Aug 22, 2023
1 parent fc11565 commit 3152b81
Show file tree
Hide file tree
Showing 42 changed files with 207 additions and 47 deletions.
4 changes: 4 additions & 0 deletions src/lib/event
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <timed-qt6/event-declarations.h>
#else
#include <timed-qt5/event-declarations.h>
#endif
10 changes: 8 additions & 2 deletions src/lib/event-declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,22 @@ class Maemo::Timed::Event::List
List(const event_list_io_t &eeio);
QVariant dbus_output() const;
};

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::Event::Triggers &x);
const QDBusArgument &operator>>(const QDBusArgument &in, Maemo::Timed::Event::Triggers &x);
#else
declare_qtdbus_io(Maemo::Timed::Event::Triggers);

#endif
class Maemo::Timed::Event::Triggers : public QMap<quint32, quint32>
{
public:
Triggers()
: QMap<quint32, quint32>()
{}
};
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_DECLARE_METATYPE(Maemo::Timed::Event::Triggers)
#endif

#if NOT_DONE_YET
void foo()
Expand Down
23 changes: 22 additions & 1 deletion src/lib/event-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,34 @@ struct Maemo::Timed::event_list_io_t
{
QVector<event_io_t> ee;
};
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::attribute_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::attribute_io_t &x);

QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::cred_modifier_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::cred_modifier_io_t &x);

QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::action_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::action_io_t &x);

QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::button_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::button_io_t &x);

QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::recurrence_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::recurrence_io_t &x);

QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::event_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::event_io_t &x);

QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::event_list_io_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in,Maemo::Timed::event_list_io_t &x);
#else
declare_qtdbus_io(Maemo::Timed::attribute_io_t);
declare_qtdbus_io(Maemo::Timed::cred_modifier_io_t);
declare_qtdbus_io(Maemo::Timed::action_io_t);
declare_qtdbus_io(Maemo::Timed::button_io_t);
declare_qtdbus_io(Maemo::Timed::recurrence_io_t);
declare_qtdbus_io(Maemo::Timed::event_io_t);
declare_qtdbus_io(Maemo::Timed::event_list_io_t);

#endif
#endif
4 changes: 4 additions & 0 deletions src/lib/hidden/exception
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <timed-qt6/exception.h>
#else
#include <timed-qt5/exception.h>
#endif
4 changes: 4 additions & 0 deletions src/lib/interface
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <timed-qt6/interface.h>
#else
#include <timed-qt5/interface.h>
#endif
8 changes: 4 additions & 4 deletions src/lib/lib.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TEMPLATE = lib
QT += dbus
QT -= gui

TARGET = timed-qt5
TARGET = timed-qt$${QT_MAJOR_VERSION}

VERSION = 0.$$(TIMED_VERSION)

Expand All @@ -20,14 +20,14 @@ devheaders.files += hidden/exception exception.h qmacro.h
devheaders.files += interface interface.h
devheaders.files += event event-declarations.h
devheaders.files += wallclock wall-declarations.h
devheaders.path = /usr/include/timed-qt5
devheaders.path = /usr/include/timed-qt$${QT_MAJOR_VERSION}
devheaders.path = /usr/include/$$TARGET

pc.path = $$[QT_INSTALL_LIBS]/pkgconfig
pc.files = timed-qt5.pc
pc.files = timed-qt$${QT_MAJOR_VERSION}.pc

prf.path = $$[QT_INSTALL_DATA]/mkspecs/features
prf.files = timed-qt5.prf
prf.files = timed-qt$${QT_MAJOR_VERSION}.prf

INSTALLS = target devheaders prf pc

Expand Down
7 changes: 5 additions & 2 deletions src/lib/nanotime.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ QTextStream &operator<<(QTextStream &os, const QVector<T> &x)
os << "]";
return os;
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDBusArgument &operator<<(QDBusArgument &out, const nanotime_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in, nanotime_t &x);
#else
declare_qtdbus_io(nanotime_t);

#endif
#endif
4 changes: 2 additions & 2 deletions src/lib/qmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ inline QString Maemo::Timed::c2q(const char *c)
{
return QString::fromLatin1(c);
}

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#define declare_qtdbus_io(type_name) \
QDBusArgument &operator<<(QDBusArgument &out, const type_name &x); \
const QDBusArgument &operator>>(const QDBusArgument &in, type_name &x); \
Q_DECLARE_METATYPE(type_name)

#endif
#define declare_qtdbus_io_friends(type_name) \
friend QDBusArgument & ::operator<<(QDBusArgument &, const type_name &); \
friend const QDBusArgument & ::operator>>(const QDBusArgument &in, type_name &x);
Expand Down
5 changes: 5 additions & 0 deletions src/lib/timed-qt6.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Name: libtimed-qt6
Description: timed communication library
Version: 3.6
Requires: Qt6DBus
Libs: -ltimed-qt6
2 changes: 2 additions & 0 deletions src/lib/timed-qt6.prf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LIBS += -ltimed-qt6
QT += dbus
14 changes: 11 additions & 3 deletions src/lib/wall-declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ enum OffsetSource { OffsetManual, OffsetNitz };
} // namespace WallClock
} // namespace Timed
} // namespace Maemo

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::WallClock::Info &x);
const QDBusArgument &operator>>(const QDBusArgument &in, Maemo::Timed::WallClock::Info &x);
#else
declare_qtdbus_io(Maemo::Timed::WallClock::Info);

#endif
class Maemo::Timed::WallClock::Info
{
declare_qtdbus_io_friends(Info);
Expand Down Expand Up @@ -89,8 +92,13 @@ class Maemo::Timed::WallClock::Info
QString defaultTimezone() const;

QString str() const;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
declare_qtdbus_io_friends(Info);
#endif
};

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Q_DECLARE_METATYPE(Maemo::Timed::WallClock::Info)
#endif
// struct wall_settings_pimple_t ;

class Maemo::Timed::WallClock::Settings
Expand Down
7 changes: 6 additions & 1 deletion src/lib/wall-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ QString Maemo::Timed::WallClock::Info::str() const
os << " clock_back=" << p->systime_diff;
os << " nitz_supported=" << p->nitz_supported;
os << " default_timezone=" << p->default_timezone.toStdString().c_str();
os << "}" << flush;
os << "}" ;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
os << Qt::flush;
#else
os << flush;
#endif
return res;
}

Expand Down
7 changes: 6 additions & 1 deletion src/lib/wall-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ QString Maemo::Timed::WallClock::wall_settings_pimple_t::str() const
os << "time_at_zero=" << time_at_zero.str().c_str() << ", ";
os << "offset=" << offset << ", ";
os << "zone='" << zone << "', ";
os << "valid=" << valid << "}" << flush;
os << "valid=" << valid << "}";
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
os << Qt::flush;
#else
os << flush;
#endif
return res;
}

Expand Down
8 changes: 7 additions & 1 deletion src/lib/wall-settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ struct Maemo::Timed::WallClock::wall_settings_pimple_t
QString str() const;
};

declare_qtdbus_io(Maemo::Timed::WallClock::wall_settings_pimple_t);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDBusArgument &operator<<(QDBusArgument &out, const Maemo::Timed::WallClock::wall_settings_pimple_t &x);
const QDBusArgument &operator>>(const QDBusArgument &in, Maemo::Timed::WallClock::wall_settings_pimple_t &x);

Q_DECLARE_METATYPE(Maemo::Timed::WallClock::wall_settings_pimple_t)
#else
declare_qtdbus_io(Maemo::Timed::WallClock::wall_settings_pimple_t);
#endif
#endif
4 changes: 4 additions & 0 deletions src/lib/wallclock
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <timed-qt6/wall-declarations.h>
#else
#include <timed-qt5/wall-declarations.h>
#endif
8 changes: 8 additions & 0 deletions src/server/cellular.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ cellular_time_t::cellular_time_t(const NetworkTimeInfo &cnti)
, ts(0)
{
if (cnti.isValid() and cnti.dateTime().isValid()) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
value = cnti.dateTime().toSecsSinceEpoch();
#else
value = cnti.dateTime().toTime_t();
#endif
ts = nanotime_t::from_timespec(*cnti.timestamp());
}
log_debug("constructed %s out of %s",
Expand Down Expand Up @@ -178,7 +182,11 @@ cellular_offset_t::cellular_offset_t(const NetworkTimeInfo &cnti)

if (cnti.dateTime().isValid() and cnti.dateTime().timeSpec() == Qt::UTC) {
sender_time = true;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
timestamp = cnti.dateTime().toSecsSinceEpoch();
#else
timestamp = cnti.dateTime().toTime_t();
#endif
} else {
// the exact moment of sending isn't clear, let's guess it
nanotime_t monotonic_received = nanotime_t::from_timespec(*cnti.timestamp());
Expand Down
4 changes: 4 additions & 0 deletions src/server/credentials.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ using namespace std;
#include <QDBusConnection>
#include <QDBusMessage>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <iodata-qt6/iodata>
#else
#include <iodata-qt5/iodata>
#endif

uint32_t get_name_owner_from_dbus_sync(const QDBusConnection &bus, const QString &name);

Expand Down
4 changes: 4 additions & 0 deletions src/server/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ using namespace std;

#include <QDBusPendingCallWatcher>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <iodata-qt6/iodata>
#else
#include <iodata-qt5/iodata>
#endif

#include "../lib/event-declarations.h"
#include "../lib/event-io.h"
Expand Down
14 changes: 7 additions & 7 deletions src/server/server.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ QT += dbus

TEMPLATE = app

TARGET = timed-qt5
TARGET = timed

VERSION = $$(TIMED_VERSION)

INCLUDEPATH += ../h

QMAKE_LIBDIR_FLAGS += -L../lib -L../voland
LIBS += -ltimed-qt5 -ltimed-voland-qt5
LIBS += -ltimed-qt$${QT_MAJOR_VERSION} -ltimed-voland-qt$${QT_MAJOR_VERSION} -liodata-qt$${QT_MAJOR_VERSION}

IODATA_TYPES = queue.type config.type settings.type customization.type tzdata.type

Expand Down Expand Up @@ -81,7 +81,7 @@ HEADERS += tz.h
SOURCES += notification.cpp
HEADERS += notification.h

CONFIG += link_pkgconfig iodata-qt5
CONFIG += link_pkgconfig iodata-qt$${QT_MAJOR_VERSION}
PKGCONFIG += libpcrecpp libsystemd
PKGCONFIG += sailfishaccesscontrol

Expand All @@ -92,16 +92,16 @@ CONFIG(dsme_dbus_if) {
target.path = $$(DESTDIR)/usr/bin

timedrc.path = $$(DESTDIR)/etc
timedrc.files = timed-qt5.rc
timedrc.files = timed.rc

dbusconf.path = $$(DESTDIR)/etc/dbus-1/system.d
dbusconf.files = timed-qt5.conf
dbusconf.files = timed.conf

systemd.path = $$(DESTDIR)/usr/lib/systemd/user
systemd.files = timed-qt5.service
systemd.files = timed.service

oneshot.path = $$(DESTDIR)/usr/lib/oneshot.d
oneshot.files = setcaps-timed-qt5.sh
oneshot.files = setcaps-timed-qt$${QT_MAJOR_VERSION}.sh

INSTALLS += target xml timedrc dbusconf systemd oneshot

Expand Down
7 changes: 7 additions & 0 deletions src/server/setcaps-timed-qt6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
if [ "$MIC_RUN" != "" ]; then
echo "setcaps-timed-qt6.sh - returning FAIL to postpone oneshot to first boot"
exit 1
fi

setcap cap_sys_time+ep /usr/bin/timed-qt6
6 changes: 5 additions & 1 deletion src/server/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
#define SETTINGS_H

#include <string>
#include <QtGlobal>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <iodata-qt6/iodata>
#else
#include <iodata-qt5/iodata>
#include <QtGlobal>
#endif

#include "../lib/nanotime.h"
#include "../lib/wall-declarations.h"
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions src/server/timed.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
#include <QDBusConnectionInterface>
#include <QDBusServiceWatcher>
#include <QMetaMethod>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <iodata-qt6/storage>
#include <iodata-qt6/validator>
#else
#include <iodata-qt5/storage>
#include <iodata-qt5/validator>

#endif
#include "event.h"
#include "machine.h"
#include "settings.h"
Expand All @@ -55,7 +58,7 @@ class csd_t;
struct Timed : public QCoreApplication
{
public:
inline const char *configuration_path() { return "/etc/timed-qt5.rc"; }
inline const char *configuration_path() { return "/etc/timed.rc"; }
// inline const char *configuration_type() { return "/usr/share/timed/typeinfo/config.type" ; }

inline const char *customization_path()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/server/timed-qt5.service → src/server/timed.service
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=dbus.socket
# Service type should be dbus, but timed dbus API is on the system bus, which systemd does not detect
[Service]
Type=notify
ExecStart=/usr/bin/timed-qt5 --systemd
ExecStart=/usr/bin/timed --systemd
Restart=always
RestartSec=1

Expand Down
5 changes: 4 additions & 1 deletion src/server/timeutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
#include <string>
#include <QObject>
using namespace std;

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <iodata-qt6/iodata>
#else
#include <iodata-qt5/iodata>
#endif

struct recurrence_pattern_t;

Expand Down
Loading

0 comments on commit 3152b81

Please sign in to comment.