Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblinphone
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
10
Issues
10
List
Board
Labels
Milestones
Merge Requests
22
Merge Requests
22
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
liblinphone
Commits
88fbd50b
Commit
88fbd50b
authored
Oct 18, 2017
by
Ronan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(MainDB): supports chat messages store
parent
2a9d4afe
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
6 deletions
+52
-6
chat-message.cpp
src/chat/chat-message/chat-message.cpp
+8
-0
chat-message.h
src/chat/chat-message/chat-message.h
+2
-0
basic-chat-room.h
src/chat/chat-room/basic-chat-room.h
+1
-1
chat-room.h
src/chat/chat-room/chat-room.h
+3
-1
client-group-chat-room.h
src/chat/chat-room/client-group-chat-room.h
+1
-1
real-time-text-chat-room.h
src/chat/chat-room/real-time-text-chat-room.h
+1
-1
main-db.cpp
src/db/main-db.cpp
+36
-2
No files found.
src/chat/chat-message/chat-message.cpp
View file @
88fbd50b
...
...
@@ -1327,6 +1327,14 @@ void ChatMessage::setToAddress(Address to) {
d
->
to
=
to
;
}
const
Address
&
ChatMessage
::
getLocalAddress
()
const
{
return
getDirection
()
==
Direction
::
Incoming
?
getToAddress
()
:
getFromAddress
();
}
const
Address
&
ChatMessage
::
getRemoteAddress
()
const
{
return
getDirection
()
!=
Direction
::
Incoming
?
getToAddress
()
:
getFromAddress
();
}
const
string
&
ChatMessage
::
getFileTransferFilepath
()
const
{
L_D
();
return
d
->
fileTransferFilePath
;
...
...
src/chat/chat-message/chat-message.h
View file @
88fbd50b
...
...
@@ -85,6 +85,8 @@ public:
const
Address
&
getFromAddress
()
const
;
const
Address
&
getToAddress
()
const
;
const
Address
&
getLocalAddress
()
const
;
const
Address
&
getRemoteAddress
()
const
;
const
LinphoneErrorInfo
*
getErrorInfo
()
const
;
...
...
src/chat/chat-room/basic-chat-room.h
View file @
88fbd50b
...
...
@@ -33,7 +33,7 @@ public:
BasicChatRoom
(
LinphoneCore
*
core
,
const
Address
&
peerAddress
);
virtual
~
BasicChatRoom
()
=
default
;
int
getCapabilities
()
const
override
;
CapabilitiesMask
getCapabilities
()
const
override
;
/* ConferenceInterface. */
void
addParticipant
(
const
Address
&
addr
,
const
CallSessionParams
*
params
,
bool
hasMedia
)
override
;
...
...
src/chat/chat-room/chat-room.h
View file @
88fbd50b
...
...
@@ -39,10 +39,12 @@ public:
L_DECLARE_ENUM
(
Capabilities
,
L_ENUM_VALUES_CHAT_ROOM_CAPABILITIES
);
L_DECLARE_ENUM
(
State
,
L_ENUM_VALUES_CHAT_ROOM_STATE
);
typedef
int
CapabilitiesMask
;
ChatRoom
(
LinphoneCore
*
core
);
virtual
~
ChatRoom
()
=
default
;
virtual
int
getCapabilities
()
const
=
0
;
virtual
CapabilitiesMask
getCapabilities
()
const
=
0
;
void
compose
();
std
::
shared_ptr
<
ChatMessage
>
createFileTransferMessage
(
const
LinphoneContent
*
initialContent
);
...
...
src/chat/chat-room/client-group-chat-room.h
View file @
88fbd50b
...
...
@@ -34,7 +34,7 @@ public:
ClientGroupChatRoom
(
LinphoneCore
*
core
,
const
Address
&
me
,
const
std
::
string
&
uri
,
const
std
::
string
&
subject
);
virtual
~
ClientGroupChatRoom
()
=
default
;
int
getCapabilities
()
const
override
;
CapabilitiesMask
getCapabilities
()
const
override
;
/* ConferenceInterface */
void
addParticipant
(
const
Address
&
addr
,
const
CallSessionParams
*
params
,
bool
hasMedia
)
override
;
...
...
src/chat/chat-room/real-time-text-chat-room.h
View file @
88fbd50b
...
...
@@ -33,7 +33,7 @@ public:
RealTimeTextChatRoom
(
LinphoneCore
*
core
,
const
Address
&
peerAddress
);
virtual
~
RealTimeTextChatRoom
()
=
default
;
int
getCapabilities
()
const
override
;
CapabilitiesMask
getCapabilities
()
const
override
;
uint32_t
getChar
()
const
;
LinphoneCall
*
getCall
()
const
;
...
...
src/db/main-db.cpp
View file @
88fbd50b
...
...
@@ -247,8 +247,37 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
}
long
MainDbPrivate
::
insertMessageEvent
(
const
EventLog
&
eventLog
)
{
// TODO.
return
0
;
shared_ptr
<
ChatMessage
>
chatMessage
=
static_cast
<
const
ChatMessageEvent
&>
(
eventLog
).
getChatMessage
();
shared_ptr
<
ChatRoom
>
chatRoom
=
chatMessage
->
getChatRoom
();
if
(
!
chatRoom
)
{
lError
()
<<
"Unable to get a valid chat room. It was removed from database."
;
return
-
1
;
}
tm
eventTime
=
Utils
::
getLongAsTm
(
static_cast
<
long
>
(
eventLog
.
getTime
()));
struct
MessageEventReferences
references
;
references
.
eventId
=
insertEvent
(
EventLog
::
Type
::
ChatMessage
,
eventTime
);
references
.
localSipAddressId
=
insertSipAddress
(
chatMessage
->
getLocalAddress
().
asString
());
references
.
remoteSipAddressId
=
insertSipAddress
(
chatMessage
->
getRemoteAddress
().
asString
());
references
.
chatRoomId
=
insertChatRoom
(
references
.
remoteSipAddressId
,
chatRoom
->
getCapabilities
(),
eventTime
);
insertChatRoomParticipant
(
references
.
chatRoomId
,
references
.
remoteSipAddressId
,
false
);
long
eventId
=
insertMessageEvent
(
references
,
static_cast
<
int
>
(
chatMessage
->
getState
()),
static_cast
<
int
>
(
chatMessage
->
getDirection
()),
chatMessage
->
getImdnMessageId
(),
chatMessage
->
isSecured
(),
chatMessage
->
getContents
()
);
return
eventId
;
}
long
MainDbPrivate
::
insertConferenceEvent
(
const
EventLog
&
eventLog
)
{
...
...
@@ -260,6 +289,7 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
soci
::
session
*
session
=
dbSession
.
getBackendSession
<
soci
::
session
>
();
*
session
<<
"INSERT INTO conference_event (event_id, chat_room_id)"
" VALUES (:eventId, :chatRoomId)"
,
soci
::
use
(
eventId
),
soci
::
use
(
chatRoomId
);
return
eventId
;
}
...
...
@@ -271,6 +301,7 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
" VALUES (:eventId, :notifyId)"
,
soci
::
use
(
eventId
),
soci
::
use
(
static_cast
<
const
ConferenceNotifiedEvent
&>
(
eventLog
).
getNotifyId
()
);
return
eventId
;
}
...
...
@@ -283,6 +314,7 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
soci
::
session
*
session
=
dbSession
.
getBackendSession
<
soci
::
session
>
();
*
session
<<
"INSERT INTO conference_participant_event (event_id, participant_address_id)"
" VALUES (:eventId, :participantAddressId)"
,
soci
::
use
(
eventId
),
soci
::
use
(
participantAddressId
);
return
eventId
;
}
...
...
@@ -295,6 +327,7 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
soci
::
session
*
session
=
dbSession
.
getBackendSession
<
soci
::
session
>
();
*
session
<<
"INSERT INTO conference_participant_device_event (event_id, gruu_address_id)"
" VALUES (:eventId, :gruuAddressId)"
,
soci
::
use
(
eventId
),
soci
::
use
(
gruuAddressId
);
return
eventId
;
}
...
...
@@ -306,6 +339,7 @@ MainDb::MainDb () : AbstractDb(*new MainDbPrivate) {}
" VALUES (:eventId, :subject)"
,
soci
::
use
(
eventId
),
soci
::
use
(
static_cast
<
const
ConferenceSubjectEvent
&>
(
eventLog
).
getSubject
()
);
return
eventId
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment