FirstLogin.xaml.cs 4.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
FirstLogin.xaml.cs
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 22 23 24 25 26
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Linphone.Model;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml;

Erwan Croze's avatar
Erwan Croze committed
27
namespace Linphone.Views {
28 29 30
    /// <summary>
    /// Handles the first login and the account creation
    /// </summary>
Erwan Croze's avatar
Erwan Croze committed
31
    public partial class FirstLogin : Page {
32 33 34 35 36
        private SIPAccountSettingsManager _settings = new SIPAccountSettingsManager();

        /// <summary>
        /// Public constructor
        /// </summary>
Erwan Croze's avatar
Erwan Croze committed
37
        public FirstLogin() {
38 39 40 41 42 43
            this.InitializeComponent();
        }

        /// <summary>
        /// Method called when the page is displayed.
        /// </summary>
Erwan Croze's avatar
Erwan Croze committed
44
        protected override void OnNavigatedTo(NavigationEventArgs e) {
45 46
            base.OnNavigatedTo(e);

Erwan Croze's avatar
Erwan Croze committed
47
            if (LinphoneManager.Instance.Core.ProxyConfigList.Count() > 0) {
Erwan Croze's avatar
Erwan Croze committed
48 49
                // NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
                // NavigationService.RemoveBackEntry(); // Prevent a back to this screen from the dialer
50 51 52
            }
        }

Erwan Croze's avatar
Erwan Croze committed
53 54 55 56 57 58 59 60 61 62 63
        private void LogIn_Click(object sender, RoutedEventArgs e) {
            /* ErrorMessage.Text = "";
             if (Username.Text.Length > 0 && Domain.Text.Length > 0)
             {
                 LogIn.IsEnabled = false;
                 Register.IsEnabled = false;
                 LinphoneLogIn.IsEnabled = false;
                 Loading.Visibility = Visibility.Visible;
                 Username.IsEnabled = false;
                 Password.IsEnabled = false;
                 Domain.IsEnabled = false;
64

Erwan Croze's avatar
Erwan Croze committed
65 66 67 68 69 70 71 72 73
                 NetworkSettingsManager networkSettings = new NetworkSettingsManager();
                 _settings.Username = Username.Text;
                 _settings.Password = Password.Password;
                 _settings.Domain = Domain.Text;
                 if (Domain.Text.Equals("sip.linphone.org"))
                 {
                     _settings.Proxy = "<sip:sip.linphone.org:5223;transport=tls>";
                     _settings.Transport = AppResources.TransportTLS;
                     _settings.OutboundProxy = true;
74

Erwan Croze's avatar
Erwan Croze committed
75 76 77 78 79
                     networkSettings.StunServer = "stun.linphone.org";
                     networkSettings.FWPolicy = AppResources.FirewallPolicyIce;
                 }
                 networkSettings.Save();
                 _settings.Save();
80

Erwan Croze's avatar
Erwan Croze committed
81 82 83 84 85 86 87
                 //NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
                 //NavigationService.RemoveBackEntry(); // Prevent a back to this screen from the dialer
             }
             else
             {
                 ErrorMessage.Text = AppResources.ErrorLogin;
             }*/
88 89
        }

Erwan Croze's avatar
Erwan Croze committed
90
        private void Register_Click(object sender, RoutedEventArgs e) {
91 92 93
            //TODO
        }

Erwan Croze's avatar
Erwan Croze committed
94 95 96
        private void LinphoneLogIn_Click(object sender, RoutedEventArgs e) {
            /* Domain.Text = "sip.linphone.org";
             LinphoneLogIn.IsEnabled = false;*/
97 98
        }

Erwan Croze's avatar
Erwan Croze committed
99 100 101
        private void Skip_Click(object sender, RoutedEventArgs e) {
            // NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
            // NavigationService.RemoveBackEntry(); // Prevent a back to this screen from the dialer
102 103 104
        }
    }
}