Commit 13f4afe1 authored by Ronan's avatar Ronan

feat(MainDb): supports local chat room id

parent d2a7cfaf
...@@ -675,11 +675,11 @@ ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &chatRoom, ChatMessage::Dir ...@@ -675,11 +675,11 @@ ChatMessage::ChatMessage (const shared_ptr<ChatRoom> &chatRoom, ChatMessage::Dir
d->chatRoom = chatRoom; d->chatRoom = chatRoom;
d->chatRoomId = chatRoom->getChatRoomId(); d->chatRoomId = chatRoom->getChatRoomId();
if (direction == Direction::Outgoing) { if (direction == Direction::Outgoing) {
d->fromAddress = chatRoom->getLocalAddress(); d->fromAddress = d->chatRoomId.getLocalAddress();
d->toAddress = chatRoom->getPeerAddress(); d->toAddress = d->chatRoomId.getPeerAddress();
} else { } else {
d->fromAddress = chatRoom->getPeerAddress(); d->fromAddress = d->chatRoomId.getPeerAddress();
d->toAddress = chatRoom->getLocalAddress(); d->toAddress = d->chatRoomId.getLocalAddress();
} }
d->direction = direction; d->direction = direction;
} }
...@@ -766,16 +766,6 @@ const IdentityAddress &ChatMessage::getToAddress () const { ...@@ -766,16 +766,6 @@ const IdentityAddress &ChatMessage::getToAddress () const {
return d->toAddress; return d->toAddress;
} }
const IdentityAddress &ChatMessage::getLocalAddress () const {
L_D();
return d->chatRoomId.getLocalAddress();
}
const IdentityAddress &ChatMessage::getRemoteAddress () const {
L_D();
return d->direction == Direction::Outgoing ? d->chatRoomId.getPeerAddress() : d->fromAddress;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
const LinphoneErrorInfo *ChatMessage::getErrorInfo () const { const LinphoneErrorInfo *ChatMessage::getErrorInfo () const {
......
...@@ -83,9 +83,6 @@ public: ...@@ -83,9 +83,6 @@ public:
const IdentityAddress &getFromAddress () const; const IdentityAddress &getFromAddress () const;
const IdentityAddress &getToAddress () const; const IdentityAddress &getToAddress () const;
const IdentityAddress &getLocalAddress () const;
const IdentityAddress &getRemoteAddress () const;
// TODO: Return a cpp reference. // TODO: Return a cpp reference.
const LinphoneErrorInfo *getErrorInfo () const; const LinphoneErrorInfo *getErrorInfo () const;
......
...@@ -74,4 +74,9 @@ const IdentityAddress &ChatRoomId::getLocalAddress () const { ...@@ -74,4 +74,9 @@ const IdentityAddress &ChatRoomId::getLocalAddress () const {
return d->localAddress; return d->localAddress;
} }
bool ChatRoomId::isValid () const {
L_D();
return d->peerAddress.isValid() && d->localAddress.isValid();
}
LINPHONE_END_NAMESPACE LINPHONE_END_NAMESPACE
...@@ -44,6 +44,8 @@ public: ...@@ -44,6 +44,8 @@ public:
const IdentityAddress &getPeerAddress () const; const IdentityAddress &getPeerAddress () const;
const IdentityAddress &getLocalAddress () const; const IdentityAddress &getLocalAddress () const;
bool isValid () const;
private: private:
L_DECLARE_PRIVATE(ChatRoomId); L_DECLARE_PRIVATE(ChatRoomId);
}; };
......
...@@ -42,10 +42,20 @@ private: ...@@ -42,10 +42,20 @@ private:
long long insertSipAddress (const std::string &sipAddress); long long insertSipAddress (const std::string &sipAddress);
void insertContent (long long messageEventId, const Content &content); void insertContent (long long messageEventId, const Content &content);
long long insertContentType (const std::string &contentType); long long insertContentType (const std::string &contentType);
long long insertChatRoom (long long sipAddressId, int capabilities, const tm &date); long long insertChatRoom (
long long peerSipAddressId,
long long localSipAddressId,
int capabilities,
const tm &date
);
long long insertChatRoom (const ChatRoomId &chatRoomId, int capabilities, const tm &date);
void insertChatRoomParticipant (long long chatRoomId, long long sipAddressId, bool isAdmin); void insertChatRoomParticipant (long long chatRoomId, long long sipAddressId, bool isAdmin);
void insertChatMessageParticipant (long long messageEventId, long long sipAddressId, int state); void insertChatMessageParticipant (long long messageEventId, long long sipAddressId, int state);
long long selectSipAddressId (const std::string &sipAddress) const;
long long selectChatRoomId (long long peerSipAddressId, long long localSipAddressId) const;
long long selectChatRoomId (const ChatRoomId &chatRoomId) const;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Events API. // Events API.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -54,56 +64,56 @@ private: ...@@ -54,56 +64,56 @@ private:
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
std::shared_ptr<EventLog> selectConferenceEvent ( std::shared_ptr<EventLog> selectConferenceEvent (
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
std::shared_ptr<EventLog> selectConferenceCallEvent ( std::shared_ptr<EventLog> selectConferenceCallEvent (
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
std::shared_ptr<EventLog> selectConferenceChatMessageEvent ( std::shared_ptr<EventLog> selectConferenceChatMessageEvent (
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
std::shared_ptr<EventLog> selectConferenceParticipantEvent ( std::shared_ptr<EventLog> selectConferenceParticipantEvent (
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
std::shared_ptr<EventLog> selectConferenceParticipantDeviceEvent ( std::shared_ptr<EventLog> selectConferenceParticipantDeviceEvent (
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
std::shared_ptr<EventLog> selectConferenceSubjectEvent ( std::shared_ptr<EventLog> selectConferenceSubjectEvent (
long long eventId, long long eventId,
EventLog::Type type, EventLog::Type type,
time_t date, time_t date,
const std::string &peerAddress const ChatRoomId &chatRoomId
) const; ) const;
long long insertEvent (const std::shared_ptr<EventLog> &eventLog); long long insertEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceEvent (const std::shared_ptr<EventLog> &eventLog, long long *chatRoomId = nullptr); long long insertConferenceEvent (const std::shared_ptr<EventLog> &eventLog, long long *chatRoomId = nullptr);
long long insertConferenceCallEvent (const std::shared_ptr<EventLog> &eventLog); long long insertConferenceCallEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceChatMessageEvent (const std::shared_ptr<EventLog> &eventLog); long long insertConferenceChatMessageEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceNotifiedEvent (const std::shared_ptr<EventLog> &eventLog); long long insertConferenceNotifiedEvent (const std::shared_ptr<EventLog> &eventLog, long long *chatRoomId = nullptr);
long long insertConferenceParticipantEvent (const std::shared_ptr<EventLog> &eventLog); long long insertConferenceParticipantEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceParticipantDeviceEvent (const std::shared_ptr<EventLog> &eventLog); long long insertConferenceParticipantDeviceEvent (const std::shared_ptr<EventLog> &eventLog);
long long insertConferenceSubjectEvent (const std::shared_ptr<EventLog> &eventLog); long long insertConferenceSubjectEvent (const std::shared_ptr<EventLog> &eventLog);
...@@ -113,7 +123,7 @@ private: ...@@ -113,7 +123,7 @@ private:
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
std::shared_ptr<EventLog> getEventFromCache (long long eventId) const; std::shared_ptr<EventLog> getEventFromCache (long long eventId) const;
void invalidEventsFromQuery (const std::string &query, const std::string &peerAddress); void invalidConferenceEventsFromQuery (const std::string &query, long long chatRoomId);
L_DECLARE_PUBLIC(MainDb); L_DECLARE_PUBLIC(MainDb);
}; };
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment