Example #1
0
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
 {
     if ((config == null) || BaseModel.UIDispatcher == null)
     {
         return;
     }
     BaseModel.UIDispatcher.BeginInvoke(() =>
     {
         try
         {
             Logger.Msg("[LinphoneManager] Registration state changed: " + state.ToString() + ", message=" + message + " for identity " + config.GetIdentity() + "\r\n");
             LastKnownState = state;
             if (BasePage.StatusBar != null)
             {
                 BasePage.StatusBar.RefreshStatus(state);
             }
             if ((state == Core.RegistrationState.RegistrationFailed) && (config.Error == Reason.LinphoneReasonForbidden))
             {
                 if (RegistrationFailedNotification != null)
                 {
                     RegistrationFailedNotification.Dismiss();
                 }
                 RegistrationFailedNotification = new CustomMessageBox()
                 {
                     Caption            = ResourceManager.GetString("RegistrationFailedPopupTitle", CultureInfo.CurrentCulture),
                     Message            = ResourceManager.GetString("RegistrationFailedForbidden", CultureInfo.CurrentCulture),
                     RightButtonContent = AppResources.Close
                 };
                 RegistrationFailedNotification.Show();
             }
         }
         catch { }
     });
 }
Example #2
0
        private bool IsAccountConfigured()
        {
            LinphoneCore        lc  = LinphoneManager.Instance.LinphoneCore;
            LinphoneProxyConfig cfg = lc.DefaultProxyConfig;

            return(cfg != null);
        }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
 {
     if (state == Linphone.Core.RegistrationState.RegistrationOk || state == Linphone.Core.RegistrationState.RegistrationFailed)
     {
         Debug.WriteLine("[KeepAliveAgent] Notify complete (" + state.ToString() + ")");
         base.NotifyComplete();
     }
 }
Example #4
0
        private bool IsRegisterEnabled()
        {
            LinphoneCore        lc  = LinphoneManager.Instance.LinphoneCore;
            LinphoneProxyConfig cfg = lc.DefaultProxyConfig;

            if (cfg != null)
            {
                return(cfg.RegisterEnabled);
            }
            return(true);
        }
Example #5
0
        private void EnableRegister(bool enable)
        {
            LinphoneCore        lc  = LinphoneManager.Instance.LinphoneCore;
            LinphoneProxyConfig cfg = lc.DefaultProxyConfig;

            if (cfg != null)
            {
                cfg.Edit();
                cfg.RegisterEnabled = enable;
                cfg.Done();
            }
        }
Example #6
0
        private void Register()
        {
            string localUri = this.localAddress.Text;
            string password = this.password.Text;

            if (string.IsNullOrWhiteSpace(localUri))
            {
                return;
            }

            var localAddress = Globals.Instance.LinphoneCoreFactory.CreateLinphoneAddress(localUri);

            if (localAddress == null)
            {
                MessageBox.Show("Your SIP address is invalid");
                return;
            }
            var proxyCfg = new LinphoneProxyConfig();

            proxyCfg.SetIdentity(localUri);
            proxyCfg.RegisterEnabled = true;
            proxyCfg.Expires         = 3600;
            proxyCfg.ServerAddr      = localAddress.Domain;

            lc.ClearProxyConfigs();
            lc.AddProxyConfig(proxyCfg);
            lc.DefaultProxyConfig = proxyCfg;

            var authInfo = new LinphoneAuthInfo(localAddress.UserName, string.Empty, password, string.Empty, string.Empty, string.Empty);

            lc.AddAuthInfo(authInfo);

            lc.IterateEnabled = true;
            while (lc.DefaultProxyConfig.State != Linphone.Core.RegistrationState.RegistrationOk)
            {
                WriteLog("Registering...");
                System.Threading.Thread.Sleep(1000);
                if (lc.DefaultProxyConfig.State == Linphone.Core.RegistrationState.RegistrationFailed)
                {
                    WriteLog("Reason: {0}", lc.DefaultProxyConfig.Error);
                    lc.IterateEnabled = false;
                    return;
                }
            }

            this.btnLogin.Text = "Logout";
        }
Example #7
0
        static void Main(string[] args)
        {
            var listener = new LinphoneManager();

            Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(listener);
            LinphoneCore lc = Globals.Instance.LinphoneCore;

            listener.Lc = lc;

            var proxyCfg = new LinphoneProxyConfig();

            proxyCfg.SetIdentity("test 1000 <sip:[email protected]>");
            proxyCfg.ServerAddr      = "192.168.6.241";
            proxyCfg.RegisterEnabled = true;
            proxyCfg.Expires         = 60000;
            lc.ClearProxyConfigs();
            lc.AddProxyConfig(proxyCfg);
            lc.DefaultProxyConfig = proxyCfg;

            var authInfo = new LinphoneAuthInfo("1000", string.Empty, "12345", string.Empty, string.Empty, string.Empty);

            lc.AddAuthInfo(authInfo);

            lc.IterateEnabled = true;
            while (lc.DefaultProxyConfig.State != RegistrationState.RegistrationOk)
            {
                Console.WriteLine("Registering...");
                System.Threading.Thread.Sleep(1000);
                if (lc.DefaultProxyConfig.State == RegistrationState.RegistrationFailed)
                {
                    Console.WriteLine("Reason: {0}", lc.DefaultProxyConfig.Error);
                    lc.IterateEnabled = false;
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("Registered");
            Console.ReadKey();

#if CALL
            Console.WriteLine("Calling to sip:[email protected] ...");

            var callParams = lc.CreateDefaultCallParameters();
            callParams.VideoEnabled = false;
            //var callAddr = Globals.Instance.LinphoneCoreFactory.CreateLinphoneAddress("sip:[email protected]");
            //var call = lc.InviteAddressWithParams(callAddr, callParams);
            var call = lc.InviteWithParams("sip:[email protected]", callParams);

            if (call.State != LinphoneCallState.Connected)
            {
                Console.WriteLine("Waiting accept call...");
                System.Threading.Thread.Sleep(2000);
            }
            Console.ReadKey();

            lc.TerminateAllCalls();
#endif
            // De-activate registering
            var defaultCfg = lc.DefaultProxyConfig;
            defaultCfg.Edit();
            defaultCfg.RegisterEnabled = false;
            defaultCfg.Done();
            while (lc.DefaultProxyConfig.State != RegistrationState.RegistrationCleared)
            {
                Console.WriteLine("UnRegistering...");
                System.Threading.Thread.Sleep(1000);
            }
            Console.WriteLine("UnRegistered");
            lc.IterateEnabled = false;
            Console.ReadKey();
        }
Example #8
0
 public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
 {
     Console.WriteLine("RegistrationState: {0} | ", state, message);
 }
 public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
 {
     WriteLog("RegistrationState: {0} | ", state, message);
 }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
 {
     if ((config == null) || BaseModel.UIDispatcher == null) return;
     BaseModel.UIDispatcher.BeginInvoke(() =>
     {
         try
         {
             Logger.Msg("[LinphoneManager] Registration state changed: " + state.ToString() + ", message=" + message + " for identity " + config.GetIdentity() + "\r\n");
             LastKnownState = state;
             if (BasePage.StatusBar != null)
                 BasePage.StatusBar.RefreshStatus(state);
             if ((state == Core.RegistrationState.RegistrationFailed) && (config.Error == Reason.LinphoneReasonForbidden))
             {
                 if (RegistrationFailedNotification != null)
                 {
                     RegistrationFailedNotification.Dismiss();
                 }
                 RegistrationFailedNotification = new CustomMessageBox()
                 {
                     Caption = ResourceManager.GetString("RegistrationFailedPopupTitle", CultureInfo.CurrentCulture),
                     Message = ResourceManager.GetString("RegistrationFailedForbidden", CultureInfo.CurrentCulture),
                     RightButtonContent = AppResources.Close
                 };
                 RegistrationFailedNotification.Show();
             }
         }
         catch { }
     });
 }
Example #11
0
        private void Register()
        {
            string localUri = this.localAddress.Text;
            string password = this.password.Text;
            if (string.IsNullOrWhiteSpace(localUri))
                return;

            var localAddress = Globals.Instance.LinphoneCoreFactory.CreateLinphoneAddress(localUri);
            if (localAddress == null)
            {
                MessageBox.Show("Your SIP address is invalid");
                return;
            }
            var proxyCfg = new LinphoneProxyConfig();
            proxyCfg.SetIdentity(localUri);
            proxyCfg.RegisterEnabled = true;
            proxyCfg.Expires = 3600;            
            proxyCfg.ServerAddr = localAddress.Domain;

            lc.ClearProxyConfigs();
            lc.AddProxyConfig(proxyCfg);
            lc.DefaultProxyConfig = proxyCfg;

            var authInfo = new LinphoneAuthInfo(localAddress.UserName, string.Empty, password, string.Empty, string.Empty, string.Empty);
            lc.AddAuthInfo(authInfo);

            lc.IterateEnabled = true;
            while (lc.DefaultProxyConfig.State != Linphone.Core.RegistrationState.RegistrationOk)
            {
                WriteLog("Registering...");
                System.Threading.Thread.Sleep(1000);
                if (lc.DefaultProxyConfig.State == Linphone.Core.RegistrationState.RegistrationFailed)
                {
                    WriteLog("Reason: {0}", lc.DefaultProxyConfig.Error);
                    lc.IterateEnabled = false;
                    return;
                }
            }

            this.btnLogin.Text = "Logout";
        }
Example #12
0
        static void Main(string[] args)
        {
            var listener = new LinphoneManager();
            Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(listener);
            LinphoneCore lc = Globals.Instance.LinphoneCore;
            listener.Lc = lc;

            var proxyCfg = new LinphoneProxyConfig();
            proxyCfg.SetIdentity("test 1000 <sip:[email protected]>");
            proxyCfg.ServerAddr = "192.168.6.241";
            proxyCfg.RegisterEnabled = true;
            proxyCfg.Expires = 60000;
            lc.ClearProxyConfigs();
            lc.AddProxyConfig(proxyCfg);
            lc.DefaultProxyConfig = proxyCfg;

            var authInfo = new LinphoneAuthInfo("1000", string.Empty, "12345", string.Empty, string.Empty, string.Empty);
            lc.AddAuthInfo(authInfo);
            
            lc.IterateEnabled = true;
            while (lc.DefaultProxyConfig.State != RegistrationState.RegistrationOk)
            {
                Console.WriteLine("Registering...");
                System.Threading.Thread.Sleep(1000);
                if (lc.DefaultProxyConfig.State == RegistrationState.RegistrationFailed)
                {
                    Console.WriteLine("Reason: {0}", lc.DefaultProxyConfig.Error);
                    lc.IterateEnabled = false;
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("Registered");
            Console.ReadKey();

#if CALL
            Console.WriteLine("Calling to sip:[email protected] ...");
            
            var callParams = lc.CreateDefaultCallParameters();
            callParams.VideoEnabled = false;
            //var callAddr = Globals.Instance.LinphoneCoreFactory.CreateLinphoneAddress("sip:[email protected]");
            //var call = lc.InviteAddressWithParams(callAddr, callParams);
            var call = lc.InviteWithParams("sip:[email protected]", callParams);
            
            if (call.State != LinphoneCallState.Connected)
            {
                Console.WriteLine("Waiting accept call...");
                System.Threading.Thread.Sleep(2000);
            }
            Console.ReadKey();
            
            lc.TerminateAllCalls();
#endif
            // De-activate registering
            var defaultCfg = lc.DefaultProxyConfig;
            defaultCfg.Edit();
            defaultCfg.RegisterEnabled = false;
            defaultCfg.Done();
            while (lc.DefaultProxyConfig.State != RegistrationState.RegistrationCleared)
            {
                Console.WriteLine("UnRegistering...");
                System.Threading.Thread.Sleep(1000);
            }
            Console.WriteLine("UnRegistered");
            lc.IterateEnabled = false;
            Console.ReadKey();
        }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void RegistrationState(LinphoneProxyConfig config, RegistrationState state, string message)
 {
     if (state == Linphone.Core.RegistrationState.RegistrationOk || state == Linphone.Core.RegistrationState.RegistrationFailed)
     {
         Debug.WriteLine("[KeepAliveAgent] Notify complete (" + state.ToString() + ")");
         base.NotifyComplete();
     }
 }