Redesign genversion and make only main.cpp depend on it
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 1 Oct 2008 15:19:19 +0000 (17:19 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 4 Oct 2008 21:53:28 +0000 (23:53 +0200)
Finally removes Global:: and properly fills Quassel::buildInfo() instead.
Also, recompiles of mod_common are no longer needed for every make.

15 files changed:
.gitattributes
CMakeLists.txt
src/CMakeLists.txt
src/client/clientsyncer.cpp
src/common/genversion.cpp
src/common/main.cpp
src/common/quassel.cpp
src/common/quassel.h
src/core/core.cpp
src/core/corecoreinfo.cpp
src/core/ctcphandler.cpp
src/qtui/aboutdlg.cpp
src/qtui/coreinfodlg.cpp
version.dist [deleted file]
version.inc

index 9f8caf5..750dc52 100644 (file)
@@ -1 +1 @@
-version.dist   export-subst
+version.inc    export-subst
index 60da133..be6493c 100644 (file)
@@ -184,7 +184,7 @@ target_link_libraries(genversion ${QT_LIBRARIES} ${QT_CORE_LIB_DEPENDENCIES})
 
 get_target_property(GENVERSION_EXECUTABLE genversion LOCATION)
 add_custom_target(genversion_run ALL ${GENVERSION_EXECUTABLE}
-                  ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/common/version.gen)
+                  ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/src/version.gen)
 add_dependencies(genversion_run genversion)
 
 # Decide what to do with icons
@@ -217,7 +217,3 @@ add_subdirectory(icons)
 #add_subdirectory(pics)
 add_subdirectory(i18n)
 add_subdirectory(src)
-
-# Make sure version.gen exists before building mod_common
-# TODO: make only main.cpp depend on that! Recompiles suck...
-add_dependencies(mod_common genversion_run)
index bf3a92f..33374db 100644 (file)
@@ -15,6 +15,8 @@ if(WANT_QTCLIENT OR WANT_MONO)
   include_directories(qtui)
 endif(WANT_QTCLIENT OR WANT_MONO)
 
+include_directories(${CMAKE_CURRENT_BINARY_DIR}) # for version.gen
+
 # We always add stuff in :/pics
 qt4_add_resources(CLIENT_DEPS ../pics/pics.qrc)
 
@@ -31,6 +33,7 @@ endif(OXYGEN_ICONS MATCHES "Builtin")
 if(WANT_CORE)
   setup_qt4_variables(NETWORK SCRIPT SQL)
   add_executable(quasselcore common/main.cpp ${COMMON_DEPS} ${CORE_DEPS})
+  add_dependencies(quasselcore genversion_run)
   set_target_properties(quasselcore PROPERTIES
                                     COMPILE_FLAGS "-DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_CORE"
                                     OUTPUT_NAME ../quasselcore)
@@ -42,7 +45,7 @@ endif(WANT_CORE)
 if(WANT_QTCLIENT)
   setup_qt4_variables(${LINK_DBUS} GUI NETWORK ${LINK_WEBKIT})
   add_executable(quasselclient WIN32 common/main.cpp ${COMMON_DEPS} ${CLIENT_DEPS})
-  add_dependencies(quasselclient icons)
+  add_dependencies(quasselclient icons genversion_run)
   set_target_properties(quasselclient PROPERTIES
                                       COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DBUILD_QTUI"
                                       OUTPUT_NAME ../quasselclient)
@@ -54,7 +57,7 @@ endif(WANT_QTCLIENT)
 if(WANT_MONO)
   setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL ${LINK_WEBKIT})
   add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS})
-  add_dependencies(quassel icons)
+  add_dependencies(quassel icons genversion_run)
   set_target_properties(quassel PROPERTIES
                                 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO"
                                 OUTPUT_NAME ../quassel)
index e24d830..234a3c9 100644 (file)
@@ -156,10 +156,10 @@ void ClientSyncer::coreSocketConnected() {
   //emit coreConnectionMsg(tr("Synchronizing to core..."));
   QVariantMap clientInit;
   clientInit["MsgType"] = "ClientInit";
-  clientInit["ClientVersion"] = Global::quasselVersion;
+  clientInit["ClientVersion"] = Quassel::buildInfo().fancyVersionString;
   clientInit["ClientBuild"] = 860; // FIXME legacy!
-  clientInit["ClientDate"] = Global::quasselBuildDate;
-  clientInit["ProtocolVersion"] = Global::protocolVersion;
+  clientInit["ClientDate"] = Quassel::buildInfo().buildDate;
+  clientInit["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
   clientInit["UseSsl"] = coreConnectionInfo["useSsl"];
 #ifndef QT_NO_COMPRESS
   clientInit["UseCompression"] = true;
@@ -187,9 +187,9 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) {
   uint ver = 0;
   if(!msg.contains("ProtocolVersion") && msg["CoreBuild"].toUInt() >= 732) ver = 1; // legacy!
   if(msg.contains("ProtocolVersion")) ver = msg["ProtocolVersion"].toUInt();
-  if(ver < Global::clientNeedsProtocol) {
+  if(ver < Quassel::buildInfo().clientNeedsProtocol) {
     emit connectionError(tr("<b>The Quassel Core you are trying to connect to is too old!</b><br>"
-        "Need at least core/client protocol v%1 to connect.").arg(Global::clientNeedsProtocol));
+        "Need at least core/client protocol v%1 to connect.").arg(Quassel::buildInfo().clientNeedsProtocol));
     disconnectFromCore();
     return;
   }
index cf64461..3a552f3 100644 (file)
@@ -20,7 +20,6 @@
 
 /** This is called at compile time and generates a suitable version.gen.
  *  usage: genversion git_root target_file
- * 
  */
 
 #include <QDebug>
@@ -37,56 +36,78 @@ int main(int argc, char **argv) {
   }
   QString gitroot = argv[1];
   QString target = argv[2];
-  QString version, commit, archivetime;
+  QString basever, protover, clientneeds, coreneeds, descrver, dirty;
+  QString committish, commitdate;
 
+  // check Git for information if present
   if(QFile::exists(gitroot + "/.git")) {
     // try to execute git-describe to get a version string
     QProcess git;
     git.setWorkingDirectory(gitroot);
     git.start("git", QStringList() << "describe" << "--long");
     if(git.waitForFinished(10000)) {
-      QString gitversion = git.readAllStandardOutput();
-      if(!gitversion.isEmpty() && !gitversion.contains("fatal")) {
-        // seems we have a valid version string, now prettify it...
-        // check if the workdir is dirty first
-        QString dirty;
-        QStringList params = QStringList() << "diff-index" << "--name-only" << "HEAD";
-        git.start("git", params);
+      QString descr = git.readAllStandardOutput().trimmed();
+      if(!descr.isEmpty() && !descr.contains("fatal")) {
+        // seems we have a valid git describe string
+        descrver = descr;
+        // check if the workdir is dirty
+        git.start("git", QStringList() << "diff-index" << "--name-only" << "HEAD");
         if(git.waitForFinished(10000)) {
           if(!git.readAllStandardOutput().isEmpty()) dirty = "*";
         }
+        // get a full committish
+        git.start("git", QStringList() << "rev-parse" << "HEAD");
+        if(git.waitForFinished(10000)) {
+          committish = git.readAllStandardOutput().trimmed();
+        }
         // Now we do some replacement magic...
-        QRegExp rxCheckTag("(.*)-0-g[0-9a-f]+\n$");
-        QRegExp rxGittify("(.*)-(\\d+)-g([0-9a-f]+)\n$");
-        gitversion.replace(rxCheckTag, QString("\\1%1").arg(dirty));
-        gitversion.replace(rxGittify, QString("\\1:git-\\3+\\2%1").arg(dirty));
-        if(!gitversion.isEmpty()) version = gitversion;
+        //QRegExp rxCheckTag("(.*)-0-g[0-9a-f]+\n$");
+        //QRegExp rxGittify("(.*)-(\\d+)-g([0-9a-f]+)\n$");
+        //gitversion.replace(rxCheckTag, QString("\\1%1").arg(dirty));
+        //gitversion.replace(rxGittify, QString("\\1:git-\\3+\\2%1").arg(dirty));
       }
     }
   }
-  if(version.isEmpty()) {
-    // hmm, Git failed... let's check for version.dist instead
-    QFile dist(gitroot + "/version.dist");
-    if(dist.open(QIODevice::ReadOnly | QIODevice::Text)) {
-      QRegExp rxCommit("(^[0-9a-f]+)");
-      QRegExp rxTimestamp("(^[0-9]+)");
-      if(rxCommit.indexIn(dist.readLine()) > -1) commit = rxCommit.cap(1);
-      if(rxTimestamp.indexIn(dist.readLine()) > -1) archivetime = rxTimestamp.cap(1);
-      dist.close();
+
+  // parse version.inc
+  QFile verfile(gitroot + "/version.inc");
+  if(verfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+    QString ver = verfile.readAll();
+
+    QRegExp rxBasever("baseVersion\\s*=\\s*\"(.*)\";");
+    if(rxBasever.indexIn(ver) >= 0)
+      basever = rxBasever.cap(1);
+
+    QRegExp rxProtover("protocolVersion\\s*=\\s*(\\d+)");
+    if(rxProtover.indexIn(ver) >= 0)
+      protover = rxProtover.cap(1);
+
+    QRegExp rxClientneeds("clientNeedsProtocol\\s*=\\s*(\\d+)");
+    if(rxClientneeds.indexIn(ver) >= 0)
+      clientneeds = rxClientneeds.cap(1);
+
+    QRegExp rxCoreneeds("coreNeedsProtocol\\s*=\\s*(\\d+)");
+    if(rxCoreneeds.indexIn(ver) >= 0)
+      coreneeds = rxCoreneeds.cap(1);
+
+    if(committish.isEmpty()) {
+      QRegExp rxCommit("distCommittish\\s*=\\s*([0-9a-f]+)");
+      if(rxCommit.indexIn(ver) >= 0) committish = rxCommit.cap(1);
     }
+
+    QRegExp rxTimestamp("distCommitDate\\s*=\\s*([0-9]+)");
+    if(rxTimestamp.indexIn(ver) >= 0) commitdate = rxTimestamp.cap(1);
+    verfile.close();
   }
+
   // ok, create our version.gen now
   QFile gen(target);
   if(!gen.open(QIODevice::WriteOnly | QIODevice::Text)) {
     qFatal("%s", qPrintable(QString("Could not write %1!").arg(target)));
-    return 255;
+    return EXIT_FAILURE;
   }
-  gen.write(QString("quasselGeneratedVersion = \"%1\";\n"
-                    "quasselBuildDate = \"%2\";\n"
-                    "quasselBuildTime = \"%3\";\n"
-                    "quasselCommit = \"%4\";\n"
-                    "quasselArchiveDate = %5;\n")
-                    .arg(version).arg(__DATE__).arg(__TIME__).arg(commit).arg(archivetime.toUInt()).toAscii());
+  gen.write(QString("QString buildinfo = \"%1,%2,%3,%4,%5,%6,%7,%8\";")
+           .arg(basever, descrver, dirty, committish, commitdate, protover, clientneeds, coreneeds).toAscii());
   gen.close();
   return EXIT_SUCCESS;
 }
index a179559..57e6a90 100644 (file)
@@ -43,6 +43,10 @@ int main(int argc, char **argv) {
     MonolithicApplication app(argc, argv);
 #  endif
 
+# include "version.gen"
+  buildinfo.append(QString(",%1,%2").arg(__DATE__, __TIME__));
+  app.setupBuildInfo(buildinfo);
+
   if(!app.init()) return EXIT_FAILURE;
   return app.exec();
 }
index 2584a94..88b87c2 100644 (file)
@@ -77,8 +77,6 @@ bool Quassel::init() {
   qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
 
   registerMetaTypes();
-  setupBuildInfo();
-  Global::setupVersion();
   setupTranslations();
 
   QCoreApplication::setApplicationName(buildInfo().applicationName);
@@ -147,30 +145,59 @@ void Quassel::setupTranslations() {
   qApp->installTranslator(quasselTranslator);
 }
 
-void Quassel::setupBuildInfo() {
+void Quassel::setupBuildInfo(const QString &generated) {
   _buildInfo.applicationName = "Quassel IRC";
   _buildInfo.coreApplicationName = "Quassel Core";
   _buildInfo.clientApplicationName = "Quassel Client";
   _buildInfo.organizationName = "Quassel Project";
   _buildInfo.organizationDomain = "quassel-irc.org";
-/*
-#  include "version.inc"
-#  include "version.gen"
-
-  if(quasselGeneratedVersion.isEmpty()) {
-    if(quasselCommit.isEmpty())
-      quasselVersion = QString("v%1 (unknown rev)").arg(quasselBaseVersion);
-    else
-      quasselVersion = QString("v%1 (dist-%2, %3)").arg(quasselBaseVersion).arg(quasselCommit.left(7))
-      .arg(QDateTime::fromTime_t(quasselArchiveDate).toLocalTime().toString("yyyy-MM-dd"));
+
+  QStringList gen = generated.split(',');
+  Q_ASSERT(gen.count() == 10);
+  _buildInfo.baseVersion = gen[0];
+  _buildInfo.generatedVersion = gen[1];
+  _buildInfo.isSourceDirty = !gen[2].isEmpty();
+  _buildInfo.commitHash = gen[3];
+  _buildInfo.commitDate = gen[4].toUInt();
+  _buildInfo.protocolVersion = gen[5].toUInt();
+  _buildInfo.clientNeedsProtocol = gen[6].toUInt();
+  _buildInfo.coreNeedsProtocol = gen[7].toUInt();
+  _buildInfo.buildDate = QString("%1 %2").arg(gen[8], gen[9]);
+  // create a nice version string
+  if(_buildInfo.generatedVersion.isEmpty()) {
+    if(!_buildInfo.commitHash.isEmpty()) {
+      // dist version
+      _buildInfo.plainVersionString = QString("v%1 (dist-%2)")
+                                        .arg(_buildInfo.baseVersion)
+                                        .arg(_buildInfo.commitHash.left(7));
+      _buildInfo.fancyVersionString = QString("v%1 (dist-<a href=\"http://git.quassel-irc.org/%3\">%2</a>)")
+                                        .arg(_buildInfo.baseVersion)
+                                        .arg(_buildInfo.commitHash.left(7))
+                                        .arg(_buildInfo.commitHash);
+    } else {
+    // we only have a base version :(
+      _buildInfo.plainVersionString = QString("v%1 (unknown rev)").arg(_buildInfo.baseVersion);
+    }
   } else {
-    QStringList parts = quasselGeneratedVersion.split(':');
-    quasselVersion = QString("v%1").arg(parts[0]);
-    if(parts.count() >= 2) quasselVersion.append(QString(" (%1)").arg(parts[1]));
+    // analyze what we got from git-describe
+    QRegExp rx("(.*)-(\\d+)-g([0-9a-f]+)$");
+    if(rx.exactMatch(_buildInfo.generatedVersion)) {
+      QString distance = rx.cap(2) == "0" ? QString() : QString(" [+%1]").arg(rx.cap(2));
+      _buildInfo.plainVersionString = QString("v%1%2 (git-%3%4)")
+                                        .arg(rx.cap(1), distance, rx.cap(3))
+                                        .arg(_buildInfo.isSourceDirty ? "*" : "");
+      if(!_buildInfo.commitHash.isEmpty()) {
+        _buildInfo.fancyVersionString = QString("v%1%2 (git-<a href=\"http://git.quassel-irc.org/%5\">%3</a>%4)")
+                                          .arg(rx.cap(1), distance, rx.cap(3))
+                                          .arg(_buildInfo.isSourceDirty ? "*" : "")
+                                          .arg(_buildInfo.commitHash);
+      }
+    } else {
+      _buildInfo.plainVersionString = QString("v%1 (invalid rev)").arg(_buildInfo.baseVersion);
+    }
   }
-  quasselBuildDate = __DATE__;
-  quasselBuildTime = __TIME__;
-  */
+  if(_buildInfo.fancyVersionString.isEmpty())
+    _buildInfo.fancyVersionString = _buildInfo.plainVersionString;
 }
 
 //! Signal handler for graceful shutdown.
@@ -257,36 +284,3 @@ void Quassel::handleCrash() {
   exit(27);
 #endif /* BUILD_CRASHHANDLER */
 }
-
-// FIXME temporary
-
-void Global::setupVersion() {
-
-  #  include "version.inc"
-  #  include "version.gen"
-
-  if(quasselGeneratedVersion.isEmpty()) {
-    if(quasselCommit.isEmpty())
-      quasselVersion = QString("v%1 (unknown rev)").arg(quasselBaseVersion);
-    else
-      quasselVersion = QString("v%1 (dist-%2, %3)").arg(quasselBaseVersion).arg(quasselCommit.left(7))
-      .arg(QDateTime::fromTime_t(quasselArchiveDate).toLocalTime().toString("yyyy-MM-dd"));
-  } else {
-    QStringList parts = quasselGeneratedVersion.split(':');
-    quasselVersion = QString("v%1").arg(parts[0]);
-    if(parts.count() >= 2) quasselVersion.append(QString(" (%1)").arg(parts[1]));
-  }
-  quasselBuildDate = __DATE__;
-  quasselBuildTime = __TIME__;
-}
-
-QString Global::quasselVersion;
-QString Global::quasselBaseVersion;
-QString Global::quasselGeneratedVersion;
-QString Global::quasselBuildDate;
-QString Global::quasselBuildTime;
-QString Global::quasselCommit;
-uint Global::quasselArchiveDate;
-uint Global::protocolVersion;
-uint Global::clientNeedsProtocol;
-uint Global::coreNeedsProtocol;
index 40e2e12..bed6eac 100644 (file)
@@ -37,13 +37,15 @@ class Quassel {
     };
 
     struct BuildInfo {
-      QString version;
+      QString fancyVersionString; // clickable rev
+      QString plainVersionString; // no <a> tag
+
       QString baseVersion;
       QString generatedVersion;
-      QString buildDate;
-      QString buildTime;
       QString commitHash;
-      uint archiveDate;
+      uint commitDate;
+      QString buildDate;
+      bool isSourceDirty;
       uint protocolVersion;
       uint clientNeedsProtocol;
       uint coreNeedsProtocol;
@@ -55,6 +57,8 @@ class Quassel {
       QString organizationDomain;
     };
 
+    void setupBuildInfo(const QString &generated);
+
     virtual ~Quassel();
 
     static inline const BuildInfo & buildInfo();
@@ -74,7 +78,6 @@ class Quassel {
 
 
   private:
-    void setupBuildInfo();
     void setupTranslations();
     void registerMetaTypes();
 
@@ -87,24 +90,6 @@ class Quassel {
     static bool _initialized;
 };
 
-// FIXME temporary
-namespace Global {
-  extern QString quasselVersion;
-  extern QString quasselBaseVersion;
-  extern QString quasselBuildDate;
-  extern QString quasselBuildTime;
-  extern QString quasselCommit;
-  extern uint quasselArchiveDate;
-  extern uint protocolVersion;
-
-  extern uint clientNeedsProtocol;  //< Minimum protocol version the client needs
-  extern uint coreNeedsProtocol;    //< Minimum protocol version the core needs
-
-  extern QString quasselGeneratedVersion;  //< This is possibly set in version.gen
-
-  void setupVersion();
-};
-
 const Quassel::BuildInfo & Quassel::buildInfo() { return _buildInfo; }
 Quassel::RunMode Quassel::runMode() { return _runMode; }
 void Quassel::setRunMode(Quassel::RunMode mode) { _runMode = mode; }
index 4d555cf..7a27432 100644 (file)
@@ -347,11 +347,13 @@ bool Core::startListening() {
   uint port = Quassel::optionValue("port").toUInt();
 
   if(_server.listen(QHostAddress::Any, port)) {
-    quInfo() << "Listening for GUI clients on IPv6 port" << _server.serverPort() << "using protocol version" << Global::protocolVersion;
+    quInfo() << "Listening for GUI clients on IPv6 port" << _server.serverPort()
+             << "using protocol version" << Quassel::buildInfo().protocolVersion;
     success = true;
   }
   if(_v6server.listen(QHostAddress::AnyIPv6, port)) {
-    quInfo() << "Listening for GUI clients on IPv4 port" << _v6server.serverPort() << "using protocol version" << Global::protocolVersion;
+    quInfo() << "Listening for GUI clients on IPv4 port" << _v6server.serverPort()
+             << "using protocol version" << Quassel::buildInfo().protocolVersion;
     success = true;
   }
 
@@ -415,20 +417,20 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
     uint ver = 0;
     if(!msg.contains("ProtocolVersion") && msg["ClientBuild"].toUInt() >= 732) ver = 1; // FIXME legacy
     if(msg.contains("ProtocolVersion")) ver = msg["ProtocolVersion"].toUInt();
-    if(ver < Global::coreNeedsProtocol) {
+    if(ver < Quassel::buildInfo().coreNeedsProtocol) {
       reply["MsgType"] = "ClientInitReject";
       reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
       "This core needs at least client/core protocol version %1.<br>"
-      "Please consider upgrading your client.").arg(Global::coreNeedsProtocol);
+      "Please consider upgrading your client.").arg(Quassel::buildInfo().coreNeedsProtocol);
       SignalProxy::writeDataToDevice(socket, reply);
       quWarning() << qPrintable(tr("Client")) << qPrintable(socket->peerAddress().toString()) << qPrintable(tr("too old, rejecting."));
       socket->close(); return;
     }
 
-    reply["CoreVersion"] = Global::quasselVersion;
-    reply["CoreDate"] = Global::quasselBuildDate;
+    reply["CoreVersion"] = Quassel::buildInfo().fancyVersionString;
+    reply["CoreDate"] = Quassel::buildInfo().buildDate;
     reply["CoreBuild"] = 860; // FIXME legacy
-    reply["ProtocolVersion"] = Global::protocolVersion;
+    reply["ProtocolVersion"] = Quassel::buildInfo().protocolVersion;
     // TODO: Make the core info configurable
     int uptime = startTime().secsTo(QDateTime::currentDateTime().toUTC());
     int updays = uptime / 86400; uptime %= 86400;
@@ -436,7 +438,8 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) {
     int upmins = uptime / 60;
     reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
                           "Built: %2<br>"
-                          "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate)
+                          "Up %3d%4h%5m (since %6)").arg(Quassel::buildInfo().fancyVersionString)
+                                                     .arg(Quassel::buildInfo().buildDate)
       .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate));
 
 #ifdef HAVE_SSL
index d1b3e15..da0234a 100644 (file)
@@ -33,8 +33,8 @@ CoreCoreInfo::CoreCoreInfo(CoreSession *parent)
 
 QVariantMap CoreCoreInfo::coreData() const {
   QVariantMap data;
-  data["quasselVersion"] = Global::quasselVersion;
-  data["quasselBuildDate"] = Global::quasselBuildDate;
+  data["quasselVersion"] = Quassel::buildInfo().fancyVersionString;
+  data["quasselBuildDate"] = Quassel::buildInfo().buildDate;
   data["startTime"] = Core::instance()->startTime();
   data["sessionConnectedClients"] = _coreSession->signalProxy()->peerCount();
   return data;
index a944c02..420693a 100644 (file)
@@ -176,7 +176,8 @@ void CtcpHandler::handleVersion(CtcpType ctcptype, const QString &prefix, const
   Q_UNUSED(target)
   if(ctcptype == CtcpQuery) {
     reply(nickFromMask(prefix), "VERSION", QString("Quassel IRC %1 (built on %2) -- http://www.quassel-irc.org")
-        .arg(Global::quasselVersion).arg(Global::quasselBuildDate));
+        .arg(Quassel::buildInfo().plainVersionString)
+        .arg(Quassel::buildInfo().buildDate));
     emit displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Received CTCP VERSION request by %1").arg(prefix));
   } else {
     // display Version answer
index de4e72f..c0e4d75 100644 (file)
@@ -18,6 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
+#include <QDateTime>
+
 #include "aboutdlg.h"
 #include "icon.h"
 #include "iconloader.h"
@@ -27,9 +29,10 @@ AboutDlg::AboutDlg(QWidget *parent) : QDialog(parent) {
   ui.setupUi(this);
   ui.quasselLogo->setPixmap(DesktopIcon("quassel", IconLoader::SizeHuge));
 
-  ui.versionLabel->setText(QString(tr("<b>Version %1</b><br>Protocol version: %2<br>Built: %3 %4")).arg(Global::quasselVersion)
-                          .arg(Global::protocolVersion)
-                          .arg(Global::quasselBuildDate).arg(Global::quasselBuildTime));
+  ui.versionLabel->setText(QString(tr("<b>Version:</b> %1<br><b>Protocol version:</b> %2<br><b>Built:</b> %3"))
+                           .arg(Quassel::buildInfo().fancyVersionString)
+                          .arg(Quassel::buildInfo().protocolVersion)
+                          .arg(Quassel::buildInfo().buildDate));
   ui.aboutTextBrowser->setHtml(about());
   ui.authorTextBrowser->setHtml(authors());
   ui.contributorTextBrowser->setHtml(contributors());
index 6c5d6fa..f55b80a 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "coreinfodlg.h"
 
+#include <QDateTime>
+
 #include "client.h"
 #include "signalproxy.h"
 
@@ -34,7 +36,7 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent)
 
 void CoreInfoDlg::coreInfoAvailable() {
   ui.labelCoreVersion->setText(_coreInfo["quasselVersion"].toString());
-  ui.labelCoreBuildDate->setText(_coreInfo["quasselBuildDate"].toString());
+  ui.labelCoreBuildDate->setText(QDateTime::fromTime_t(_coreInfo["quasselBuildDate"].toUInt()).toLocalTime().toString());
   ui.labelClientCount->setNum(_coreInfo["sessionConnectedClients"].toInt());
   updateUptime();
   startTimer(1000);
@@ -42,7 +44,7 @@ void CoreInfoDlg::coreInfoAvailable() {
 
 void CoreInfoDlg::updateUptime() {
   QDateTime startTime = _coreInfo["startTime"].toDateTime();
-  
+
   int uptime = startTime.secsTo(QDateTime::currentDateTime().toUTC());
   int updays = uptime / 86400; uptime %= 86400;
   int uphours = uptime / 3600; uptime %= 3600;
diff --git a/version.dist b/version.dist
deleted file mode 100644 (file)
index 9d5da4a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-$Format:%H$
-$Format:%at$
index 0de69bd..a1c145c 100644 (file)
@@ -1,9 +1,9 @@
-// Versioning, should be kept current :)
-// This is included in main.cpp
-
 //! This is the fallback version number in case we can't autogenerate one
-quasselBaseVersion = "0.3.0";
-protocolVersion = 5;       //< Version of the client/core protocol
+baseVersion = "0.3.0";
 
+protocolVersion = 5;       //< Version of the client/core protocol
 coreNeedsProtocol   = 5;   //< Minimum protocol version the core needs
 clientNeedsProtocol = 5;   //< Minimum protocol version the client needs
+
+distCommittish = $Format:%H$
+distCommitDate = $Format:%at$