Commit cad9f8f9 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Sort chat rooms automatically + added option to hide empty 1-1 rooms + added...

Sort chat rooms automatically + added option to hide empty 1-1 rooms + added option to hide chat rooms from removed proxy config
parent 22339a0b
......@@ -341,14 +341,47 @@ void CorePrivate::replaceChatRoom (const shared_ptr<AbstractChatRoom> &replacedC
// -----------------------------------------------------------------------------
static bool compare_chat_room (const shared_ptr<AbstractChatRoom>& first, const shared_ptr<AbstractChatRoom>& second) {
return first->getLastUpdateTime() > second->getLastUpdateTime();
}
list<shared_ptr<AbstractChatRoom>> Core::getChatRooms () const {
L_D();
LinphoneCore *lc = getCCore();
LinphoneConfig *config = linphone_core_get_config(lc);
bool hideEmptyChatRooms = !!linphone_config_get_int(config, "misc", "hide_empty_chat_rooms", 1);
bool hideChatRoomsFromRemovedProxyConfig = !!linphone_config_get_int(config, "misc", "hide_chat_rooms_from_removed_proxies", 1);
list<shared_ptr<AbstractChatRoom>> rooms;
for (auto it = d->chatRoomsById.begin(); it != d->chatRoomsById.end(); it++) {
const auto &chatRoom = it->second;
if (hideEmptyChatRooms) {
if (chatRoom->isEmpty()) {
continue;
}
}
if (hideChatRoomsFromRemovedProxyConfig) {
const bctbx_list_t *it;
bool found = false;
for (it = linphone_core_get_proxy_config_list(lc); it != NULL; it = it->next) {
LinphoneProxyConfig *cfg = (LinphoneProxyConfig *)it->data;
const LinphoneAddress *identityAddr = linphone_proxy_config_get_identity_address(cfg);
if (L_GET_CPP_PTR_FROM_C_OBJECT(identityAddr)->weakEqual(chatRoom->getLocalAddress())) {
found = true;
break;
}
}
if (!found) {
continue;
}
}
rooms.push_front(chatRoom);
}
rooms.sort(compare_chat_room);
return rooms;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment