Commit e80aa34f authored by Ghislain MARY's avatar Ghislain MARY

Use properties in LinphoneAddress object.

parent 3328dc2c
#include "LinphoneAddress.h"
#include "Server.h"
Platform::String^ Linphone::Core::LinphoneAddress::GetDisplayName()
Platform::String^ Linphone::Core::LinphoneAddress::DisplayName::get()
{
return Linphone::Core::Utils::cctops(linphone_address_get_display_name(this->address));
}
Platform::String^ Linphone::Core::LinphoneAddress::GetUserName()
Platform::String^ Linphone::Core::LinphoneAddress::UserName::get()
{
return Linphone::Core::Utils::cctops(linphone_address_get_username(this->address));
}
Platform::String^ Linphone::Core::LinphoneAddress::GetDomain()
Platform::String^ Linphone::Core::LinphoneAddress::Domain::get()
{
return Linphone::Core::Utils::cctops(linphone_address_get_domain(this->address));
}
int Linphone::Core::LinphoneAddress::GetPort()
int Linphone::Core::LinphoneAddress::Port::get()
{
return linphone_address_get_port(this->address);
}
Linphone::Core::LinphoneTransport Linphone::Core::LinphoneAddress::GetTransport()
Linphone::Core::LinphoneTransport Linphone::Core::LinphoneAddress::Transport::get()
{
LinphoneTransportType transport = linphone_address_get_transport(this->address);
switch (transport)
......@@ -39,33 +39,38 @@ Linphone::Core::LinphoneTransport Linphone::Core::LinphoneAddress::GetTransport(
}
}
void Linphone::Core::LinphoneAddress::SetDisplayName(Platform::String^ name)
Platform::String^ Linphone::Core::LinphoneAddress::Scheme::get()
{
return Linphone::Core::Utils::cctops(linphone_address_get_scheme(this->address));
}
void Linphone::Core::LinphoneAddress::DisplayName::set(Platform::String^ name)
{
const char *cc = Linphone::Core::Utils::pstoccs(name);
linphone_address_set_display_name(this->address, cc);
delete(cc);
}
void Linphone::Core::LinphoneAddress::SetUserName(Platform::String^ username)
void Linphone::Core::LinphoneAddress::UserName::set(Platform::String^ username)
{
const char *cc = Linphone::Core::Utils::pstoccs(username);
linphone_address_set_username(this->address, cc);
delete(cc);
}
void Linphone::Core::LinphoneAddress::SetDomain(Platform::String^ domain)
void Linphone::Core::LinphoneAddress::Domain::set(Platform::String^ domain)
{
const char *cc = Linphone::Core::Utils::pstoccs(domain);
linphone_address_set_domain(this->address, cc);
delete(cc);
}
void Linphone::Core::LinphoneAddress::SetPort(int port)
void Linphone::Core::LinphoneAddress::Port::set(int port)
{
linphone_address_set_port(this->address, port);
}
void Linphone::Core::LinphoneAddress::SetTransport(Linphone::Core::LinphoneTransport transport)
void Linphone::Core::LinphoneAddress::Transport::set(Linphone::Core::LinphoneTransport transport)
{
LinphoneTransportType transportType = LinphoneTransportUdp;
if (transport == LinphoneTransport::LinphoneTransportTCP)
......
......@@ -29,68 +29,64 @@ namespace Linphone
{
public:
/// <summary>
/// Gets the human display name of the address.
/// The human display name of the address.
/// For example for the "Alice &lt;sip:alice@example.net&gt;" URI, it will return "Alice".
/// </summary>
/// <returns>The human display name or an empty string if not set</returns>
Platform::String^ GetDisplayName();
property Platform::String^ DisplayName
{
Platform::String^ get();
void set(Platform::String^ value);
}
/// <summary>
/// Gets the username part of the address.
/// The username part of the address.
/// For example for the "Alice &lt;sip:alice@example.net&gt;" URI, it will return "alice".
/// </summary>
/// <returns>The username part of the address or an empty string if not set</returns>
Platform::String^ GetUserName();
property Platform::String^ UserName
{
Platform::String^ get();
void set(Platform::String^ value);
}
/// <summary>
/// Gets the domain part of the address.
/// The domain part of the address.
/// For example for the "Alice &lt;sip:alice@example.net&gt;" URI, it will return "example.net".
/// </summary>
/// <returns>The domain part of the address or an empty string if not set</returns>
Platform::String^ GetDomain();
/// <summary>
/// Gets the port part of the address.
/// </summary>
/// <returns>The port part of the address or 0 if not set</returns>
int GetPort();
/// <summary>
/// Gets the transport of the address.
/// </summary>
/// <returns>The transport if specified. If not set, it will return UDP.</returns>
LinphoneTransport GetTransport();
/// <summary>
/// Sets the human display name of the address.
/// </summary>
/// <param name="name">The human display name to set to the address</param>
void SetDisplayName(Platform::String^ name);
property Platform::String^ Domain
{
Platform::String^ get();
void set(Platform::String^ value);
}
/// <summary>
/// Sets the username part of the address.
/// The port part of the address.
/// </summary>
/// <param name="username">The username to set to the address</param>
void SetUserName(Platform::String^ username);
property int Port
{
int get();
void set(int value);
}
/// <summary>
/// Sets the domain part of the address.
/// The transport of the address.
/// </summary>
/// <param name="domain">The domain to set to the address</param>
void SetDomain(Platform::String^ domain);
property LinphoneTransport Transport
{
LinphoneTransport get();
void set(LinphoneTransport value);
}
/// <summary>
/// Sets the port part of the address.
/// The address scheme, normally "sip".
/// </summary>
/// <param name="port">The port to set to the address</param>
void SetPort(int port);
property Platform::String^ Scheme
{
Platform::String^ get();
}
/// <summary>
/// Sets the transport in the address.
/// Removes address's tags and uri headers so that it is displayable to the user.
/// </summary>
/// <param name="transport">The transport to set.</param>
void SetTransport(LinphoneTransport transport);
void Clean();
/// <summary>
......
......@@ -1552,10 +1552,10 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
Linphone::Core::CallController^ callController = Linphone::Core::Globals::Instance->CallController;
if (state == Linphone::Core::LinphoneCallState::IncomingReceived) {
Platform::String^ name = lCall->GetRemoteAddress()->GetDisplayName();
Platform::String^ name = lCall->GetRemoteAddress()->DisplayName;
if (name == nullptr || name->Length() <= 0)
{
name = lCall->GetRemoteAddress()->GetUserName();
name = lCall->GetRemoteAddress()->UserName;
}
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = callController->OnIncomingCallReceived(lCall, name, lCall->GetRemoteAddress()->AsStringUriOnly(), callController->IncomingCallViewDismissed);
lCall->CallContext = platformCall;
......@@ -1583,7 +1583,7 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
Windows::Phone::Networking::Voip::VoipPhoneCall^ platformCall = (Windows::Phone::Networking::Voip::VoipPhoneCall^) lCall->CallContext;
if (platformCall == nullptr) {
// If CallContext is null here, it is because we have an incoming call using the custom incoming call view so create the VoipPhoneCall now
platformCall = callController->NewIncomingCallForCustomIncomingCallView(lCall->GetRemoteAddress()->GetDisplayName());
platformCall = callController->NewIncomingCallForCustomIncomingCallView(lCall->GetRemoteAddress()->DisplayName);
lCall->CallContext = platformCall;
}
if (lCall->IsCameraEnabled()) {
......
......@@ -46,9 +46,9 @@ Linphone::Core::LinphoneAddress^ LinphoneCoreFactory::CreateLinphoneAddress(Plat
{
API_LOCK;
Linphone::Core::LinphoneAddress^ address = CreateLinphoneAddress("sip:user@domain.com");
address->SetUserName(username);
address->SetDomain(domain);
address->SetDisplayName(displayName);
address->UserName = username;
address->Domain = domain;
address->DisplayName = displayName;
API_UNLOCK;
return address;
}
......
......@@ -156,8 +156,8 @@ namespace Linphone.Model
public void FindContact(String numberOrAddress)
{
LinphoneAddress address = LinphoneManager.Instance.LinphoneCore.InterpretURL(numberOrAddress);
string addressWithoutScheme = String.Format("{0}@{1}", address.GetUserName(), address.GetDomain());
string username = address.GetUserName();
string addressWithoutScheme = String.Format("{0}@{1}", address.UserName, address.Domain);
string username = address.UserName;
if (IsPhoneNumber(username))
{
FindContactByNumber(username, addressWithoutScheme);
......
......@@ -459,18 +459,18 @@ namespace Linphone.Model
{
foreach (LinphoneCallLog log in LinphoneCore.GetCallLogs())
{
string from = log.GetFrom().GetDisplayName();
string from = log.GetFrom().DisplayName;
if (from.Length == 0)
{
LinphoneAddress fromAddress = log.GetFrom();
from = String.Format("{0}@{1}", fromAddress.GetUserName(), fromAddress.GetDomain());
from = String.Format("{0}@{1}", fromAddress.UserName, fromAddress.Domain);
}
string to = log.GetTo().GetDisplayName();
string to = log.GetTo().DisplayName;
if (to.Length == 0)
{
LinphoneAddress toAddress = log.GetTo();
to = String.Format("{0}@{1}", toAddress.GetUserName(), toAddress.GetDomain());
to = String.Format("{0}@{1}", toAddress.UserName, toAddress.Domain);
}
bool isMissed = log.GetStatus() == LinphoneCallStatus.Missed;
......@@ -868,16 +868,16 @@ namespace Linphone.Model
if (call.GetDirection() == CallDirection.Outgoing)
{
text = ResourceManager.GetString("CallErrorDeclined", CultureInfo.CurrentCulture);
ShowCallError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
ShowCallError(text.Replace("#address#", call.GetRemoteAddress().UserName));
}
break;
case Reason.LinphoneReasonNotFound:
text = ResourceManager.GetString("CallErrorNotFound", CultureInfo.CurrentCulture);
ShowCallError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
ShowCallError(text.Replace("#address#", call.GetRemoteAddress().UserName));
break;
case Reason.LinphoneReasonBusy:
text = ResourceManager.GetString("CallErrorBusy", CultureInfo.CurrentCulture);
ShowCallError(text.Replace("#address#", call.GetRemoteAddress().GetUserName()));
ShowCallError(text.Replace("#address#", call.GetRemoteAddress().UserName));
break;
case Reason.LinphoneReasonNotAcceptable:
ShowCallError(ResourceManager.GetString("CallErrorNotAcceptable", CultureInfo.CurrentCulture));
......@@ -1044,7 +1044,7 @@ namespace Linphone.Model
BaseModel.UIDispatcher.BeginInvoke(() =>
{
LinphoneAddress fromAddress = message.GetFrom();
string sipAddress = String.Format("{0}@{1}", fromAddress.GetUserName(), fromAddress.GetDomain());
string sipAddress = String.Format("{0}@{1}", fromAddress.UserName, fromAddress.Domain);
Logger.Msg("[LinphoneManager] Message received from " + sipAddress + ": " + message.GetText() + "\r\n");
//Vibrate
......@@ -1123,7 +1123,7 @@ namespace Linphone.Model
{
string currentListenerSipAddress = ComposingListener.GetSipAddressAssociatedWithDisplayConversation();
LinphoneAddress peerAddress = room.GetPeerAddress();
string roomComposingSipAddress = String.Format("{0}@{1}", peerAddress.GetUserName(), peerAddress.GetDomain());
string roomComposingSipAddress = String.Format("{0}@{1}", peerAddress.UserName, peerAddress.Domain);
if (currentListenerSipAddress != null && roomComposingSipAddress.Equals(currentListenerSipAddress))
ComposingListener.ComposeReceived();
......@@ -1194,9 +1194,9 @@ namespace Linphone.Model
try
{
LinphoneAddress remoteAddress = call.GetRemoteAddress();
if (remoteAddress.GetDisplayName().Length == 0)
if (remoteAddress.DisplayName.Length == 0)
{
string sipAddress = String.Format("{0}@{1}", remoteAddress.GetUserName(), remoteAddress.GetDomain());
string sipAddress = String.Format("{0}@{1}", remoteAddress.UserName, remoteAddress.Domain);
Logger.Msg("[LinphoneManager] Display name null, looking for remote address in contact: " + sipAddress + "\r\n");
ContactManager.ContactFound += OnContactFound;
......@@ -1204,7 +1204,7 @@ namespace Linphone.Model
}
else
{
Logger.Msg("[LinphoneManager] Display name found: " + call.GetRemoteAddress().GetDisplayName() + "\r\n");
Logger.Msg("[LinphoneManager] Display name found: " + call.GetRemoteAddress().DisplayName + "\r\n");
}
}
catch
......@@ -1224,7 +1224,7 @@ namespace Linphone.Model
// Store the contact name as display name for call logs
if (LinphoneManager.Instance.LinphoneCore.GetCurrentCall() != null)
{
LinphoneManager.Instance.LinphoneCore.GetCurrentCall().GetRemoteAddress().SetDisplayName(e.ContactFound.DisplayName);
LinphoneManager.Instance.LinphoneCore.GetCurrentCall().GetRemoteAddress().DisplayName = e.ContactFound.DisplayName;
}
}
ContactManager.ContactFound -= OnContactFound;
......
......@@ -278,9 +278,9 @@ namespace Linphone.Model
{
LinphoneAddress proxyAddress = LinphoneManager.Instance.LinphoneCoreFactory.CreateLinphoneAddress(cfg.GetAddr());
dict[ProxyKeyName] = proxyAddress.AsStringUriOnly();
dict[TransportKeyName] = EnumToTransport[proxyAddress.GetTransport()];
dict[UsernameKeyName] = address.GetUserName();
dict[DomainKeyName] = address.GetDomain();
dict[TransportKeyName] = EnumToTransport[proxyAddress.Transport];
dict[UsernameKeyName] = address.UserName;
dict[DomainKeyName] = address.Domain;
dict[OutboundProxyKeyName] = (cfg.GetRoute().Length > 0).ToString();
var authInfos = LinphoneManager.Instance.LinphoneCore.GetAuthInfos();
if (authInfos.Count > 0)
......@@ -289,7 +289,7 @@ namespace Linphone.Model
dict[PasswordKeyName] = info.GetPassword();
dict[UserIdKeyName] = info.GetUserId();
}
dict[DisplayNameKeyName] = address.GetDisplayName();
dict[DisplayNameKeyName] = address.DisplayName;
}
}
}
......@@ -361,7 +361,7 @@ namespace Linphone.Model
LinphoneAddress proxyAddr = LinphoneManager.Instance.LinphoneCoreFactory.CreateLinphoneAddress(cfg.GetAddr());
if (proxyAddr != null)
{
proxyAddr.SetTransport(TransportToEnum[transport]);
proxyAddr.Transport = TransportToEnum[transport];
cfg.SetProxy(proxyAddr.AsStringUriOnly());
}
}
......
......@@ -17,7 +17,7 @@ namespace Linphone.Model
{
string sipAddress = (string)value;
LinphoneAddress addr = LinphoneManager.Instance.LinphoneCore.InterpretURL(sipAddress);
return addr.GetUserName();
return addr.UserName;
}
/// <summary>
......
......@@ -276,8 +276,8 @@ namespace Linphone.Views
private void CreateChatRoom(LinphoneAddress sipAddress)
{
this.sipAddress = sipAddress;
ContactManager.Instance.FindContact(String.Format("{0}@{1}", sipAddress.GetUserName(), sipAddress.GetDomain()));
ContactName.Text = sipAddress.GetUserName();
ContactManager.Instance.FindContact(String.Format("{0}@{1}", sipAddress.UserName, sipAddress.Domain));
ContactName.Text = sipAddress.UserName;
ContactName.Visibility = Visibility.Visible;
NewChat.Visibility = Visibility.Collapsed;
......@@ -503,9 +503,9 @@ namespace Linphone.Views
Debug.WriteLine("[Chat] Is remote composing ? " + isRemoteComposing);
RemoteComposing.Visibility = isRemoteComposing ? Visibility.Visible : Visibility.Collapsed;
string remoteName = chatRoom.GetPeerAddress().GetDisplayName();
string remoteName = chatRoom.GetPeerAddress().DisplayName;
if (remoteName.Length <= 0)
remoteName = chatRoom.GetPeerAddress().GetUserName();
remoteName = chatRoom.GetPeerAddress().UserName;
RemoteComposing.Text = remoteName + AppResources.RemoteComposing;
}
......@@ -515,7 +515,7 @@ namespace Linphone.Views
/// <returns></returns>
public string GetSipAddressAssociatedWithDisplayConversation()
{
return String.Format("{0}@{1}", sipAddress.GetUserName(), sipAddress.GetDomain());
return String.Format("{0}@{1}", sipAddress.UserName, sipAddress.Domain);
}
private void scrollToBottom()
......
......@@ -117,11 +117,11 @@ namespace Linphone.Views
if (conversation.GetHistorySize() > 0)
{
LinphoneAddress peerAddress = conversation.GetPeerAddress();
string address = String.Format("{0}@{1}", peerAddress.GetUserName(), peerAddress.GetDomain());
string name = peerAddress.GetDisplayName();
string address = String.Format("{0}@{1}", peerAddress.UserName, peerAddress.Domain);
string name = peerAddress.DisplayName;
if (name == null || name.Length <= 0)
{
name = peerAddress.GetUserName();
name = peerAddress.UserName;
}
_conversations.Add(new Conversation(address, name, conversation.GetHistory()));
ContactManager.Instance.FindContact(address);
......
......@@ -186,7 +186,7 @@ namespace Linphone.Views
{
String calledNumber = NavigationContext.QueryString["sip"];
LinphoneAddress address = LinphoneManager.Instance.LinphoneCore.InterpretURL(calledNumber);
calledNumber = String.Format("{0}@{1}", address.GetUserName(), address.GetDomain());
calledNumber = String.Format("{0}@{1}", address.UserName, address.Domain);
// While we dunno if the number matches a contact one, we consider it won't and we display the phone number as username
Contact.Text = calledNumber;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment