Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
54e0f253
Commit
54e0f253
authored
Oct 27, 2017
by
Ronan
Browse files
feat(MainDb): add getConferenceNotifiedEvents impl
parent
a100df85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
26 deletions
+69
-26
coreapi/linphonecore.c
coreapi/linphonecore.c
+0
-4
include/linphone/utils/utils.h
include/linphone/utils/utils.h
+2
-2
src/db/main-db.cpp
src/db/main-db.cpp
+62
-15
src/db/main-db.h
src/db/main-db.h
+2
-2
src/utils/utils.cpp
src/utils/utils.cpp
+3
-3
No files found.
coreapi/linphonecore.c
View file @
54e0f253
...
...
@@ -2284,10 +2284,6 @@ static void _linphone_core_set_platform_helpers(LinphoneCore *lc, LinphonePrivat
static
void
_linphone_core_set_system_context
(
LinphoneCore
*
lc
,
void
*
system_context
){
_linphone_core_set_platform_helpers
(
lc
,
LinphonePrivate
::
createAndroidPlatformHelpers
(
lc
,
system_context
));
}
#else
static
void
_linphone_core_set_system_context
(
LinphoneCore
*
lc
,
void
*
system_context
){
}
#endif
...
...
include/linphone/utils/utils.h
View file @
54e0f253
...
...
@@ -105,8 +105,8 @@ namespace Utils {
return
object
;
}
LINPHONE_PUBLIC
std
::
tm
get
Long
AsTm
(
long
time
);
LINPHONE_PUBLIC
long
getTmAs
Long
(
const
std
::
tm
&
time
);
LINPHONE_PUBLIC
std
::
tm
get
TimeT
AsTm
(
std
::
time_t
time
);
LINPHONE_PUBLIC
std
::
time_t
getTmAs
TimeT
(
const
std
::
tm
&
time
);
}
LINPHONE_END_NAMESPACE
...
...
src/db/main-db.cpp
View file @
54e0f253
...
...
@@ -70,9 +70,9 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
}
static
constexpr
EnumToSql
<
MainDb
::
Filter
>
eventFilterToSql
[]
=
{
{
MainDb
::
ConferenceCallFilter
,
"
1
,
2
"
},
{
MainDb
::
ConferenceCallFilter
,
"
3
,
4
"
},
{
MainDb
::
ConferenceChatMessageFilter
,
"5"
},
{
MainDb
::
ConferenceInfoFilter
,
"
3
,
4
, 6, 7, 8, 9, 10, 11, 12"
}
{
MainDb
::
ConferenceInfoFilter
,
"
1
,
2
, 6, 7, 8, 9, 10, 11, 12"
}
};
static
constexpr
const
char
*
mapEventFilterToSql
(
MainDb
::
Filter
filter
)
{
...
...
@@ -375,7 +375,7 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
soci
::
session
*
session
=
dbSession
.
getBackendSession
<
soci
::
session
>
();
*
session
<<
"INSERT INTO event (type, date) VALUES (:type, :date)"
,
soci
::
use
(
static_cast
<
int
>
(
eventLog
->
getType
())),
soci
::
use
(
Utils
::
get
Long
AsTm
(
eventLog
->
getTime
()));
soci
::
use
(
static_cast
<
int
>
(
eventLog
->
getType
())),
soci
::
use
(
Utils
::
get
TimeT
AsTm
(
eventLog
->
getTime
()));
return
q
->
getLastInsertId
();
}
...
...
@@ -408,7 +408,7 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
return
-
1
;
}
tm
eventTime
=
Utils
::
get
LongAsTm
(
static_cast
<
long
>
(
eventLog
->
getTime
())
)
;
tm
eventTime
=
Utils
::
get
TimeTAsTm
(
eventLog
->
getTime
());
long
long
localSipAddressId
=
insertSipAddress
(
chatMessage
->
getLocalAddress
().
asString
());
long
long
remoteSipAddressId
=
insertSipAddress
(
chatMessage
->
getRemoteAddress
().
asString
());
...
...
@@ -842,12 +842,45 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
return
count
;
}
list
<
shared_ptr
<
EventLog
>>
MainDb
::
get
HistorySinceNotifyId
(
list
<
shared_ptr
<
EventLog
>>
MainDb
::
get
ConferenceNotifiedEvents
(
const
string
&
peerAddress
,
unsigned
int
n
otifyId
unsigned
int
lastN
otifyId
)
{
// TODO.
return
list
<
shared_ptr
<
EventLog
>>
();
static
const
string
query
=
"SELECT id, type, date FROM event"
" WHERE id IN ("
" SELECT event_id FROM conference_notified_event WHERE event_id IN ("
" SELECT event_id FROM conference_event WHERE chat_room_id = ("
" SELECT id FROM sip_address WHERE value = :peerAddress"
" )"
" ) AND notify_id > :lastNotifyId"
" )"
;
L_D
();
if
(
!
isConnected
())
{
lWarning
()
<<
"Unable to get conference notified events. Not connected."
;
return
list
<
shared_ptr
<
EventLog
>>
();
}
list
<
shared_ptr
<
EventLog
>>
events
;
L_BEGIN_LOG_EXCEPTION
soci
::
session
*
session
=
d
->
dbSession
.
getBackendSession
<
soci
::
session
>
();
soci
::
transaction
tr
(
*
session
);
soci
::
rowset
<
soci
::
row
>
rows
=
(
session
->
prepare
<<
query
,
soci
::
use
(
peerAddress
),
soci
::
use
(
lastNotifyId
));
for
(
const
auto
&
row
:
rows
)
events
.
push_back
(
d
->
selectGenericConferenceEvent
(
getBackend
()
==
Sqlite3
?
static_cast
<
long
long
>
(
row
.
get
<
int
>
(
0
))
:
row
.
get
<
long
long
>
(
0
),
static_cast
<
EventLog
::
Type
>
(
row
.
get
<
int
>
(
1
)),
Utils
::
getTmAsTimeT
(
row
.
get
<
tm
>
(
2
)),
peerAddress
));
L_END_LOG_EXCEPTION
return
events
;
}
int
MainDb
::
getMessagesCount
(
const
string
&
peerAddress
)
const
{
...
...
@@ -969,17 +1002,15 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
soci
::
transaction
tr
(
*
session
);
soci
::
rowset
<
soci
::
row
>
rows
=
(
session
->
prepare
<<
query
,
soci
::
use
(
peerAddress
));
for
(
const
auto
&
row
:
rows
)
{
tm
date
=
row
.
get
<
tm
>
(
2
);
for
(
const
auto
&
row
:
rows
)
events
.
push_back
(
d
->
selectGenericConferenceEvent
(
// See: http://soci.sourceforge.net/doc/master/backends/
// `row id` is not supported by soci on Sqlite3. It's necessary to cast id to int...
getBackend
()
==
Sqlite3
?
static_cast
<
long
long
>
(
row
.
get
<
int
>
(
0
))
:
row
.
get
<
long
long
>
(
0
),
static_cast
<
EventLog
::
Type
>
(
row
.
get
<
int
>
(
1
)),
mktime
(
&
date
),
Utils
::
getTmAsTimeT
(
row
.
get
<
tm
>
(
2
)
),
peerAddress
));
}
L_END_LOG_EXCEPTION
...
...
@@ -1022,6 +1053,11 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
L_D
();
if
(
!
isConnected
())
{
lWarning
()
<<
"Unable to get chat rooms. Not connected."
;
return
list
<
shared_ptr
<
ChatRoom
>>
();
}
list
<
shared_ptr
<
ChatRoom
>>
chatRooms
;
L_BEGIN_LOG_EXCEPTION
...
...
@@ -1066,16 +1102,27 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
void
MainDb
::
insertChatRoom
(
const
string
&
peerAddress
,
int
capabilities
)
{
L_D
();
if
(
!
isConnected
())
{
lWarning
()
<<
"Unable to insert chat room. Not connected."
;
return
;
}
d
->
insertChatRoom
(
d
->
insertSipAddress
(
peerAddress
),
capabilities
,
Utils
::
get
LongAsTm
(
static_cast
<
long
>
(
time
(
0
))
)
Utils
::
get
TimeTAsTm
(
time
(
0
))
);
}
void
MainDb
::
deleteChatRoom
(
const
string
&
peerAddress
)
{
L_D
();
if
(
!
isConnected
())
{
lWarning
()
<<
"Unable to delete chat room. Not connected."
;
return
;
}
L_BEGIN_LOG_EXCEPTION
soci
::
session
*
session
=
d
->
dbSession
.
getBackendSession
<
soci
::
session
>
();
...
...
@@ -1154,7 +1201,7 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
continue
;
}
const
tm
date
=
Utils
::
get
Long
AsTm
(
message
.
get
<
int
>
(
LEGACY_MESSAGE_COL_DATE
,
0
));
const
tm
date
=
Utils
::
get
TimeT
AsTm
(
message
.
get
<
int
>
(
LEGACY_MESSAGE_COL_DATE
,
0
));
bool
isNull
;
const
string
url
=
getValueFromLegacyMessage
<
string
>
(
message
,
LEGACY_MESSAGE_COL_URL
,
isNull
);
...
...
@@ -1259,7 +1306,7 @@ MainDb::MainDb (Core *core) : AbstractDb(*new MainDbPrivate) {
return
0
;
}
list
<
shared_ptr
<
EventLog
>>
MainDb
::
get
HistorySinceNotifyId
(
list
<
shared_ptr
<
EventLog
>>
MainDb
::
get
ConferenceNotifiedEvents
(
const
string
&
peerAddress
,
unsigned
int
notifyId
)
{
...
...
src/db/main-db.h
View file @
54e0f253
...
...
@@ -55,9 +55,9 @@ public:
int
getEventsCount
(
FilterMask
mask
=
NoFilter
)
const
;
// Messages, calls and conferences.
std
::
list
<
std
::
shared_ptr
<
EventLog
>>
get
HistorySinceNotifyId
(
std
::
list
<
std
::
shared_ptr
<
EventLog
>>
get
ConferenceNotifiedEvents
(
const
std
::
string
&
peerAddress
,
unsigned
int
n
otifyId
unsigned
int
lastN
otifyId
);
int
getMessagesCount
(
const
std
::
string
&
peerAddress
=
""
)
const
;
...
...
src/utils/utils.cpp
View file @
54e0f253
...
...
@@ -173,12 +173,12 @@ char *Utils::utf8ToChar (uint32_t ic) {
// -----------------------------------------------------------------------------
tm
Utils
::
get
Long
AsTm
(
long
time
)
{
tm
Utils
::
get
TimeT
AsTm
(
time_t
time
)
{
tm
result
;
return
*
gmtime_r
(
&
static_cast
<
time_t
&>
(
time
)
,
&
result
);
return
*
gmtime_r
(
&
time
,
&
result
);
}
long
Utils
::
getTmAs
Long
(
const
tm
&
time
)
{
long
Utils
::
getTmAs
TimeT
(
const
tm
&
time
)
{
return
timegm
(
&
const_cast
<
tm
&>
(
time
));
}
...
...
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