diff --git a/.travis.yml b/.travis.yml index 9d843c584..4b0278d19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ +git: + depth: 2000 + language: cpp matrix: diff --git a/appveyor.yml b/appveyor.yml index b0b602cd1..42d2f0a58 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -58,7 +58,7 @@ clone_folder: C:\projects\RetroShare #shallow_clone: true # default is "false" # set clone depth -clone_depth: 1 # clone entire repository history if not defined +clone_depth: 2000 # clone entire repository history if not defined environment: global: diff --git a/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl b/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl index 9a9c8eada..d5ca5c828 100644 --- a/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl +++ b/jsonapi-generator/src/async-method-wrapper-template.cpp.tmpl @@ -31,19 +31,7 @@ registerHandler("$%apiPath%$", const std::shared_ptr session, const rb::Bytes& body ) { - RsGenericSerializer::SerializeContext cReq( - nullptr, 0, - RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); - RsJson& jReq(cReq.mJson); - jReq.Parse(reinterpret_cast(body.data()), body.size()); - - RsGenericSerializer::SerializeContext cAns; - RsJson& jAns(cAns.mJson); - - // if caller specified caller_data put it back in the answhere - const char kcd[] = "caller_data"; - if(jReq.HasMember(kcd)) - jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()); + INITIALIZE_API_CALL_JSON_CONTEXT; if( !checkRsServicePtrReady( $%instanceName%$, "$%instanceName%$", cAns, session ) ) diff --git a/jsonapi-generator/src/method-wrapper-template.cpp.tmpl b/jsonapi-generator/src/method-wrapper-template.cpp.tmpl index 4e1e76133..4125e1b69 100644 --- a/jsonapi-generator/src/method-wrapper-template.cpp.tmpl +++ b/jsonapi-generator/src/method-wrapper-template.cpp.tmpl @@ -24,19 +24,7 @@ registerHandler("$%apiPath%$", const std::shared_ptr session, const rb::Bytes& body ) { - RsGenericSerializer::SerializeContext cReq( - nullptr, 0, - RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); - RsJson& jReq(cReq.mJson); - jReq.Parse(reinterpret_cast(body.data()), body.size()); - - RsGenericSerializer::SerializeContext cAns; - RsJson& jAns(cAns.mJson); - - // if caller specified caller_data put it back in the answhere - const char kcd[] = "caller_data"; - if(jReq.HasMember(kcd)) - jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()); + INITIALIZE_API_CALL_JSON_CONTEXT; if( !checkRsServicePtrReady( $%instanceName%$, "$%instanceName%$", cAns, session ) ) @@ -54,15 +42,7 @@ $%functionCall%$ $%outputParamsSerialization%$ // return them to the API caller - std::stringstream ss; - ss << jAns; - std::string&& ans(ss.str()); - const std::multimap headers - { - { "Content-Type", "text/json" }, - { "Content-Length", std::to_string(ans.length()) } - }; - session->close(rb::OK, ans, headers); + DEFAULT_API_CALL_JSON_RETURN(rb::OK); } ); }); diff --git a/libretroshare/src/jsonapi/jsonapi.cpp b/libretroshare/src/jsonapi/jsonapi.cpp index b8e982312..e8d8f9345 100644 --- a/libretroshare/src/jsonapi/jsonapi.cpp +++ b/libretroshare/src/jsonapi/jsonapi.cpp @@ -26,10 +26,38 @@ #include "util/rsjson.h" #include "retroshare/rsfiles.h" #include "util/radix64.h" +#include "retroshare/rsversion.h" // Generated at compile time #include "jsonapi-includes.inl" +#define INITIALIZE_API_CALL_JSON_CONTEXT \ + RsGenericSerializer::SerializeContext cReq( \ + nullptr, 0, \ + RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); \ + RsJson& jReq(cReq.mJson); \ + jReq.Parse(reinterpret_cast(body.data()), body.size()); \ +\ + RsGenericSerializer::SerializeContext cAns; \ + RsJson& jAns(cAns.mJson); \ +\ + /* if caller specified caller_data put it back in the answhere */ \ + const char kcd[] = "caller_data"; \ + if(jReq.HasMember(kcd)) \ + jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()) + +#define DEFAULT_API_CALL_JSON_RETURN(RET_CODE) \ + std::stringstream ss; \ + ss << jAns; \ + std::string&& ans(ss.str()); \ + const std::multimap headers \ + { \ + { "Content-Type", "text/json" }, \ + { "Content-Length", std::to_string(ans.length()) } \ + }; \ + session->close(RET_CODE, ans, headers) + + static bool checkRsServicePtrReady( void* serviceInstance, const std::string& serviceName, RsGenericSerializer::SerializeContext& ctx, @@ -45,18 +73,12 @@ static bool checkRsServicePtrReady( RsGenericSerializer::SerializeJob j(RsGenericSerializer::TO_JSON); RS_SERIAL_PROCESS(jsonApiError); - std::stringstream ss; - ss << ctx.mJson; - std::string&& ans(ss.str()); - const std::multimap headers - { - { "Content-Type", "text/json" }, - { "Content-Length", std::to_string(ans.length()) } - }; - session->close(rb::CONFLICT, ans, headers); + RsJson& jAns(ctx.mJson); + DEFAULT_API_CALL_JSON_RETURN(rb::CONFLICT); return false; } + JsonApiServer::JsonApiServer( uint16_t port, const std::string& bindAddress, const std::function shutdownCallback ) : @@ -69,6 +91,32 @@ JsonApiServer::JsonApiServer( shutdown(); }); + registerHandler("/jsonApiServer/version", + [](const std::shared_ptr session) + { + size_t reqSize = session->get_request()->get_header("Content-Length", 0); + session->fetch( reqSize, []( + const std::shared_ptr session, + const rb::Bytes& body ) + { + INITIALIZE_API_CALL_JSON_CONTEXT; + + uint32_t major = RS_MAJOR_VERSION; + uint32_t minor = RS_MINOR_VERSION; + uint32_t mini = RS_MINI_VERSION; + std::string human = RS_HUMAN_READABLE_VERSION; + + RsGenericSerializer::SerializeContext& ctx(cAns); + RsGenericSerializer::SerializeJob j(RsGenericSerializer::TO_JSON); + RS_SERIAL_PROCESS(major); + RS_SERIAL_PROCESS(minor); + RS_SERIAL_PROCESS(mini); + RS_SERIAL_PROCESS(human); + + DEFAULT_API_CALL_JSON_RETURN(rb::OK); + } ); + }); + registerHandler("/rsFiles/getFileData", [](const std::shared_ptr session) { @@ -77,19 +125,7 @@ JsonApiServer::JsonApiServer( const std::shared_ptr session, const rb::Bytes& body ) { - RsGenericSerializer::SerializeContext cReq( - nullptr, 0, - RsGenericSerializer::SERIALIZATION_FLAG_YIELDING ); - RsJson& jReq(cReq.mJson); - jReq.Parse(reinterpret_cast(body.data()), body.size()); - - RsGenericSerializer::SerializeContext cAns; - RsJson& jAns(cAns.mJson); - - // if caller specified caller_data put it back in the answhere - const char kcd[] = "caller_data"; - if(jReq.HasMember(kcd)) - jAns.AddMember(kcd, jReq[kcd], jAns.GetAllocator()); + INITIALIZE_API_CALL_JSON_CONTEXT; if(!checkRsServicePtrReady(rsFiles, "rsFiles", cAns, session)) return; @@ -133,16 +169,7 @@ JsonApiServer::JsonApiServer( if(!errorMessage.empty()) RS_SERIAL_PROCESS(errorMessage); } - // return them to the API caller - std::stringstream ss; - ss << jAns; - std::string&& ans(ss.str()); - const std::multimap headers - { - { "Content-Type", "text/json" }, - { "Content-Length", std::to_string(ans.length()) } - }; - session->close(rb::OK, ans, headers); + DEFAULT_API_CALL_JSON_RETURN(rb::OK); } ); }); diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 68bf97161..6a308488a 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -515,7 +515,6 @@ HEADERS += util/folderiterator.h \ util/rsstring.h \ util/rsstd.h \ util/rsthreads.h \ - util/rsversioninfo.h \ util/rswin.h \ util/rsrandom.h \ util/rsmemcache.h \ @@ -666,7 +665,6 @@ SOURCES += util/folderiterator.cc \ util/rsprint.cc \ util/rsstring.cc \ util/rsthreads.cc \ - util/rsversioninfo.cc \ util/rsrandom.cc \ util/rstickevent.cc \ util/rsrecogn.cc \ diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index ea3a72932..ad03bc31c 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include #include @@ -351,7 +351,6 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name,bool first_time) std::cerr << " -> plugin revision number: " << pinfo.svn_revision << std::endl; std::cerr << " plugin API number : " << std::hex << pinfo.API_version << std::dec << std::endl; - std::cerr << " retroshare svn number: " << RsUtil::retroshareRevision() << std::endl; // Check that the plugin provides a svn revision number and a API number // diff --git a/libretroshare/src/retroshare/rsinit.h b/libretroshare/src/retroshare/rsinit.h index 68e70fe65..731b111cc 100644 --- a/libretroshare/src/retroshare/rsinit.h +++ b/libretroshare/src/retroshare/rsinit.h @@ -284,12 +284,6 @@ struct RsLoginHelper * @return true if already logged in, false otherwise */ bool isLoggedIn(); - - /** - * @brief Close RetroShare session - * @jsonapi{development} - */ - void closeSession(); }; #endif diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index 557f9a61d..af553b785 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -205,7 +205,7 @@ class RsPlugin // // All these items appear in the config->plugins tab, as a description of the plugin. // - uint32_t getSvnRevision() const { return RS_REVISION_NUMBER ; } // This is read from libretroshare/retroshare/rsversion.h + uint32_t getSvnRevision() const { return 0; } // This is read from libretroshare/retroshare/rsversion.h virtual std::string getShortPluginDescription() const = 0 ; virtual std::string getPluginName() const = 0 ; diff --git a/libretroshare/src/retroshare/rsservicecontrol.h b/libretroshare/src/retroshare/rsservicecontrol.h index 57511be4c..726b3efb4 100644 --- a/libretroshare/src/retroshare/rsservicecontrol.h +++ b/libretroshare/src/retroshare/rsservicecontrol.h @@ -141,7 +141,7 @@ public: /** * @brief getServiceName lookup the name of a service. * @jsonapi{development} - * @param[in] service_id service to look up + * @param[in] serviceId service to look up * @return name of service */ virtual std::string getServiceName(uint32_t serviceId) = 0; @@ -149,7 +149,7 @@ public: /** * @brief getServiceItemNames return a map of service item names. * @jsonapi{development} - * @param[in] service_id service to look up + * @param[in] serviceId service to look up * @param[out] names names of items * @return true on success false otherwise */ diff --git a/libretroshare/src/retroshare/rsversion.h b/libretroshare/src/retroshare/rsversion.h index 110d622fa..1e1356233 100644 --- a/libretroshare/src/retroshare/rsversion.h +++ b/libretroshare/src/retroshare/rsversion.h @@ -19,14 +19,63 @@ * along with this program. If not, see . * * * *******************************************************************************/ -#define RS_MAJOR_VERSION 0 -#define RS_MINOR_VERSION 6 -#define RS_BUILD_NUMBER 4 -#define RS_BUILD_NUMBER_ADD "" // <-- do we need this? -// The revision number should be the 4 first bytes of the git revision hash, which is obtained using: -// git log --pretty="%H" | head -1 | cut -c1-8 -// -// Do not forget the 0x, since the RS_REVISION_NUMBER should be an integer. -// -#define RS_REVISION_STRING "01234567" -#define RS_REVISION_NUMBER 0x01234567 +#pragma once + + +/** + * @def RS_MINI_VERSION + * First number of RetroShare versioning scheme + * Customize it trough qmake command line @see retroshare.pri + */ +#ifndef RS_MAJOR_VERSION +# define RS_MAJOR_VERSION 0 +#endif + +/** + * @def RS_MINI_VERSION + * Second number of RetroShare versioning scheme + * Customize it trough qmake command line @see retroshare.pri + */ +#ifndef RS_MINOR_VERSION +# define RS_MINOR_VERSION 0 +#endif + +/** + * @def RS_MINI_VERSION + * Third number of RetroShare versioning scheme + * Customize it trough qmake command line @see retroshare.pri + */ +#ifndef RS_MINI_VERSION +# define RS_MINI_VERSION 0 +#endif + +/** + * @def RS_EXTRA_VERSION + * An extra string to append to the version to make it more descriptive. + * Customize it trough qmake command line @see retroshare.pri + */ +#ifndef RS_EXTRA_VERSION +# define RS_EXTRA_VERSION "unknown" +#endif + + +/** + * Use this macro to check in your code if version of RetroShare is at least the + * specified. + */ +#define RS_VERSION_AT_LEAST(A,B,C) (RS_MAJOR_VERSION > (A) || \ + (RS_MAJOR_VERSION == (A) && \ + (RS_MINOR_VERSION > (B) || \ + (RS_MINOR_VERSION == (B) && RS_MINI_VERSION >= (C))))) + + +#define __RS_PRIVATE_STRINGIFY2(X) #X +#define __RS_PRIVATE_STRINGIFY(X) __RS_PRIVATE_STRINGIFY2(X) + +/** + * Human readable string describing RetroShare version + */ +constexpr auto RS_HUMAN_READABLE_VERSION = + __RS_PRIVATE_STRINGIFY(RS_MAJOR_VERSION) "." \ + __RS_PRIVATE_STRINGIFY(RS_MINOR_VERSION) "." \ + __RS_PRIVATE_STRINGIFY(RS_MINI_VERSION) RS_EXTRA_VERSION; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index d02199b3d..e334895cd 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -2014,11 +2014,6 @@ bool RsLoginHelper::isLoggedIn() return RsControl::instance()->isReady(); } -void RsLoginHelper::closeSession() -{ - RsControl::instance()->rsGlobalShutDown(); -} - void RsLoginHelper::Location::serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index 9a5b82fd3..7b07312ce 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -22,7 +22,7 @@ *******************************************************************************/ #include "services/p3discovery2.h" #include "pqi/p3peermgr.h" -#include "util/rsversioninfo.h" +#include "retroshare/rsversion.h" #include "retroshare/rsiface.h" #include "rsserver/p3face.h" @@ -349,7 +349,7 @@ void p3discovery2::sendOwnContactInfo(const SSLID &sslid) * revert an hardcoded policy. */ //populateContactInfo(detail, pkt, true); - pkt->version = RsUtil::retroshareVersion(); + pkt->version = RS_HUMAN_READABLE_VERSION; pkt->PeerId(sslid); #ifdef P3DISC_DEBUG @@ -408,7 +408,7 @@ void p3discovery2::recvOwnContactInfo(const SSLID &fromId, const RsDiscContactIt sendPGPList(fromId); // Update mDiscStatus. - RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + RS_STACK_MUTEX(mDiscMtx); PGPID pgpId = getPGPId(fromId); std::map::iterator it = mFriendList.find(pgpId); diff --git a/libretroshare/src/util/rsversioninfo.cc b/libretroshare/src/util/rsversioninfo.cc deleted file mode 100644 index 6e48d3939..000000000 --- a/libretroshare/src/util/rsversioninfo.cc +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * libretroshare/src/util: rsversioninfo.cc * - * * - * libretroshare: retroshare core library * - * * - * Copyright 2013-2013 by Alexandrut * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * 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 Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ -#include "rsversioninfo.h" -#include "retroshare/rsversion.h" -#include "rsstring.h" - -std::string RsUtil::retroshareVersion() -{ - std::string version; - rs_sprintf(version, "%d.%d.%d%s Revision %08x", RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_NUMBER); - - return version; -} - -uint32_t RsUtil::retroshareRevision() -{ - return RS_REVISION_NUMBER; -} diff --git a/libretroshare/src/util/rsversioninfo.h b/libretroshare/src/util/rsversioninfo.h deleted file mode 100644 index 041839b21..000000000 --- a/libretroshare/src/util/rsversioninfo.h +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * libretroshare/src/util: rsversioninfo.h * - * * - * libretroshare: retroshare core library * - * * - * Copyright 2013-2013 by Alexandrut * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License as * - * published by the Free Software Foundation, either version 3 of the * - * License, or (at your option) any later version. * - * * - * 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 Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public License * - * along with this program. If not, see . * - * * - *******************************************************************************/ -#include -#include - -namespace RsUtil { - - uint32_t retroshareRevision(); - std::string retroshareVersion(); - -} diff --git a/plugins/FeedReader/FeedReaderPlugin.cpp b/plugins/FeedReader/FeedReaderPlugin.cpp index cc45fb5dc..ff69ce40b 100644 --- a/plugins/FeedReader/FeedReaderPlugin.cpp +++ b/plugins/FeedReader/FeedReaderPlugin.cpp @@ -56,7 +56,7 @@ extern "C" { #ifdef WIN32 __declspec(dllexport) #endif - uint32_t RETROSHARE_PLUGIN_revision = RS_REVISION_NUMBER ; + uint32_t RETROSHARE_PLUGIN_revision = 0; // This symbol contains the svn revision number grabbed from the executable. // It will be tested by RS to load the plugin automatically, since it is safe to load plugins @@ -72,8 +72,8 @@ void FeedReaderPlugin::getPluginVersion(int& major, int& minor, int &build, int& { major = RS_MAJOR_VERSION; minor = RS_MINOR_VERSION; - build = RS_BUILD_NUMBER; - svn_rev = RS_REVISION_NUMBER; + build = RS_MINI_VERSION; + svn_rev = 0; } FeedReaderPlugin::FeedReaderPlugin() diff --git a/plugins/VOIP/VOIPPlugin.cpp b/plugins/VOIP/VOIPPlugin.cpp index 96be0d3ac..eacb1460c 100644 --- a/plugins/VOIP/VOIPPlugin.cpp +++ b/plugins/VOIP/VOIPPlugin.cpp @@ -61,7 +61,7 @@ extern "C" { // It will be tested by RS to load the plugin automatically, since it is safe to load plugins // with same revision numbers, assuming that the revision numbers are up-to-date. // - uint32_t RETROSHARE_PLUGIN_revision = RS_REVISION_NUMBER ; + uint32_t RETROSHARE_PLUGIN_revision = 0; // This symbol contains the svn revision number grabbed from the executable. // It will be tested by RS to load the plugin automatically, since it is safe to load plugins @@ -74,8 +74,8 @@ void VOIPPlugin::getPluginVersion(int& major, int& minor, int& build, int& svn_r { major = RS_MAJOR_VERSION ; minor = RS_MINOR_VERSION ; - build = RS_BUILD_NUMBER ; - svn_rev = RS_REVISION_NUMBER ; + build = RS_MINI_VERSION ; + svn_rev = 0; } VOIPPlugin::VOIPPlugin() diff --git a/retroshare-gui/src/gui/images/retroshare_win.rc b/retroshare-gui/src/gui/images/retroshare_win.rc index 76840ad79..97e58f4d3 100644 --- a/retroshare-gui/src/gui/images/retroshare_win.rc +++ b/retroshare-gui/src/gui/images/retroshare_win.rc @@ -5,11 +5,11 @@ IDI_ICON1 ICON "logo/logo_64.ico" #define STRINGIZER(version) #version -#define VERSION_STRING(major,minor,build,buildadd,revision) STRINGIZER(major) "." STRINGIZER(minor) "." STRINGIZER(build) buildadd "." revision +#define VERSION_STRING(major,minor,mini,extra) STRINGIZER(major) "." STRINGIZER(minor) "." STRINGIZER(mini) STRINGIZER(extra) VS_VERSION_INFO VERSIONINFO -FILEVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_BUILD_NUMBER,0 -PRODUCTVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_BUILD_NUMBER,0 +FILEVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_MINI_VERSION,0 +PRODUCTVERSION RS_MAJOR_VERSION,RS_MINOR_VERSION,RS_MINI_VERSION,0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 @@ -22,11 +22,11 @@ BEGIN BEGIN VALUE "CompanyName", "" VALUE "FileDescription", "RetroShare" - VALUE "FileVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_STRING) + VALUE "FileVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_MINI_VERSION, RS_EXTRA_VERSION) VALUE "InternalName", "RetroShare" VALUE "OriginalFilename", "RetroShare.exe" VALUE "ProductName", "RetroShare" - VALUE "ProductVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_STRING) + VALUE "ProductVersion", VERSION_STRING(RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_MINI_VERSION, RS_EXTRA_VERSION) VALUE "LegalCopyright", "" END END diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index f1b08396a..7939d7611 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -356,15 +356,7 @@ void Rshare::slotConnectionEstablished() } } -QString Rshare::retroshareVersion(bool withRevision) -{ - QString version = QString("%1.%2.%3%4").arg(RS_MAJOR_VERSION).arg(RS_MINOR_VERSION).arg(RS_BUILD_NUMBER).arg(RS_BUILD_NUMBER_ADD); - if (withRevision) { - version += QString(" %1 %2").arg(tr("Revision")).arg(RS_REVISION_NUMBER,8,16,QChar('0')); - } - - return version; -} +QString Rshare::retroshareVersion(bool) { return RS_HUMAN_READABLE_VERSION; } /** Enters the main event loop and waits until exit() is called. The signal * running() will be emitted when the event loop has started. */ diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h index 2d154a361..c7810e431 100644 --- a/retroshare-gui/src/rshare.h +++ b/retroshare-gui/src/rshare.h @@ -61,7 +61,7 @@ public: ~Rshare(); /** Return the version info */ - static QString retroshareVersion(bool withRevision); + static QString retroshareVersion(bool=true); /** Return the map of command-line arguments and values. */ static QMap arguments() { return _args; } diff --git a/retroshare.pri b/retroshare.pri index f622bed80..7393d27bd 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -144,6 +144,23 @@ CONFIG+=no_rs_deep_search CONFIG *= rs_deep_search no_rs_deep_search:CONFIG -= rs_deep_search +# Specify RetroShare major version appending the following assignation to qmake +# command line 'RS_MAJOR_VERSION=0' +#RS_MAJOR_VERSION=0 + +# Specify RetroShare major version appending the following assignation to qmake +# command line 'RS_MINOR_VERSION=6' +#RS_MINOR_VERSION=6 + +# Specify RetroShare major version appending the following assignation to qmake +# command line 'RS_MINI_VERSION=4' +#RS_MINI_VERSION=4 + +# Specify RetroShare major version appending the following assignation to qmake +# command line 'RS_EXTRA_VERSION=""' +#RS_EXTRA_VERSION=git + + ########################################################################################################################################################### # # V07_NON_BACKWARD_COMPATIBLE_CHANGE_001: @@ -259,7 +276,6 @@ defineReplace(linkDynamicLibs) { return($$retDlib) } - ################################################################################ ## Statements and variables that depends on build options (CONFIG) goes here ### ################################################################################ @@ -283,6 +299,42 @@ defineReplace(linkDynamicLibs) { ## RS_THREAD_LIB String viariable containing the name of the multi threading ## library to use (pthread, "") it usually depend on platform. +defined(RS_MAJOR_VERSION,var):\ +defined(RS_MINOR_VERSION,var):\ +defined(RS_MINI_VERSION,var):\ +defined(RS_EXTRA_VERSION,var) { + message("RetroShare version $${RS_MAJOR_VERSION}.$${RS_MINOR_VERSION}.$${RS_MINI_VERSION}$${RS_EXTRA_VERSION} defined in command line") + DEFINES += RS_MAJOR_VERSION=$${RS_MAJOR_VERSION} + DEFINES += RS_MINOR_VERSION=$${RS_MINOR_VERSION} + DEFINES += RS_MINI_VERSION=$${RS_MINI_VERSION} + DEFINES += RS_EXTRA_VERSION=\\\"$${RS_EXTRA_VERSION}\\\" +} else { + RS_GIT_DESCRIBE = $$system(git describe) + isEmpty(RS_GIT_DESCRIBE) { + warning("Determining RetroShare version via git failed plese specify it trough qmake command line arguments!") + } else { + RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE,v) + RS_GIT_DESCRIBE_SPLIT = $$take_first(RS_GIT_DESCRIBE_SPLIT) + RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE_SPLIT,.) + + RS_MAJOR_VERSION = $$take_first(RS_GIT_DESCRIBE_SPLIT) + RS_MINOR_VERSION = $$take_first(RS_GIT_DESCRIBE_SPLIT) + + RS_GIT_DESCRIBE_SPLIT = $$take_first(RS_GIT_DESCRIBE_SPLIT) + RS_GIT_DESCRIBE_SPLIT = $$split(RS_GIT_DESCRIBE_SPLIT,-) + + RS_MINI_VERSION = $$take_first(RS_GIT_DESCRIBE_SPLIT) + RS_EXTRA_VERSION = $$join(RS_GIT_DESCRIBE_SPLIT,-,-) + + message("RetroShare version $${RS_MAJOR_VERSION}.$${RS_MINOR_VERSION}.$${RS_MINI_VERSION}$${RS_EXTRA_VERSION} determined via git") + + DEFINES += RS_MAJOR_VERSION=$${RS_MAJOR_VERSION} + DEFINES += RS_MINOR_VERSION=$${RS_MINOR_VERSION} + DEFINES += RS_MINI_VERSION=$${RS_MINI_VERSION} + DEFINES += RS_EXTRA_VERSION=\\\"$${RS_EXTRA_VERSION}\\\" + } +} + gxsdistsync:DEFINES *= RS_USE_GXS_DISTANT_SYNC wikipoos:DEFINES *= RS_USE_WIKI rs_gxs:DEFINES *= RS_ENABLE_GXS