LCOV - code coverage report
Current view: top level - src - account_config.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 20 20 100.0 %
Date: 2024-04-27 08:55:53 Functions: 6 6 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  This program is free software; you can redistribute it and/or modify
       5             :  *  it under the terms of the GNU General Public License as published by
       6             :  *  the Free Software Foundation; either version 3, or (at your option)
       7             :  *  any later version.
       8             :  *
       9             :  *  This program is distributed in the hope that it will be useful,
      10             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  *  GNU General Public License for more details.
      13             :  *
      14             :  *  You should have received a copy of the GNU General Public License
      15             :  *  along with this program; if not, see <https://www.gnu.org/licenses/>.
      16             :  */
      17             : #pragma once
      18             : #include "connectivity/sip_utils.h"
      19             : #include "config/serializable.h"
      20             : #include "string_utils.h"
      21             : 
      22             : #include <string>
      23             : #include <string_view>
      24             : #include <utility>
      25             : #include <map>
      26             : #include <filesystem>
      27             : 
      28             : using namespace std::literals;
      29             : 
      30             : namespace jami {
      31             : constexpr const char* const DEFAULT_RINGTONE_PATH = "default.opus";
      32             : 
      33             : struct AccountConfig : public Serializable
      34             : {
      35         956 :     AccountConfig(const std::string& type_, const std::string& id_, const std::filesystem::path& path_ = {})
      36        1912 :         : type(type_)
      37         956 :         , id(id_)
      38        1912 :         , path(path_)
      39         956 :     {}
      40             : 
      41             :     void serializeDiff(YAML::Emitter& out, const AccountConfig& def) const;
      42             : 
      43             :     virtual void serialize(YAML::Emitter& out) const = 0;
      44             :     virtual void unserialize(const YAML::Node& node);
      45             : 
      46             :     virtual std::map<std::string, std::string> toMap() const;
      47             :     virtual void fromMap(const std::map<std::string, std::string>&);
      48             : 
      49             :     /** Account type */
      50             :     const std::string type;
      51             : 
      52             :     /** Account id */
      53             :     const std::string id;
      54             : 
      55             :     /** Path where the configuration file is stored.
      56             :      * Part of the context but not stored in the configuration
      57             :      * Used to compute relative paths for configuraton fields */
      58             :     const std::filesystem::path path;
      59             : 
      60             :     /** A user-defined name for this account */
      61             :     std::string alias {};
      62             : 
      63             :     std::string username {};
      64             : 
      65             :     /** SIP hostname (SIP account) or DHT bootstrap nodes (Jami account) */
      66             :     std::string hostname {};
      67             : 
      68             :     /** True if the account is enabled. */
      69             :     bool enabled {true};
      70             : 
      71             :     /** If true, automatically answer calls to this account */
      72             :     bool autoAnswerEnabled {false};
      73             : 
      74             :     /** If true, send displayed status (and emit to the client) */
      75             :     bool sendReadReceipt {true};
      76             : 
      77             :     /** If true, send composing status (and emit to the client) */
      78             :     bool sendComposing {true};
      79             : 
      80             :     /** If true mix calls into a conference */
      81             :     bool isRendezVous {false};
      82             : 
      83             :     /**
      84             :      * The number of concurrent calls for the account
      85             :      * -1: Unlimited
      86             :      *  0: Do not disturb
      87             :      *  1: Single call
      88             :      *  +: Multi line
      89             :      */
      90             :     int activeCallLimit {-1};
      91             : 
      92             :     std::vector<unsigned> activeCodecs {};
      93             : 
      94             :     /**
      95             :      * Play ringtone when receiving a call
      96             :      */
      97             :     bool ringtoneEnabled {true};
      98             : 
      99             :     /**
     100             :      * Ringtone file used for this account
     101             :      */
     102             :     std::string ringtonePath {DEFAULT_RINGTONE_PATH};
     103             : 
     104             :     /**
     105             :      * Allows user to temporarily disable video calling
     106             :      */
     107             :     bool videoEnabled {true};
     108             : 
     109             :     /**
     110             :      * Display name when calling
     111             :      */
     112             :     std::string displayName {};
     113             : 
     114             :     /**
     115             :      * User-agent used for registration
     116             :      */
     117             :     std::string customUserAgent {};
     118             : 
     119             :     /**
     120             :      * Account mail box
     121             :      */
     122             :     std::string mailbox {};
     123             : 
     124             :     /**
     125             :      * UPnP IGD controller and the mutex to access it
     126             :      */
     127             :     bool upnpEnabled {true};
     128             : 
     129             :     std::set<std::string> defaultModerators {};
     130             :     bool localModeratorsEnabled {true};
     131             :     bool allModeratorsEnabled {true};
     132             : 
     133             :     /**
     134             :      * Device push notification token.
     135             :      */
     136             :     std::string deviceKey {};
     137             :     /**
     138             :      * Device push notification platform.
     139             :      */
     140             :     std::string platform {};
     141             : 
     142             :     /**
     143             :      * Push notification topic.
     144             :      */
     145             :     std::string notificationTopic {};
     146             : 
     147             :     /**
     148             :      * information about the customization of ui
     149             :      */
     150             :     std::string uiCustomization {};
     151             : };
     152             : 
     153             : inline void
     154       38199 : parseString(const std::map<std::string, std::string>& details, const char* key, std::string& s)
     155             : {
     156       38199 :     auto it = details.find(key);
     157       38199 :     if (it != details.end())
     158       16846 :         s = it->second;
     159       38199 : }
     160             : 
     161             : inline void
     162       25941 : parseBool(const std::map<std::string, std::string>& details, const char* key, bool& s)
     163             : {
     164       25941 :     auto it = details.find(key);
     165       25941 :     if (it != details.end())
     166       13778 :         s = it->second == TRUE_STR;
     167       25941 : }
     168             : 
     169             : template<class T>
     170             : inline void
     171        7494 : parseInt(const std::map<std::string, std::string>& details, const char* key, T& s)
     172             : {
     173        7494 :     auto it = details.find(key);
     174        7494 :     if (it != details.end())
     175        4005 :         s = to_int<T>(it->second);
     176        7494 : }
     177             : 
     178             : void parsePath(const std::map<std::string, std::string>& details,
     179             :                const char* key,
     180             :                std::string& s,
     181             :                const std::filesystem::path& base);
     182             : 
     183             : } // namespace jami

Generated by: LCOV version 1.14