Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
liblinphone
Commits
6ef85b29
Commit
6ef85b29
authored
Nov 09, 2017
by
Ronan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(MainDb): provide a way to invalid events from query
parent
2111b62d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
22 deletions
+36
-22
src/db/main-db-p.h
src/db/main-db-p.h
+1
-0
src/db/main-db.cpp
src/db/main-db.cpp
+34
-22
src/event-log/event-log.h
src/event-log/event-log.h
+1
-0
No files found.
src/db/main-db-p.h
View file @
6ef85b29
...
...
@@ -113,6 +113,7 @@ private:
// ---------------------------------------------------------------------------
std
::
shared_ptr
<
EventLog
>
getEventFromCache
(
long
long
eventId
)
const
;
void
invalidEventsFromQuery
(
const
std
::
string
&
query
,
const
std
::
string
&
peerAddress
);
L_DECLARE_PUBLIC
(
MainDb
);
};
...
...
src/db/main-db.cpp
View file @
6ef85b29
...
...
@@ -89,8 +89,8 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
)
{
L_ASSERT
(
find_if
(
filters
.
cbegin
(),
filters
.
cend
(),
[](
const
MainDb
::
Filter
&
filter
)
{
return
filter
==
MainDb
::
NoFilter
;
})
==
filters
.
cend
()
return
filter
==
MainDb
::
NoFilter
;
})
==
filters
.
cend
()
);
if
(
mask
==
MainDb
::
NoFilter
)
...
...
@@ -134,7 +134,6 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
void
MainDbPrivate
::
insertContent
(
long
long
eventId
,
const
Content
&
content
)
{
L_Q
();
soci
::
session
*
session
=
dbSession
.
getBackendSession
<
soci
::
session
>
();
long
long
contentTypeId
=
insertContentType
(
content
.
getContentType
().
asString
());
...
...
@@ -253,15 +252,11 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
}
shared_ptr
<
EventLog
>
MainDbPrivate
::
selectConferenceEvent
(
long
long
eventId
,
long
long
,
EventLog
::
Type
type
,
time_t
date
,
const
string
&
peerAddress
)
const
{
// Useless here.
(
void
)
eventId
;
// TODO: Use cache.
return
make_shared
<
ConferenceEvent
>
(
type
,
date
,
...
...
@@ -352,7 +347,6 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
" AND participant_address.id = participant_address_id"
,
soci
::
into
(
notifyId
),
soci
::
into
(
participantAddress
),
soci
::
use
(
eventId
);
// TODO: Use cache.
return
make_shared
<
ConferenceParticipantEvent
>
(
type
,
date
,
...
...
@@ -383,7 +377,6 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
" AND gruu_address.id = gruu_address_id"
,
soci
::
into
(
notifyId
),
soci
::
into
(
participantAddress
),
soci
::
into
(
gruuAddress
),
soci
::
use
(
eventId
);
// TODO: Use cache.
return
make_shared
<
ConferenceParticipantDeviceEvent
>
(
type
,
date
,
...
...
@@ -410,7 +403,6 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
" AND conference_notified_event.event_id = conference_subject_event.event_id"
,
soci
::
into
(
notifyId
),
soci
::
into
(
subject
),
soci
::
use
(
eventId
);
// TODO: Use cache.
return
make_shared
<
ConferenceSubjectEvent
>
(
date
,
Address
(
peerAddress
),
...
...
@@ -478,7 +470,7 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
soci
::
use
(
static_cast
<
int
>
(
chatMessage
->
getState
())),
soci
::
use
(
static_cast
<
int
>
(
chatMessage
->
getDirection
())),
soci
::
use
(
chatMessage
->
getImdnMessageId
()),
soci
::
use
(
chatMessage
->
isSecured
()
?
1
:
0
);
for
(
Content
*
content
:
chatMessage
->
getContents
())
for
(
const
Content
*
content
:
chatMessage
->
getContents
())
insertContent
(
eventId
,
*
content
);
return
eventId
;
...
...
@@ -549,6 +541,23 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
return
eventLog
;
}
void
MainDbPrivate
::
invalidEventsFromQuery
(
const
string
&
query
,
const
string
&
peerAddress
)
{
L_Q
();
soci
::
session
*
session
=
dbSession
.
getBackendSession
<
soci
::
session
>
();
soci
::
rowset
<
soci
::
row
>
rows
=
(
session
->
prepare
<<
query
,
soci
::
use
(
peerAddress
));
for
(
const
auto
&
row
:
rows
)
{
shared_ptr
<
EventLog
>
eventLog
=
getEventFromCache
(
q
->
getBackend
()
==
AbstractDb
::
Sqlite3
?
static_cast
<
long
long
>
(
row
.
get
<
int
>
(
0
))
:
row
.
get
<
long
long
>
(
0
)
);
if
(
eventLog
)
{
const
EventLogPrivate
*
dEventLog
=
eventLog
->
getPrivate
();
L_ASSERT
(
dEventLog
->
dbKey
.
isValid
());
dEventLog
->
dbKey
=
MainDbEventKey
();
}
}
}
// -----------------------------------------------------------------------------
void
MainDb
::
init
()
{
...
...
@@ -1154,19 +1163,15 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
return
;
}
// TODO: Deal with mask.
string
query
;
if
(
mask
==
MainDb
::
NoFilter
||
mask
&
ConferenceChatMessageFilter
)
query
+=
"SELECT event_id FROM conference_event WHERE chat_room_id = ("
" SELECT id FROM sip_address WHERE value = :peerAddress"
")"
;
if
(
query
.
empty
())
return
;
string
query
=
"SELECT event_id FROM conference_event WHERE chat_room_id = ("
" SELECT id FROM sip_address WHERE value = :peerAddress"
")"
+
buildSqlEventFilter
({
ConferenceCallFilter
,
ConferenceChatMessageFilter
,
ConferenceInfoFilter
},
mask
);
L_BEGIN_LOG_EXCEPTION
d
->
invalidEventsFromQuery
(
query
,
peerAddress
);
soci
::
session
*
session
=
d
->
dbSession
.
getBackendSession
<
soci
::
session
>
();
*
session
<<
"DELETE FROM event WHERE id IN ("
+
query
+
")"
,
soci
::
use
(
peerAddress
);
...
...
@@ -1272,6 +1277,13 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
L_BEGIN_LOG_EXCEPTION
d
->
invalidEventsFromQuery
(
"SELECT event_id FROM conference_event WHERE chat_room_id = ("
" SELECT id FROM sip_address WHERE value = :peerAddress"
")"
,
peerAddress
);
soci
::
session
*
session
=
d
->
dbSession
.
getBackendSession
<
soci
::
session
>
();
*
session
<<
"DELETE FROM chat_room WHERE peer_sip_address_id = ("
" SELECT id FROM sip_address WHERE value = :peerAddress"
...
...
src/event-log/event-log.h
View file @
6ef85b29
...
...
@@ -35,6 +35,7 @@ class EventLogPrivate;
class
LINPHONE_PUBLIC
EventLog
:
public
BaseObject
{
friend
class
MainDb
;
friend
class
MainDbPrivate
;
public:
L_DECLARE_ENUM
(
Type
,
L_ENUM_VALUES_EVENT_LOG_TYPE
);
...
...
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