LCOV - code coverage report
Current view: top level - src/client - datatransfer.cpp (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 0 28 0.0 %
Date: 2024-04-26 09:41:19 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  Author: Guillaume Roguez <guillaume.roguez@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             : #include "datatransfer_interface.h"
      22             : 
      23             : #include "manager.h"
      24             : #include "data_transfer.h"
      25             : #include "client/ring_signal.h"
      26             : #include "jamidht/jamiaccount.h"
      27             : 
      28             : namespace libjami {
      29             : 
      30             : void
      31           0 : registerDataXferHandlers(const std::map<std::string, std::shared_ptr<CallbackWrapperBase>>& handlers)
      32             : {
      33           0 :     registerSignalHandlers(handlers);
      34           0 : }
      35             : 
      36             : void
      37           0 : sendFile(const std::string& accountId,
      38             :          const std::string& conversationId,
      39             :          const std::string& path,
      40             :          const std::string& displayName,
      41             :          const std::string& replyTo) noexcept
      42             : {
      43           0 :     if (auto acc = jami::Manager::instance().getAccount<jami::JamiAccount>(accountId)) {
      44           0 :         acc->sendFile(conversationId, path, displayName, replyTo);
      45           0 :     }
      46           0 : }
      47             : 
      48             : bool
      49           0 : downloadFile(const std::string& accountId,
      50             :              const std::string& conversationId,
      51             :              const std::string& interactionId,
      52             :              const std::string& fileId,
      53             :              const std::string& path) noexcept
      54             : {
      55           0 :     if (auto acc = jami::Manager::instance().getAccount<jami::JamiAccount>(accountId))
      56           0 :         if (auto convModule = acc->convModule(true))
      57           0 :             return convModule->downloadFile(conversationId, interactionId, fileId, path);
      58           0 :     return {};
      59             : }
      60             : 
      61             : DataTransferError
      62           0 : cancelDataTransfer(const std::string& accountId,
      63             :                    const std::string& conversationId,
      64             :                    const std::string& fileId) noexcept
      65             : {
      66           0 :     if (auto acc = jami::Manager::instance().getAccount<jami::JamiAccount>(accountId)) {
      67           0 :         if (auto dt = acc->dataTransfer(conversationId))
      68           0 :             return dt->cancel(fileId) ? libjami::DataTransferError::success
      69           0 :                                       : libjami::DataTransferError::invalid_argument;
      70           0 :     }
      71           0 :     return libjami::DataTransferError::invalid_argument;
      72             : }
      73             : 
      74             : DataTransferError
      75           0 : fileTransferInfo(const std::string& accountId,
      76             :                  const std::string& conversationId,
      77             :                  const std::string& fileId,
      78             :                  std::string& path,
      79             :                  int64_t& total,
      80             :                  int64_t& progress) noexcept
      81             : {
      82           0 :     if (auto acc = jami::Manager::instance().getAccount<jami::JamiAccount>(accountId)) {
      83           0 :         if (auto dt = acc->dataTransfer(conversationId))
      84           0 :             return dt->info(fileId, path, total, progress)
      85           0 :                        ? libjami::DataTransferError::success
      86           0 :                        : libjami::DataTransferError::invalid_argument;
      87           0 :     }
      88           0 :     return libjami::DataTransferError::invalid_argument;
      89             : }
      90             : 
      91             : } // namespace libjami

Generated by: LCOV version 1.14