Config.h 7.68 KB
Newer Older
1
/*
Erwan Croze's avatar
Erwan Croze committed
2
Config.h
3 4 5 6 7 8 9 10 11 12 13
Copyright (C) 2015  Belledonne Communications, Grenoble, France
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 2
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, write to the Free Software
14
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
15 16 17 18 19 20 21
*/

#pragma once

#include "Core.h"


22
namespace BelledonneCommunications
23
{
24
	namespace Linphone
25
	{
26
		namespace Native
27
		{
28
			ref class Core;
29 30

			/// <summary>
31 32 33 34 35 36 37 38 39 40 41 42
			/// Object used to manipulate a configuration file.
			/// The format of the configuration file is a .ini like format:
			/// - sections are defined in []
			/// - each section contains a sequence of key=value pairs.
			/// <example>
			/// [sound]
			/// echocanceler=1
			/// playback_dev=ALSA: Default device
			/// 
			/// [video]
			/// enabled=1
			/// </example>
43
			/// </summary>
Erwan Croze's avatar
Erwan Croze committed
44
			public ref class Config sealed
45 46 47
			{
			public:
				/// <summary>
Erwan Croze's avatar
Erwan Croze committed
48
				/// Creates a Config object using the path to linphonerc files.
49 50 51
				/// </summary>
				/// <param name="configPath">The path to the user configuration file that must be readable and writable</param>
				/// <param name="factoryConfigPath">The path to the factory configuration file that only needs to be readable</param>
Erwan Croze's avatar
Erwan Croze committed
52 53
				/// <returns>The created Config</returns>
				Config(Platform::String^ configPath, Platform::String^ factoryConfigPath);
54 55

				/// <summary>
Erwan Croze's avatar
Erwan Croze committed
56
				/// Destructor of Config object.
57
				/// </summary>
Erwan Croze's avatar
Erwan Croze committed
58
				virtual ~Config();
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165

				/// <summary>
				/// Gets a boolean configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="defaultValue">The value to return if the configuration item is not found</param>
				/// <returns>The value of the configuration item or defaultValue if the item is not found</returns>
				bool GetBool(Platform::String^ section, Platform::String^ key, bool defaultValue);

				/// <summary>
				/// Sets a boolean configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="value">The value to set for the configuration item</param>
				void SetBool(Platform::String^ section, Platform::String^ key, bool value);

				/// <summary>
				/// Gets an integer configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="defaultValue">The value to return if the configuration item is not found</param>
				/// <returns>The value of the configuration item or defaultValue if the item is not found</returns>
				int GetInt(Platform::String^ section, Platform::String^ key, int defaultValue);

				/// <summary>
				/// Sets an integer configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="value">The value to set for the configuration item</param>
				void SetInt(Platform::String^ section, Platform::String^ key, int value);

				/// <summary>
				/// Gets a 64 bit integer configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="defaultValue">The value to return if the configuration item is not found</param>
				/// <returns>The value of the configuration item or defaultValue if the item is not found</returns>
				int64 GetInt64(Platform::String^ section, Platform::String^ key, int64 defaultValue);

				/// <summary>
				/// Sets a 64 bit integer configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="value">The value to set for the configuration item</param>
				void SetInt64(Platform::String^ section, Platform::String^ key, int64 value);

				/// <summary>
				/// Gets a float configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="defaultValue">The value to return if the configuration item is not found</param>
				/// <returns>The value of the configuration item or defaultValue if the item is not found</returns>
				float GetFloat(Platform::String^ section, Platform::String^ key, float defaultValue);

				/// <summary>
				/// Sets a float configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="value">The value to set for the configuration item</param>
				void SetFloat(Platform::String^ section, Platform::String^ key, float value);

				/// <summary>
				/// Gets a string configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="defaultValue">The value to return if the configuration item is not found</param>
				/// <returns>The value of the configuration item or defaultValue if the item is not found</returns>
				Platform::String^ GetString(Platform::String^ section, Platform::String^ key, Platform::String^ defaultValue);

				/// <summary>
				/// Sets a string configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="value">The value to set for the configuration item</param>
				void SetString(Platform::String^ section, Platform::String^ key, Platform::String^ value);

				/// <summary>
				/// Gets an integer range configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="defaultValue">The value to return if the configuration item is not found</param>
				/// <returns>The value of the configuration item or defaultValue if the item is not found</returns>
				Platform::Array<int>^ GetRange(Platform::String^ section, Platform::String^ key, const Platform::Array<int>^ defaultValue);

				/// <summary>
				/// Sets an integer range configuration item.
				/// </summary>
				/// <param name="section">The name of the configuration section where the item is located</param>
				/// <param name="key">The configuration item name</param>
				/// <param name="value">The value to set for the configuration item</param>
				void SetRange(Platform::String^ section, Platform::String^ key, const Platform::Array<int>^ value);

			private:
				friend class Utils;
				friend ref class Core;

Erwan Croze's avatar
Erwan Croze committed
166
				Config(::LinphoneConfig *config);
167

Erwan Croze's avatar
Erwan Croze committed
168
				::LinphoneConfig *config;
169 170
			};
		}
171
	}
172
}