Finish 64-bit time conversion, modify protocol
[quassel.git] / src / common / quassel.cpp
index dea2cd9..9685c24 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2016 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -20,7 +20,9 @@
 
 #include "quassel.h"
 
+#include <algorithm>
 #include <iostream>
+
 #include <signal.h>
 #if !defined Q_OS_WIN && !defined Q_OS_MAC
 #  include <sys/types.h>
@@ -294,7 +296,14 @@ void Quassel::setupBuildInfo()
     if (!QString(GIT_HEAD).isEmpty()) {
         buildInfo.commitHash = GIT_HEAD;
         QDateTime date;
-        date.setTime_t(GIT_COMMIT_DATE);
+#if QT_VERSION >= 0x050800
+        date.setSecsSinceEpoch(GIT_COMMIT_DATE);
+#else
+        // toSecsSinceEpoch() was added in Qt 5.8.  Manually downconvert to seconds for now.
+        // See https://doc.qt.io/qt-5/qdatetime.html#toMSecsSinceEpoch
+        // Warning generated if not converting the 1000 to a qint64 first.
+        date.setMSecsSinceEpoch(GIT_COMMIT_DATE * (qint64)1000);
+#endif
         buildInfo.commitDate = date.toString();
     }
     else if (!QString(DIST_HASH).contains("Format")) {
@@ -720,7 +729,13 @@ bool Quassel::Features::isEnabled(Feature feature) const
 
 QStringList Quassel::Features::toStringList(bool enabled) const
 {
+    // Check if any feature is enabled
+    if (!enabled && std::all_of(_features.cbegin(), _features.cend(), [](bool feature) { return !feature; })) {
+        return QStringList{} << "NoFeatures";
+    }
+
     QStringList result;
+
     // TODO Qt5: Use QMetaEnum::fromType()
     auto featureEnum = Quassel::staticMetaObject.enumerator(Quassel::staticMetaObject.indexOfEnumerator("Feature"));
     for (quint32 i = 0; i < _features.size(); ++i) {