ProxyConfig.h 7.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
ProxyConfig.h
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
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#pragma once

#include "ApiLock.h"
#include "Core.h"


23
namespace BelledonneCommunications
24
{
25
	namespace Linphone
26
	{
27
		namespace Native
28 29
		{
			/// <summary>
30 31 32 33 34 35
			/// This object represents a proxy configuration to be used by the Core object. 
			/// Its fields mustn't be used directly in favour of the accessors methods.
			/// Once created and filled properly, the ProxyConfig can be given to Core using Core::AddProxyConfig.
			/// This will automatically triggers the registration if enabled.
			/// The proxy configuration are persistent to restarts because they are saved in the configuration file.
			/// As a consequence, after creating a Core there might already be a default proxy that can be examined with Core::GetDefaultProxyConfig.
36
			/// </summary>
37
			public ref class ProxyConfig sealed
38
			{
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 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 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
			public:
				/// <summary>
				/// Sets the contact params to be sent along with the REGISTERs.
				/// </summary>
				property Platform::String^ ContactParameters
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// Set optional contact parameters that will be added to the contact information sent in the registration, inside the URI.
				/// The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id.
				/// As an example, the contact address in the SIP register sent will look like &lt;sip:joe@15.128.128.93:50421;apple-push-id=43143-DFE23F-2323-FA2232&gt;.
				/// </summary>
				property Platform::String^ ContactUriParameters
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// Sets whether Linphone should replace "+" by "00" in dialed numbers passed to Core::Invite.
				/// </summary>
				property Platform::Boolean DialEscapePlus
				{
					Platform::Boolean get();
					void set(Platform::Boolean value);
				}

				/// <summary>
				/// Automatically add international prefix to e164 phone numbers
				/// </summary>
				property Platform::String^ DialPrefix
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// Gets the domain of the address.
				/// </summary>
				property Platform::String^ Domain
				{
					Platform::String^ get();
				}

				/// <summary>
				/// Get the reason why registration failed when the proxy config state is LinphoneRegistrationFailed.
				/// <returns>The reason why registration failed for this proxy config.</returns>
				/// </summary>
				property Reason Error
				{
					Reason get();
				}

				/// <summary>
				/// Sets the registration expiration time in seconds.
				/// </summary>
				property int Expires
				{
					int get();
					void set(int value);
				}

				/// <summary>
				/// Sets the identity for this proxy config.
				/// </summary>
				property Platform::String^ Identity
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// Indicates whether AVPF/SAVPF is being used for calls using this proxy config.
				/// </summary>
				property Platform::Boolean IsAvpfEnabled
				{
					Platform::Boolean get();
					void set(Platform::Boolean value);
				}

				/// <summary>
				/// Indicates either or not PUBLISH must be issued for this ProxyConfig.
				/// </summary>
				property Platform::Boolean IsPublishEnabled
				{
					Platform::Boolean get();
					void set(Platform::Boolean value);
				}

				/// <summary>
				/// Returns true if this proxy config is currently registered, else returns false.
				/// </summary>
				property Platform::Boolean IsRegistered
				{
					Platform::Boolean get();
				}

				/// <summary>
				/// Enables register for this proxy config.
				/// Register message is issued after call to Done.
				/// </summary>
				property Platform::Boolean IsRegisterEnabled
				{
					Platform::Boolean get();
					void set(Platform::Boolean value);
				}

				/// <summary>
				/// Sets a SIP route.
				/// When a route is set, all outgoing calls will go the the route's destination if this proxy is the default one (see Core::GetDefaultProxyConfig).
				/// </summary>
				property Platform::String^ Route
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// Sets the proxy address.
				/// <example>
				/// Examples of valid sip proxy are:
				/// <list type="bullet">
				/// <item>
				/// <term>sip:87.98.157.38</term>
				/// <description>IP address</description>
				/// </item>
				/// <item>
				/// <term>sip:87.98.157.38:5062</term>
				/// <description>IP address with port</description>
				/// </item>
				/// <item>
				/// <term>sip:sip.example.net</term>
				/// <description>Hostname</description>
				/// </item>
				/// </list>
				/// </example>
				/// </summary>
				property Platform::String^ ServerAddr
				{
					Platform::String^ get();
					void set(Platform::String^ value);
				}

				/// <summary>
				/// Returns the current RegistrationState for this proxy config.
				/// </summary>
				property RegistrationState State
				{
					RegistrationState get();
				}

				/// <summary>
				/// Commits changes made to the proxy config.
				/// </summary>
				void Done();

				/// <summary>
				/// Starts editing a proxy config.
				/// Because proxy config must be consistent, app MUST call Edit before doing any attempts to modify proxy config (such as identity, address and so on).
				/// Once modifications are done, then the app MUST call Done to commit the changes.
				/// </summary>
				void Edit();

				/// <summary>
				/// Returns the international prefix for the given e164 number.
				/// </summary>
				/// <param name="e164">The e164 number</param>
				/// <returns>The international prefix or -1 if not found</returns>
				int LookupCccFromE164(Platform::String^ e164);

				/// <summary>
				/// Returns the international prefix for the given country.
				/// </summary>
				/// <param name="iso">The country as ISO 3166-1 alpha-2 code</param>
				/// <returns>The international prefix or -1 if not found</returns>
				int LookupCccFromIso(Platform::String^ iso);

				/// <summary>
				/// Normalizes a human readable phone number into a basic string.
				/// <example>
				/// 888-444-222 becomes 888444222
				/// </example>
				/// </summary>
				/// <param name="phoneNumber">The phone number to be normalized</param>
				/// <returns>The normalized phone number</returns>
				Platform::String^ NormalizeNumber(Platform::String^ phoneNumber);

			private:
				friend ref class Core;
				friend class Utils;

				ProxyConfig(::LinphoneProxyConfig* proxyConfig);
				~ProxyConfig();

				::LinphoneProxyConfig *proxyConfig;
			};
		}
239
	}
240
}