Fix Android compilation after rebase on master

This commit is contained in:
Gioacchino Mazzurco 2020-04-01 01:30:57 +02:00
parent b42c0410f1
commit ce5f5faa97
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
3 changed files with 56 additions and 66 deletions

View File

@ -30,6 +30,7 @@
#include "retroshare/rsreputations.h"
#include "rsgxsflags.h"
#include "util/rsdeprecate.h"
#include "util/rsdebug.h"
/*!
* This class only make method of internal members visible tu upper level to
@ -46,7 +47,7 @@
enum class TokenRequestType: uint8_t
{
UNDEFINED = 0x00,
__NONE = 0x00, /// Used to detect uninitialized
GROUP_DATA = 0x01,
GROUP_META = 0x02,
POSTS = 0x03,
@ -55,6 +56,7 @@ enum class TokenRequestType: uint8_t
GROUP_STATISTICS = 0x06,
SERVICE_STATISTICS = 0x07,
NO_KILL_TYPE = 0x08,
__MAX /// Used to detect out of range
};
class RsGxsIfaceHelper
@ -444,9 +446,9 @@ protected:
uint32_t token,
std::chrono::milliseconds maxWait = std::chrono::milliseconds(20000),
std::chrono::milliseconds checkEvery = std::chrono::milliseconds(100),
bool auto_delete_if_unsuccessful=true)
bool auto_delete_if_unsuccessful=true)
{
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
auto wkStartime = std::chrono::steady_clock::now();
int maxWorkAroundCnt = 10;
LLwaitTokenBeginLabel:
@ -454,13 +456,14 @@ LLwaitTokenBeginLabel:
auto timeout = std::chrono::steady_clock::now() + maxWait;
auto st = requestStatus(token);
while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE) && std::chrono::steady_clock::now() < timeout )
while( !(st == RsTokenService::FAILED || st >= RsTokenService::COMPLETE)
&& std::chrono::steady_clock::now() < timeout )
{
std::this_thread::sleep_for(checkEvery);
st = requestStatus(token);
}
if(st != RsTokenService::COMPLETE && auto_delete_if_unsuccessful)
cancelRequest(token);
if(st != RsTokenService::COMPLETE && auto_delete_if_unsuccessful)
cancelRequest(token);
#if defined(__ANDROID__) && (__ANDROID_API__ < 24)
/* Work around for very slow/old android devices, we don't expect this
@ -487,35 +490,39 @@ LLwaitTokenBeginLabel:
#endif
{
RS_STACK_MUTEX(mMtx);
RS_STACK_MUTEX(mMtx);
mActiveTokens.erase(token);
}
}
return st;
}
return st;
}
private:
RsGxsIface& mGxs;
RsTokenService& mTokenService;
RsMutex mMtx;
RsMutex mMtx;
std::map<uint32_t,TokenRequestType> mActiveTokens;
std::map<uint32_t,TokenRequestType> mActiveTokens;
void locked_dumpTokens()
{
uint16_t service_id = mGxs.serviceType();
void locked_dumpTokens()
{
const uint16_t service_id = mGxs.serviceType();
const auto countSize = static_cast<const size_t>(TokenRequestType::__MAX);
uint32_t count[countSize] = {0};
uint32_t count[7] = {0};
RsDbg() << __PRETTY_FUNCTION__ << "Service 0x" << std::hex << service_id
<< " (" << rsServiceControl->getServiceName(
RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id) )
<< ") this=0x" << static_cast<void*>(this)
<< ") Active tokens (per type): ";
RsDbg() << "Service " << std::hex << service_id << std::dec
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;
// let's count how many token of each type we've got.
for(auto& it: mActiveTokens) ++count[static_cast<int>(it.second)];
for(auto& it: mActiveTokens) // let's count how many token of each type we've got.
++count[static_cast<int>(it.second)];
for(uint32_t i=0; i < countSize; ++i)
RsDbg().uStream() /* << i << ":" */ << count[i] << " ";
RsDbg().uStream() << std::endl;
}
for(uint32_t i=0;i<7;++i)
std::cerr << std::dec /* << i << ":" */ << count[i] << " ";
std::cerr << std::endl;
}
RS_SET_CONTEXT_DEBUG_LEVEL(1)
};

View File

@ -191,37 +191,35 @@ struct RsMsgMetaData : RsSerializable
}
};
struct RsGxsGenericMsgData
struct GxsGroupStatistic : RsSerializable
{
virtual ~RsGxsGenericMsgData() = default; // making the type polymorphic
GxsGroupStatistic() :
mNumMsgs(0), mTotalSizeOfMsgs(0), mNumThreadMsgsNew(0),
mNumThreadMsgsUnread(0), mNumChildMsgsNew(0), mNumChildMsgsUnread(0) {}
RsMsgMetaData mMeta;
};
class GxsGroupStatistic
{
public:
GxsGroupStatistic()
/// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx) override
{
mNumMsgs = 0;
mTotalSizeOfMsgs = 0;
mNumThreadMsgsNew = 0;
mNumThreadMsgsUnread = 0;
mNumChildMsgsNew = 0;
mNumChildMsgsUnread = 0;
RS_SERIAL_PROCESS(mGrpId);
RS_SERIAL_PROCESS(mNumMsgs);
RS_SERIAL_PROCESS(mTotalSizeOfMsgs);
RS_SERIAL_PROCESS(mNumThreadMsgsNew);
RS_SERIAL_PROCESS(mNumThreadMsgsUnread);
RS_SERIAL_PROCESS(mNumChildMsgsNew);
RS_SERIAL_PROCESS(mNumChildMsgsUnread);
}
public:
/// number of message
RsGxsGroupId mGrpId;
uint32_t mNumMsgs; // from the database
RsGxsGroupId mGrpId;
uint32_t mNumMsgs; /// number of message, from the database
uint32_t mTotalSizeOfMsgs;
uint32_t mNumThreadMsgsNew;
uint32_t mNumThreadMsgsUnread;
uint32_t mNumChildMsgsNew;
uint32_t mNumChildMsgsUnread;
uint32_t mNumChildMsgsUnread;
~GxsGroupStatistic() override = default;
};
class GxsServiceStatistic
@ -254,30 +252,15 @@ public:
uint32_t mSizeStore;
};
class UpdateItem
{
public:
virtual ~UpdateItem() { }
};
class StringUpdateItem : public UpdateItem
{
public:
StringUpdateItem(const std::string update) : mUpdate(update) {}
const std::string& getUpdate() const { return mUpdate; }
private:
std::string mUpdate;
};
class RsGxsGroupUpdateMeta
class RS_DEPRECATED RsGxsGroupUpdateMeta
{
public:
// expand as support is added for other utypes
enum UpdateType { DESCRIPTION, NAME };
RsGxsGroupUpdateMeta(const RsGxsGroupId& groupId) : mGroupId(groupId) {}
explicit RsGxsGroupUpdateMeta(const RsGxsGroupId& groupId):
mGroupId(groupId) {}
typedef std::map<UpdateType, std::string> GxsMetaUpdate;

View File

@ -37,7 +37,7 @@
#include "serialiser/rstypeserializer.h"
#include "util/rsdeprecate.h"
struct RsIdentity;
class RsIdentity;
/**
* Pointer to global instance of RsIdentity service implementation