Example #1
0
 public override void Finish(bool result)
 {
     OnClose.SafeInvoke(result);
     OnClose = null;
     Close();
     base.Finish(result);
 }
Example #2
0
        private void Open(PopupViewType popupViewType, Action <bool> onClose)
        {
            OnClose.SafeInvoke(false);
            OnClose = null;

            var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;

            if (viewNeedsAuthentication)
            {
                Client.GetCurrentUser(user =>
                {
                    OpenInternal(popupViewType, onClose);
                    shouldCloseOnFinish = true;
                },
                                      exception =>
                {
                    authenticationView.Initialize(exception);
                    OpenInternal(PopupViewType.AuthenticationView, completedAuthentication =>
                    {
                        if (completedAuthentication)
                        {
                            Open(popupViewType, onClose);
                        }
                    });
                    shouldCloseOnFinish = false;
                });
            }
            else
            {
                OpenInternal(popupViewType, onClose);
                shouldCloseOnFinish = true;
            }
        }
Example #3
0
        private void Open(PopupViewType popupViewType, Action <bool> onClose)
        {
            OnClose.SafeInvoke(false);
            OnClose = null;

            var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;

            if (viewNeedsAuthentication)
            {
                var userHasAuthentication = false;
                foreach (var keychainConnection in Platform.Keychain.Connections.OrderByDescending(HostAddress.IsGitHubDotCom))
                {
                    var apiClient = new ApiClient(Platform.Keychain, Platform.ProcessManager, TaskManager,
                                                  Environment, keychainConnection.Host);

                    try
                    {
                        apiClient.EnsureValidCredentials();
                        userHasAuthentication = true;
                        break;
                    }
                    catch (Exception ex)
                    {
                        Logger.Trace(ex, "Exception validating host {0}", keychainConnection.Host);
                    }
                }

                if (userHasAuthentication)
                {
                    OpenInternal(popupViewType, onClose);
                    shouldCloseOnFinish = true;
                }
                else
                {
                    authenticationView.Initialize(null);
                    OpenInternal(PopupViewType.AuthenticationView, completedAuthentication =>
                    {
                        if (completedAuthentication)
                        {
                            Open(popupViewType, onClose);
                        }
                    });

                    shouldCloseOnFinish = false;
                }
            }
            else
            {
                OpenInternal(popupViewType, onClose);
                shouldCloseOnFinish = true;
            }
        }
Example #4
0
        public override void Finish(bool result)
        {
            OnClose.SafeInvoke(result);
            OnClose = null;

            if (shouldCloseOnFinish)
            {
                shouldCloseOnFinish = false;
                Close();
            }

            base.Finish(result);
        }
Example #5
0
        private void Open(PopupViewType popupViewType, Action <bool> onClose)
        {
            OnClose.SafeInvoke(false);
            OnClose = null;

            //Logger.Trace("OpenView: {0}", popupViewType.ToString());

            var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;

            if (viewNeedsAuthentication)
            {
                //Logger.Trace("Validating to open view");

                Client.ValidateCurrentUser(() => {
                    //Logger.Trace("User validated opening view");

                    OpenInternal(popupViewType, onClose);
                    shouldCloseOnFinish = true;
                }, exception => {
                    //Logger.Trace("User required validation opening AuthenticationView");
                    authenticationView.Initialize(exception);
                    OpenInternal(PopupViewType.AuthenticationView, completedAuthentication => {
                        if (completedAuthentication)
                        {
                            //Logger.Trace("User completed validation opening view: {0}", popupViewType.ToString());

                            Open(popupViewType, onClose);
                        }
                    });

                    shouldCloseOnFinish = false;
                });
            }
            else
            {
                OpenInternal(popupViewType, onClose);
                shouldCloseOnFinish = true;
            }
        }
Example #6
0
 public override void OnDestroy()
 {
     base.OnDestroy();
     OnClose.SafeInvoke(false);
     OnClose = null;
 }
Example #7
0
 protected void RaiseOnClose(bool result)
 {
     OnClose.SafeInvoke(result);
 }