LCOV - code coverage report
Current view: top level - src - account_config.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 100.0 % 20 20
Test Date: 2026-06-13 09:18:46 Functions: 100.0 % 6 6

            Line data    Source code
       1              : /*
       2              :  *  Copyright (C) 2004-2026 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 of the License, or
       7              :  *  (at your option) 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 "config/serializable.h"
      19              : #include "string_utils.h"
      20              : 
      21              : #include <string>
      22              : #include <utility>
      23              : #include <map>
      24              : #include <filesystem>
      25              : 
      26              : using namespace std::literals;
      27              : 
      28              : namespace jami {
      29              : constexpr const char* const DEFAULT_RINGTONE_PATH = "default.opus";
      30              : 
      31              : struct AccountConfig : public Serializable
      32              : {
      33         1199 :     AccountConfig(const std::string& type_, const std::string& id_, const std::filesystem::path& path_ = {})
      34         2398 :         : type(type_)
      35         1199 :         , id(id_)
      36         4796 :         , path(path_)
      37         1199 :     {}
      38              : 
      39              :     void serializeDiff(YAML::Emitter& out, const AccountConfig& def) const;
      40              : 
      41              :     virtual void serialize(YAML::Emitter& out) const = 0;
      42              :     virtual void unserialize(const YAML::Node& node);
      43              : 
      44              :     virtual std::map<std::string, std::string> toMap() const;
      45              :     virtual void fromMap(const std::map<std::string, std::string>&);
      46              : 
      47              :     /** Account type */
      48              :     const std::string type;
      49              : 
      50              :     /** Account id */
      51              :     const std::string id;
      52              : 
      53              :     /** Path where the configuration file is stored.
      54              :      * Part of the context but not stored in the configuration
      55              :      * Used to compute relative paths for configuraton fields */
      56              :     const std::filesystem::path path;
      57              : 
      58              :     /** A user-defined name for this account */
      59              :     std::string alias {};
      60              : 
      61              :     std::string username {};
      62              : 
      63              :     /** SIP hostname (SIP account) or DHT bootstrap nodes (Jami account) */
      64              :     std::string hostname {};
      65              : 
      66              :     /** True if the account is enabled. */
      67              :     bool enabled {true};
      68              : 
      69              :     /** If true, automatically answer calls to this account */
      70              :     bool autoAnswerEnabled {false};
      71              : 
      72              :     /** If true, automatically deny new calls when already in one call to this account */
      73              :     bool denySecondCallEnabled {false};
      74              : 
      75              :     /** If true, send displayed status (and emit to the client) */
      76              :     bool sendReadReceipt {true};
      77              : 
      78              :     /** If true, send composing status (and emit to the client) */
      79              :     bool sendComposing {true};
      80              : 
      81              :     /** If true mix calls into a conference */
      82              :     bool isRendezVous {false};
      83              : 
      84              :     /**
      85              :      * The number of concurrent calls for the account
      86              :      * -1: Unlimited
      87              :      *  0: Do not disturb
      88              :      *  1: Single call
      89              :      *  +: Multi line
      90              :      */
      91              :     int activeCallLimit {-1};
      92              : 
      93              :     std::vector<unsigned> activeCodecs {};
      94              : 
      95              :     /**
      96              :      * Play ringtone when receiving a call
      97              :      */
      98              :     bool ringtoneEnabled {true};
      99              : 
     100              :     /**
     101              :      * Ringtone file used for this account
     102              :      */
     103              :     std::string ringtonePath {DEFAULT_RINGTONE_PATH};
     104              : 
     105              :     /**
     106              :      * Allows user to temporarily disable video calling
     107              :      */
     108              :     bool videoEnabled {true};
     109              : 
     110              :     /**
     111              :      * Display name when calling
     112              :      */
     113              :     std::string displayName {};
     114              : 
     115              :     /**
     116              :      * User-agent used for registration
     117              :      */
     118              :     std::string customUserAgent {};
     119              : 
     120              :     /**
     121              :      * Account mail box
     122              :      */
     123              :     std::string mailbox {};
     124              : 
     125              :     /**
     126              :      * UPnP IGD controller and the mutex to access it
     127              :      */
     128              :     bool upnpEnabled {true};
     129              : 
     130              :     std::set<std::string> defaultModerators {};
     131              :     bool localModeratorsEnabled {true};
     132              :     bool allModeratorsEnabled {true};
     133              : 
     134              :     /**
     135              :      * Device push notification token.
     136              :      */
     137              :     std::string deviceKey {};
     138              :     /**
     139              :      * Device push notification platform.
     140              :      */
     141              :     std::string platform {};
     142              : 
     143              :     /**
     144              :      * Push notification topic.
     145              :      */
     146              :     std::string notificationTopic {};
     147              : 
     148              :     /**
     149              :      * information about the customization of ui
     150              :      */
     151              :     std::string uiCustomization {};
     152              : };
     153              : 
     154              : inline void
     155        49328 : parseString(const std::map<std::string, std::string>& details, const char* key, std::string& s)
     156              : {
     157        49328 :     auto it = details.find(key);
     158        49328 :     if (it != details.end())
     159        20877 :         s = it->second;
     160        49328 : }
     161              : 
     162              : inline void
     163        38184 : parseBool(const std::map<std::string, std::string>& details, const char* key, bool& s)
     164              : {
     165        38184 :     auto it = details.find(key);
     166        38184 :     if (it != details.end())
     167        20151 :         s = it->second == TRUE_STR;
     168        38184 : }
     169              : 
     170              : template<class T>
     171              : inline void
     172        11216 : parseInt(const std::map<std::string, std::string>& details, const char* key, T& s)
     173              : {
     174        11216 :     auto it = details.find(key);
     175        11216 :     if (it != details.end())
     176         5940 :         s = to_int<T>(it->second);
     177        11216 : }
     178              : 
     179              : void parsePath(const std::map<std::string, std::string>& details,
     180              :                const char* key,
     181              :                std::string& s,
     182              :                const std::filesystem::path& base);
     183              : 
     184              : } // namespace jami
        

Generated by: LCOV version 2.0-1