mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 15:15:15 -04:00
merged with upstream/master
This commit is contained in:
commit
ae37787853
11 changed files with 201 additions and 83 deletions
|
@ -275,31 +275,30 @@ bool DistantChatService::initiateDistantChatConnexion(const RsGxsId& to_gxs_id,
|
|||
|
||||
bool DistantChatService::getDistantChatStatus(const DistantChatPeerId& tunnel_id, DistantChatPeerInfo& cinfo)
|
||||
{
|
||||
RsStackMutex stack(mDistantChatMtx); /********** STACK LOCKED MTX ******/
|
||||
RS_STACK_MUTEX(mDistantChatMtx);
|
||||
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo ;
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo;
|
||||
|
||||
if(!mGxsTunnels->getTunnelInfo(RsGxsTunnelId(tunnel_id),tinfo))
|
||||
return false;
|
||||
if(!mGxsTunnels->getTunnelInfo(RsGxsTunnelId(tunnel_id),tinfo)) return false;
|
||||
|
||||
cinfo.to_id = tinfo.destination_gxs_id;
|
||||
cinfo.own_id = tinfo.source_gxs_id;
|
||||
cinfo.peer_id = tunnel_id;
|
||||
cinfo.to_id = tinfo.destination_gxs_id;
|
||||
cinfo.own_id = tinfo.source_gxs_id;
|
||||
cinfo.peer_id = tunnel_id;
|
||||
|
||||
switch(tinfo.tunnel_status)
|
||||
{
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_CAN_TALK : cinfo.status = RS_DISTANT_CHAT_STATUS_CAN_TALK;
|
||||
break ;
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_TUNNEL_DN: cinfo.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN ;
|
||||
break ;
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_REMOTELY_CLOSED: cinfo.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED ;
|
||||
break ;
|
||||
default:
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_UNKNOWN: cinfo.status = RS_DISTANT_CHAT_STATUS_UNKNOWN;
|
||||
break ;
|
||||
}
|
||||
switch(tinfo.tunnel_status)
|
||||
{
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_CAN_TALK :
|
||||
cinfo.status = RS_DISTANT_CHAT_STATUS_CAN_TALK; break;
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_TUNNEL_DN:
|
||||
cinfo.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN; break;
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_REMOTELY_CLOSED:
|
||||
cinfo.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED; break;
|
||||
case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_UNKNOWN:
|
||||
default:
|
||||
cinfo.status = RS_DISTANT_CHAT_STATUS_UNKNOWN; break;
|
||||
}
|
||||
|
||||
return true ;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DistantChatService::closeDistantChatConnexion(const DistantChatPeerId &tunnel_id)
|
||||
|
|
|
@ -292,14 +292,11 @@ void p3ChatService::checkSizeAndSendMessage(RsChatMsgItem *msg)
|
|||
|
||||
bool p3ChatService::isOnline(const RsPeerId& pid)
|
||||
{
|
||||
// check if the id is a tunnel id or a peer id.
|
||||
|
||||
DistantChatPeerInfo dcpinfo;
|
||||
|
||||
if(getDistantChatStatus(DistantChatPeerId(pid),dcpinfo))
|
||||
return dcpinfo.status == RS_DISTANT_CHAT_STATUS_CAN_TALK ;
|
||||
else
|
||||
return mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid);
|
||||
// check if the id is a tunnel id or a peer id.
|
||||
DistantChatPeerInfo dcpinfo;
|
||||
if(getDistantChatStatus(DistantChatPeerId(pid),dcpinfo))
|
||||
return dcpinfo.status == RS_DISTANT_CHAT_STATUS_CAN_TALK;
|
||||
else return mServiceCtrl->isPeerConnected(getServiceInfo().mServiceType, pid);
|
||||
}
|
||||
|
||||
bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
||||
|
@ -318,8 +315,7 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
|||
}
|
||||
// destination is peer or distant
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "p3ChatService::sendChat()";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3ChatService::sendChat()" << std::endl;
|
||||
#endif
|
||||
|
||||
RsPeerId vpid;
|
||||
|
@ -341,12 +337,12 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
|
|||
message.online = true;
|
||||
|
||||
if(!isOnline(vpid))
|
||||
{
|
||||
/* peer is offline, add to outgoing list */
|
||||
{
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
privateOutgoingList.push_back(ci);
|
||||
}
|
||||
{
|
||||
/* peer is offline, add to outgoing list */
|
||||
{
|
||||
RS_STACK_MUTEX(mChatMtx);
|
||||
privateOutgoingList.push_back(ci);
|
||||
}
|
||||
|
||||
message.online = false;
|
||||
RsServer::notify()->notifyChatMessage(message);
|
||||
|
|
|
@ -90,7 +90,7 @@ bool RsGxsMessageCleanUp::clean()
|
|||
RsGxsMsgMetaData* meta = *vit;
|
||||
|
||||
// check if expired
|
||||
bool remove = (meta->mPublishTs + store_period) < now;
|
||||
bool remove = store_period > 0 && (meta->mPublishTs + store_period) < now;
|
||||
|
||||
// check client does not want the message kept regardless of age
|
||||
remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP);
|
||||
|
|
|
@ -1464,7 +1464,7 @@ RsGxsId p3GxsTunnelService::destinationGxsIdFromHash(const TurtleFileHash& sum)
|
|||
|
||||
bool p3GxsTunnelService::getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info)
|
||||
{
|
||||
RsStackMutex stack(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
RS_STACK_MUTEX(mGxsTunnelMtx);
|
||||
|
||||
std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it = _gxs_tunnel_contacts.find(tunnel_id) ;
|
||||
|
||||
|
|
|
@ -527,7 +527,8 @@ HEADERS += util/folderiterator.h \
|
|||
util/rstickevent.h \
|
||||
util/rsrecogn.h \
|
||||
util/rsscopetimer.h \
|
||||
util/stacktrace.h
|
||||
util/stacktrace.h \
|
||||
util/rsdeprecate.h
|
||||
|
||||
SOURCES += ft/ftchunkmap.cc \
|
||||
ft/ftcontroller.cc \
|
||||
|
@ -540,7 +541,7 @@ SOURCES += ft/ftchunkmap.cc \
|
|||
ft/fttransfermodule.cc \
|
||||
ft/ftturtlefiletransferitem.cc
|
||||
|
||||
SOURCES += crypto/chacha20.cpp
|
||||
SOURCES += crypto/chacha20.cpp
|
||||
|
||||
SOURCES += chat/distantchat.cc \
|
||||
chat/p3chatservice.cc \
|
||||
|
|
|
@ -79,22 +79,21 @@ ChatId::ChatId(ChatLobbyId id):
|
|||
lobby_id = id;
|
||||
}
|
||||
|
||||
ChatId::ChatId(std::string str):
|
||||
lobby_id(0)
|
||||
ChatId::ChatId(std::string str) : lobby_id(0)
|
||||
{
|
||||
type = TYPE_NOT_SET;
|
||||
if(str.empty())
|
||||
return;
|
||||
type = TYPE_NOT_SET;
|
||||
if(str.empty()) return;
|
||||
|
||||
if(str[0] == 'P')
|
||||
{
|
||||
type = TYPE_PRIVATE;
|
||||
peer_id = RsPeerId(str.substr(1));
|
||||
}
|
||||
else if(str[0] == 'D')
|
||||
{
|
||||
type = TYPE_PRIVATE_DISTANT;
|
||||
distant_chat_id == DistantChatPeerId(str.substr(1));
|
||||
}
|
||||
}
|
||||
else if(str[0] == 'D')
|
||||
{
|
||||
type = TYPE_PRIVATE_DISTANT;
|
||||
distant_chat_id = DistantChatPeerId(str.substr(1));
|
||||
}
|
||||
else if(str[0] == 'L')
|
||||
{
|
||||
if(sizeof(ChatLobbyId) != 8)
|
||||
|
@ -401,7 +400,7 @@ bool p3Msgs::resetMessageStandardTagTypes(MsgTagType& tags)
|
|||
/****************************************/
|
||||
bool p3Msgs::sendChat(ChatId destination, std::string msg)
|
||||
{
|
||||
return mChatSrv->sendChat(destination, msg);
|
||||
return mChatSrv->sendChat(destination, msg);
|
||||
}
|
||||
|
||||
uint32_t p3Msgs::getMaxMessageSecuritySize(int type)
|
||||
|
|
34
libretroshare/src/util/rsdeprecate.h
Normal file
34
libretroshare/src/util/rsdeprecate.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
/*
|
||||
* RetroShare deprecation macros
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
# define RS_DEPRECATED __attribute__((__deprecated__))
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
# define RS_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
# define RS_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
|
||||
# define RS_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
|
||||
#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320)
|
||||
# define RS_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead"))
|
||||
#else
|
||||
# define RS_DEPRECATED_FOR(f) RS_DEPRECATED
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue