mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-04-22 15:38:33 +00:00
feat(EventsDb): insert data for message_state, message_direction and event_type tables
This commit is contained in:
parent
8af55bcf34
commit
79d716d9d7
1 changed files with 54 additions and 11 deletions
|
|
@ -48,17 +48,14 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {}
|
||||||
// Helpers.
|
// Helpers.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static constexpr pair<EventsDb::Filter, const char *> eventFilterToSql[] = {
|
||||||
|
{ EventsDb::MessageFilter, "1" },
|
||||||
|
{ EventsDb::CallFilter, "2" },
|
||||||
|
{ EventsDb::ConferenceFilter, "3" }
|
||||||
|
};
|
||||||
|
|
||||||
inline constexpr const char *mapEventFilterToSql (EventsDb::Filter filter) {
|
inline constexpr const char *mapEventFilterToSql (EventsDb::Filter filter) {
|
||||||
// Ugly. Yes. But constexpr...
|
return eventFilterToSql[filter].second;
|
||||||
return filter == EventsDb::MessageFilter
|
|
||||||
? "1"
|
|
||||||
: (filter == EventsDb::CallFilter
|
|
||||||
? "2"
|
|
||||||
: (filter == EventsDb::ConferenceFilter
|
|
||||||
? "3"
|
|
||||||
: ""
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline constexpr const char *mapMessageDirectionToSql (Message::Direction direction) {
|
inline constexpr const char *mapMessageDirectionToSql (Message::Direction direction) {
|
||||||
|
|
@ -77,7 +74,7 @@ static constexpr pair<Message::State, const char *> messageStateToSql[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
inline constexpr const char *mapMessageStateToSql (Message::State state) {
|
inline constexpr const char *mapMessageStateToSql (Message::State state) {
|
||||||
return mapMessageStateToSql(state);
|
return messageStateToSql[state].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -189,6 +186,52 @@ static string buildSqlEventFilter (const list<EventsDb::Filter> &filters, Events
|
||||||
" REFERENCES message_direction(id)"
|
" REFERENCES message_direction(id)"
|
||||||
" ON DELETE CASCADE"
|
" ON DELETE CASCADE"
|
||||||
")";
|
")";
|
||||||
|
|
||||||
|
{
|
||||||
|
string query = getBackend() == Mysql
|
||||||
|
? "INSERT INTO event_type (id, value)"
|
||||||
|
: "INSERT OR IGNORE INTO event_type (id, value)";
|
||||||
|
query += "VALUES"
|
||||||
|
"(1, \"Message\"),"
|
||||||
|
"(2, \"Call\"),"
|
||||||
|
"(3, \"Conference\")";
|
||||||
|
if (getBackend() == Mysql)
|
||||||
|
query += "ON DUPLICATE KEY UPDATE value = VALUES(value)";
|
||||||
|
|
||||||
|
*session << query;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
string query = getBackend() == Mysql
|
||||||
|
? "INSERT INTO message_direction (id, value)"
|
||||||
|
: "INSERT OR IGNORE INTO message_direction (id, value)";
|
||||||
|
query += "VALUES"
|
||||||
|
"(1, \"Incoming\"),"
|
||||||
|
"(2, \"Outgoing\")";
|
||||||
|
if (getBackend() == Mysql)
|
||||||
|
query += "ON DUPLICATE KEY UPDATE value = VALUES(value)";
|
||||||
|
|
||||||
|
*session << query;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
string query = getBackend() == Mysql
|
||||||
|
? "INSERT INTO message_state (id, value)"
|
||||||
|
: "INSERT OR IGNORE INTO message_state (id, value)";
|
||||||
|
query += "VALUES"
|
||||||
|
"(1, \"Idle\"),"
|
||||||
|
"(2, \"InProgress\"),"
|
||||||
|
"(3, \"Delivered\"),"
|
||||||
|
"(4, \"NotDelivered\"),"
|
||||||
|
"(5, \"FileTransferError\"),"
|
||||||
|
"(6, \"FileTransferDone\"),"
|
||||||
|
"(7, \"DeliveredToUser\"),"
|
||||||
|
"(8, \"Displayed\")";
|
||||||
|
if (getBackend() == Mysql)
|
||||||
|
query += "ON DUPLICATE KEY UPDATE value = VALUES(value)";
|
||||||
|
|
||||||
|
*session << query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventsDb::addEvent (const Event &event) {
|
bool EventsDb::addEvent (const Event &event) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue