mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-26 16:05:48 -04:00
Merge remote-tracking branch 'upstream/master' into v0.6-TorControl
This commit is contained in:
commit
3de68bf5e5
17 changed files with 857 additions and 602 deletions
|
@ -142,7 +142,6 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
|
|||
retroshare/rsmsgs.h \
|
||||
retroshare/rsnotify.h \
|
||||
retroshare/rspeers.h \
|
||||
retroshare/rsrank.h \
|
||||
retroshare/rsstatus.h \
|
||||
retroshare/rsturtle.h \
|
||||
retroshare/rsbanlist.h \
|
||||
|
@ -353,13 +352,13 @@ HEADERS += ft/ftchunkmap.h \
|
|||
ft/ftturtlefiletransferitem.h
|
||||
|
||||
HEADERS += crypto/chacha20.h \
|
||||
crypto/rsaes.h \
|
||||
crypto/hashstream.h \
|
||||
crypto/rscrypto.h
|
||||
crypto/rsaes.h \
|
||||
crypto/hashstream.h \
|
||||
crypto/rscrypto.h
|
||||
|
||||
HEADERS += directory_updater.h \
|
||||
directory_list.h \
|
||||
p3filelists.h
|
||||
HEADERS += file_sharing/directory_updater.h \
|
||||
file_sharing/directory_list.h \
|
||||
file_sharing/p3filelists.h
|
||||
|
||||
HEADERS += chat/distantchat.h \
|
||||
chat/p3chatservice.h \
|
||||
|
@ -421,7 +420,7 @@ HEADERS += grouter/groutercache.h \
|
|||
retroshare/rsgrouter.h \
|
||||
grouter/grouteritems.h \
|
||||
grouter/p3grouter.h \
|
||||
grouter/rsgroutermatrix.h \
|
||||
grouter/groutermatrix.h \
|
||||
grouter/groutertypes.h \
|
||||
grouter/grouterclientservice.h
|
||||
|
||||
|
@ -434,7 +433,6 @@ HEADERS += rsitems/rsitem.h \
|
|||
rsitems/rsmsgitems.h \
|
||||
serialiser/rsserial.h \
|
||||
rsitems/rsserviceids.h \
|
||||
serialiser/rsserviceitems.h \
|
||||
rsitems/rsstatusitems.h \
|
||||
serialiser/rstlvaddrs.h \
|
||||
serialiser/rstlvbase.h \
|
||||
|
|
|
@ -41,7 +41,7 @@ static const uint32_t RS_HISTORY_TYPE_PRIVATE = 1 ;
|
|||
static const uint32_t RS_HISTORY_TYPE_LOBBY = 2 ;
|
||||
static const uint32_t RS_HISTORY_TYPE_DISTANT = 3 ;
|
||||
|
||||
class HistoryMsg
|
||||
class HistoryMsg: RsSerializable
|
||||
{
|
||||
public:
|
||||
HistoryMsg()
|
||||
|
@ -52,7 +52,18 @@ public:
|
|||
recvTime = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx) override
|
||||
{
|
||||
RS_SERIAL_PROCESS(msgId);
|
||||
RS_SERIAL_PROCESS(chatPeerId);
|
||||
RS_SERIAL_PROCESS(incoming);
|
||||
RS_SERIAL_PROCESS(peerId);
|
||||
RS_SERIAL_PROCESS(peerName);
|
||||
RS_SERIAL_PROCESS(sendTime);
|
||||
RS_SERIAL_PROCESS(recvTime);
|
||||
RS_SERIAL_PROCESS(message);
|
||||
}
|
||||
|
||||
uint32_t msgId;
|
||||
RsPeerId chatPeerId;
|
||||
bool incoming;
|
||||
|
@ -71,20 +82,80 @@ class RsHistory
|
|||
{
|
||||
public:
|
||||
virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id) = 0;
|
||||
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Retrieves the history of messages for a given chatId
|
||||
* @jsonapi{development}
|
||||
* @param[in] chatPeerId Chat Id for which the history needs to be retrieved
|
||||
* @param[out] msgs retrieved messages
|
||||
* @param[in] loadCount maximum number of messages to get
|
||||
* @return true if messages can be retrieved, false otherwise.
|
||||
*/
|
||||
virtual bool getMessages(const ChatId& chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Retrieves a specific message from the history
|
||||
* @jsonapi{development}
|
||||
* @param[in] msgId Id of the message to get
|
||||
* @param[out] msg retrieved message
|
||||
* @return true if message can be retrieved, false otherwise.
|
||||
*/
|
||||
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
|
||||
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
|
||||
virtual void clear(const ChatId &chatPeerId) = 0;
|
||||
|
||||
virtual bool getEnable(uint32_t chat_type) = 0;
|
||||
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
|
||||
/*!
|
||||
* @brief Remove messages from the history
|
||||
* @jsonapi{development}
|
||||
* @param[in] msgIds list of messages to remove
|
||||
*/
|
||||
virtual void removeMessages(const std::list<uint32_t>& msgIds) = 0;
|
||||
|
||||
/*!
|
||||
* @brief clears the message history for a given chat peer
|
||||
* @jsonapi{development}
|
||||
* @param[in] chatPeerID Id of the chat/peer for which the history needs to be wiped
|
||||
*/
|
||||
virtual void clear(const ChatId &chatPeerId) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Get whether chat history is enabled or not
|
||||
* @jsonapi{development}
|
||||
* @param[in] chat_type Type of chat (see list of constants above)
|
||||
* @return true when the information is available
|
||||
*/
|
||||
virtual bool getEnable(uint32_t chat_type) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Set whether chat history is enabled or not
|
||||
* @jsonapi{development}
|
||||
* @param[in] chat_type Type of chat (see list of constants above)
|
||||
* @param[in] enabled Desired state of the variable
|
||||
*/
|
||||
virtual void setEnable(uint32_t chat_type, bool enable) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Retrieves the maximum storage time period for messages in history
|
||||
* @return max storage duration of chat.
|
||||
*/
|
||||
virtual uint32_t getMaxStorageDuration() = 0;
|
||||
virtual void setMaxStorageDuration(uint32_t seconds) = 0;
|
||||
/*!
|
||||
* @brief Sets the maximum storage time period for messages in history
|
||||
* @param[in] seconds max storage duration time in seconds
|
||||
*/
|
||||
virtual void setMaxStorageDuration(uint32_t seconds) = 0;
|
||||
|
||||
// 0 = no limit, >0 count of saved messages
|
||||
virtual uint32_t getSaveCount(uint32_t chat_type) = 0;
|
||||
virtual void setSaveCount(uint32_t chat_type, uint32_t count) = 0;
|
||||
/*!
|
||||
* @brief Gets the maximum number of messages to save
|
||||
* @param[in] chat_type Type of chat for that number limit
|
||||
* @return maximum number of messages to save
|
||||
*/
|
||||
virtual uint32_t getSaveCount(uint32_t chat_type) = 0;
|
||||
|
||||
/*!
|
||||
* @brief Sets the maximum number of messages to save
|
||||
* @param[in] chat_type Type of chat for that number limit
|
||||
* @param[in] count Max umber of messages, 0 meaning indefinitly
|
||||
*/
|
||||
virtual void setSaveCount(uint32_t chat_type, uint32_t count) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2019 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2019-2021 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -131,23 +132,25 @@ struct RsGxsIdGroup : RsSerializable
|
|||
// ??? 160 bits.
|
||||
|
||||
Sha1CheckSum mPgpIdHash;
|
||||
// Need a signature as proof - otherwise anyone could add others Hashes.
|
||||
// This is a string, as the length is variable.
|
||||
std::string mPgpIdSign;
|
||||
|
||||
// Recognition Strings. MAX# defined above.
|
||||
/** Need a signature as proof - otherwise anyone could add others Hashes.
|
||||
* This is a string, as the length is variable.
|
||||
* TODO: Thing like this should actually be a byte array (pointer+size),
|
||||
* using an std::string breaks the JSON serialization, as a workaround this
|
||||
* field is ignored by JSON serial operations */
|
||||
std::string mPgpIdSign;
|
||||
|
||||
/// Unused
|
||||
RS_DEPRECATED std::list<std::string> mRecognTags;
|
||||
|
||||
// Avatar
|
||||
RsGxsImage mImage ;
|
||||
rstime_t mLastUsageTS ;
|
||||
RsGxsImage mImage; /// Avatar
|
||||
rstime_t mLastUsageTS;
|
||||
|
||||
// Not Serialised - for GUI's benefit.
|
||||
bool mPgpLinked;
|
||||
bool mPgpKnown;
|
||||
bool mIsAContact; // change that into flags one day
|
||||
RsPgpId mPgpId;
|
||||
GxsReputation mReputation;
|
||||
bool mPgpLinked;
|
||||
bool mPgpKnown;
|
||||
bool mIsAContact;
|
||||
RsPgpId mPgpId;
|
||||
GxsReputation mReputation;
|
||||
|
||||
/// @see RsSerializable
|
||||
void serial_process( RsGenericSerializer::SerializeJob j,
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
* *
|
||||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright 2012-2012 by Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2021 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -19,8 +21,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
#ifndef RS_GXS_IDENTITY_ITEMS_H
|
||||
#define RS_GXS_IDENTITY_ITEMS_H
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
|
@ -57,15 +58,20 @@ public:
|
|||
bool toGxsIdGroup(RsGxsIdGroup &group, bool moveImage);
|
||||
|
||||
Sha1CheckSum mPgpIdHash;
|
||||
// Need a signature as proof - otherwise anyone could add others Hashes.
|
||||
// This is a string, as the length is variable.
|
||||
std::string mPgpIdSign;
|
||||
|
||||
// Recognition Strings. MAX# defined above.
|
||||
std::list<std::string> mRecognTags;
|
||||
/** Need a signature as proof - otherwise anyone could add others Hashes.
|
||||
* This is a string, as the length is variable.
|
||||
* TODO: this should actually be a byte array (pointer+size), using an
|
||||
* std::string breaks the JSON serialization.
|
||||
* Be careful refactoring this as it may break retrocompatibility as this
|
||||
* item is sent over the network */
|
||||
std::string mPgpIdSign;
|
||||
|
||||
// Avatar
|
||||
RsTlvImage mImage ;
|
||||
/// Unused
|
||||
RS_DEPRECATED std::list<std::string> mRecognTags;
|
||||
|
||||
/// Avatar
|
||||
RsTlvImage mImage;
|
||||
};
|
||||
|
||||
struct RsGxsIdLocalInfoItem : public RsGxsIdItem
|
||||
|
@ -89,5 +95,3 @@ public:
|
|||
|
||||
virtual RsItem *create_item(uint16_t service_id,uint8_t item_subtype) const ;
|
||||
};
|
||||
|
||||
#endif /* RS_GXS_IDENTITY_ITEMS_H */
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
* libretroshare/src/services: p3idservice.cc *
|
||||
* *
|
||||
* Copyright (C) 2012-2014 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2017-2019 Gioacchino Mazzurco <gio@altermundi.net> *
|
||||
* Copyright (C) 2017-2021 Gioacchino Mazzurco <gio@altermundi.net> *
|
||||
* Copyright (C) 2021 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -4960,7 +4961,21 @@ void RsGxsIdGroup::serial_process(
|
|||
{
|
||||
RS_SERIAL_PROCESS(mMeta);
|
||||
RS_SERIAL_PROCESS(mPgpIdHash);
|
||||
RS_SERIAL_PROCESS(mPgpIdSign);
|
||||
switch(j)
|
||||
{
|
||||
/* mPgpIdSign is declared as std::string but it is a disguised raw memory
|
||||
* chunk, serializing it as plain string breaks JSON and eventually
|
||||
* teminals if it get printed, it should have been declared as a raw memory
|
||||
* chunk in the first place, but as of today just ignoring it in *JSON and
|
||||
* PRINT operations seems a reasonable workaround */
|
||||
case RsGenericSerializer::SerializeJob::PRINT: // [[fallthrough]]
|
||||
case RsGenericSerializer::SerializeJob::TO_JSON: // [[fallthrough]]
|
||||
case RsGenericSerializer::SerializeJob::FROM_JSON:
|
||||
break;
|
||||
default:
|
||||
RS_SERIAL_PROCESS(mPgpIdSign);
|
||||
break;
|
||||
}
|
||||
RS_SERIAL_PROCESS(mImage);
|
||||
RS_SERIAL_PROCESS(mLastUsageTS);
|
||||
RS_SERIAL_PROCESS(mPgpKnown);
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* libretroshare: retroshare core library *
|
||||
* *
|
||||
* Copyright (C) 2004-2007 Robert Fernie <retroshare@lunamutt.com> *
|
||||
* Copyright (C) 2020 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2020 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* Copyright (C) 2020-2021 Gioacchino Mazzurco <gio@eigenlab.org> *
|
||||
* Copyright (C) 2020-2021 Asociación Civil Altermundi <info@altermundi.net> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
|
@ -64,6 +64,26 @@
|
|||
* #define RSDIR_DEBUG 1
|
||||
****/
|
||||
|
||||
#if __cplusplus < 201703L
|
||||
bool std::filesystem::create_directories(const std::string& path)
|
||||
{
|
||||
for( std::string::size_type lastIndex = 0; lastIndex < std::string::npos;
|
||||
lastIndex = path.find('/', lastIndex) )
|
||||
{
|
||||
std::string&& curDir = path.substr(0, ++lastIndex);
|
||||
if(!RsDirUtil::checkCreateDirectory(curDir))
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " failure creating: " << curDir
|
||||
<< " of: " << path << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
# include <filesystem>
|
||||
#endif // __cplusplus < 201703L
|
||||
|
||||
std::string RsDirUtil::getTopDir(const std::string& dir)
|
||||
{
|
||||
std::string top;
|
||||
|
@ -528,24 +548,6 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir)
|
|||
return true;
|
||||
}
|
||||
|
||||
#if __cplusplus < 201703L
|
||||
bool std::filesystem::create_directories(const std::string& path)
|
||||
{
|
||||
for( std::string::size_type lastIndex = 0; lastIndex < std::string::npos;
|
||||
lastIndex = path.find('/', lastIndex) )
|
||||
{
|
||||
std::string&& curDir = path.substr(0, ++lastIndex);
|
||||
if(!RsDirUtil::checkCreateDirectory(curDir))
|
||||
{
|
||||
RsErr() << __PRETTY_FUNCTION__ << " failure creating: " << curDir
|
||||
<< " of: " << path << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // __cplusplus < 201703L
|
||||
|
||||
std::string RsDirUtil::removeSymLinks(const std::string& path)
|
||||
{
|
||||
#if defined(WINDOWS_SYS) || defined(__APPLE__) || defined(__ANDROID__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue