diff --git a/include/linphone/api/c-account.h b/include/linphone/api/c-account.h index 3f9f57b75b96c9b31b95aff81428e8e1a789849e..74a9ab5467132775a034799273fc3c00e3f629ee 100644 --- a/include/linphone/api/c-account.h +++ b/include/linphone/api/c-account.h @@ -301,6 +301,14 @@ LINPHONE_PUBLIC bctbx_list_t *linphone_account_get_call_logs_for_address(const L **/ LINPHONE_PUBLIC void linphone_account_clear_call_logs(const LinphoneAccount *account); +/** + * Returns the list of conference information for a given account. + * This list must be freed after use. + * @param account The #LinphoneAccount object. @notnil + * @return The list of call logs \bctbx_list{LinphoneConferenceInfo}. @tobefreed @maybenil + **/ +LINPHONE_PUBLIC bctbx_list_t *linphone_account_get_conference_information_list(const LinphoneAccount *account); + /** * Detect if the given input is a phone number or not. * @param account The #LinphoneAccount object, unused yet but may contain useful data. Can be NULL. @maybenil diff --git a/src/account/account.cpp b/src/account/account.cpp index 126e0feed09bfc869b8c3f3d7f2a49da734d2c43..25769f680d40a9b5d82099c037872fc75abd375c 100644 --- a/src/account/account.cpp +++ b/src/account/account.cpp @@ -890,6 +890,18 @@ void Account::deleteCallLogs() const { mainDb->deleteCallHistoryForLocalAddress(localAddress); } +list<shared_ptr<ConferenceInfo>> Account::getConferenceInfos() const { + if (!mParams) { + lWarning() << "getConferenceInfos is called but no AccountParams is set on Account [" << this->toC() << "]"; + list<shared_ptr<ConferenceInfo>> conferences; + return conferences; + } + + auto localAddress = mParams->mIdentityAddress; + unique_ptr<MainDb> &mainDb = getCore()->getPrivate()->mainDb; + return mainDb->getConferenceInfosForLocalAddress(localAddress); +} + void Account::writeToConfigFile(int index) { if (!mParams) { lWarning() << "writeToConfigFile is called but no AccountParams is set on Account [" << this->toC() << "]"; diff --git a/src/account/account.h b/src/account/account.h index b50971cbe44449e3f93bddb87e3e16e8f3f6ef71..4f3218b9c039a700b9c3e7f5a4c30361f8781492 100644 --- a/src/account/account.h +++ b/src/account/account.h @@ -27,6 +27,7 @@ #include "c-wrapper/c-wrapper.h" #include "c-wrapper/internal/c-sal.h" #include "call/call-log.h" +#include "conference/conference-info.h" #include "linphone/api/c-types.h" #include "sal/register-op.h" @@ -101,6 +102,7 @@ public: int getMissedCallsCount() const; std::list<std::shared_ptr<CallLog>> getCallLogs() const; std::list<std::shared_ptr<CallLog>> getCallLogsForAddress(const std::shared_ptr<Address>) const; + std::list<std::shared_ptr<ConferenceInfo>> getConferenceInfos() const; // Other void resetMissedCallsCount(); diff --git a/src/c-wrapper/api/c-account.cpp b/src/c-wrapper/api/c-account.cpp index e81000209fff7265c3a6a520448c2fa151749711..e1facbcc247124169049ae420a6ab1a97aab7f74 100644 --- a/src/c-wrapper/api/c-account.cpp +++ b/src/c-wrapper/api/c-account.cpp @@ -220,6 +220,20 @@ void linphone_account_clear_call_logs(const LinphoneAccount *account) { Account::toCpp(account)->deleteCallLogs(); } +bctbx_list_t *linphone_account_get_conference_information_list(const LinphoneAccount *account) { + AccountLogContextualizer logContextualizer(account); + + bctbx_list_t *results = NULL; + std::list list = Account::toCpp(account)->getConferenceInfos(); + if (!list.empty()) { + for (auto &confInfo : list) { + results = bctbx_list_append(results, linphone_conference_info_ref(confInfo->toC())); + } + } + + return results; +} + void linphone_account_add_callbacks(LinphoneAccount *account, LinphoneAccountCbs *cbs) { Account::toCpp(account)->addCallbacks(AccountCbs::toCpp(cbs)->getSharedFromThis()); } diff --git a/src/db/main-db.cpp b/src/db/main-db.cpp index e96cb9f84416d87abaf9a594111c7e1ef3310ac2..44aac9ee1953d38138306c20ceae03dacfa4d6cf 100644 --- a/src/db/main-db.cpp +++ b/src/db/main-db.cpp @@ -5448,6 +5448,47 @@ std::list<std::shared_ptr<ConferenceInfo>> MainDb::getConferenceInfos(time_t aft #endif } +std::list<std::shared_ptr<ConferenceInfo>> +MainDb::getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localAddress) const { +#ifdef HAVE_DB_STORAGE + string query = "SELECT conference_info.id, organizer_sip_address.value, uri_sip_address.value," + " start_time, duration, subject, description, state, ics_sequence, ics_uid, security_level" + " FROM conference_info, sip_address AS organizer_sip_address, sip_address AS uri_sip_address" + " WHERE conference_info.organizer_sip_address_id = organizer_sip_address.id" + " AND conference_info.uri_sip_address_id = uri_sip_address.id" + " AND (conference_info.organizer_sip_address_id = :sipAddressId" + " OR :sipAddressId IN (" + " SELECT participant_sip_address_id FROM conference_info_participant WHERE" + " conference_info_id = conference_info.id" + " ))"; + query += " ORDER BY start_time"; + + DurationLogger durationLogger("Get conference infos for account."); + + return L_DB_TRANSACTION { + L_D(); + + list<shared_ptr<ConferenceInfo>> conferenceInfos; + + const long long &sipAddressId = d->selectSipAddressId(localAddress->toStringUriOnlyOrdered()); + + soci::session *session = d->dbSession.getBackendSession(); + soci::rowset<soci::row> rows = (session->prepare << query, soci::use(sipAddressId)); + + for (const auto &row : rows) { + auto confInfo = d->selectConferenceInfo(row); + conferenceInfos.push_back(confInfo); + } + + tr.commit(); + + return conferenceInfos; + }; +#else + return list<shared_ptr<ConferenceInfo>>(); +#endif +} + std::shared_ptr<ConferenceInfo> MainDb::getConferenceInfo(long long conferenceInfoId) const { #ifdef HAVE_DB_STORAGE static const string query = diff --git a/src/db/main-db.h b/src/db/main-db.h index d7e68835dd863d2e007080f475edd1f34b9b92d4..da0ac5d4f47454c69b0ae08ede1125bac6c95cd7 100644 --- a/src/db/main-db.h +++ b/src/db/main-db.h @@ -209,6 +209,8 @@ public: // --------------------------------------------------------------------------- std::list<std::shared_ptr<ConferenceInfo>> getConferenceInfos(time_t afterThisTime = -1) const; + std::list<std::shared_ptr<ConferenceInfo>> + getConferenceInfosForLocalAddress(const std::shared_ptr<Address> &localAddress) const; std::shared_ptr<ConferenceInfo> getConferenceInfo(long long conferenceInfoId) const; std::shared_ptr<ConferenceInfo> getConferenceInfoFromURI(const std::shared_ptr<Address> &uri) const; long long insertConferenceInfo(const std::shared_ptr<ConferenceInfo> &conferenceInfo);