Commit dd215e31 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Stubs almost finished (need exceptions)

parent cafc6964
......@@ -145,7 +145,6 @@ popd</Command>
<ItemGroup>
<ClCompile Include="ApiLock.cpp" />
<ClCompile Include="CallController.cpp" />
<ClCompile Include="CallDirection.cpp" />
<ClCompile Include="Globals.cpp" />
<ClCompile Include="LinphoneAddress.cpp" />
<ClCompile Include="LinphoneAuthInfo.cpp" />
......@@ -157,7 +156,6 @@ popd</Command>
<ClCompile Include="LinphoneCoreFactory.cpp" />
<ClCompile Include="LinphoneProxyConfig.cpp" />
<ClCompile Include="LpConfig.cpp" />
<ClCompile Include="OnlineStatus.cpp" />
<ClCompile Include="PayloadType.cpp" />
</ItemGroup>
<ItemGroup>
......
#include "CallDirection.h"
#include "Server.h"
using namespace Linphone::BackEnd;
\ No newline at end of file
......@@ -4,9 +4,10 @@ namespace Linphone
{
namespace BackEnd
{
public ref class CallDirection sealed
public enum class CallDirection : int
{
Outgoing,
Incoming
};
}
}
\ No newline at end of file
......@@ -8,9 +8,9 @@
using namespace Linphone::BackEnd;
LinphoneCallState^ LinphoneCall::GetState()
LinphoneCallState LinphoneCall::GetState()
{
return nullptr;
return LinphoneCallState::Error;
}
LinphoneAddress^ LinphoneCall::GetRemoteAddress()
......@@ -18,9 +18,9 @@ LinphoneAddress^ LinphoneCall::GetRemoteAddress()
return nullptr;
}
CallDirection^ LinphoneCall::GetDirection()
CallDirection LinphoneCall::GetDirection()
{
return nullptr;
return CallDirection::Incoming;
}
LinphoneCallLog^ LinphoneCall::GetCallLog()
......
#pragma once
#include "CallDirection.h"
namespace Linphone
{
namespace BackEnd
{
ref class LinphoneAddress;
ref class CallDirection;
ref class LinphoneCallLog;
ref class LinphoneCallStats;
ref class LinphoneCallParams;
public ref class LinphoneCallState sealed
public enum class LinphoneCallState : int
{
Idle = 0,
IncomingReceived = 1,
OutgoingInit = 2,
OutgoingProgress = 3,
OutgoingRinging = 4,
OutgoingEarlyMedia = 5,
Connected = 6,
StreamsRunning = 7,
Pausing = 8,
Paused = 9,
Resuming = 10,
Refered = 11,
Error = 12,
CallEnd = 13,
PausedByRemote = 14,
UpdatedByRemote = 15,
IncomingEarlyMedia = 16,
Udating = 17,
Released = 18
};
public ref class LinphoneCall sealed
{
public:
LinphoneCallState^ GetState();
LinphoneCallState GetState();
LinphoneAddress^ GetRemoteAddress();
CallDirection^ GetDirection();
CallDirection GetDirection();
LinphoneCallLog^ GetCallLog();
LinphoneCallStats^ GetAudioStats();
LinphoneCallParams^ GetRemoteParams();
......
......@@ -15,14 +15,14 @@ LinphoneAddress^ LinphoneCallLog::GetTo()
return nullptr;
}
CallDirection^ LinphoneCallLog::GetDirection()
CallDirection LinphoneCallLog::GetDirection()
{
return nullptr;
return CallDirection::Incoming;
}
LinphoneCallStatus^ LinphoneCallLog::GetStatus()
LinphoneCallStatus LinphoneCallLog::GetStatus()
{
return nullptr;
return LinphoneCallStatus::Aborted;
}
Platform::String^ LinphoneCallLog::GetStartDate()
......
#pragma once
#include "CallDirection.h"
namespace Linphone
{
namespace BackEnd
{
ref class LinphoneAddress;
ref class CallDirection;
public ref class LinphoneCallStatus sealed
public enum class LinphoneCallStatus : int
{
Success = 0,
Aborted = 1,
Missed = 2,
Declined = 3
};
public ref class LinphoneCallLog sealed
......@@ -17,8 +21,8 @@ namespace Linphone
public:
LinphoneAddress^ GetFrom();
LinphoneAddress^ GetTo();
CallDirection^ GetDirection();
LinphoneCallStatus^ GetStatus();
CallDirection GetDirection();
LinphoneCallStatus GetStatus();
Platform::String^ GetStartDate();
int64 GetTimestamp();
int GetCallDuration();
......
......@@ -10,12 +10,12 @@ void LinphoneCallParams::SetAudioBandwidth()
}
MediaEncryption^ LinphoneCallParams::GetMediaEncryption()
MediaEncryption LinphoneCallParams::GetMediaEncryption()
{
return nullptr;
return MediaEncryption::None;
}
void LinphoneCallParams::SetMediaEncryption(MediaEncryption^ menc)
void LinphoneCallParams::SetMediaEncryption(MediaEncryption menc)
{
}
......
#pragma once
#include "LinphoneCore.h"
namespace Linphone
{
namespace BackEnd
{
ref class MediaEncryption;
ref class PayloadType;
public ref class LinphoneCallParams sealed
{
public:
void SetAudioBandwidth();
MediaEncryption^ GetMediaEncryption();
void SetMediaEncryption(MediaEncryption^ menc);
MediaEncryption GetMediaEncryption();
void SetMediaEncryption(MediaEncryption menc);
PayloadType^ GetUsedAudioCodec();
void EnableLowBandwidth(Platform::Boolean enable);
Platform::Boolean IsLowBandwidthEnabled();
......
......@@ -3,14 +3,14 @@
using namespace Linphone::BackEnd;
MediaType^ LinphoneCallStats::GetMediaType()
MediaType LinphoneCallStats::GetMediaType()
{
return nullptr;
return MediaType::Audio;
}
IceState^ LinphoneCallStats::GetIceState()
IceState LinphoneCallStats::GetIceState()
{
return nullptr;
return IceState::Failed;
}
float LinphoneCallStats::GetDownloadBandwidth()
......
......@@ -4,19 +4,27 @@ namespace Linphone
{
namespace BackEnd
{
public ref class MediaType sealed
public enum class MediaType : int
{
Audio = 0,
Video = 1
};
public ref class IceState sealed
public enum class IceState : int
{
NotActivated = 0,
Failed = 1,
InProgress = 2,
HostConnection = 3,
ReflexiveConnection = 4,
RelayConnection = 5
};
public ref class LinphoneCallStats sealed
{
public:
MediaType^ GetMediaType();
IceState^ GetIceState();
MediaType GetMediaType();
IceState GetIceState();
float GetDownloadBandwidth();
float GetUploadBandwidth();
float GetSenderLossRate();
......
......@@ -165,7 +165,7 @@ LinphoneCallParams^ LinphoneCore::CreateDefaultCallParameters()
return nullptr;
}
Windows::Foundation::Collections::IVector<LinphoneCallLog^>^ LinphoneCore::GetCallLOgs()
Windows::Foundation::Collections::IVector<LinphoneCallLog^>^ LinphoneCore::GetCallLogs()
{
return nullptr;
}
......@@ -305,7 +305,7 @@ void LinphoneCore::EnableIPv6(Platform::Boolean enable)
}
void LinphoneCore::SetPresenceInfo(int minuteAway, Platform::String^ alternativeContact, OnlineStatus^ status)
void LinphoneCore::SetPresenceInfo(int minuteAway, Platform::String^ alternativeContact, OnlineStatus status)
{
}
......@@ -320,14 +320,14 @@ Platform::String^ LinphoneCore::GetStunServer()
return nullptr;
}
void LinphoneCore::SetFirewallPolicy(FirewallPolicy^ policy)
void LinphoneCore::SetFirewallPolicy(FirewallPolicy policy)
{
}
FirewallPolicy^ LinphoneCore::GetFirewallPolicy()
FirewallPolicy LinphoneCore::GetFirewallPolicy()
{
return nullptr;
return FirewallPolicy::NoFirewall;
}
void LinphoneCore::SetRootCA(Platform::String^ path)
......@@ -465,19 +465,19 @@ Platform::Boolean LinphoneCore::IsSoundResourcesLocked()
return false;
}
Platform::Boolean LinphoneCore::IsMediaEncryptionSupported(MediaEncryption^ menc)
Platform::Boolean LinphoneCore::IsMediaEncryptionSupported(MediaEncryption menc)
{
return false;
}
void LinphoneCore::SetMediaEncryption(MediaEncryption^ menc)
void LinphoneCore::SetMediaEncryption(MediaEncryption menc)
{
}
MediaEncryption^ LinphoneCore::GetMediaEncryption()
MediaEncryption LinphoneCore::GetMediaEncryption()
{
return nullptr;
return MediaEncryption::None;
}
void LinphoneCore::SetMediaEncryptionMandatory(Platform::Boolean yesno)
......
#pragma once
#include "OnlineStatus.h"
namespace Linphone
{
namespace BackEnd
......@@ -12,19 +14,46 @@ namespace Linphone
ref class LinphoneCallParams;
ref class LinphoneCallLog;
ref class PayloadType;
ref class OnlineStatus;
ref class LpConfig;
public ref class RegistrationState sealed
public enum class GlobalState : int
{
GlobalOff = 0,
GlobalStartup = 1,
GlobalOn = 2,
GlobalShutdown = 3
};
public enum class RegistrationState : int
{
RegistrationNone = 0,
RegistrationInProgress = 1,
RegistrationOk = 2,
RegistrationCleared = 3,
RegistrationFailed = 4
};
public enum class MediaEncryption : int
{
None = 0,
SRTP = 1,
ZRTP = 2
};
public ref class MediaEncryption sealed
public enum class FirewallPolicy : int
{
NoFirewall = 0,
UseNatAddress = 1,
UseStun = 2,
UseIce = 3
};
public ref class FirewallPolicy sealed
public enum class EcCalibratorStatus : int
{
InProgress = 0,
Done = 1,
Failed = 2,
DoneNoEcho = 3
};
public ref class Transports sealed
......@@ -83,7 +112,7 @@ namespace Linphone
void UpdateCall(LinphoneCall^ call, LinphoneCallParams^ params);
LinphoneCallParams^ CreateDefaultCallParameters();
Windows::Foundation::Collections::IVector<LinphoneCallLog^>^ GetCallLOgs();
Windows::Foundation::Collections::IVector<LinphoneCallLog^>^ GetCallLogs();
void ClearCallLogs();
void RemoveCallLog(LinphoneCallLog^ log);
......@@ -118,13 +147,13 @@ namespace Linphone
Transports^ GetSignalingTransportsPorts();
void EnableIPv6(Platform::Boolean enable);
void SetPresenceInfo(int minuteAway, Platform::String^ alternativeContact, OnlineStatus^ status);
void SetPresenceInfo(int minuteAway, Platform::String^ alternativeContact, OnlineStatus status);
void SetStunServer(Platform::String^ stun);
Platform::String^ GetStunServer();
void SetFirewallPolicy(FirewallPolicy^ policy);
FirewallPolicy^ GetFirewallPolicy();
void SetFirewallPolicy(FirewallPolicy policy);
FirewallPolicy GetFirewallPolicy();
void SetRootCA(Platform::String^ path);
void SetUploadBandwidth(int bw);
......@@ -157,9 +186,9 @@ namespace Linphone
Platform::Boolean IsMyself(Platform::String^ uri);
Platform::Boolean IsSoundResourcesLocked();
Platform::Boolean IsMediaEncryptionSupported(MediaEncryption^ menc);
void SetMediaEncryption(MediaEncryption^ menc);
MediaEncryption^ GetMediaEncryption();
Platform::Boolean IsMediaEncryptionSupported(MediaEncryption menc);
void SetMediaEncryption(MediaEncryption menc);
MediaEncryption GetMediaEncryption();
void SetMediaEncryptionMandatory(Platform::Boolean yesno);
Platform::Boolean IsMediaEncryptionMandatory();
......
#pragma once
#include "ApiLock.h"
#include "LinphoneCoreListener.h"
namespace Linphone
{
......@@ -10,7 +11,6 @@ namespace Linphone
ref class LinphoneCore;
ref class LinphoneAuthInfo;
ref class LinphoneAddress;
ref class LinphoneCoreListener;
public ref class LinphoneCoreFactory sealed
{
......
#pragma once
#include "LinphoneCore.h"
#include "LinphoneCall.h"
namespace Linphone
{
namespace BackEnd
{
public ref class LinphoneCoreListener sealed
public interface class LinphoneCoreListener
{
void GlobalState(GlobalState state, Platform::String^ message);
void CallState(LinphoneCall^ call, LinphoneCallState state);
void RegistrationState(LinphoneProxyConfig^ config, RegistrationState state, Platform::String^ message);
void DTMFReceived(LinphoneCall^ call, int dtmf);
void EcCalibrationStatus(EcCalibratorStatus status, int delay_ms, Platform::Object^ data);
void CallEncryptionChanged(LinphoneCall^ call, Platform::Boolean encrypted, Platform::String^ authenticationToken);
void CallStatsUpdated(LinphoneCall^ call, LinphoneCallStats^ stats);
};
}
}
\ No newline at end of file
......@@ -84,9 +84,9 @@ Platform::Boolean LinphoneProxyConfig::IsPublishEnabled()
return false;
}
RegistrationState^ LinphoneProxyConfig::GetState()
RegistrationState LinphoneProxyConfig::GetState()
{
return nullptr;
return RegistrationState::RegistrationNone;
}
void LinphoneProxyConfig::SetExpires(int delay)
......
#pragma once
#include "LinphoneCore.h"
namespace Linphone
{
namespace BackEnd
{
ref class RegistrationState;
public ref class LinphoneProxyConfig sealed
{
public:
......@@ -25,7 +25,7 @@ namespace Linphone
Platform::String^ GetRoute();
void EnablePublish(Platform::Boolean enable);
Platform::Boolean IsPublishEnabled();
RegistrationState^ GetState();
RegistrationState GetState();
void SetExpires(int delay);
void SetContactParameters(Platform::String^ params);
int LookupCCCFromIso(Platform::String^ iso);
......
#include "OnlineStatus.h"
#include "Server.h"
using namespace Linphone::BackEnd;
\ No newline at end of file
......@@ -4,8 +4,19 @@ namespace Linphone
{
namespace BackEnd
{
public ref class OnlineStatus sealed
public enum class OnlineStatus : int
{
Offline = 0,
Online = 1,
Busy = 2,
BeRightBack = 3,
Away = 4,
OnThePhone = 5,
OutToLunch = 6,
DoNotDisturb = 7,
StatusMoved = 8,
StatusAltService = 9,
Pending = 10
};
}
}
\ No newline at end of file
No preview for this file type
......@@ -38,6 +38,19 @@ namespace Linphone.Model
private static BitmapImage _outgoingIcon = new BitmapImage(new Uri("/Assets/call_status_outgoing.png", UriKind.Relative));
private static BitmapImage _missedIcon = new BitmapImage(new Uri("/Assets/call_status_missed.png", UriKind.Relative));
private Object _nativeLog;
public Object NativeLog
{
get
{
return _nativeLog;
}
set
{
_nativeLog = value;
}
}
private String _from;
public String From
{
......@@ -117,8 +130,9 @@ namespace Linphone.Model
}
}
public CallLog(String from, String to, bool isIncoming, bool isMissed)
public CallLog(Object nativeLog, String from, String to, bool isIncoming, bool isMissed)
{
_nativeLog = nativeLog;
_from = from;
_to = to;
_isIncoming = isIncoming;
......
......@@ -14,7 +14,7 @@ using Linphone.Resources;
namespace Linphone.Model
{
public sealed class LinphoneManager
public sealed class LinphoneManager : LinphoneCoreListener
{
private static LinphoneManager singleton;
public static LinphoneManager Instance
......@@ -32,9 +32,6 @@ namespace Linphone.Model
{
get
{
if (server.LinphoneCore == null)
server.LinphoneCoreFactory.CreateLinphoneCore(null);
return server.LinphoneCore;
}
}
......@@ -45,14 +42,14 @@ namespace Linphone.Model
// An event that indicates that the UI process is no longer connected to the background process
private EventWaitHandle uiDisconnectedEvent;
// A proxy to the server object in the VoIP background agent host process
// A proxy to the server object in the background agent host process
private Server server;
// A timespan representing fifteen seconds
private static readonly TimeSpan fifteenSecs = new TimeSpan(0, 0, 15);
// A timespan representing an indefinite wait
private static readonly TimeSpan indefiniteWait = new TimeSpan(0, 0, 0, 0, -1);
private static readonly TimeSpan indefiniteWait = new TimeSpan(0, 0, 0, 0, -1);
/// <summary>
/// Starts and connects the UI to the background process
......@@ -99,13 +96,12 @@ namespace Linphone.Model
server = (Server)WindowsRuntimeMarshal.GetActivationFactory(typeof(Server)).ActivateInstance();
// Un-set an event that indicates that the UI process is disconnected from the background process.
// The VoIP background process waits for this event to get set before shutting down.
// This ensures that the VoIP background agent host process doesn't shut down while the UI process is connected to it.
// The background process waits for this event to get set before shutting down.
// This ensures that the background agent host process doesn't shut down while the UI process is connected to it.
string uiDisconnectedEventName = Globals.GetUiDisconnectedEventName((uint)backgroundProcessID);
uiDisconnectedEvent = new EventWaitHandle(initialState: false, mode: EventResetMode.ManualReset, name: uiDisconnectedEventName);
uiDisconnectedEvent.Reset();
// The UI process is now connected to the background process
BackgroundProcessConnected = true;
Debug.WriteLine("[LinphoneManager] Background process connected to interface");
}
......@@ -123,9 +119,9 @@ namespace Linphone.Model
BackgroundProcessConnected = false;
Debug.WriteLine("[LinphoneManager] Background process disconnected from interface");
// From this point onwards, it is no longer safe to use any objects in the VoIP background process,
// or for the VoIP background process to call back into this process.
// From this point onwards, it is no longer safe to use any objects in the background process,
// or for the background process to call back into this process.
server = null;
// Lastly, set the event that indicates that the UI is no longer connected to the background process.
......@@ -134,7 +130,18 @@ namespace Linphone.Model
uiDisconnectedEvent.Set();
uiDisconnectedEvent.Dispose();
uiDisconnectedEvent = null;
uiDisconnectedEvent = null;
}
/// <summary>
/// Creates a new LinphoneCore using a LinphoneCoreFactory
/// </summary>
public void InitLinphoneCore()
{
if (LinphoneCore != null)
return;
server.LinphoneCoreFactory.CreateLinphoneCore(this);
}
/// <summary>
......@@ -157,6 +164,28 @@ namespace Linphone.Model
ObservableCollection<CallLog> calls = new ObservableCollection<CallLog>();
ObservableCollection<CallLog> missedCalls = new ObservableCollection<CallLog>();
if (LinphoneCore.GetCallLogs() != null)
{
foreach (LinphoneCallLog log in LinphoneCore.GetCallLogs())
{
string from = log.GetFrom().GetDisplayName();
if (from == null)
from = log.GetFrom().AsStringUriOnly();
string to = log.GetTo().GetDisplayName();
if (to == null)
to = log.GetTo().AsStringUriOnly();
bool isMissed = log.GetStatus() == LinphoneCallStatus.Missed;
CallLog callLog = new CallLog(log, from, to, log.GetDirection() == CallDirection.Incoming, isMissed);
calls.Add(callLog);
if (isMissed)
missedCalls.Add(callLog);
}
}
CallLogs all = new CallLogs("All", calls);
_history.Add(all);
......@@ -178,10 +207,7 @@ namespace Linphone.Model
while (logsToRemove.Count() > 0)
{
CallLog logToRemove = logsToRemove.First();
foreach (CallLogs logs in _history)
{
logs.Calls.Remove(logToRemove);
}
LinphoneCore.RemoveCallLog(logToRemove.NativeLog as LinphoneCallLog);
}
return _history;
......@@ -236,5 +262,42 @@ namespace Linphone.Model
LinphoneCore.ResumeCall(call);
}
}
#region LinphoneCoreListener Callbacks
public void GlobalState(GlobalState state, string message)
{
}
public void CallState(LinphoneCall call, LinphoneCallState state)
{
}
public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
{
}
public void DTMFReceived(LinphoneCall call, int dtmf)
{
}
public void EcCalibrationStatus(EcCalibratorStatus status, int delay_ms, object data)
{
}
public void CallEncryptionChanged(LinphoneCall call, bool encrypted, string authenticationToken)
{
}
public void CallStatsUpdated(LinphoneCall call, LinphoneCallStats stats)
{
}
#endregion
}
}
......@@ -50,25 +50,18 @@
<ActivatableClass ActivatableClassId="Linphone.BackEnd.IncomingCallDialogDismissedCallback" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.CallController" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.Globals" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.CallDirection" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCoreFactory" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.RegistrationState" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.MediaEncryption" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.FirewallPolicy" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.Transports" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCore" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCall" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCoreFactory" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneAddress" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneAuthInfo" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCallState" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCall" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCallStats" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCallLog" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneCallParams" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.PayloadType" ThreadingModel="MTA" />
<ActivatableClass ActivatableClassId="Linphone.BackEnd.LinphoneProxyConfig" ThreadingModel="MTA" />