Skip to content
Snippets Groups Projects
Select Git revision
  • 8f2b6d3f5afbc911a5cf8425203c8a60ee20f0d2
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
31 results

conversation_module.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    conversation_module.cpp 129.70 KiB
    /*
     *  Copyright (C) 2004-2025 Savoir-faire Linux Inc.
     *
     *  This program is free software: you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation, either version 3 of the License, or
     *  (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     *  GNU General Public License for more details.
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program. If not, see <https://www.gnu.org/licenses/>.
     */
    
    #include "conversation_module.h"
    
    #include <algorithm>
    #include <fstream>
    
    #include <opendht/thread_pool.h>
    
    #include "account_const.h"
    #include "call.h"
    #include "client/ring_signal.h"
    #include "fileutils.h"
    #include "jamidht/account_manager.h"
    #include "jamidht/jamiaccount.h"
    #include "manager.h"
    #include "sip/sipcall.h"
    #include "vcard.h"
    
    namespace jami {
    
    using ConvInfoMap = std::map<std::string, ConvInfo>;
    
    struct PendingConversationFetch
    {
        bool ready {false};
        bool cloning {false};
        std::string deviceId {};
        std::string removeId {};
        std::map<std::string, std::string> preferences {};
        std::map<std::string, std::map<std::string, std::string>> status {};
        std::set<std::string> connectingTo {};
        std::shared_ptr<dhtnet::ChannelSocket> socket {};
    };
    
    constexpr std::chrono::seconds MAX_FALLBACK {12 * 3600s};
    
    struct SyncedConversation
    {
        std::mutex mtx;
        std::unique_ptr<asio::steady_timer> fallbackClone;
        std::chrono::seconds fallbackTimer {5s};
        ConvInfo info;
        std::unique_ptr<PendingConversationFetch> pending;
        std::shared_ptr<Conversation> conversation;
    
        SyncedConversation(const std::string& convId)
            : info {convId}
        {
            fallbackClone = std::make_unique<asio::steady_timer>(*Manager::instance().ioContext());
        }
        SyncedConversation(const ConvInfo& info)
            : info {info}
        {
            fallbackClone = std::make_unique<asio::steady_timer>(*Manager::instance().ioContext());