mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-05 23:55:35 -04:00
updated branch to upstream/master
This commit is contained in:
commit
a1ce7f2d6f
273 changed files with 7386 additions and 14262 deletions
|
@ -1019,8 +1019,8 @@ bool DistantChatService::getDistantChatStatus(const RsGxsId& gxs_id,uint32_t& st
|
|||
{
|
||||
status = it->second.status ;
|
||||
|
||||
if(from_gxs_id != NULL)
|
||||
*from_gxs_id = it->second.own_gxs_id ;
|
||||
if(from_gxs_id != NULL)
|
||||
*from_gxs_id = it->second.own_gxs_id ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ static const time_t CONNECTION_CHALLENGE_MAX_MSG_AGE = 30 ; // maximum age o
|
|||
static const int CONNECTION_CHALLENGE_MIN_DELAY = 15 ; // sends a connection at most every 15 seconds
|
||||
static const int LOBBY_CACHE_CLEANING_PERIOD = 10 ; // clean lobby caches every 10 secs (remove old messages)
|
||||
|
||||
static const time_t MAX_KEEP_MSG_RECORD = 1200 ; // keep msg record for 1200 secs max.
|
||||
static const time_t MAX_KEEP_MSG_RECORD = 1200 ; // keep msg record for 1200 secs max.
|
||||
static const time_t MAX_KEEP_INACTIVE_NICKNAME = 180 ; // keep inactive nicknames for 3 mn max.
|
||||
static const time_t MAX_DELAY_BETWEEN_LOBBY_KEEP_ALIVE = 120 ; // send keep alive packet every 2 minutes.
|
||||
static const time_t MAX_KEEP_PUBLIC_LOBBY_RECORD = 60 ; // keep inactive lobbies records for 60 secs max.
|
||||
|
@ -57,11 +57,11 @@ static const uint32_t MAX_ALLOWED_LOBBIES_IN_LIST_WARNING = 50 ;
|
|||
static const uint32_t MAX_MESSAGES_PER_SECONDS_NUMBER = 5 ; // max number of messages from a given peer in a window for duration below
|
||||
static const uint32_t MAX_MESSAGES_PER_SECONDS_PERIOD = 10 ; // duration window for max number of messages before messages get dropped.
|
||||
|
||||
#define IS_PUBLIC_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_PUBLIC )
|
||||
#define IS_ANONYMOUS_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_ANONYMOUS)
|
||||
#define IS_CONNEXION_CHALLENGE(flags) (flags & RS_CHAT_LOBBY_FLAGS_CHALLENGE)
|
||||
#define IS_PUBLIC_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_PUBLIC )
|
||||
#define IS_PGP_SIGNED_LOBBY(flags) (flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED)
|
||||
#define IS_CONNEXION_CHALLENGE(flags) (flags & RS_CHAT_LOBBY_FLAGS_CHALLENGE )
|
||||
|
||||
#define EXTRACT_PRIVACY_FLAGS(flags) (ChatLobbyFlags(flags.toUInt32()) & RS_CHAT_LOBBY_FLAGS_PUBLIC)
|
||||
#define EXTRACT_PRIVACY_FLAGS(flags) (ChatLobbyFlags(flags.toUInt32()) * (RS_CHAT_LOBBY_FLAGS_PUBLIC | RS_CHAT_LOBBY_FLAGS_PGP_SIGNED))
|
||||
|
||||
DistributedChatService::DistributedChatService(uint32_t serv_type,p3ServiceControl *sc,p3HistoryMgr *hm, RsGixs *is)
|
||||
: mServType(serv_type),mDistributedChatMtx("Distributed Chat"), mServControl(sc), mHistMgr(hm),mGixs(is)
|
||||
|
@ -144,7 +144,37 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
|
|||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
ChatLobbyFlags fl ;
|
||||
|
||||
// delete items that are not for us, as early as possible.
|
||||
{
|
||||
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// send upward for display
|
||||
|
||||
std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it = _chat_lobbys.find(cli->lobby_id) ;
|
||||
|
||||
if(it == _chat_lobbys.end())
|
||||
{
|
||||
#ifdef DEBUG_CHAT_LOBBIES
|
||||
std::cerr << "Chatlobby for id " << std::hex << item->lobby_id << " has no record. Dropping the msg." << std::dec << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
fl = it->second.lobby_flags ;
|
||||
}
|
||||
if(IS_PGP_SIGNED_LOBBY(fl))
|
||||
{
|
||||
RsIdentityDetails details;
|
||||
|
||||
if(!rsIdentity->getIdDetails(cli->signature.keyId,details) || !details.mPgpKnown)
|
||||
{
|
||||
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (id=" << cli->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
|
||||
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
if(!bounceLobbyObject(cli,cli->PeerId())) // forwards the message to friends, keeps track of subscribers, etc.
|
||||
return false;
|
||||
|
||||
|
@ -157,7 +187,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
|
|||
//name = cli->nick;
|
||||
//popupChatFlag = RS_POPUP_CHATLOBBY;
|
||||
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_CHATLOBBY, cli->signature.keyId.toStdString(), cli->nick, cli->message); /* notify private chat message */
|
||||
RsServer::notify()->AddPopupMessage(RS_POPUP_CHATLOBBY, virtual_peer_id.toStdString(), cli->signature.keyId.toStdString(), cli->message); /* notify private chat message */
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
@ -181,33 +211,34 @@ bool DistributedChatService::checkSignature(RsChatLobbyBouncingObject *obj,const
|
|||
std::cerr << " signature id: " << obj->signature.keyId << std::endl;
|
||||
#endif
|
||||
|
||||
if(!obj->serialise_signed_part(memory,size))
|
||||
{
|
||||
std::cerr << " (EE) Cannot serialise message item. " << std::endl;
|
||||
return false ;
|
||||
}
|
||||
if(!obj->serialise_signed_part(memory,size))
|
||||
{
|
||||
std::cerr << " (EE) Cannot serialise message item. " << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
uint32_t error_status ;
|
||||
uint32_t error_status ;
|
||||
|
||||
if(!mGixs->validateData(memory,obj->signed_serial_size(),obj->signature,false,error_status))
|
||||
{
|
||||
bool res = false ;
|
||||
if(!mGixs->validateData(memory,obj->signed_serial_size(),obj->signature,false,error_status))
|
||||
{
|
||||
bool res = false ;
|
||||
|
||||
switch(error_status)
|
||||
{
|
||||
case RsGixs::RS_GIXS_ERROR_KEY_NOT_AVAILABLE:
|
||||
switch(error_status)
|
||||
{
|
||||
case RsGixs::RS_GIXS_ERROR_KEY_NOT_AVAILABLE:
|
||||
#ifdef DEBUG_CHAT_LOBBIES
|
||||
std::cerr << "(WW) Key is not is cache. Cannot verify." << std::endl;
|
||||
std::cerr << "(WW) Key is not is cache. Cannot verify." << std::endl;
|
||||
#endif
|
||||
res =true ;
|
||||
break ;
|
||||
case RsGixs::RS_GIXS_ERROR_SIGNATURE_MISMATCH: std::cerr << "(EE) Signature mismatch. Spoofing/MITM?." << std::endl;
|
||||
res =false ;
|
||||
break ;
|
||||
default: break ;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
res =true ;
|
||||
break ;
|
||||
case RsGixs::RS_GIXS_ERROR_SIGNATURE_MISMATCH: std::cerr << "(EE) Signature mismatch. Spoofing/MITM?." << std::endl;
|
||||
res =false ;
|
||||
break ;
|
||||
default: break ;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_CHAT_LOBBIES
|
||||
std::cerr << " signature: CHECKS" << std::endl;
|
||||
|
@ -249,11 +280,11 @@ void DistributedChatService::locked_printDebugInfo() const
|
|||
{
|
||||
std::cerr << " Lobby id\t\t: " << std::hex << it->first << std::dec << std::endl;
|
||||
std::cerr << " Lobby name\t\t: " << it->second.lobby_name << std::endl;
|
||||
std::cerr << " Lobby topic\t\t: " << it->second.lobby_topic << std::endl;
|
||||
std::cerr << " nick name\t\t: " << it->second.gxs_id << std::endl;
|
||||
std::cerr << " Lobby type\t\t: " << ((IS_PUBLIC_LOBBY(it->second.lobby_flags))?"Public":"Private") << std::endl;
|
||||
std::cerr << " Lobby policy\t\t: " << ((IS_ANONYMOUS_LOBBY(it->second.lobby_flags))?"Unsigned":"Signature required") << std::endl;
|
||||
std::cerr << " Lobby peer id\t: " << it->second.virtual_peer_id << std::endl;
|
||||
std::cerr << " Lobby topic\t\t: " << it->second.lobby_topic << std::endl;
|
||||
std::cerr << " nick name\t\t: " << it->second.gxs_id << std::endl;
|
||||
std::cerr << " Lobby type\t\t: " << ((IS_PUBLIC_LOBBY(it->second.lobby_flags))?"Public":"Private") << std::endl;
|
||||
std::cerr << " Lobby security\t\t: " << ((IS_PGP_SIGNED_LOBBY(it->second.lobby_flags))?"PGP-signed IDs required":"Anon IDs accepted") << std::endl;
|
||||
std::cerr << " Lobby peer id\t: " << it->second.virtual_peer_id << std::endl;
|
||||
std::cerr << " Challenge count\t: " << it->second.connexion_challenge_count << std::endl;
|
||||
std::cerr << " Last activity\t: " << now - it->second.last_activity << " seconds ago." << std::endl;
|
||||
std::cerr << " Cached messages\t: " << it->second.msg_cache.size() << std::endl;
|
||||
|
@ -268,7 +299,7 @@ void DistributedChatService::locked_printDebugInfo() const
|
|||
|
||||
std::cerr << " Participating nick names: " << std::endl;
|
||||
|
||||
for(std::map<RsGxsId,time_t>::const_iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();++it2)
|
||||
for(std::map<RsGxsId,time_t>::const_iterator it2(it->second.gxs_ids.begin());it2!=it->second.gxs_ids.end();++it2)
|
||||
std::cerr << " " << it2->first << ": " << now - it2->second << " secs ago" << std::endl;
|
||||
|
||||
}
|
||||
|
@ -446,7 +477,7 @@ void DistributedChatService::handleRecvChatLobbyListRequest(RsChatLobbyListReque
|
|||
info.name = it->second.lobby_name ;
|
||||
info.topic = it->second.lobby_topic ;
|
||||
info.count = it->second.gxs_ids.size() ;
|
||||
info.flags = it->second.lobby_flags ;
|
||||
info.flags = ChatLobbyFlags(EXTRACT_PRIVACY_FLAGS(it->second.lobby_flags)) ;
|
||||
|
||||
item->lobbies.push_back(info) ;
|
||||
}
|
||||
|
@ -496,7 +527,7 @@ void DistributedChatService::handleRecvChatLobbyList(RsChatLobbyListItem *item)
|
|||
rec.total_number_of_peers = std::max(rec.total_number_of_peers,item->lobbies[i].count) ;
|
||||
|
||||
rec.last_report_time = now ;
|
||||
rec.lobby_flags = item->lobbies[i].flags ;
|
||||
rec.lobby_flags = EXTRACT_PRIVACY_FLAGS(item->lobbies[i].flags) ;
|
||||
|
||||
std::map<ChatLobbyId,ChatLobbyFlags>::const_iterator it(_known_lobbies_flags.find(item->lobbies[i].id)) ;
|
||||
|
||||
|
@ -596,19 +627,24 @@ void DistributedChatService::addTimeShiftStatistics(int D)
|
|||
|
||||
void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *item)
|
||||
{
|
||||
ChatLobbyFlags fl ;
|
||||
|
||||
// delete items that are not for us, as early as possible.
|
||||
{
|
||||
RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
// send upward for display
|
||||
|
||||
if(_chat_lobbys.find(item->lobby_id) == _chat_lobbys.end())
|
||||
std::map<ChatLobbyId,ChatLobbyEntry>::const_iterator it = _chat_lobbys.find(item->lobby_id) ;
|
||||
|
||||
if(it == _chat_lobbys.end())
|
||||
{
|
||||
#ifdef DEBUG_CHAT_LOBBIES
|
||||
std::cerr << "Chatlobby for id " << std::hex << item->lobby_id << " has no record. Dropping the msg." << std::dec << std::endl;
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
fl = it->second.lobby_flags ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -624,7 +660,18 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
|
|||
std::cerr << std::endl;
|
||||
return ;
|
||||
}
|
||||
|
||||
if(IS_PGP_SIGNED_LOBBY(fl))
|
||||
{
|
||||
RsIdentityDetails details;
|
||||
|
||||
if(!rsIdentity->getIdDetails(item->signature.keyId,details) || !details.mPgpKnown)
|
||||
{
|
||||
std::cerr << "(WW) Received a lobby msg/item that is not PGP-authed (ID=" << item->signature.keyId << "), whereas the lobby flags require it. Rejecting!" << std::endl;
|
||||
|
||||
return ;
|
||||
}
|
||||
}
|
||||
addTimeShiftStatistics((int)now - (int)item->sendTime) ;
|
||||
|
||||
if(now+100 > (time_t) item->sendTime + MAX_KEEP_MSG_RECORD) // the message is older than the max cache keep minus 100 seconds ! It's too old, and is going to make an echo!
|
||||
|
@ -912,10 +959,8 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
|
|||
|
||||
// now sign the object, if the lobby expects it
|
||||
|
||||
if(!IS_ANONYMOUS_LOBBY(lobby.lobby_flags))
|
||||
{
|
||||
uint32_t size = item.signed_serial_size() ;
|
||||
unsigned char *memory = (unsigned char *)malloc(size) ;
|
||||
RsTemporaryMemory memory(size) ;
|
||||
|
||||
if(!item.serialise_signed_part(memory,size))
|
||||
{
|
||||
|
@ -934,12 +979,9 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
|
|||
default: std::cerr << "(EE) Cannot sign item: unknown error" << std::endl;
|
||||
break ;
|
||||
}
|
||||
free(memory) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG_CHAT_LOBBIES
|
||||
std::cerr << " signature done." << std::endl;
|
||||
|
||||
|
@ -953,8 +995,6 @@ bool DistributedChatService::locked_initLobbyBouncableObject(const ChatLobbyId&
|
|||
std::cerr << " Item dump:" << std::endl;
|
||||
item.print(std::cerr,2) ;
|
||||
#endif
|
||||
free(memory) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
|
|
@ -587,7 +587,8 @@ RsGRouterAbstractMsgItem *GRouterDataInfo::addDataChunk(RsGRouterTransactionChun
|
|||
std::cerr << " ERROR: chunk numbering is wrong. Dropping." << std::endl;
|
||||
delete chunk ;
|
||||
delete incoming_data_buffer ;
|
||||
return NULL;
|
||||
incoming_data_buffer = NULL ;
|
||||
return NULL;
|
||||
}
|
||||
incoming_data_buffer->chunk_data = (uint8_t*)realloc((uint8_t*)incoming_data_buffer->chunk_data,incoming_data_buffer->chunk_size + chunk->chunk_size) ;
|
||||
memcpy(&incoming_data_buffer->chunk_data[incoming_data_buffer->chunk_size],chunk->chunk_data,chunk->chunk_size) ;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,15 +29,6 @@
|
|||
#include "gxs/rsgds.h"
|
||||
#include "util/retrodb.h"
|
||||
|
||||
class MsgOffset
|
||||
{
|
||||
public:
|
||||
|
||||
MsgOffset() : msgOffset(0), msgLen(0) {}
|
||||
RsGxsMessageId msgId;
|
||||
uint32_t msgOffset, msgLen;
|
||||
};
|
||||
|
||||
class MsgUpdate
|
||||
{
|
||||
public:
|
||||
|
@ -233,8 +224,9 @@ private:
|
|||
/*!
|
||||
* Creates an sql database and its associated file
|
||||
* also creates the message and groups table
|
||||
* @param isNewDatabase is new database
|
||||
*/
|
||||
void initialise();
|
||||
void initialise(bool isNewDatabase);
|
||||
|
||||
/*!
|
||||
* Remove entries for data base
|
||||
|
@ -243,34 +235,99 @@ private:
|
|||
bool locked_removeMessageEntries(const GxsMsgReq& msgIds);
|
||||
bool locked_removeGroupEntries(const std::vector<RsGxsGroupId>& grpIds);
|
||||
|
||||
typedef std::map<RsGxsGroupId, std::vector<MsgUpdate> > MsgUpdates;
|
||||
private:
|
||||
/*!
|
||||
* Start release update
|
||||
* @param release
|
||||
* @return true/false
|
||||
*/
|
||||
bool startReleaseUpdate(int release);
|
||||
|
||||
/*!
|
||||
* Update messages entries with new values
|
||||
* @param msgIds
|
||||
* @param cv contains values to update message entries with
|
||||
* Finish release update
|
||||
* @param release
|
||||
* @param result
|
||||
* @return true/false
|
||||
*/
|
||||
bool locked_updateMessageEntries(const MsgUpdates& updates);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void locked_getMessageOffsets(const RsGxsGroupId& grpId, std::vector<MsgOffset>& msgOffsets);
|
||||
bool finishReleaseUpdate(int release, bool result);
|
||||
|
||||
private:
|
||||
|
||||
RsMutex mDbMutex;
|
||||
|
||||
std::list<std::string> msgColumns;
|
||||
std::list<std::string> msgMetaColumns;
|
||||
std::list<std::string> mMsgOffSetColumns;
|
||||
std::list<std::string> mMsgColumns;
|
||||
std::list<std::string> mMsgMetaColumns;
|
||||
std::list<std::string> mMsgIdColumn;
|
||||
|
||||
std::list<std::string> grpColumns;
|
||||
std::list<std::string> grpMetaColumns;
|
||||
std::list<std::string> grpIdColumn;
|
||||
std::list<std::string> mGrpColumns;
|
||||
std::list<std::string> mGrpMetaColumns;
|
||||
std::list<std::string> mGrpIdColumn;
|
||||
|
||||
std::string mServiceDir, mDbName;
|
||||
// Message meta column
|
||||
int mColMsgMeta_GrpId;
|
||||
int mColMsgMeta_TimeStamp;
|
||||
int mColMsgMeta_NxsFlags;
|
||||
int mColMsgMeta_SignSet;
|
||||
int mColMsgMeta_NxsIdentity;
|
||||
int mColMsgMeta_NxsHash;
|
||||
int mColMsgMeta_MsgId;
|
||||
int mColMsgMeta_OrigMsgId;
|
||||
int mColMsgMeta_MsgStatus;
|
||||
int mColMsgMeta_ChildTs;
|
||||
int mColMsgMeta_MsgParentId;
|
||||
int mColMsgMeta_MsgThreadId;
|
||||
int mColMsgMeta_Name;
|
||||
int mColMsgMeta_NxsServString;
|
||||
int mColMsgMeta_RecvTs;
|
||||
int mColMsgMeta_NxsDataLen;
|
||||
|
||||
// Message columns
|
||||
int mColMsg_GrpId;
|
||||
int mColMsg_NxsData;
|
||||
int mColMsg_MetaData;
|
||||
int mColMsg_MsgId;
|
||||
|
||||
// Group meta columns
|
||||
int mColGrpMeta_GrpId;
|
||||
int mColGrpMeta_TimeStamp;
|
||||
int mColGrpMeta_NxsFlags;
|
||||
// int mColGrpMeta_SignSet;
|
||||
int mColGrpMeta_NxsIdentity;
|
||||
int mColGrpMeta_NxsHash;
|
||||
int mColGrpMeta_KeySet;
|
||||
int mColGrpMeta_SubscrFlag;
|
||||
int mColGrpMeta_Pop;
|
||||
int mColGrpMeta_MsgCount;
|
||||
int mColGrpMeta_Status;
|
||||
int mColGrpMeta_Name;
|
||||
int mColGrpMeta_LastPost;
|
||||
int mColGrpMeta_OrigGrpId;
|
||||
int mColGrpMeta_ServString;
|
||||
int mColGrpMeta_SignFlags;
|
||||
int mColGrpMeta_CircleId;
|
||||
int mColGrpMeta_CircleType;
|
||||
int mColGrpMeta_InternCircle;
|
||||
int mColGrpMeta_Originator;
|
||||
int mColGrpMeta_AuthenFlags;
|
||||
int mColGrpMeta_ParentGrpId;
|
||||
int mColGrpMeta_RecvTs;
|
||||
int mColGrpMeta_RepCutoff;
|
||||
int mColGrpMeta_NxsDataLen;
|
||||
|
||||
// Group columns
|
||||
int mColGrp_GrpId;
|
||||
int mColGrp_NxsData;
|
||||
int mColGrp_MetaData;
|
||||
|
||||
// Group id columns
|
||||
int mColGrpId_GrpId;
|
||||
|
||||
// Msg id columns
|
||||
int mColMsgId_MsgId;
|
||||
|
||||
std::string mServiceDir;
|
||||
std::string mDbName;
|
||||
std::string mDbPath;
|
||||
uint16_t mServType;
|
||||
|
||||
RetroDb* mDb;
|
||||
|
|
|
@ -908,7 +908,7 @@ int RsGenExchange::validateGrp(RsNxsGrp* grp)
|
|||
PrivacyBitPos pos = GRP_OPTION_BITS;
|
||||
|
||||
// Check required permissions, and allow them to sign it - if they want too - as well!
|
||||
if (!(metaData.mAuthorId.isNull()) || checkAuthenFlag(pos, author_flag))
|
||||
if ((!metaData.mAuthorId.isNull()) || checkAuthenFlag(pos, author_flag))
|
||||
{
|
||||
needIdentitySign = true;
|
||||
std::cerr << "Needs Identity sign! (Service Flags)";
|
||||
|
@ -1718,7 +1718,7 @@ void RsGenExchange::processGrpMetaChanges()
|
|||
// process mask
|
||||
bool ok = processGrpMask(g.grpId, g.val);
|
||||
|
||||
ok &= mDataStore->updateGroupMetaData(g) == 1;
|
||||
ok = ok && (mDataStore->updateGroupMetaData(g) == 1);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
|
@ -1761,6 +1761,12 @@ bool RsGenExchange::processGrpMask(const RsGxsGroupId& grpId, ContentValue &grpC
|
|||
if((mit = grpMetaMap.find(grpId)) != grpMetaMap.end())
|
||||
{
|
||||
grpMeta = mit->second;
|
||||
if (!grpMeta)
|
||||
{
|
||||
std::cerr << "RsGenExchange::processGrpMask() Ignore update for not existing grp id " << grpId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
return false;
|
||||
}
|
||||
ok = true;
|
||||
}
|
||||
|
||||
|
@ -2090,7 +2096,7 @@ void RsGenExchange::processGroupDelete()
|
|||
gprIds.push_back(groupId);
|
||||
mDataStore->removeGroups(gprIds);
|
||||
toNotify.insert(std::make_pair(
|
||||
token, GrpNote(true, RsGxsGroupId())));
|
||||
token, GrpNote(true, groupId)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE = 3;
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE = 4;
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_DONE = 5; // ONCE ALL DATA RETRIEVED.
|
||||
|
||||
const uint8_t RsTokenService::GXS_REQUEST_V2_STATUS_CANCELLED = 6;
|
||||
|
||||
/***********
|
||||
* #define DATA_DEBUG 1
|
||||
|
@ -367,13 +367,19 @@ uint32_t RsGxsDataAccess::requestStatus(uint32_t token)
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool RsGxsDataAccess::cancelRequest(const uint32_t& token)
|
||||
{
|
||||
return clearRequest(token);
|
||||
RsStackMutex stack(mDataMutex); /****** LOCKED *****/
|
||||
|
||||
GxsRequest* req = locked_retrieveRequest(token);
|
||||
if (!req)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
req->status = GXS_REQUEST_V2_STATUS_CANCELLED;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
||||
|
@ -389,7 +395,7 @@ bool RsGxsDataAccess::clearRequest(const uint32_t& token)
|
|||
}
|
||||
|
||||
delete it->second;
|
||||
mRequests.erase(it->first);
|
||||
mRequests.erase(it);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -707,7 +713,6 @@ bool RsGxsDataAccess::getGroupList(const uint32_t& token, std::list<RsGxsGroupId
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token)
|
||||
{
|
||||
|
||||
|
@ -722,15 +727,84 @@ GxsRequest* RsGxsDataAccess::locked_retrieveRequest(const uint32_t& token)
|
|||
|
||||
void RsGxsDataAccess::processRequests()
|
||||
{
|
||||
|
||||
std::list<uint32_t> toClear;
|
||||
std::list<uint32_t>::iterator cit;
|
||||
time_t now = time(NULL);
|
||||
std::map<uint32_t, GxsRequest*>::iterator it;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
||||
|
||||
std::map<uint32_t, GxsRequest*>::iterator it;
|
||||
// process status of the requests
|
||||
for (it = mRequests.begin(); it != mRequests.end(); ++it)
|
||||
{
|
||||
GxsRequest* req = it->second;
|
||||
|
||||
switch (req->status)
|
||||
{
|
||||
case GXS_REQUEST_V2_STATUS_PENDING:
|
||||
// process request later
|
||||
break;
|
||||
case GXS_REQUEST_V2_STATUS_PARTIAL:
|
||||
// should not happen
|
||||
req->status = GXS_REQUEST_V2_STATUS_COMPLETE;
|
||||
break;
|
||||
case GXS_REQUEST_V2_STATUS_DONE:
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: " << req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
break;
|
||||
case GXS_REQUEST_V2_STATUS_CANCELLED:
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Cancelled Request Token: " << req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
break;
|
||||
default:
|
||||
if (now - req->reqTime > MAX_REQUEST_AGE)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Old Request Token: " << req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // END OF MUTEX.
|
||||
|
||||
// clear requests
|
||||
std::list<uint32_t>::iterator cit;
|
||||
for (cit = toClear.begin(); cit != toClear.end(); ++cit)
|
||||
{
|
||||
clearRequest(*cit);
|
||||
}
|
||||
|
||||
// process requests
|
||||
while (true)
|
||||
{
|
||||
GxsRequest* req = NULL;
|
||||
{
|
||||
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
||||
|
||||
// get the first pending request
|
||||
for (it = mRequests.begin(); it != mRequests.end(); ++it)
|
||||
{
|
||||
GxsRequest* reqCheck = it->second;
|
||||
if (reqCheck->status == GXS_REQUEST_V2_STATUS_PENDING)
|
||||
{
|
||||
req = reqCheck;
|
||||
req->status = GXS_REQUEST_V2_STATUS_PARTIAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // END OF MUTEX.
|
||||
|
||||
if (!req) {
|
||||
break;
|
||||
}
|
||||
|
||||
GroupMetaReq* gmr;
|
||||
GroupDataReq* gdr;
|
||||
|
@ -739,101 +813,69 @@ void RsGxsDataAccess::processRequests()
|
|||
MsgMetaReq* mmr;
|
||||
MsgDataReq* mdr;
|
||||
MsgIdReq* mir;
|
||||
MsgRelatedInfoReq* mri;
|
||||
GroupStatisticRequest* gsr;
|
||||
ServiceStatisticRequest* ssr;
|
||||
MsgRelatedInfoReq* mri;
|
||||
GroupStatisticRequest* gsr;
|
||||
ServiceStatisticRequest* ssr;
|
||||
|
||||
for(it = mRequests.begin(); it != mRequests.end(); ++it)
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Processing Token: " << req->token << " Status: "
|
||||
<< req->status << " ReqType: " << req->reqType << " Age: "
|
||||
<< now - req->reqTime << std::endl;
|
||||
#endif
|
||||
|
||||
/* PROCESS REQUEST! */
|
||||
bool ok = false;
|
||||
|
||||
if((gmr = dynamic_cast<GroupMetaReq*>(req)) != NULL)
|
||||
{
|
||||
|
||||
GxsRequest* req = it->second;
|
||||
if (req->status == GXS_REQUEST_V2_STATUS_PENDING)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Processing Token: " << req->token << " Status: "
|
||||
<< req->status << " ReqType: " << req->reqType << " Age: "
|
||||
<< now - req->reqTime << std::endl;
|
||||
#endif
|
||||
|
||||
req->status = GXS_REQUEST_V2_STATUS_PARTIAL;
|
||||
|
||||
/* PROCESS REQUEST! */
|
||||
|
||||
if((gmr = dynamic_cast<GroupMetaReq*>(req)) != NULL)
|
||||
{
|
||||
getGroupSummary(gmr);
|
||||
}
|
||||
else if((gdr = dynamic_cast<GroupDataReq*>(req)) != NULL)
|
||||
{
|
||||
getGroupData(gdr);
|
||||
}
|
||||
else if((gir = dynamic_cast<GroupIdReq*>(req)) != NULL)
|
||||
{
|
||||
getGroupList(gir);
|
||||
}
|
||||
else if((mmr = dynamic_cast<MsgMetaReq*>(req)) != NULL)
|
||||
{
|
||||
getMsgSummary(mmr);
|
||||
}
|
||||
else if((mdr = dynamic_cast<MsgDataReq*>(req)) != NULL)
|
||||
{
|
||||
getMsgData(mdr);
|
||||
}
|
||||
else if((mir = dynamic_cast<MsgIdReq*>(req)) != NULL)
|
||||
{
|
||||
getMsgList(mir);
|
||||
}
|
||||
else if((mri = dynamic_cast<MsgRelatedInfoReq*>(req)) != NULL)
|
||||
{
|
||||
getMsgRelatedInfo(mri);
|
||||
}
|
||||
else if((gsr = dynamic_cast<GroupStatisticRequest*>(req)) != NULL)
|
||||
{
|
||||
getGroupStatistic(gsr);
|
||||
}
|
||||
else if((ssr = dynamic_cast<ServiceStatisticRequest*>(req)) != NULL)
|
||||
{
|
||||
getServiceStatistic(ssr);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
<< req->token << std::endl;
|
||||
|
||||
req->status = GXS_REQUEST_V2_STATUS_FAILED;
|
||||
}
|
||||
}
|
||||
else if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL)
|
||||
{
|
||||
req->status = GXS_REQUEST_V2_STATUS_COMPLETE;
|
||||
}
|
||||
else if (req->status == GXS_REQUEST_V2_STATUS_DONE)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Done Request Token: "
|
||||
<< req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
}
|
||||
else if (now - req->reqTime > MAX_REQUEST_AGE)
|
||||
{
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << "RsGxsDataAccess::processrequests() Clearing Old Request Token: " << req->token;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
toClear.push_back(req->token);
|
||||
}
|
||||
ok = getGroupSummary(gmr);
|
||||
}
|
||||
else if((gdr = dynamic_cast<GroupDataReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupData(gdr);
|
||||
}
|
||||
else if((gir = dynamic_cast<GroupIdReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupList(gir);
|
||||
}
|
||||
else if((mmr = dynamic_cast<MsgMetaReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getMsgSummary(mmr);
|
||||
}
|
||||
else if((mdr = dynamic_cast<MsgDataReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getMsgData(mdr);
|
||||
}
|
||||
else if((mir = dynamic_cast<MsgIdReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getMsgList(mir);
|
||||
}
|
||||
else if((mri = dynamic_cast<MsgRelatedInfoReq*>(req)) != NULL)
|
||||
{
|
||||
ok = getMsgRelatedInfo(mri);
|
||||
}
|
||||
else if((gsr = dynamic_cast<GroupStatisticRequest*>(req)) != NULL)
|
||||
{
|
||||
ok = getGroupStatistic(gsr);
|
||||
}
|
||||
else if((ssr = dynamic_cast<ServiceStatisticRequest*>(req)) != NULL)
|
||||
{
|
||||
ok = getServiceStatistic(ssr);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "RsGxsDataAccess::processRequests() Failed to process request, token: "
|
||||
<< req->token << std::endl;
|
||||
}
|
||||
|
||||
} // END OF MUTEX.
|
||||
|
||||
for(cit = toClear.begin(); cit != toClear.end(); ++cit)
|
||||
{
|
||||
clearRequest(*cit);
|
||||
{
|
||||
RsStackMutex stack(mDataMutex); /******* LOCKED *******/
|
||||
if (req->status == GXS_REQUEST_V2_STATUS_PARTIAL)
|
||||
{
|
||||
req->status = ok ? GXS_REQUEST_V2_STATUS_COMPLETE : GXS_REQUEST_V2_STATUS_FAILED;
|
||||
}
|
||||
} // END OF MUTEX.
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool RsGxsDataAccess::getGroupStatistic(const uint32_t &token, GxsGroupStatistic &grpStatistic)
|
||||
|
@ -1719,7 +1761,7 @@ bool RsGxsDataAccess::checkRequestStatus(const uint32_t& token,
|
|||
|
||||
GxsRequest* req = locked_retrieveRequest(token);
|
||||
|
||||
if(req == NULL)
|
||||
if (req == NULL || req->status == GXS_REQUEST_V2_STATUS_CANCELLED)
|
||||
return false;
|
||||
|
||||
anstype = req->ansType;
|
||||
|
|
|
@ -235,6 +235,10 @@ void RsGxsNetService::syncWithPeers()
|
|||
|
||||
std::set<RsPeerId> peers;
|
||||
mNetMgr->getOnlineList(mServiceInfo.mServiceType, peers);
|
||||
if (peers.empty()) {
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
|
||||
std::set<RsPeerId>::iterator sit = peers.begin();
|
||||
|
||||
|
@ -1160,7 +1164,7 @@ void RsGxsNetService::data_tick()
|
|||
//Start waiting as nothing to do in runup
|
||||
usleep((int) (timeDelta * 1000 * 1000)); // timeDelta sec
|
||||
|
||||
if(mUpdateCounter >= 20)
|
||||
if(mUpdateCounter >= 120) // 60 seconds
|
||||
{
|
||||
updateServerSyncTS();
|
||||
mUpdateCounter = 0;
|
||||
|
@ -2156,6 +2160,9 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
std::cerr << "locked_genReqGrpTransaction(): " << std::endl;
|
||||
#endif
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetaMap;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator metaIter;
|
||||
|
||||
std::list<RsNxsSyncGrpItem*> grpItemL;
|
||||
std::list<RsNxsItem*>::iterator lit = tr->mItems.begin();
|
||||
|
||||
|
@ -2165,6 +2172,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
if(item)
|
||||
{
|
||||
grpItemL.push_back(item);
|
||||
grpMetaMap[item->grpId] = NULL;
|
||||
}else
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG
|
||||
|
@ -2174,8 +2182,11 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
}
|
||||
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetaMap;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*>::const_iterator metaIter;
|
||||
if (grpItemL.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mDataStore->retrieveGxsGrpMetaData(grpMetaMap);
|
||||
|
||||
// now do compare and add loop
|
||||
|
@ -2195,7 +2206,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
metaIter = grpMetaMap.find(grpId);
|
||||
bool haveItem = false;
|
||||
bool latestVersion = false;
|
||||
if (metaIter != grpMetaMap.end())
|
||||
if (metaIter != grpMetaMap.end() && metaIter->second)
|
||||
{
|
||||
haveItem = true;
|
||||
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
!include("../../retroshare.pri"): error("Could not include file ../../retroshare.pri")
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib bitdht
|
||||
CONFIG += create_prl
|
||||
CONFIG -= qt
|
||||
TARGET = retroshare
|
||||
TARGET_PRL = libretroshare
|
||||
|
||||
|
||||
#GXS Stuff.
|
||||
# This should be disabled for releases until further notice.
|
||||
CONFIG += gxs debug
|
||||
CONFIG += gxs
|
||||
|
||||
#CONFIG += dsdv
|
||||
|
||||
|
@ -19,7 +23,6 @@ profiling {
|
|||
#QMAKE_CFLAGS += -Werror
|
||||
#QMAKE_CXXFLAGS += -Werror
|
||||
|
||||
CONFIG += debug
|
||||
debug {
|
||||
# DEFINES *= DEBUG
|
||||
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
|
||||
|
@ -81,6 +84,8 @@ SOURCES += tcponudp/udppeer.cc \
|
|||
# The next line is for compliance with debian packages. Keep it!
|
||||
INCLUDEPATH += ../libbitdht
|
||||
DEFINES *= RS_USE_BITDHT
|
||||
PRE_TARGETDEPS *= ../../libbitdht/src/lib/libbitdht.a
|
||||
LIBS += ../../libbitdht/src/lib/libbitdht.a
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,10 +125,6 @@ HEADERS += $$PUBLIC_HEADERS
|
|||
|
||||
################################# Linux ##########################################
|
||||
linux-* {
|
||||
isEmpty(PREFIX) { PREFIX = /usr }
|
||||
isEmpty(INC_DIR) { INC_DIR = $${PREFIX}/include/retroshare/ }
|
||||
isEmpty(LIB_DIR) { LIB_DIR = $${PREFIX}/lib/ }
|
||||
|
||||
# These two lines fixe compilation on ubuntu natty. Probably a ubuntu packaging error.
|
||||
INCLUDEPATH += $$system(pkg-config --cflags glib-2.0 | sed -e "s/-I//g")
|
||||
|
||||
|
@ -140,27 +141,25 @@ linux-* {
|
|||
DEPENDPATH += . $${SSL_DIR} $${UPNP_DIR}
|
||||
INCLUDEPATH += . $${SSL_DIR} $${UPNP_DIR}
|
||||
|
||||
# where to put the shared library itself
|
||||
target.path = $$LIB_DIR
|
||||
INSTALLS *= target
|
||||
|
||||
SQLCIPHER_OK = $$system(pkg-config --exists sqlcipher && echo yes)
|
||||
isEmpty(SQLCIPHER_OK) {
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
!exists(../../../lib/sqlcipher/.libs/libsqlcipher.a) {
|
||||
message(libsqlcipher.a not found. Compilation will not use SQLCIPER. Database will be unencrypted.)
|
||||
DEFINES *= NO_SQLCIPHER
|
||||
contains(CONFIG, NO_SQLCIPHER) {
|
||||
DEFINES *= NO_SQLCIPHER
|
||||
LIBS *= -lsqlite3
|
||||
} else {
|
||||
SQLCIPHER_OK = $$system(pkg-config --exists sqlcipher && echo yes)
|
||||
isEmpty(SQLCIPHER_OK) {
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
exists(../../../lib/sqlcipher/.libs/libsqlcipher.a) {
|
||||
LIBS += ../../../lib/sqlcipher/.libs/libsqlcipher.a
|
||||
DEPENDPATH += ../../../lib/
|
||||
INCLUDEPATH += ../../../lib/
|
||||
} else {
|
||||
error("libsqlcipher is not installed and libsqlcipher.a not found. SQLCIPHER is necessary for encrypted database, to build with unencrypted database, run: qmake CONFIG+=NO_SQLCIPHER")
|
||||
}
|
||||
} else {
|
||||
DEPENDPATH += ../../../lib/
|
||||
INCLUDEPATH += ../../../lib/
|
||||
LIBS *= -lsqlcipher
|
||||
}
|
||||
}
|
||||
|
||||
# where to put the librarys interface
|
||||
include_rsiface.path = $${INC_DIR}
|
||||
include_rsiface.files = $$PUBLIC_HEADERS
|
||||
INSTALLS += include_rsiface
|
||||
|
||||
#CONFIG += version_detail_bash_script
|
||||
|
||||
|
||||
|
@ -179,6 +178,22 @@ linux-* {
|
|||
DEFINES *= UBUNTU
|
||||
INCLUDEPATH += /usr/include/glib-2.0/ /usr/lib/glib-2.0/include
|
||||
LIBS *= -lgnome-keyring
|
||||
LIBS *= -lssl -lupnp -lixml
|
||||
LIBS *= -lcrypto -lz -lpthread
|
||||
}
|
||||
|
||||
unix {
|
||||
DEFINES *= LIB_DIR=\"\\\"$${LIB_DIR}\\\"\"
|
||||
DEFINES *= DATA_DIR=\"\\\"$${DATA_DIR}\\\"\"
|
||||
|
||||
## where to put the librarys interface
|
||||
#include_rsiface.path = "$${INC_DIR}"
|
||||
#include_rsiface.files = $$PUBLIC_HEADERS
|
||||
#INSTALLS += include_rsiface
|
||||
|
||||
## where to put the shared library itself
|
||||
#target.path = "$$LIB_DIR"
|
||||
#INSTALLS *= target
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
|
@ -190,9 +205,16 @@ linux-g++-64 {
|
|||
}
|
||||
|
||||
version_detail_bash_script {
|
||||
QMAKE_EXTRA_TARGETS += write_version_detail
|
||||
PRE_TARGETDEPS = write_version_detail
|
||||
write_version_detail.commands = ./version_detail.sh
|
||||
linux-* {
|
||||
QMAKE_EXTRA_TARGETS += write_version_detail
|
||||
PRE_TARGETDEPS = write_version_detail
|
||||
write_version_detail.commands = ./version_detail.sh
|
||||
}
|
||||
win32 {
|
||||
QMAKE_EXTRA_TARGETS += write_version_detail
|
||||
PRE_TARGETDEPS = write_version_detail
|
||||
write_version_detail.commands = $$PWD/version_detail.bat
|
||||
}
|
||||
}
|
||||
|
||||
#################### Cross compilation for windows under Linux ####################
|
||||
|
@ -318,6 +340,10 @@ openbsd-* {
|
|||
|
||||
################################### COMMON stuff ##################################
|
||||
|
||||
# openpgpsdk
|
||||
PRE_TARGETDEPS *= ../../openpgpsdk/src/lib/libops.a
|
||||
LIBS *= ../../openpgpsdk/src/lib/libops.a -lbz2
|
||||
|
||||
HEADERS += dbase/cachestrapper.h \
|
||||
dbase/fimonitor.h \
|
||||
dbase/findex.h \
|
||||
|
@ -477,6 +503,7 @@ HEADERS += util/folderiterator.h \
|
|||
util/rsmemcache.h \
|
||||
util/rstickevent.h \
|
||||
util/rsrecogn.h \
|
||||
util/rsscopetimer.h
|
||||
|
||||
SOURCES += dbase/cachestrapper.cc \
|
||||
dbase/fimonitor.cc \
|
||||
|
@ -626,6 +653,7 @@ SOURCES += util/folderiterator.cc \
|
|||
util/rsrandom.cc \
|
||||
util/rstickevent.cc \
|
||||
util/rsrecogn.cc \
|
||||
util/rsscopetimer.cc
|
||||
|
||||
|
||||
upnp_miniupnpc {
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
set QTDIR=C:\Qt\4.8.6
|
||||
set MINGW=C:\MinGW
|
||||
set GIT=C:\Program Files\Git
|
||||
|
||||
set PATH=%QTDIR%\bin;%MINGW%\bin;%PATH%
|
||||
set PATH=%QTDIR%\bin;%MINGW%\bin;;%GIT%\bin;%PATH%
|
||||
|
||||
"c:\Program Files\TortoiseSVN\bin\SubWCRev" . retroshare\rsversion.in retroshare\rsversion.h
|
||||
mingw32-make clean
|
||||
|
||||
mingw32-make clean
|
||||
|
||||
qmake libretroshare.pro
|
||||
qmake libretroshare.pro "CONFIG+=version_detail_bash_script"
|
||||
|
||||
mingw32-make
|
||||
|
||||
|
|
|
@ -99,7 +99,17 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
|
|||
enabled = true;
|
||||
}
|
||||
|
||||
// not handled: private distant chat
|
||||
if (cm.chat_id.isGxsId() && mPrivateEnable == true) {
|
||||
if (cm.incoming) {
|
||||
peerName = cm.chat_id.toGxsId().toStdString();
|
||||
} else {
|
||||
uint32_t status;
|
||||
RsGxsId from_gxs_id;
|
||||
if (rsMsgs->getDistantChatStatus(cm.chat_id.toGxsId(), status, &from_gxs_id))
|
||||
peerName = from_gxs_id.toStdString();
|
||||
}
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
if(enabled == false)
|
||||
return;
|
||||
|
@ -115,11 +125,6 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
|
|||
item->sendTime = cm.sendTime;
|
||||
item->recvTime = cm.recvTime;
|
||||
|
||||
if (cm.chat_id.isLobbyId()) {
|
||||
// disable save to disc for chat lobbies until they are saved
|
||||
item->saveToDisc = false;
|
||||
}
|
||||
|
||||
item->message = cm.msg ;
|
||||
//librs::util::ConvertUtf16ToUtf8(chatItem->message, item->message);
|
||||
|
||||
|
@ -392,7 +397,10 @@ bool p3HistoryMgr::chatIdToVirtualPeerId(ChatId chat_id, RsPeerId &peer_id)
|
|||
return true;
|
||||
}
|
||||
|
||||
// not handled: private distant chat
|
||||
if (chat_id.isGxsId()) {
|
||||
peer_id = RsPeerId(chat_id.toGxsId());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -428,6 +436,9 @@ bool p3HistoryMgr::getMessages(const ChatId &chatId, std::list<HistoryMsg> &msgs
|
|||
if (chatId.isLobbyId() && mLobbyEnable == true) {
|
||||
enabled = true;
|
||||
}
|
||||
if (chatId.isGxsId() && mPrivateEnable == true) {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
if(enabled == false)
|
||||
return false;
|
||||
|
|
|
@ -1322,7 +1322,9 @@ int pqissl::Authorise_SSL_Connection()
|
|||
|
||||
if(!rsBanList->isAddressAccepted(remote_addr,checking_flags,&check_result))
|
||||
{
|
||||
std::cerr << "(SS) connection attempt from banned IP address " << sockaddr_storage_iptostring(remote_addr) << ". Refusing it. Reason: " << check_result << ". Attack??" << std::endl;
|
||||
std::cerr << "(SS) refusing connection attempt from IP address " << sockaddr_storage_iptostring(remote_addr) << ". Reason: " <<
|
||||
((check_result == RSBANLIST_CHECK_RESULT_NOT_WHITELISTED)?"not whitelisted (peer requires whitelist)":"blacklisted") << std::endl;
|
||||
|
||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_IP_BLACKLISTED, PeerId().toStdString(), sockaddr_storage_iptostring(remote_addr), "", "", check_result);
|
||||
reset_locked();
|
||||
return 0 ;
|
||||
|
@ -1825,6 +1827,12 @@ bool pqissl::moretoread(uint32_t usec)
|
|||
}
|
||||
#endif
|
||||
|
||||
if(sockfd == -1)
|
||||
{
|
||||
std::cerr << "pqissl::moretoread(): socket is invalid or closed." << std::endl;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
fd_set ReadFDs, WriteFDs, ExceptFDs;
|
||||
FD_ZERO(&ReadFDs);
|
||||
FD_ZERO(&WriteFDs);
|
||||
|
@ -1887,6 +1895,12 @@ bool pqissl::cansend(uint32_t usec)
|
|||
"pqissl::cansend() polling socket!");
|
||||
#endif
|
||||
|
||||
if(sockfd == -1)
|
||||
{
|
||||
std::cerr << "pqissl::cansend(): socket is invalid or closed." << std::endl;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
// Interestingly - This code might be portable....
|
||||
|
||||
fd_set ReadFDs, WriteFDs, ExceptFDs;
|
||||
|
|
0
libretroshare/src/retroshare/rsexpr.h
Executable file → Normal file
0
libretroshare/src/retroshare/rsexpr.h
Executable file → Normal file
|
@ -28,6 +28,7 @@ template<int n> class t_RsFlags32
|
|||
|
||||
inline t_RsFlags32<n> operator| (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits | f._bits) ; }
|
||||
inline t_RsFlags32<n> operator^ (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits ^ f._bits) ; }
|
||||
inline t_RsFlags32<n> operator* (const t_RsFlags32<n>& f) const { return t_RsFlags32<n>(_bits & f._bits) ; }
|
||||
|
||||
inline bool operator!=(const t_RsFlags32<n>& f) const { return _bits != f._bits ; }
|
||||
inline bool operator==(const t_RsFlags32<n>& f) const { return _bits == f._bits ; }
|
||||
|
|
|
@ -90,9 +90,10 @@
|
|||
#define RS_CHAT_TYPE_DISTANT 4
|
||||
|
||||
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_AUTO_SUBSCRIBE( 0x00000001 ) ;
|
||||
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_ANONYMOUS ( 0x00000002 ) ;
|
||||
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_deprecated ( 0x00000002 ) ;
|
||||
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PUBLIC ( 0x00000004 ) ;
|
||||
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_CHALLENGE ( 0x00000008 ) ;
|
||||
const ChatLobbyFlags RS_CHAT_LOBBY_FLAGS_PGP_SIGNED ( 0x00000010 ) ; // requires the signing ID to be PGP-linked. Avoids anonymous crap.
|
||||
|
||||
typedef uint64_t ChatLobbyId ;
|
||||
typedef uint64_t ChatLobbyMsgId ;
|
||||
|
|
|
@ -121,6 +121,7 @@ public:
|
|||
static const uint8_t GXS_REQUEST_V2_STATUS_FINISHED_INCOMPLETE;
|
||||
static const uint8_t GXS_REQUEST_V2_STATUS_COMPLETE;
|
||||
static const uint8_t GXS_REQUEST_V2_STATUS_DONE; // ONCE ALL DATA RETRIEVED.
|
||||
static const uint8_t GXS_REQUEST_V2_STATUS_CANCELLED;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -2,4 +2,11 @@
|
|||
#define RS_MINOR_VERSION 6
|
||||
#define RS_BUILD_NUMBER 0
|
||||
#define RS_BUILD_NUMBER_ADD "x" // <-- do we need this?
|
||||
#define RS_REVISION_NUMBER 0001
|
||||
|
||||
// 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
|
||||
|
|
|
@ -2,4 +2,11 @@
|
|||
#define RS_MINOR_VERSION 6
|
||||
#define RS_BUILD_NUMBER 0
|
||||
#define RS_BUILD_NUMBER_ADD "x" // <-- do we need this?
|
||||
#define RS_REVISION_NUMBER $WCREV$
|
||||
|
||||
// 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 "$REV$"
|
||||
#define RS_REVISION_NUMBER 0x$REV$
|
||||
|
|
|
@ -781,9 +781,12 @@ static bool checkAccount(std::string accountdir, AccountDetails &account,std::ma
|
|||
std::cerr << "getRetroshareDataDirectory() BSD: " << dataDirectory;
|
||||
|
||||
#else
|
||||
/* For Linux, we have a fixed standard data directory */
|
||||
dataDirectory = "/usr/share/RetroShare06";
|
||||
std::cerr << "getRetroshareDataDirectory() Linux: " << dataDirectory;
|
||||
/* 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
|
||||
|
|
|
@ -1251,7 +1251,7 @@ int RsServer::StartupRetroShare()
|
|||
std::vector<std::string> plugins_directories ;
|
||||
|
||||
#ifndef WINDOWS_SYS
|
||||
plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions6/")) ;
|
||||
plugins_directories.push_back(std::string(LIB_DIR) + "/retroshare/extensions6/") ;
|
||||
#endif
|
||||
std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ;
|
||||
plugins_directories.push_back(extensions_dir) ;
|
||||
|
|
|
@ -602,6 +602,11 @@ bool GetTlvString(void *data, uint32_t size, uint32_t *offset,
|
|||
in = std::string(strdata, strsize);
|
||||
}
|
||||
|
||||
#ifdef TLV_BASE_DEBUG
|
||||
if(type == TLV_TYPE_STR_MSG)
|
||||
std::cerr << "Checking string \"" << in << "\"" << std::endl;
|
||||
#endif
|
||||
|
||||
// Check for string content. We want to avoid possible lol bombs as soon as possible.
|
||||
|
||||
static const int number_of_suspiscious_strings = 4 ;
|
||||
|
|
|
@ -649,7 +649,6 @@ bool RsTlvKeySignatureSet::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
|||
|
||||
/* get the next type */
|
||||
uint16_t tlvsubtype = GetTlvType( &(((uint8_t *) data)[*offset]) );
|
||||
SignType currType;
|
||||
|
||||
switch(tlvsubtype)
|
||||
{
|
||||
|
@ -659,16 +658,13 @@ bool RsTlvKeySignatureSet::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
|||
ok &= sign.GetTlv(data, size, offset);
|
||||
if (ok)
|
||||
{
|
||||
keySignSet[currType] = sign;
|
||||
keySignSet[sign_type] = sign;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TLV_TYPE_KEYSIGNATURETYPE:
|
||||
{
|
||||
ok = GetTlvUInt32(data, size, offset, TLV_TYPE_KEYSIGNATURETYPE, &sign_type);
|
||||
|
||||
if(ok)
|
||||
currType = sign_type;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -718,7 +718,9 @@ bool p3IdService::validateData(const uint8_t *data,uint32_t data_size,const RsTl
|
|||
|
||||
if(signature_key.keyData.bin_data == NULL)
|
||||
{
|
||||
#ifdef DEBUG_IDS
|
||||
std::cerr << "(EE) Cannot validate signature for unknown key " << signature.keyId << std::endl;
|
||||
#endif
|
||||
signing_error = RS_GIXS_ERROR_KEY_NOT_AVAILABLE ;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
@echo off
|
||||
"D:\Programme\TortoiseSVN\bin\SubWCRev" . util\rsversion.in util\rsversion.h
|
|
@ -183,12 +183,11 @@ RetroCursor* RetroDb::sqlQuery(const std::string& tableName, const std::list<std
|
|||
std::list<std::string>::const_iterator it = columns.begin();
|
||||
|
||||
for(; it != columns.end(); ++it){
|
||||
columnSelection += *it;
|
||||
|
||||
++it;
|
||||
if(it != columns.end())
|
||||
if (it != columns.begin()) {
|
||||
columnSelection += ",";
|
||||
--it;
|
||||
}
|
||||
|
||||
columnSelection += *it;
|
||||
}
|
||||
|
||||
// construct query
|
||||
|
@ -265,6 +264,32 @@ std::string RetroDb::getKey() const
|
|||
return mKey;
|
||||
}
|
||||
|
||||
bool RetroDb::beginTransaction()
|
||||
{
|
||||
if (!isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return execSQL("BEGIN;");
|
||||
}
|
||||
|
||||
bool RetroDb::commitTransaction()
|
||||
{
|
||||
if (!isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return execSQL("COMMIT;");
|
||||
}
|
||||
bool RetroDb::rollbackTransaction()
|
||||
{
|
||||
if (!isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return execSQL("ROLLBACK;");
|
||||
}
|
||||
|
||||
bool RetroDb::execSQL_bind(const std::string &query, std::list<RetroBind*> ¶mBindings){
|
||||
|
||||
// prepare statement
|
||||
|
@ -532,6 +557,43 @@ bool RetroDb::sqlUpdate(const std::string &tableName, std::string whereClause, c
|
|||
return execSQL_bind(sqlQuery, paramBindings);
|
||||
}
|
||||
|
||||
bool RetroDb::tableExists(const std::string &tableName)
|
||||
{
|
||||
if (!isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string sqlQuery = "PRAGMA table_info(" + tableName + ");";
|
||||
|
||||
bool result = false;
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
||||
int rc = sqlite3_prepare_v2(mDb, sqlQuery.c_str(), sqlQuery.length(), &stmt, NULL);
|
||||
if (rc == SQLITE_OK) {
|
||||
rc = sqlite3_step(stmt);
|
||||
switch (rc) {
|
||||
case SQLITE_ROW:
|
||||
result = true;
|
||||
break;
|
||||
case SQLITE_DONE:
|
||||
break;
|
||||
default:
|
||||
std::cerr << "RetroDb::tableExists(): Error executing statement (code: " << rc << ")"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "RetroDb::tableExists(): Error preparing statement\n";
|
||||
std::cerr << "Error code: " << sqlite3_errmsg(mDb)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
if (stmt) {
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/********************** RetroCursor ************************/
|
||||
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
|
||||
#include "contentvalue.h"
|
||||
|
||||
|
||||
|
||||
class RetroCursor;
|
||||
|
||||
/*!
|
||||
|
@ -90,7 +88,23 @@ public:
|
|||
/* modifying db */
|
||||
public:
|
||||
|
||||
/*!
|
||||
* Start transaction
|
||||
* @return true/false
|
||||
*/
|
||||
bool beginTransaction();
|
||||
|
||||
/*!
|
||||
* Commit transaction
|
||||
* @return true/false
|
||||
*/
|
||||
bool commitTransaction();
|
||||
|
||||
/*!
|
||||
* Rollback transaction
|
||||
* @return true/false
|
||||
*/
|
||||
bool rollbackTransaction();
|
||||
|
||||
/*!
|
||||
* To a make query which do not return a result \n
|
||||
|
@ -153,22 +167,13 @@ public:
|
|||
*/
|
||||
void vacuum();
|
||||
|
||||
|
||||
/*!
|
||||
* Build the "VALUE" part of an insertiong sql query
|
||||
* @param parameter contains place holder query
|
||||
* @param paramBindings
|
||||
* Check if table exist in database
|
||||
* @param tableName table to check
|
||||
* @return true/false
|
||||
*/
|
||||
void buildInsertQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
||||
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
||||
bool tableExists(const std::string& tableName);
|
||||
|
||||
/*!
|
||||
* Build the "VALUE" part of an insertiong sql query
|
||||
* @param parameter contains place holder query
|
||||
* @param paramBindings
|
||||
*/
|
||||
void buildUpdateQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
||||
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
||||
public:
|
||||
|
||||
static const int OPEN_READONLY;
|
||||
|
@ -179,6 +184,22 @@ private:
|
|||
|
||||
bool execSQL_bind(const std::string &query, std::list<RetroBind*>& blobs);
|
||||
|
||||
/*!
|
||||
* Build the "VALUE" part of an insertiong sql query
|
||||
* @param parameter contains place holder query
|
||||
* @param paramBindings
|
||||
*/
|
||||
void buildInsertQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
||||
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
||||
|
||||
/*!
|
||||
* Build the "VALUE" part of an insertiong sql query
|
||||
* @param parameter contains place holder query
|
||||
* @param paramBindings
|
||||
*/
|
||||
void buildUpdateQueryValue(const std::map<std::string, uint8_t> keyMap, const ContentValue& cv,
|
||||
std::string& parameter, std::list<RetroBind*>& paramBindings);
|
||||
|
||||
private:
|
||||
|
||||
sqlite3* mDb;
|
||||
|
|
59
libretroshare/src/util/rsscopetimer.cc
Normal file
59
libretroshare/src/util/rsscopetimer.cc
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* libretroshare/src/util: rsscopetimer.cc
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2013- by Cyril Soler
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/time.h>
|
||||
#include "rsscopetimer.h"
|
||||
|
||||
RsScopeTimer::RsScopeTimer(const std::string& name)
|
||||
{
|
||||
_name = name ;
|
||||
start();
|
||||
}
|
||||
|
||||
RsScopeTimer::~RsScopeTimer()
|
||||
{
|
||||
if (!_name.empty())
|
||||
{
|
||||
std::cerr << "Time for \"" << _name << "\": " << duration() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
double RsScopeTimer::currentTime()
|
||||
{
|
||||
timeval tv ;
|
||||
gettimeofday(&tv,NULL) ;
|
||||
return (tv.tv_sec % 10000) + tv.tv_usec/1000000.0f ; // the %1000 is here to allow double precision to cover the decimals.
|
||||
}
|
||||
|
||||
void RsScopeTimer::start()
|
||||
{
|
||||
_seconds = currentTime();
|
||||
}
|
||||
|
||||
double RsScopeTimer::duration()
|
||||
{
|
||||
return currentTime() - _seconds;
|
||||
}
|
|
@ -31,29 +31,22 @@
|
|||
// callToMeasure() ;
|
||||
// }
|
||||
//
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class RsScopeTimer
|
||||
{
|
||||
public:
|
||||
RsScopeTimer(const std::string& name)
|
||||
{
|
||||
timeval tv ;
|
||||
gettimeofday(&tv,NULL) ;
|
||||
_seconds = (tv.tv_sec % 10000) + tv.tv_usec/1000000.0f ; // the %1000 is here to allow double precision to cover the decimals.
|
||||
_name = name ;
|
||||
}
|
||||
public:
|
||||
RsScopeTimer(const std::string& name);
|
||||
~RsScopeTimer();
|
||||
|
||||
~RsScopeTimer()
|
||||
{
|
||||
timeval tv ;
|
||||
gettimeofday(&tv,NULL) ;
|
||||
double ss = (tv.tv_sec % 10000) + tv.tv_usec/1000000.0f ;
|
||||
void start();
|
||||
double duration();
|
||||
|
||||
std::cerr << "Time for \"" << _name << "\": " << ss - _seconds << std::endl;
|
||||
}
|
||||
private:
|
||||
double currentTime();
|
||||
|
||||
private:
|
||||
std::string _name ;
|
||||
double _seconds ;
|
||||
private:
|
||||
std::string _name ;
|
||||
double _seconds ;
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
std::string RsUtil::retroshareVersion()
|
||||
{
|
||||
std::string version;
|
||||
rs_sprintf(version, "%d.%d.%d%s Revision %d", RS_MAJOR_VERSION, RS_MINOR_VERSION, RS_BUILD_NUMBER, RS_BUILD_NUMBER_ADD, RS_REVISION_NUMBER);
|
||||
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;
|
||||
}
|
||||
|
|
48
libretroshare/src/version_detail.bat
Normal file
48
libretroshare/src/version_detail.bat
Normal file
|
@ -0,0 +1,48 @@
|
|||
@echo off
|
||||
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
:: Search git in PATH
|
||||
set GitPath=
|
||||
for %%P in ("%PATH:;=" "%") do (
|
||||
if exist "%%~P.\git.exe" (
|
||||
set GitPath=%%~P
|
||||
goto found_git
|
||||
)
|
||||
)
|
||||
|
||||
:found_git
|
||||
if "%GitPath%"=="" (
|
||||
echo git not found in PATH. Version update cancelled.
|
||||
endlocal
|
||||
exit /B 0
|
||||
)
|
||||
|
||||
echo Update version
|
||||
|
||||
:: Retrieve git information
|
||||
set RsHash=
|
||||
|
||||
pushd "%~dp0"
|
||||
for /f "tokens=1*" %%A in ('"git log --pretty=format:"%%H" --max-count=1"') do set RsHash=%%A
|
||||
popd
|
||||
|
||||
if "%RsHash%"=="" (
|
||||
echo Git hash not found.
|
||||
endlocal
|
||||
exit /B 1
|
||||
)
|
||||
|
||||
:: Create file
|
||||
set InFile=%~dp0retroshare\rsversion.in
|
||||
set OutFile=%~dp0retroshare\rsversion.h
|
||||
if exist "%OutFile%" del /Q "%OutFile%"
|
||||
|
||||
for /f "tokens=* delims= " %%a in (%InFile%) do (
|
||||
set line=%%a
|
||||
set line=!line:$REV$=%RsHash:~0,8%!
|
||||
echo !line!>>"%OutFile%"
|
||||
)
|
||||
|
||||
endlocal
|
||||
exit /B 0
|
|
@ -5,24 +5,24 @@ set +e
|
|||
|
||||
if ( git log -n 1 &> /dev/null); then
|
||||
#retrieve git information
|
||||
version="git : $(git status | grep branch | cut -c 13-) $(git log -n 1 | grep commit | cut -c 8-)"
|
||||
version="$(git log --pretty=format:"%H" | head -1 | cut -c1-8)"
|
||||
fi
|
||||
|
||||
if ( git log -n 1 | grep svn &> /dev/null); then
|
||||
#retrieve git svn information
|
||||
version="${version} svn : $(git log -n 1 | awk '/svn/ {print $2}' | head -1 | sed 's/.*@//')"
|
||||
elif ( git log -n 10 | grep svn &> /dev/null); then
|
||||
#retrieve git svn information
|
||||
version="${version} svn closest version : $(git log -n 10 | awk '/svn/ {print $2}' | head -1 | sed 's/.*@//')"
|
||||
fi
|
||||
# if ( git log -n 1 | grep svn &> /dev/null); then
|
||||
# #retrieve git svn information
|
||||
# version="${version} svn : $(git log -n 1 | awk '/svn/ {print $2}' | head -1 | sed 's/.*@//')"
|
||||
# elif ( git log -n 10 | grep svn &> /dev/null); then
|
||||
# #retrieve git svn information
|
||||
# version="${version} svn closest version : $(git log -n 10 | awk '/svn/ {print $2}' | head -1 | sed 's/.*@//')"
|
||||
# fi
|
||||
|
||||
if ( svn info &> /dev/null); then
|
||||
version=$(svn info | awk '/^Revision:/ {print $NF}')
|
||||
fi
|
||||
# if ( svn info &> /dev/null); then
|
||||
# version=$(svn info | awk '/^Revision:/ {print $NF}')
|
||||
# fi
|
||||
|
||||
if [[ ${version} != '' ]]; then
|
||||
echo "Writing version to retroshare/rsversion.h : ${version}"
|
||||
sed -e "s%RS_REVISION_NUMBER.*%RS_REVISION_NUMBER ${version}%" retroshare/rsversion.in >retroshare/rsversion.h
|
||||
sed -e "s%RS_REVISION_NUMBER.*%RS_REVISION_NUMBER 0x${version}%" retroshare/rsversion.in >retroshare/rsversion.h
|
||||
fi
|
||||
echo "script version_detail.sh finished normally"
|
||||
exit 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue