Add1PageCompleted() public method

First step of remote folder addition wizard is complete, switch to second step
public Add1PageCompleted ( Uri address, string user, string password ) : void
address System.Uri
user string
password string
return void
        partial void OnContinue(MonoMac.Foundation.NSObject sender)
        {
            ServerCredentials credentials = new ServerCredentials()
            {
                UserName = UserText.StringValue,
                Password = PasswordText.StringValue,
                Address  = new Uri(AddressText.StringValue),
                Binding  = (this.Controller.saved_binding == null) ? ServerCredentials.BindingBrowser : this.Controller.saved_binding
            };

            WarnText.StringValue   = string.Empty;
            AddressText.Enabled    = false;
            UserText.Enabled       = false;
            PasswordText.Enabled   = false;
            ContinueButton.Enabled = false;
            CancelButton.Enabled   = false;
            //  monomac bug: animation GUI effect will cause GUI to hang, when backend thread is busy
//            LoginProgress.StartAnimation(this);
            Thread check = new Thread(() => {
                var result = SetupController.GetRepositories(credentials);
                if (result.Repositories != null)
                {
                    this.Controller.repositories = result.Repositories.WithoutHiddenOnce();
                }
                else
                {
                    this.Controller.repositories = null;
                }

                InvokeOnMainThread(delegate {
                    if (this.Controller.repositories == null)
                    {
                        AddressText.StringValue = result.Credentials.Address.ToString();
                        WarnText.StringValue    = this.Controller.GetConnectionsProblemWarning(result.FailedException);
                        AddressText.Enabled     = true;
                        UserText.Enabled        = true;
                        PasswordText.Enabled    = true;
                        ContinueButton.Enabled  = true;
                        CancelButton.Enabled    = true;
                    }
                    else
                    {
                        RemoveEvent();
                        Controller.Add1PageCompleted(result.Credentials.Address, result.Credentials.Binding, credentials.UserName, credentials.Password.ToString());
                    }

                    LoginProgress.StopAnimation(this);
                });
            });

            check.Start();
        }
Esempio n. 2
0
        partial void OnContinue(MonoMac.Foundation.NSObject sender)
        {
            ServerCredentials credentials = new ServerCredentials()
            {
                UserName = UserText.StringValue,
                Password = PasswordText.StringValue,
                Address  = new Uri(AddressText.StringValue)
            };

            WarnText.StringValue   = String.Empty;
            AddressText.Enabled    = false;
            UserText.Enabled       = false;
            PasswordText.Enabled   = false;
            ContinueButton.Enabled = false;
            CancelButton.Enabled   = false;
            //  monomac bug: animation GUI effect will cause GUI to hang, when backend thread is busy
//            LoginProgress.StartAnimation(this);
            Thread check = new Thread(() => {
                Tuple <CmisServer, Exception> fuzzyResult = CmisUtils.GetRepositoriesFuzzy(credentials);
                CmisServer cmisServer = fuzzyResult.Item1;
                if (cmisServer != null)
                {
                    Controller.repositories = cmisServer.Repositories;
                }
                else
                {
                    Controller.repositories = null;
                }
                InvokeOnMainThread(delegate {
                    if (Controller.repositories == null)
                    {
                        WarnText.StringValue   = Controller.GetConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2);
                        AddressText.Enabled    = true;
                        UserText.Enabled       = true;
                        PasswordText.Enabled   = true;
                        ContinueButton.Enabled = true;
                        CancelButton.Enabled   = true;
                    }
                    else
                    {
                        RemoveEvent();
                        Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString());
                    }
                    LoginProgress.StopAnimation(this);
                });
            });

            check.Start();
        }
Esempio n. 3
0
        partial void OnContinue(MonoMac.Foundation.NSObject sender)
        {
            ServerCredentials credentials = new ServerCredentials()
            {
                UserName = UserText.StringValue,
                Password = PasswordText.StringValue,
                Address  = new Uri(AddressText.StringValue)
            };

            AddressText.Enabled    = false;
            UserText.Enabled       = false;
            PasswordText.Enabled   = false;
            ContinueButton.Enabled = false;
            CancelButton.Enabled   = false;

            Thread check = new Thread(() => {
                Tuple <CmisServer, Exception> fuzzyResult = CmisUtils.GetRepositoriesFuzzy(credentials);
                CmisServer cmisServer = fuzzyResult.Item1;
                if (cmisServer != null)
                {
                    Controller.repositories = cmisServer.Repositories;
                }
                else
                {
                    Controller.repositories = null;
                }
                InvokeOnMainThread(delegate {
                    if (Controller.repositories == null)
                    {
                        WarnText.StringValue   = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2);
                        AddressText.Enabled    = true;
                        UserText.Enabled       = true;
                        PasswordText.Enabled   = true;
                        ContinueButton.Enabled = true;
                        CancelButton.Enabled   = true;
                    }
                    else
                    {
                        RemoveEvent();
                        Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString());
                    }
                });
            });

            check.Start();
        }
Esempio n. 4
0
        void ShowLoginPage()
        {
            Header       = CmisSync.Properties_Resources.Where;
            Description  = "";
            AddressLabel = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(190, 320, 196 + 196 + 16, 17),
                StringValue     = Properties_Resources.EnterWebAddress,
                Font            = GUI.BoldFont
            };
            AddressTextField = new NSTextField()
            {
                Frame       = new RectangleF(190, 290, 196 + 196 + 16, 22),
                Font        = GUI.Font,
                Delegate    = new TextFieldDelegate(),
                StringValue = (Controller.PreviousAddress == null || String.IsNullOrEmpty(Controller.PreviousAddress.ToString())) ? "https://" : Controller.PreviousAddress.ToString()
            };
            AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingHead;
            AddressHelpLabel = new NSTextField()
            {
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                TextColor       = NSColor.DisabledControlText,
                Editable        = false,
                Frame           = new RectangleF(190, 265, 196 + 196 + 16, 17),
                Font            = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11),
            };
            NSTextField UserLabel = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Font            = GUI.BoldFont,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(190, 230, 196, 17),
                StringValue     = Properties_Resources.User
            };
            NSTextField UserTextField = new NSTextField()
            {
                Font        = GUI.Font,
                StringValue = String.IsNullOrEmpty(Controller.saved_user) ? Environment.UserName : Controller.saved_user,
                Frame       = new RectangleF(190, 200, 196, 22)
            };

            UserTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingHead;
            PasswordLabel = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(190 + 196 + 16, 230, 196, 17),
                StringValue     = Properties_Resources.Password,
                Font            = GUI.BoldFont
            };
            PasswordTextField = new NSSecureTextField()
            {
                Frame    = new RectangleF(190 + 196 + 16, 200, 196, 22),
                Delegate = new TextFieldDelegate()
            };
            WarningTextField = new NSTextField()
            {
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                TextColor       = NSColor.Red,
                Editable        = false,
                Frame           = new RectangleF(190, 30, 196 + 196 + 16, 160),
                Font            = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11),
            };
            WarningTextField.Cell.LineBreakMode = NSLineBreakMode.ByWordWrapping;
            ContinueButton = new NSButton()
            {
                Title   = Properties_Resources.Continue,
                Enabled = false
            };
            CancelButton = new NSButton()
            {
                Title = Properties_Resources.Cancel
            };
            (AddressTextField.Delegate as TextFieldDelegate).StringValueChanged += CheckAddressTextField;
            ContinueButton.Activated += delegate
            {
                ServerCredentials credentials = null;
                InvokeOnMainThread(delegate {
                    credentials = new ServerCredentials()
                    {
                        UserName = UserTextField.StringValue,
                        Password = PasswordTextField.StringValue,
                        Address  = new Uri(AddressTextField.StringValue)
                    };
                    ContinueButton.Enabled = false;
                    CancelButton.Enabled   = false;
                });
                Thread check = new Thread(() => {
                    Tuple <CmisServer, Exception> fuzzyResult = CmisUtils.GetRepositoriesFuzzy(credentials);
                    CmisServer cmisServer = fuzzyResult.Item1;
                    if (cmisServer != null)
                    {
                        Controller.repositories = cmisServer.Repositories;
                    }
                    else
                    {
                        Controller.repositories = null;
                    }
                    InvokeOnMainThread(delegate {
                        if (Controller.repositories == null)
                        {
                            // TODO fix
                            // WarningTextField.StringValue = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2);
                            WarningTextField.StringValue = "Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2)";

                            ContinueButton.Enabled = true;
                            CancelButton.Enabled   = true;
                        }
                        else
                        {
                            Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString());
                        }
                    });
                });
                check.Start();
            };
            CancelButton.Activated += delegate
            {
                Controller.PageCancelled();
            };
            ContentView.AddSubview(AddressLabel);
            ContentView.AddSubview(AddressTextField);
            ContentView.AddSubview(AddressHelpLabel);
            ContentView.AddSubview(UserLabel);
            ContentView.AddSubview(UserTextField);
            ContentView.AddSubview(PasswordLabel);
            ContentView.AddSubview(PasswordTextField);
            ContentView.AddSubview(WarningTextField);
            Buttons.Add(ContinueButton);
            Buttons.Add(CancelButton);
            Controller.CheckAddPage(AddressTextField.StringValue);
        }
Esempio n. 5
0
        private void LoadAddLoginWPF()
        {
            // define UI elements.
            Header = Properties_Resources.Where;

            System.Uri  resourceLocater = new System.Uri("/DataSpaceSync;component/SetupAddLoginWPF.xaml", System.UriKind.Relative);
            UserControl LoadAddLoginWPF = Application.LoadComponent(resourceLocater) as UserControl;

            address_label       = LoadAddLoginWPF.FindName("address_label") as TextBlock;
            address_box         = LoadAddLoginWPF.FindName("address_box") as TextBox;
            address_help_label  = LoadAddLoginWPF.FindName("address_help_label") as TextBlock;
            user_label          = LoadAddLoginWPF.FindName("user_label") as TextBlock;
            user_box            = LoadAddLoginWPF.FindName("user_box") as TextBox;
            user_help_label     = LoadAddLoginWPF.FindName("user_help_label") as TextBlock;
            password_label      = LoadAddLoginWPF.FindName("password_label") as TextBlock;
            password_box        = LoadAddLoginWPF.FindName("password_box") as PasswordBox;
            password_progress   = LoadAddLoginWPF.FindName("password_progress") as CircularProgressBar;
            password_help_label = LoadAddLoginWPF.FindName("password_help_label") as TextBlock;
            address_error_label = LoadAddLoginWPF.FindName("address_error_label") as TextBox;
            continue_button     = LoadAddLoginWPF.FindName("continue_button") as Button;
            cancel_button       = LoadAddLoginWPF.FindName("cancel_button") as Button;

            ContentCanvas.Children.Add(LoadAddLoginWPF);

            address_box.Text = (Controller.PreviousAddress != null) ? Controller.PreviousAddress.ToString() : String.Empty;

            if (Controller.saved_user == String.Empty || Controller.saved_user == null)
            {
                user_box.Text = DefaultEntries.Defaults.Name;
            }
            else
            {
                user_box.Text = Controller.saved_user;
            }

            TaskbarItemInfo.ProgressValue = 0.0;
            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
            if (!DefaultEntries.Defaults.CanModifyUrl)
            {
                address_box.IsEnabled         = false;
                address_box.Visibility        = Visibility.Hidden;
                address_help_label.Visibility = Visibility.Hidden;
                address_label.Visibility      = Visibility.Hidden;
            }

            if (Controller.PreviousAddress == null || Controller.PreviousAddress.ToString() == String.Empty)
            {
                address_box.Text = DefaultEntries.Defaults.Url;
            }
            else
            {
                address_box.Text = Controller.PreviousAddress.ToString();
            }
            address_box.Focus();
            address_box.Select(address_box.Text.Length, 0);

            // Actions.
            ControllerLoginInsertAction();
            Controller.CheckAddPage(address_box.Text);

            address_box.TextChanged += delegate {
                string error = Controller.CheckAddPage(address_box.Text);
                if (!String.IsNullOrEmpty(error))
                {
                    address_error_label.Text       = Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture);
                    address_error_label.Visibility = Visibility.Visible;
                }
                else
                {
                    address_error_label.Visibility = Visibility.Hidden;
                }
            };

            cancel_button.Click += delegate {
                ControllerLoginRemoveAction();
                Controller.PageCancelled();
            };

            string binding = Controller.saved_binding;

            if (binding == null)
            {
                binding = CmisRepoCredentials.BindingBrowser;
            }

            continue_button.Click += delegate {
                // Show wait cursor
                password_progress.Visibility        = Visibility.Visible;
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                // Try to find the CMIS server (asynchronously)
                GetRepositoriesDelegate dlgt =
                    new GetRepositoriesDelegate(SetupController.GetRepositories);
                ServerCredentials credentials = new ServerCredentials()
                {
                    UserName = user_box.Text,
                    Password = password_box.Password,
                    Address  = new Uri(address_box.Text),
                    Binding  = binding,
                };
                IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null);
                while (!ar.AsyncWaitHandle.WaitOne(100))
                {
                    System.Windows.Forms.Application.DoEvents();
                }

                var result = dlgt.EndInvoke(ar);
                Controller.repositories = result.Repositories.WithoutHiddenOnce();

                address_box.Text = result.Credentials.Address.ToString();
                binding          = result.Credentials.Binding;

                // Hide wait cursor
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                password_progress.Visibility        = Visibility.Hidden;

                if (Controller.repositories == null)
                {
                    // Could not retrieve repositories list from server, show warning.
                    string warning = Controller.GetConnectionsProblemWarning(result.FailedException);
                    address_error_label.Text       = warning;
                    address_error_label.Visibility = Visibility.Visible;
                }
                else
                {
                    ControllerLoginRemoveAction();
                    // Continue to next step, which is choosing a particular folder.
                    Controller.Add1PageCompleted(
                        new Uri(address_box.Text),
                        binding,
                        user_box.Text,
                        password_box.Password);
                }
            };
        }
Esempio n. 6
0
        private void ShowAdd1Page()
        {
            this.Present();
            Header = CmisSync.Properties_Resources.Where;

            VBox layout_vertical     = new VBox(false, 12);
            HBox layout_fields       = new HBox(true, 12);
            VBox layout_address      = new VBox(true, 0);
            HBox layout_address_help = new HBox(false, 3);
            VBox layout_user         = new VBox(true, 0);
            VBox layout_password     = new VBox(true, 0);

            // Address
            Label address_label = new Label()
            {
                UseMarkup = true,
                Xalign    = 0,
                Markup    = "<b>" +
                            CmisSync.Properties_Resources.EnterWebAddress +
                            "</b>"
            };

            Entry address_entry = new Entry()
            {
                Text             = (Controller.PreviousAddress == null || String.IsNullOrEmpty(Controller.PreviousAddress.ToString()))?"https://":Controller.PreviousAddress.ToString(),
                ActivatesDefault = false
            };

            Label address_help_label = new Label()
            {
                Xalign    = 0,
                UseMarkup = true,
                Markup    = "<span foreground=\"#808080\" size=\"small\">" +
                            CmisSync.Properties_Resources.Help + ": " +
                            "</span>"
            };
            EventBox address_help_urlbox   = new EventBox();
            Label    address_help_urllabel = new Label()
            {
                Xalign    = 0,
                UseMarkup = true,
                Markup    = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" +
                            CmisSync.Properties_Resources.WhereToFind +
                            "</span>"
            };

            address_help_urlbox.Add(address_help_urllabel);
            address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) {
                Process process = new Process();
                process.StartInfo.FileName  = "xdg-open";
                process.StartInfo.Arguments = "https://github.com/nicolas-raoul/CmisSync/wiki/What-address";
                process.Start();
            };
            address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) {
                address_help_urlbox.GdkWindow.Cursor = hand_cursor;
            };

            Label address_error_label = new Label()
            {
                Xalign    = 0,
                UseMarkup = true,
                Markup    = ""
            };

            address_error_label.Hide();

            // User
            Entry user_entry = new Entry()
            {
                Text             = Controller.PreviousPath,
                ActivatesDefault = false
            };

            if (String.IsNullOrEmpty(Controller.saved_user))
            {
                user_entry.Text = Environment.UserName;
            }
            else
            {
                user_entry.Text = Controller.saved_user;
            }

            // Password
            Entry password_entry = new Entry()
            {
                Visibility       = false,
                ActivatesDefault = true
            };

            Controller.ChangeAddressFieldEvent += delegate(string text,
                                                           string example_text) {
                Application.Invoke(delegate {
                    address_entry.Text = text;
                });
            };

            Controller.ChangeUserFieldEvent += delegate(string text,
                                                        string example_text) {
                Application.Invoke(delegate {
                    user_entry.Text = text;
                });
            };

            Controller.ChangePasswordFieldEvent += delegate(string text,
                                                            string example_text) {
                Application.Invoke(delegate {
                    password_entry.Text = text;
                });
            };

            address_entry.Changed += delegate {
                string error = Controller.CheckAddPage(address_entry.Text);
                if (!String.IsNullOrEmpty(error))
                {
                    address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>";
                    address_error_label.Show();
                }
                else
                {
                    address_error_label.Hide();
                }
            };

            // Address
            layout_address_help.PackStart(address_help_label, false, false, 0);
            layout_address_help.PackStart(address_help_urlbox, false, false, 0);
            layout_address.PackStart(address_label, true, true, 0);
            layout_address.PackStart(address_entry, true, true, 0);
            layout_address.PackStart(layout_address_help, true, true, 0);
//            layout_address.PackStart (address_error_label, true, true, 0);

            // User
            layout_user.PackStart(new Label()
            {
                Markup = "<b>" + CmisSync.Properties_Resources.User + ":</b>",
                Xalign = 0
            }, true, true, 0);
            layout_user.PackStart(user_entry, false, false, 0);

            // Password
            layout_password.PackStart(new Label()
            {
                Markup = "<b>" + CmisSync.Properties_Resources.Password + ":</b>",
                Xalign = 0
            }, true, true, 0);
            layout_password.PackStart(password_entry, false, false, 0);

            layout_fields.PackStart(layout_user);
            layout_fields.PackStart(layout_password);

//            layout_vertical.PackStart (new Label (""), false, false, 0);
            layout_vertical.PackStart(layout_address, false, false, 0);
            layout_vertical.PackStart(layout_fields, false, false, 0);
            layout_vertical.PackStart(address_error_label, true, true, 0);

            Add(layout_vertical);

            // Cancel button
            Button cancel_button = new Button(cancelText);

            cancel_button.Clicked += delegate {
                Controller.PageCancelled();
            };

            // Continue button
            Button continue_button = new Button(continueText)
            {
                Sensitive = String.IsNullOrEmpty(Controller.CheckAddPage(address_entry.Text))
            };

            continue_button.Clicked += delegate {
                // Show wait cursor
                this.GdkWindow.Cursor = wait_cursor;

                // Try to find the CMIS server (asynchronous using a delegate)
                GetRepositoriesFuzzyDelegate dlgt =
                    new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy);
                ServerCredentials credentials = new ServerCredentials()
                {
                    UserName = user_entry.Text,
                    Password = password_entry.Text,
                    Address  = new Uri(address_entry.Text)
                };
                IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null);
                while (!ar.AsyncWaitHandle.WaitOne(100))
                {
                    while (Application.EventsPending())
                    {
                        Application.RunIteration();
                    }
                }
                Tuple <CmisServer, Exception> result = dlgt.EndInvoke(ar);
                CmisServer cmisServer = result.Item1;
                if (cmisServer != null)
                {
                    Controller.repositories = cmisServer.Repositories;
                    address_entry.Text      = cmisServer.Url.ToString();
                }
                else
                {
                    Controller.repositories = null;
                }
                // Hide wait cursor
                this.GdkWindow.Cursor = default_cursor;

                if (Controller.repositories == null)
                {
                    // Show warning
                    string    warning = "";
                    string    message = result.Item2.Message;
                    Exception e       = result.Item2;
                    if (e is CmisPermissionDeniedException)
                    {
                        warning = Properties_Resources.LoginFailedForbidden;
                    }
                    else if (e is CmisServerNotFoundException)
                    {
                        warning = Properties_Resources.ConnectFailure;
                    }
                    else if (e.Message == "SendFailure" && cmisServer.Url.Scheme.StartsWith("https"))
                    {
                        warning = Properties_Resources.SendFailureHttps;
                    }
                    else if (e.Message == "TrustFailure")
                    {
                        warning = Properties_Resources.TrustFailure;
                    }
                    else
                    {
                        warning = message + Environment.NewLine + Properties_Resources.Sorry;
                    }
                    address_error_label.Markup = "<span foreground=\"red\">" + warning + "</span>";
                    address_error_label.Show();
                }
                else
                {
                    // Continue to folder selection
                    Controller.Add1PageCompleted(
                        new Uri(address_entry.Text), user_entry.Text, password_entry.Text);
                }
            };

            Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) {
                Application.Invoke(delegate {
                    continue_button.Sensitive = button_enabled;
                    if (button_enabled)
                    {
                        continue_button.SetFlag(Gtk.WidgetFlags.CanFocus);
                        continue_button.SetFlag(Gtk.WidgetFlags.CanDefault);
                        continue_button.GrabDefault();
                    }
                });
            };

            AddButton(cancel_button);
            AddButton(continue_button);

            Controller.CheckAddPage(address_entry.Text);
            address_entry.GrabFocus();
        }
        partial void OnContinue(MonoMac.Foundation.NSObject sender)
        {
            ServerCredentials credentials = new ServerCredentials()
            {
                UserName = UserText.StringValue,
                Password = PasswordText.StringValue,
                Address  = new Uri(AddressText.StringValue)
            };

            AddressText.Enabled    = false;
            UserText.Enabled       = false;
            PasswordText.Enabled   = false;
            ContinueButton.Enabled = false;
            CancelButton.Enabled   = false;

            Thread check = new Thread(() => {
                Tuple <CmisServer, Exception> fuzzyResult = CmisUtils.GetRepositoriesFuzzy(credentials);
                CmisServer cmisServer = fuzzyResult.Item1;
                if (cmisServer != null)
                {
                    Controller.repositories = cmisServer.Repositories;
                }
                else
                {
                    Controller.repositories = null;
                    // Could not retrieve repositories list from server
                    string warning = "";
                }
                InvokeOnMainThread(delegate {
                    if (Controller.repositories == null)
                    {
                        // WarnText.StringValue = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2);
                        string message = fuzzyResult.Item2.Message;
                        string warning = "";
                        Exception e    = fuzzyResult.Item2;
                        if (e is PermissionDeniedException)
                        {
                            warning = Properties_Resources.LoginFailedForbidden;
                        }
                        else if (e is ServerNotFoundException)
                        {
                            warning = Properties_Resources.ConnectFailure;
                        }
                        else if (e.Message == "SendFailure" && cmisServer.Url.Scheme.StartsWith("https"))
                        {
                            warning = Properties_Resources.SendFailureHttps;
                        }
                        else if (e.Message == "TrustFailure")
                        {
                            warning = Properties_Resources.TrustFailure;
                        }
                        else if (e.Message == "Unauthorized")
                        {
                            warning = Properties_Resources.LoginFailedForbidden;
                        }
                        else
                        {
                            warning = message + Environment.NewLine + Properties_Resources.Sorry;
                        }

                        WarnText.StringValue   = warning;
                        AddressText.Enabled    = true;
                        UserText.Enabled       = true;
                        PasswordText.Enabled   = true;
                        ContinueButton.Enabled = true;
                        CancelButton.Enabled   = true;
                        // TODO remove  this line for debug
                    }
                    else
                    {
                        RemoveEvent();
                        Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString());
                    }
                });
            });

            check.Start();
        }
Esempio n. 8
0
        private void ShowAdd1Page()
        {
            Header = CmisSync.Properties_Resources.ResourceManager.GetString("Where", CultureInfo.CurrentCulture);

            VBox layout_vertical     = new VBox(false, 12);
            HBox layout_fields       = new HBox(true, 12);
            VBox layout_address      = new VBox(true, 0);
            HBox layout_address_help = new HBox(false, 3);
            VBox layout_user         = new VBox(true, 0);
            VBox layout_password     = new VBox(true, 0);

            // Address
            Label address_label = new Label()
            {
                UseMarkup = true,
                Xalign    = 0,
                Markup    = "<b>" +
                            CmisSync.Properties_Resources.ResourceManager.GetString("EnterWebAddress", CultureInfo.CurrentCulture) +
                            "</b>"
            };

            Entry address_entry = new Entry()
            {
                Text             = Controller.PreviousAddress,
                ActivatesDefault = false
            };

            Label address_help_label = new Label()
            {
                Xalign    = 0,
                UseMarkup = true,
                Markup    = "<span foreground=\"#808080\" size=\"small\">" +
                            CmisSync.Properties_Resources.ResourceManager.GetString("Help", CultureInfo.CurrentCulture) + ": " +
                            "</span>"
            };
            EventBox address_help_urlbox   = new EventBox();
            Label    address_help_urllabel = new Label()
            {
                Xalign    = 0,
                UseMarkup = true,
                Markup    = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" +
                            CmisSync.Properties_Resources.ResourceManager.GetString("WhereToFind", CultureInfo.CurrentCulture) +
                            "</span>"
            };

            address_help_urlbox.Add(address_help_urllabel);
            address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) {
                Process process = new Process();
                process.StartInfo.FileName  = "xdg-open";
                process.StartInfo.Arguments = "https://github.com/nicolas-raoul/CmisSync/wiki/What-address";
                process.Start();
            };
            address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) {
                address_help_urlbox.GdkWindow.Cursor = hand_cursor;
            };

            Label address_error_label = new Label()
            {
                Xalign    = 0,
                UseMarkup = true,
                Markup    = ""
            };

            address_error_label.Hide();

            // User
            Entry user_entry = new Entry()
            {
                Text             = Controller.PreviousPath,
                ActivatesDefault = false
            };

            // Password
            Entry password_entry = new Entry()
            {
                Text             = Controller.PreviousPath,
                Visibility       = false,
                ActivatesDefault = true
            };

            Controller.ChangeAddressFieldEvent += delegate(string text,
                                                           string example_text) {
                Application.Invoke(delegate {
                    address_entry.Text = text;
                });
            };

            Controller.ChangeUserFieldEvent += delegate(string text,
                                                        string example_text) {
                Application.Invoke(delegate {
                    user_entry.Text = text;
                });
            };

            Controller.ChangePasswordFieldEvent += delegate(string text,
                                                            string example_text) {
                Application.Invoke(delegate {
                    password_entry.Text = text;
                });
            };

            address_entry.Changed += delegate {
                string error = Controller.CheckAddPage(address_entry.Text);
                if (!String.IsNullOrEmpty(error))
                {
                    address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>";
                    address_error_label.Show();
                }
                else
                {
                    address_error_label.Hide();
                }
            };

            // Address
            layout_address_help.PackStart(address_help_label, false, false, 0);
            layout_address_help.PackStart(address_help_urlbox, false, false, 0);
            layout_address.PackStart(address_label, true, true, 0);
            layout_address.PackStart(address_entry, true, true, 0);
            layout_address.PackStart(layout_address_help, true, true, 0);
            layout_address.PackStart(address_error_label, true, true, 0);

            // User
            layout_user.PackStart(new Label()
            {
                Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("User", CultureInfo.CurrentCulture) + ":</b>",
                Xalign = 0
            }, true, true, 0);
            layout_user.PackStart(user_entry, false, false, 0);

            // Password
            layout_password.PackStart(new Label()
            {
                Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("Password", CultureInfo.CurrentCulture) + ":</b>",
                Xalign = 0
            }, true, true, 0);
            layout_password.PackStart(password_entry, false, false, 0);

            layout_fields.PackStart(layout_user);
            layout_fields.PackStart(layout_password);

            layout_vertical.PackStart(new Label(""), false, false, 0);
            layout_vertical.PackStart(layout_address, false, false, 0);
            layout_vertical.PackStart(layout_fields, false, false, 0);

            Add(layout_vertical);

            // Cancel button
            Button cancel_button = new Button(cancelText);

            cancel_button.Clicked += delegate {
                Controller.PageCancelled();
            };

            // Continue button
            Button continue_button = new Button(continueText)
            {
                Sensitive = false
            };

            continue_button.Clicked += delegate {
                // Show wait cursor
                this.GdkWindow.Cursor = wait_cursor;

                // Try to find the CMIS server (asynchronous using a delegate)
                GetRepositoriesFuzzyDelegate dlgt =
                    new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy);
                IAsyncResult ar = dlgt.BeginInvoke(new Uri(address_entry.Text), user_entry.Text,
                                                   password_entry.Text, null, null);
                while (!ar.AsyncWaitHandle.WaitOne(100))
                {
                    while (Application.EventsPending())
                    {
                        Application.RunIteration();
                    }
                }
                CmisServer cmisServer = dlgt.EndInvoke(ar);

                Controller.repositories = cmisServer.Repositories;
                address_entry.Text      = cmisServer.Url.ToString();

                // Hide wait cursor
                this.GdkWindow.Cursor = default_cursor;

                if (Controller.repositories == null)
                {
                    // Show warning
                    address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString("Sorry", CultureInfo.CurrentCulture) + "</span>";
                    address_error_label.Show();
                }
                else
                {
                    // Continue to folder selection
                    Controller.Add1PageCompleted(
                        address_entry.Text, user_entry.Text, password_entry.Text);
                }
            };

            Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) {
                Application.Invoke(delegate {
                    continue_button.Sensitive = button_enabled;
                });
            };

            AddButton(continue_button);
            AddButton(cancel_button);

            address_entry.GrabFocus();
        }