Line data Source code
1 : /* 2 : * Copyright (C) 2021-2024 Savoir-faire Linux Inc. 3 : * 4 : * Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com> 5 : * 6 : * This program is free software; you can redistribute it and/or modify 7 : * it under the terms of the GNU General Public License as published by 8 : * the Free Software Foundation; either version 3 of the License, or 9 : * (at your option) any later version. 10 : * 11 : * This program is distributed in the hope that it will be useful, 12 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 : * GNU General Public License for more details. 15 : * 16 : * You should have received a copy of the GNU General Public License 17 : * along with this program; if not, write to the Free Software 18 : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 : */ 20 : 21 : #pragma once 22 : 23 : #include "jamidht/jamiaccount.h" 24 : 25 : namespace jami { 26 : 27 : class SyncModule 28 : { 29 : public: 30 : SyncModule(std::weak_ptr<JamiAccount>&& account); 31 233 : ~SyncModule() = default; 32 : 33 : /** 34 : * Store a new Sync connection 35 : * @param socket The new sync channel 36 : * @param peerId The contact who owns the device 37 : * @param deviceId Device linked to that transport 38 : */ 39 : void cacheSyncConnection(std::shared_ptr<dhtnet::ChannelSocket>&& socket, 40 : const std::string& peerId, 41 : const DeviceId& deviceId); 42 : 43 : /** 44 : * Send sync informations to connected device 45 : * @param deviceId Connected device 46 : * @param socket Related socket 47 : * @param syncMsg Default message 48 : */ 49 : void syncWith(const DeviceId& deviceId, 50 : const std::shared_ptr<dhtnet::ChannelSocket>& socket, 51 : const std::shared_ptr<SyncMsg>& syncMsg = nullptr); 52 : 53 : /** 54 : * Send sync to all connected devices 55 : * @param syncMsg Default message 56 : * @param deviceId If we need to filter on a device 57 : */ 58 : void syncWithConnected(const std::shared_ptr<SyncMsg>& syncMsg = nullptr, const DeviceId& deviceId = {}); 59 : 60 : private: 61 : class Impl; 62 : std::shared_ptr<Impl> pimpl_; 63 : }; 64 : 65 : } // namespace jami