diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index dbeb9b8e0..6d89ef8aa 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -33,7 +33,7 @@ SalAddress * sal_address_new(const char *uri){ } SalAddress * sal_address_clone(const SalAddress *addr){ - return (SalAddress *) belle_sip_object_ref(belle_sip_object_clone(BELLE_SIP_OBJECT(addr))); + return (SalAddress *) belle_sip_object_ref(belle_sip_header_address_clone(BELLE_SIP_HEADER_ADDRESS(addr))); } const char *sal_address_get_scheme(const SalAddress *addr){ @@ -277,4 +277,3 @@ bool_t sal_address_is_ipv6(const SalAddress *addr){ void sal_address_destroy(SalAddress *addr){ sal_address_unref(addr); } - diff --git a/src/chat/imdn.h b/src/chat/imdn.h index d23ba0245..07584fa3f 100644 --- a/src/chat/imdn.h +++ b/src/chat/imdn.h @@ -21,8 +21,9 @@ #include +#include "linphone/utils/general.h" + #include "chat-room.h" -#include "utils/general.h" #include "private.h" diff --git a/src/chat/is-composing-listener.h b/src/chat/is-composing-listener.h index dbb612825..730fc9761 100644 --- a/src/chat/is-composing-listener.h +++ b/src/chat/is-composing-listener.h @@ -19,7 +19,7 @@ #ifndef _IS_COMPOSING_LISTENER_H_ #define _IS_COMPOSING_LISTENER_H_ -#include "utils/general.h" +#include "linphone/utils/general.h" // ============================================================================= diff --git a/src/chat/is-composing.h b/src/chat/is-composing.h index a79122729..e219ec4f9 100644 --- a/src/chat/is-composing.h +++ b/src/chat/is-composing.h @@ -21,8 +21,9 @@ #include +#include "linphone/utils/general.h" + #include "is-composing-listener.h" -#include "utils/general.h" #include "private.h" diff --git a/src/db/events-db.cpp b/src/db/events-db.cpp index 79e140e5c..fd849132b 100644 --- a/src/db/events-db.cpp +++ b/src/db/events-db.cpp @@ -250,6 +250,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} } bool EventsDb::addEvent (const EventLog &eventLog) { + if (!isConnected()) { + lWarning() << "Unable to add event. Not connected."; + return false; + } + // TODO. switch (eventLog.getType()) { case EventLog::TypeNone: @@ -270,12 +275,22 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} } bool EventsDb::deleteEvent (const EventLog &eventLog) { + if (!isConnected()) { + lWarning() << "Unable to delete event. Not connected."; + return false; + } + // TODO. (void)eventLog; return true; } void EventsDb::cleanEvents (FilterMask mask) { + if (!isConnected()) { + lWarning() << "Unable to clean events. Not connected."; + return; + } + // TODO. (void)mask; } @@ -283,6 +298,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} int EventsDb::getEventsCount (FilterMask mask) const { L_D(const EventsDb); + if (!isConnected()) { + lWarning() << "Unable to get events count. Not connected."; + return 0; + } + string query = "SELECT COUNT(*) FROM event" + buildSqlEventFilter({ MessageFilter, CallFilter, ConferenceFilter }, mask); int count = 0; @@ -300,6 +320,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} int EventsDb::getMessagesCount (const string &remoteAddress) const { L_D(const EventsDb); + if (!isConnected()) { + lWarning() << "Unable to get messages count. Not connected."; + return 0; + } + string query = "SELECT COUNT(*) FROM message_event"; if (!remoteAddress.empty()) query += " WHERE dialog_id = (" @@ -322,6 +347,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} int EventsDb::getUnreadMessagesCount (const string &remoteAddress) const { L_D(const EventsDb); + if (!isConnected()) { + lWarning() << "Unable to get unread messages count. Not connected."; + return 0; + } + string query = "SELECT COUNT(*) FROM message_event"; if (!remoteAddress.empty()) query += " WHERE dialog_id = (" @@ -344,6 +374,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} } list> EventsDb::getHistory (const string &remoteAddress, int nLast, FilterMask mask) const { + if (!isConnected()) { + lWarning() << "Unable to get history. Not connected."; + return list>(); + } + // TODO. (void)remoteAddress; (void)nLast; @@ -352,6 +387,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} } list> EventsDb::getHistory (const string &remoteAddress, int begin, int end, FilterMask mask) const { + if (!isConnected()) { + lWarning() << "Unable to get history. Not connected."; + return list>(); + } + // TODO. (void)remoteAddress; (void)begin; @@ -361,6 +401,11 @@ EventsDb::EventsDb () : AbstractDb(*new EventsDbPrivate) {} } void EventsDb::cleanHistory (const string &remoteAddress) { + if (!isConnected()) { + lWarning() << "Unable to clean history. Not connected."; + return; + } + // TODO. (void)remoteAddress; } diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 60b1ab5e2..47af53d63 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -193,7 +193,7 @@ set(SOURCE_FILES_C ) set(SOURCE_FILES_CXX - cpim_tester.cpp + cpim-tester.cpp ) set(SOURCE_FILES_OBJC ) diff --git a/tester/cpim_tester.cpp b/tester/cpim-tester.cpp similarity index 96% rename from tester/cpim_tester.cpp rename to tester/cpim-tester.cpp index 27df3690c..214453389 100644 --- a/tester/cpim_tester.cpp +++ b/tester/cpim-tester.cpp @@ -1,5 +1,5 @@ /* - * liblinphone_tester - liblinphone test suite + * cpim-tester.cpp * Copyright (C) 2017 Belledonne Communications SARL * * This program is free software: you can redistribute it and/or modify @@ -20,13 +20,13 @@ #include "liblinphone_tester.h" -using namespace std; - -using namespace LinphonePrivate; - // ============================================================================= -static void parse_minimal_message (void) { +using namespace std; + +using namespace LINPHONE_NAMESPACE; + +static void parse_minimal_message () { const string str = "Content-type: Message/CPIM\r\n" "\r\n" "Content-Type: text/plain; charset=utf-8\r\n" @@ -39,7 +39,7 @@ static void parse_minimal_message (void) { BC_ASSERT_STRING_EQUAL(str2.c_str(), str.c_str()); } -static void set_generic_header_name (void) { +static void set_generic_header_name () { const list > entries = { { "toto", true }, { "george.abitbol", true }, @@ -82,7 +82,7 @@ static void set_generic_header_name (void) { } } -static void set_generic_header_value (void) { +static void set_generic_header_value () { const list > entries = { { "MyFeatures ", true }, { "2000-12-13T13:40:00-08:00", true }, @@ -106,7 +106,7 @@ static void set_generic_header_value (void) { } } -static void check_core_header_names (void) { +static void check_core_header_names () { const list, string> > entries = { { make_shared(), "From" }, { make_shared(), "To" }, @@ -123,7 +123,7 @@ static void check_core_header_names (void) { } } -static void set_core_header_values (void) { +static void set_core_header_values () { const list, list > > > entries = { { make_shared(), { { "Winnie the Pooh ", true }, @@ -196,7 +196,7 @@ static void set_core_header_values (void) { } } -static void check_subject_header_language (void) { +static void check_subject_header_language () { Cpim::SubjectHeader subjectHeader; // Check for not defined language. @@ -226,7 +226,7 @@ static void check_subject_header_language (void) { } } -static void parse_rfc_example (void) { +static void parse_rfc_example () { const string str = "Content-type: Message/CPIM\r\n" "\r\n" "From: MR SANDERS \r\n" @@ -253,7 +253,7 @@ static void parse_rfc_example (void) { BC_ASSERT_STRING_EQUAL(str2.c_str(), str.c_str()); } -static void parse_message_with_generic_header_parameters (void) { +static void parse_message_with_generic_header_parameters () { const string str = "Content-type: Message/CPIM\r\n" "\r\n" "From: MR SANDERS \r\n" @@ -275,7 +275,7 @@ static void parse_message_with_generic_header_parameters (void) { BC_ASSERT_STRING_EQUAL(str2.c_str(), str.c_str()); } -static void build_message (void) { +static void build_message () { Cpim::Message message; if (!BC_ASSERT_FALSE(message.isValid())) return;