mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -04:00
merged updatream/master
This commit is contained in:
commit
d8233bb101
21 changed files with 586 additions and 142 deletions
|
@ -240,7 +240,9 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta)
|
|||
{
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || meta.mPublishTs + MESSAGE_STORE_PERIOD >= now ;
|
||||
uint32_t store_limit = (mNetService == NULL)?MESSAGE_STORE_PERIOD:mNetService->getKeepAge(meta.mGroupId,MESSAGE_STORE_PERIOD) ;
|
||||
|
||||
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || store_limit == 0 || meta.mPublishTs + store_limit >= now ;
|
||||
}
|
||||
|
||||
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
|
||||
|
|
|
@ -2448,7 +2448,7 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
|
|||
GXSNETDEBUG_P_(tr->mTransaction->PeerId()) << " type = msgs." << std::endl;
|
||||
#endif
|
||||
RsGxsGroupId grpId;
|
||||
time_t now = time(NULL) ;
|
||||
//time_t now = time(NULL) ;
|
||||
|
||||
while(tr->mItems.size() > 0)
|
||||
{
|
||||
|
|
|
@ -910,4 +910,6 @@ android-g++ {
|
|||
INCLUDEPATH += $$NDK_TOOLCHAIN_PATH/sysroot/usr/include
|
||||
DEPENDPATH += $$NDK_TOOLCHAIN_PATH/sysroot/usr/include
|
||||
PRE_TARGETDEPS += $$NDK_TOOLCHAIN_PATH/sysroot/usr/lib/libcrypto.a
|
||||
|
||||
HEADERS += util/androiddebug.h
|
||||
}
|
||||
|
|
|
@ -743,10 +743,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
|
|||
{
|
||||
std::string dataDirectory;
|
||||
|
||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
#ifndef WINDOWS_SYS
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifdef __APPLE__
|
||||
/* NOTE: OSX also qualifies as BSD... so this #ifdef must be before the BSD check. */
|
||||
|
||||
/* For OSX, applications are Bundled in a directory...
|
||||
|
@ -767,7 +764,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
|
|||
dataDirectory += "/Contents/Resources";
|
||||
std::cerr << "getRetroshareDataDirectory() OSX: " << dataDirectory;
|
||||
|
||||
#elif (defined(BSD) && (BSD >= 199103))
|
||||
#elif (defined(BSD) && (BSD >= 199103))
|
||||
/* For BSD, the default is LOCALBASE which will be set
|
||||
* before compilation via the ports/pkg-src mechanisms.
|
||||
* For compilation without ports/pkg-src it is set to
|
||||
|
@ -775,17 +772,7 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
|
|||
*/
|
||||
dataDirectory = "/usr/local/share/retroshare";
|
||||
std::cerr << "getRetroshareDataDirectory() BSD: " << dataDirectory;
|
||||
|
||||
#else
|
||||
/* For Linux, the data directory is set in libretroshare.pro */
|
||||
#ifndef DATA_DIR
|
||||
#error DATA_DIR variable not set. Cannot compile.
|
||||
#endif
|
||||
dataDirectory = DATA_DIR;
|
||||
std::cerr << "getRetroshareDataDirectory() Linux: " << dataDirectory << std::endl;
|
||||
|
||||
#endif
|
||||
#else
|
||||
#elif defined(WINDOWS_SYS)
|
||||
// if (RsInitConfig::portable)
|
||||
// {
|
||||
// /* For Windows Portable, files must be in the data directory */
|
||||
|
@ -805,21 +792,29 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
|
|||
|
||||
/* Use RetroShare's exe dir */
|
||||
dataDirectory = ".";
|
||||
|
||||
#elif defined(DATA_DIR)
|
||||
dataDirectory = DATA_DIR;
|
||||
// For all other OS the data directory must be set in libretroshare.pro
|
||||
#else
|
||||
# error "For your target OS automatic data dir discovery is not supported, cannot compile if DATA_DIR variable not set."
|
||||
#endif
|
||||
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
|
||||
|
||||
if (!check)
|
||||
{
|
||||
std::cerr << "getRetroshareDataDirectory() unckecked: " << dataDirectory << std::endl;
|
||||
return dataDirectory;
|
||||
}
|
||||
|
||||
/* Make sure the directory exists, else return emptyString */
|
||||
if (!RsDirUtil::checkDirectory(dataDirectory))
|
||||
{
|
||||
std::cerr << "Data Directory not Found: " << dataDirectory << std::endl;
|
||||
std::cerr << "getRetroshareDataDirectory() not found: " << dataDirectory << std::endl;
|
||||
dataDirectory = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Data Directory Found: " << dataDirectory << std::endl;
|
||||
std::cerr << "getRetroshareDataDirectory() found: " << dataDirectory << std::endl;
|
||||
}
|
||||
|
||||
return dataDirectory;
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
virtual ~RsGxsGrpConfigItem() {}
|
||||
|
||||
virtual void clear() {}
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t /* indent */) { return out;}
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t /*indent*/) { return out;}
|
||||
|
||||
virtual bool serialise(void *data,uint32_t& size) const ;
|
||||
virtual uint32_t serial_size() const ;
|
||||
|
@ -116,7 +116,7 @@ class RsGxsGrpUpdateItem : public RsGxsNetServiceItem, public RsGxsGrpUpdate
|
|||
{
|
||||
public:
|
||||
RsGxsGrpUpdateItem(uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_GRP_UPDATE) {clear();}
|
||||
RsGxsGrpUpdateItem(const RsGxsGrpUpdate& u,uint16_t serv_type) : RsGxsNetServiceItem(serv_type, RS_PKT_SUBTYPE_GXS_GRP_UPDATE), RsGxsGrpUpdate(u) {clear();}
|
||||
RsGxsGrpUpdateItem(const RsGxsGrpUpdate& u,uint16_t serv_type) : RsGxsNetServiceItem(serv_type, RS_PKT_SUBTYPE_GXS_GRP_UPDATE), RsGxsGrpUpdate(u) {}
|
||||
|
||||
virtual ~RsGxsGrpUpdateItem() {}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class RsGxsServerGrpUpdateItem : public RsGxsNetServiceItem, public RsGxsServerG
|
|||
{
|
||||
public:
|
||||
RsGxsServerGrpUpdateItem(uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE) { clear();}
|
||||
RsGxsServerGrpUpdateItem(const RsGxsServerGrpUpdate& u,uint16_t serv_type) : RsGxsNetServiceItem(serv_type, RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE), RsGxsServerGrpUpdate(u) {clear();}
|
||||
RsGxsServerGrpUpdateItem(const RsGxsServerGrpUpdate& u,uint16_t serv_type) : RsGxsNetServiceItem(serv_type, RS_PKT_SUBTYPE_GXS_SERVER_GRP_UPDATE), RsGxsServerGrpUpdate(u) {}
|
||||
|
||||
virtual ~RsGxsServerGrpUpdateItem() {}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class RsGxsMsgUpdateItem : public RsGxsNetServiceItem, public RsGxsMsgUpdate
|
|||
{
|
||||
public:
|
||||
RsGxsMsgUpdateItem(uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_MSG_UPDATE) { clear();}
|
||||
RsGxsMsgUpdateItem(const RsGxsMsgUpdate& m,uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_MSG_UPDATE), RsGxsMsgUpdate(m) { clear();}
|
||||
RsGxsMsgUpdateItem(const RsGxsMsgUpdate& m,uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_MSG_UPDATE), RsGxsMsgUpdate(m) {}
|
||||
|
||||
virtual ~RsGxsMsgUpdateItem() {}
|
||||
|
||||
|
@ -195,7 +195,7 @@ class RsGxsServerMsgUpdateItem : public RsGxsNetServiceItem, public RsGxsServerM
|
|||
{
|
||||
public:
|
||||
RsGxsServerMsgUpdateItem(uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE) { clear();}
|
||||
RsGxsServerMsgUpdateItem(const RsGxsServerMsgUpdate& m,uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE),RsGxsServerMsgUpdate(m) { clear();}
|
||||
RsGxsServerMsgUpdateItem(const RsGxsServerMsgUpdate& m,uint16_t servType) : RsGxsNetServiceItem(servType, RS_PKT_SUBTYPE_GXS_SERVER_MSG_UPDATE),RsGxsServerMsgUpdate(m) {}
|
||||
virtual ~RsGxsServerMsgUpdateItem() {}
|
||||
|
||||
virtual void clear();
|
||||
|
|
117
libretroshare/src/util/androiddebug.h
Normal file
117
libretroshare/src/util/androiddebug.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
#pragma once
|
||||
/*
|
||||
* Redirect plain stdout and stderr to Android debug
|
||||
* Copyright (C) 2016 Gioacchino Mazzurco <gio@eigenlab.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Inspired by: https://codelab.wordpress.com/2014/11/03/how-to-use-standard-output-streams-for-logging-in-android-apps/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h> // for O_NONBLOCK
|
||||
#include <android/log.h>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* On Android stdout and stderr of native code is discarded, instancing this
|
||||
* class at the beginning of the main of your program to get them (stdout and
|
||||
* stderr) on logcat output.
|
||||
*/
|
||||
class AndroidStdIOCatcher
|
||||
{
|
||||
public:
|
||||
AndroidStdIOCatcher(const std::string& dTag = "RetroShare",
|
||||
android_LogPriority stdout_pri = ANDROID_LOG_INFO,
|
||||
android_LogPriority stderr_pri = ANDROID_LOG_ERROR) :
|
||||
tag(dTag), cout_pri(stdout_pri), cerr_pri(stderr_pri), should_stop(false)
|
||||
{
|
||||
// make stdout line-buffered
|
||||
//setvbuf(stdout, 0, _IOLBF, 0);
|
||||
|
||||
// make stdout and stderr unbuffered
|
||||
setvbuf(stdout, 0, _IONBF, 0);
|
||||
setvbuf(stderr, 0, _IONBF, 0);
|
||||
|
||||
// create the pipes and redirect stdout and stderr
|
||||
pipe2(pout_fd, O_NONBLOCK);
|
||||
dup2(pout_fd[1], STDOUT_FILENO);
|
||||
|
||||
pipe2(perr_fd, O_NONBLOCK);
|
||||
dup2(perr_fd[1], STDERR_FILENO);
|
||||
|
||||
// spawn the logging thread
|
||||
pthread_create(&thr, 0, thread_func, this);
|
||||
pthread_detach(thr);
|
||||
}
|
||||
|
||||
~AndroidStdIOCatcher()
|
||||
{
|
||||
should_stop = true;
|
||||
pthread_join(thr, NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string tag;
|
||||
const android_LogPriority cout_pri;
|
||||
const android_LogPriority cerr_pri;
|
||||
|
||||
int pout_fd[2];
|
||||
int perr_fd[2];
|
||||
pthread_t thr;
|
||||
std::atomic<bool> should_stop;
|
||||
|
||||
static void *thread_func(void* instance)
|
||||
{
|
||||
__android_log_write(ANDROID_LOG_INFO, "RetroShare", "Android debugging start");
|
||||
|
||||
AndroidStdIOCatcher &i = *static_cast<AndroidStdIOCatcher*>(instance);
|
||||
|
||||
std::string out_buf;
|
||||
std::string err_buf;
|
||||
|
||||
while (!i.should_stop)
|
||||
{
|
||||
for(char c; read(i.pout_fd[0], &c, 1) == 1;)
|
||||
{
|
||||
out_buf += c;
|
||||
if(c == '\n')
|
||||
{
|
||||
__android_log_write(i.cout_pri, i.tag.c_str(), out_buf.c_str());
|
||||
out_buf.clear();
|
||||
}
|
||||
}
|
||||
|
||||
for(char c; read(i.perr_fd[0], &c, 1) == 1;)
|
||||
{
|
||||
err_buf += c;
|
||||
if(c == '\n')
|
||||
{
|
||||
__android_log_write(i.cerr_pri, i.tag.c_str(), err_buf.c_str());
|
||||
err_buf.clear();
|
||||
}
|
||||
}
|
||||
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
__android_log_write(ANDROID_LOG_INFO, "RetroShare", "Android debugging stop");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue