mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 17:15:31 -05:00
Merge pull request #1842 from sehraf/pr_chat_event
Add chat events to RsEvent
This commit is contained in:
commit
208e96dc6c
@ -881,6 +881,13 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *& ci)
|
|||||||
RsServer::notify()->notifyChatMessage(cm);
|
RsServer::notify()->notifyChatMessage(cm);
|
||||||
|
|
||||||
mHistoryMgr->addMessage(cm);
|
mHistoryMgr->addMessage(cm);
|
||||||
|
|
||||||
|
if(rsEvents)
|
||||||
|
{
|
||||||
|
auto ev = std::make_shared<RsChatMessageEvent>();
|
||||||
|
ev->mChatMessage = cm;
|
||||||
|
rsEvents->postEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,22 @@ class p3HistoryMgr;
|
|||||||
|
|
||||||
typedef RsPeerId ChatLobbyVirtualPeerId ;
|
typedef RsPeerId ChatLobbyVirtualPeerId ;
|
||||||
|
|
||||||
|
struct RsChatMessageEvent : RsEvent
|
||||||
|
{
|
||||||
|
RsChatMessageEvent() : RsEvent(RsEventType::CHAT_MESSAGE) {}
|
||||||
|
~RsChatMessageEvent() override = default;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) override
|
||||||
|
{
|
||||||
|
RsEvent::serial_process(j, ctx);
|
||||||
|
|
||||||
|
RS_SERIAL_PROCESS(mChatMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatMessage mChatMessage;
|
||||||
|
};
|
||||||
|
|
||||||
//!The basic Chat service.
|
//!The basic Chat service.
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -94,7 +94,10 @@ enum class RsEventType : uint32_t
|
|||||||
/// @see RsFiles
|
/// @see RsFiles
|
||||||
FILE_TRANSFER = 14,
|
FILE_TRANSFER = 14,
|
||||||
|
|
||||||
MAX /// Used to detect invalid event type passed
|
/// @see RsMsgs
|
||||||
|
CHAT_MESSAGE = 15,
|
||||||
|
|
||||||
|
MAX /// Used to detect invalid event type passed
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,9 +426,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatMessage
|
struct ChatMessage : RsSerializable
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
ChatId chat_id; // id of chat endpoint
|
ChatId chat_id; // id of chat endpoint
|
||||||
RsPeerId broadcast_peer_id; // only used for broadcast chat: source peer id
|
RsPeerId broadcast_peer_id; // only used for broadcast chat: source peer id
|
||||||
RsGxsId lobby_peer_gxs_id; // only used for lobbys: nickname of message author
|
RsGxsId lobby_peer_gxs_id; // only used for lobbys: nickname of message author
|
||||||
@ -441,6 +440,22 @@ public:
|
|||||||
bool incoming;
|
bool incoming;
|
||||||
bool online; // for outgoing messages: was this message send?
|
bool online; // for outgoing messages: was this message send?
|
||||||
//bool system_message;
|
//bool system_message;
|
||||||
|
|
||||||
|
///* @see RsEvent @see RsSerializable
|
||||||
|
void serial_process( RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx ) override
|
||||||
|
{
|
||||||
|
RS_SERIAL_PROCESS(chat_id);
|
||||||
|
RS_SERIAL_PROCESS(broadcast_peer_id);
|
||||||
|
RS_SERIAL_PROCESS(lobby_peer_gxs_id);
|
||||||
|
RS_SERIAL_PROCESS(peer_alternate_nickname);
|
||||||
|
|
||||||
|
RS_SERIAL_PROCESS(chatflags);
|
||||||
|
RS_SERIAL_PROCESS(sendTime);
|
||||||
|
RS_SERIAL_PROCESS(recvTime);
|
||||||
|
RS_SERIAL_PROCESS(msg);
|
||||||
|
RS_SERIAL_PROCESS(incoming);
|
||||||
|
RS_SERIAL_PROCESS(online);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatLobbyInvite : RsSerializable
|
class ChatLobbyInvite : RsSerializable
|
||||||
@ -967,7 +982,15 @@ virtual bool initiateDistantChatConnexion(
|
|||||||
const RsGxsId& to_pid, const RsGxsId& from_pid,
|
const RsGxsId& to_pid, const RsGxsId& from_pid,
|
||||||
DistantChatPeerId& pid, uint32_t& error_code,
|
DistantChatPeerId& pid, uint32_t& error_code,
|
||||||
bool notify = true ) = 0;
|
bool notify = true ) = 0;
|
||||||
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,DistantChatPeerInfo& info)=0;
|
|
||||||
|
/**
|
||||||
|
* @brief getDistantChatStatus receives distant chat info to a given distant chat id
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] pid distant chat id
|
||||||
|
* @param[out] info distant chat info
|
||||||
|
* @return true on success
|
||||||
|
*/
|
||||||
|
virtual bool getDistantChatStatus(const DistantChatPeerId& pid,DistantChatPeerInfo& info)=0;
|
||||||
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
|
virtual bool closeDistantChatConnexion(const DistantChatPeerId& pid)=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user