public BrowserViewModel()
        {
            _historyStack = new Stack<Uri>();
            _browserState = ViewModels.BrowserState.Web;

            _goBack = new RelayCommand(GoBackAction);
            _goHome = new RelayCommand(GoHomeAction);

            Messenger.Default.Register<PropertyChangedMessage<PostViewModel>>(this, (msg) =>
            {
                if (!msg.NewValue.IsSelf && msg.PropertyName == "CurrentPost")
                {
                    SetUri(msg.NewValue.Link);
                    this._rootUri = msg.NewValue.Link;
                }
            });

            Messenger.Default.Register<LinkClickedMessage>(this, (msg) =>
            {
                try
                {
                    Uri newUri = new Uri(msg.UriToNavigate, UriKind.Absolute);
                    SetUri(newUri);
                }
                catch
                {
                    System.Diagnostics.Debugger.Break();
                }
            });
        }
Example #2
0
        void EnableDisableControls(BrowserState state)
        {
            bool enabled = state == BrowserState.Ready;

            this.tsBtnRefresh.Enabled  = enabled;
            this.listViewFiles.Enabled = enabled;
        }
Example #3
0
        private void TriggerClearSecret(BrowserState state)
        {
            Thread t = new Thread(ClearSecret);

            t.IsBackground = true;
            t.Start(state);
        }
Example #4
0
 public void onCancelClick()
 {
     state        = BrowserState.Cancelled;
     selectedPath = "";
     gameObject.SetActive(false);
     Debug.Log("<Color=red>PATH: </Color>" + "NONE");
 }
Example #5
0
        /// <summary>
        /// Clear the persisted secret from the server.
        /// Completion of this thread is indicated by state.Credentials being set to null.
        /// </summary>
        private void ClearSecret(object obj)
        {
            Program.AssertOffEventThread();

            BrowserState state = (BrowserState)obj;

            try
            {
                Session session = state.Obj.Connection.Session;
                Pool    pool    = Helpers.GetPoolOfOne(state.Obj.Connection);
                if (pool == null)
                {
                    return;
                }

                string secret_uuid = pool.GetXCPluginSecret(PluginDescriptor.Name, state.Obj);
                if (!string.IsNullOrEmpty(secret_uuid))
                {
                    XenRef <Secret> secret_ref = Secret.get_by_uuid(session, secret_uuid);
                    TryToDestroySecret(session, secret_ref.opaque_ref);
                    TryToRemoveSecret(pool, session, PluginDescriptor.Name, state.Obj);
                }
            }
            catch (Exception exn)
            {
                log.Warn("Ignoring exception when trying to clear secret", exn);
            }

            state.Credentials = null;
        }
Example #6
0
 public BrowserViewModel()
 {
     this.currentPath  = null;
     this.status       = String.Empty;
     this.browserState = BrowserState.Ready;
     this.Files        = new BindingList <BrowserFileInfo>();
     this.Context      = SynchronizationContext.Current;
 }
 public BrowserViewModel()
 {
     this.currentPath = null;
     this.status = String.Empty;
     this.browserState = BrowserState.Ready;
     this.Files = new BindingList<BrowserFileInfo>();
     this.Context = SynchronizationContext.Current;
 }
Example #8
0
 private void MaybePersistCredentials(Session session, Pool pool, BrowserState state)
 {
     BrowserState.BrowserCredentials creds = state.Credentials;
     if (creds != null && creds.Valid)
     {
         string val =
             creds.PersistCredentials ?
             CreateSecret(session, creds.Username, creds.Password) :
             "";
         pool.SetXCPluginSecret(session, PluginDescriptor.Name, state.Obj, val);
     }
 }
Example #9
0
        public void SetUrl()
        {
            // Never update XenCenter node tabs once loaded
            if (Browser.Url != null && Browser.Url.AbsoluteUri != "about:blank" && XenCenterOnly)
            {
                return;
            }

            BrowserState state;

            if (SelectedXenObject == null)
            {
                // XenCenter node is selected, the placeholder code will sub in "null" for all placeholders
                // After this point we will never update this url again for this node, so there is no need to store a browser state
                state = new BrowserState(Placeholders.SubstituteUri(Url, SelectedXenObject), SelectedXenObject, Browser);
            }
            else if (BrowserStates.ContainsKey(SelectedXenObject))
            {
                state      = BrowserStates[SelectedXenObject];
                state.Uris = Placeholders.SubstituteUri(Url, SelectedXenObject);
            }
            else
            {
                state = new BrowserState(Placeholders.SubstituteUri(Url, SelectedXenObject), SelectedXenObject, Browser);
                BrowserStates[SelectedXenObject] = state;
            }

            try
            {
                if (state.ObjectForScripting != null)
                {
                    if (Credentials)
                    {
                        state.ObjectForScripting.LoginSession();
                    }
                    Browser.ObjectForScripting = state.ObjectForScripting;
                }

                lastBrowserState = state;

                Browser.DocumentText = string.Empty;
                Application.DoEvents();

                lastBrowserState.IsError = false;
                ShowStatus(string.Format(Messages.WEB_BROWSER_WAITING, ShortUri(state.Uris[0])));
                Browser.Navigate(state.Uris[0]);
            }
            catch (Exception e)
            {
                log.Error(string.Format("Failed to set TabPage url to '{0}' for plugin '{1}'",
                                        string.Join(",", state.Uris.ConvertAll(u => u.ToString()).ToArray()), PluginDescriptor.Name), e);
            }
        }
 public void draw(BrowserMode _mode, DirectoryInfo startingPath,string[] _acceptedExtensions)
 {
     state = BrowserState.Processing;
     gameObject.SetActive(true);
     if (_mode == BrowserMode.FolderSelect)
         gameObject.transform.Find("Panel").Find("EnterName").gameObject.SetActive(true);
     else
         gameObject.transform.Find("Panel").Find("EnterName").gameObject.SetActive(false);
     mode = _mode;
     currentDirectory = startingPath;
     acceptedExtensions = _acceptedExtensions;
     fillList();
 }
Example #11
0
        public void ClientConnectionSetBrowserState(string connectionName, string connectionId, string userSid, Hashtable currentEnvironment, string browserIdentifierString, bool isInstalled, bool isDefaultBrowser)
        {
            EnsureValidClientConnection(connectionName, connectionId);

            // CaseInsensitiveComparer needed since we can't predict the casing of a user's environment variables across all platforms.
            currentEnvironment = new Hashtable(currentEnvironment, StringComparer.InvariantCultureIgnoreCase);

            BrowserIdentifier browserIdentifier = (BrowserIdentifier)Enum.Parse(typeof(BrowserIdentifier), browserIdentifierString, true);
            BrowserState      browserState      = new BrowserState(userSid, currentEnvironment);
            BrowserStateValue browserValue      = new BrowserStateValue(browserIdentifier, isInstalled, isDefaultBrowser);

            StateManager.Current.Transition(connectionName, browserState, browserValue);
        }
Example #12
0
        private void CompleteClearSecret(BrowserState state)
        {
            if (state.Credentials == null)
            {
                return;
            }

            TriggerClearSecret(state);
            while (state.Credentials != null)
            {
                Application.DoEvents();
            }
        }
Example #13
0
            public bool MoveNext()
            {
                if (this.state != BrowserState.Continue)
                {
                    return(false);
                }

                if (this.move != null)
                {
                    this.state = this.move(this.index++, out this.current);
                }

                return(this.state == BrowserState.Continue);
            }
Example #14
0
        private void SetUrl()
        {
            if (UrlIsLoaded && XenCenterOnly) // Never update XenCenter node tabs.
            {
                return;
            }

            BrowserState state;

            if (selectedXenObject == null)
            {
                // XenCenter node is selected, the placeholder code will sub in "null" for all placeholders
                // After this point we will never update this url again for this node, so there is no need to store a browser state
                state = new BrowserState(Placeholders.SubstituteUri(Url, selectedXenObject), selectedXenObject, Browser);
            }
            else if (BrowserStates.ContainsKey(selectedXenObject) && !BrowserStates[selectedXenObject].IsError)
            {
                // if there wasn't an error with navigation then use the stored browser-state. Otherwise try again.
                state = BrowserStates[selectedXenObject];
            }
            else
            {
                state = new BrowserState(Placeholders.SubstituteUri(Url, selectedXenObject), selectedXenObject, Browser);
                BrowserStates[selectedXenObject] = state;
            }

            if (lastBrowserState == state)
            {
                return;
            }

            try
            {
                if (state.ObjectForScripting != null)
                {
                    if (Credentials)
                    {
                        state.ObjectForScripting.LoginSession();
                    }
                    Browser.ObjectForScripting = state.ObjectForScripting;
                }
                Browser.Navigate(state.Urls);

                lastBrowserState = state;
            }
            catch (Exception e)
            {
                log.Error(string.Format("Failed to set TabPage url to '{0}' for plugin '{1}'", string.Join(",", state.Urls.ConvertAll(u => u.ToString()).ToArray()), PluginDescriptor.Name), e);
            }
        }
Example #15
0
 public void draw(BrowserMode _mode, DirectoryInfo startingPath, string[] _acceptedExtensions)
 {
     state = BrowserState.Processing;
     gameObject.SetActive(true);
     if (_mode == BrowserMode.FolderSelect)
     {
         gameObject.transform.Find("Panel").Find("EnterName").gameObject.SetActive(true);
     }
     else
     {
         gameObject.transform.Find("Panel").Find("EnterName").gameObject.SetActive(false);
     }
     mode               = _mode;
     currentDirectory   = startingPath;
     acceptedExtensions = _acceptedExtensions;
     fillList();
 }
Example #16
0
        /// <summary>
        /// Prompt for credentials, and set state.Credentials appropriately.
        /// </summary>
        /// <param name="defaultPersist">Whether the "persist these credentials" checkbox is checked on entry to the dialog.</param>
        /// <param name="state"></param>
        private void PromptForUsernamePassword(bool defaultPersist, BrowserState state)
        {
            Program.AssertOnEventThread();

            TabPageCredentialsDialog d = new TabPageCredentialsDialog();

            d.ServiceName    = Label;
            d.DefaultPersist = defaultPersist;
            BrowserState.BrowserCredentials creds = new BrowserState.BrowserCredentials();
            if (DialogResult.OK == d.ShowDialog(Program.MainWindow))
            {
                creds.Username           = d.Username;
                creds.Password           = d.Password;
                creds.PersistCredentials = d.PersistCredentials;
                creds.Valid = true;
            }
            else
            {
                creds.Valid = false;
            }
            state.Credentials = creds;
        }
Example #17
0
 void EnableDisableControls(BrowserState state)
 {
     bool enabled = state == BrowserState.Ready;
     this.tsBtnRefresh.Enabled = enabled;
     this.listViewFiles.Enabled = enabled;
     if (enabled) this.listViewFiles.Focus();
 }
 public void onSelectClick()
 {
     state = BrowserState.Selected;
     gameObject.SetActive(false);
     Debug.Log("<Color=red>PATH: </Color>" + selectedPath);
 }
Example #19
0
 void SetBroswerState(BrowserState value)
 {
     tracer.Info("browser state -> {0}", value);
     browserState = value;
 }
	//===============================================================================
	// Go to subsystem browsing; NOT FOR EXTERNAL USING!
	//===============================================================================
	public void GoToSubsystem(int subs_index)
	{
		if (IsHiddenSubsystems ())
			Subs.list [subs_index].gameObject.SetActive (true);

		isReady = false;
		state = BrowserState.ReduceAlpha;
		EnableTransparency ();
		FixTime ();
		current_subs_index = subs_index;
		if (stored_index != -1) //clear memory about task
			stored_index = -1;
	}
Example #21
0
        /// <summary>
        /// Get the persisted secret from the server, or prompt for new credentials and persist those back to the server.
        /// Completion of this thread is indicated by state.Credentials being set.
        /// </summary>
        /// <param name="obj"></param>
        private void GetSecret(object obj)
        {
            Program.AssertOffEventThread();

            BrowserState state = (BrowserState)obj;

            try
            {
                Session session = state.Obj.Connection.Session;

                do
                {
                    Pool pool = Helpers.GetPoolOfOne(state.Obj.Connection);
                    if (pool == null)
                    {
                        log.Warn("Failed to get Pool!");
                        Thread.Sleep(5000);
                        continue;
                    }

                    string secret_uuid = pool.GetXCPluginSecret(PluginDescriptor.Name, state.Obj);
                    if (string.IsNullOrEmpty(secret_uuid))
                    {
                        var msg = secret_uuid == null ? "Nothing persisted." : "User chose not to persist these credentials.";
                        log.Debug(msg + " Prompting for new credentials.");

                        Program.Invoke(Program.MainWindow, () => { state.Credentials = PromptForUsernamePassword(secret_uuid == null); });
                        MaybePersistCredentials(session, pool, state.Obj, state.Credentials);
                        return;
                    }
                    else
                    {
                        log.Debug("Found a secret.");
                        XenRef <Secret> secret = null;
                        try
                        {
                            secret = Secret.get_by_uuid(session, secret_uuid);
                        }
                        catch (Failure exn)
                        {
                            log.Warn(string.Format("Secret {0} for {1} on plugin {2} has disappeared! Removing from pool.gui_config.",
                                                   secret_uuid, Helpers.GetName(state.Obj), PluginDescriptor.Name), exn);
                            TryToRemoveSecret(pool, session, PluginDescriptor.Name, state.Obj);
                            continue;
                        }

                        string   val  = Secret.get_value(session, secret);
                        string[] bits = val.Split(CREDENTIALS_SEPARATOR);
                        if (bits.Length != 2)
                        {
                            log.WarnFormat("Corrupt secret {0} at {1} for {2} on plugin {3}!  Deleting.", val, secret_uuid,
                                           Helpers.GetName(state.Obj), PluginDescriptor.Name);

                            TryToDestroySecret(session, secret.opaque_ref);
                            TryToRemoveSecret(pool, session, PluginDescriptor.Name, state.Obj);
                            continue;
                        }

                        log.Debug("Secret successfully read.");

                        state.Credentials = new BrowserState.BrowserCredentials
                        {
                            Username           = bits[0],
                            Password           = bits[1],
                            PersistCredentials = true,
                            Valid = true
                        };
                        return;
                    }

                    // Unreachable.  Should either have returned, or continued (to retry).
                } while (true);
            }
            catch (Exception exn)
            {
                log.Warn("Ignoring exception when trying to get secret", exn);

                // Note that it's essential that we set state.Credentials before leaving this function,
                // because other threads are waiting for that value to appear.
                state.Credentials = new BrowserState.BrowserCredentials {
                    Valid = false
                };
            }
        }
Example #22
0
        /// <summary>
        /// Prompt for credentials, and set state.Credentials appropriately.
        /// </summary>
        /// <param name="defaultPersist">Whether the "persist these credentials" checkbox is checked on entry to the dialog.</param>
        /// <param name="state"></param>
        private void PromptForUsernamePassword(bool defaultPersist, BrowserState state)
        {
            Program.AssertOnEventThread();

            TabPageCredentialsDialog d = new TabPageCredentialsDialog();
            d.ServiceName = Label;
            d.DefaultPersist = defaultPersist;
            BrowserState.BrowserCredentials creds = new BrowserState.BrowserCredentials();
            if (DialogResult.OK == d.ShowDialog(Program.MainWindow))
            {
                creds.Username = d.Username;
                creds.Password = d.Password;
                creds.PersistCredentials = d.PersistCredentials;
                creds.Valid = true;
            }
            else
            {
                creds.Valid = false;
            }
            state.Credentials = creds;
        }
Example #23
0
 private void MaybePersistCredentials(Session session, Pool pool, BrowserState state)
 {
     BrowserState.BrowserCredentials creds = state.Credentials;
     if (creds != null && creds.Valid)
     {
         string val =
             creds.PersistCredentials ?
                 CreateSecret(session, creds.Username, creds.Password) :
                 "";
         pool.SetXCPluginSecret(session, PluginDescriptor.Name, state.Obj, val);
     }
 }
Example #24
0
        private void SetUrl()
        {
            if (UrlIsLoaded && XenCenterOnly) // Never update XenCenter node tabs.
                return;

            BrowserState state;
            if (selectedXenObject == null)
            {
                // XenCenter node is selected, the placeholder code will sub in "null" for all placeholders
                // After this point we will never update this url again for this node, so there is no need to store a browser state
                state = new BrowserState(Placeholders.SubstituteUri(Url, selectedXenObject), selectedXenObject, Browser);
            }
            else if (BrowserStates.ContainsKey(selectedXenObject) && !BrowserStates[selectedXenObject].IsError)
            {
                // if there wasn't an error with navigation then use the stored browser-state. Otherwise try again.
                state = BrowserStates[selectedXenObject];
            }
            else
            {
                state = new BrowserState(Placeholders.SubstituteUri(Url, selectedXenObject), selectedXenObject, Browser);
                BrowserStates[selectedXenObject] = state;
            }

            if (lastBrowserState == state)
                return;

            try
            {
                if (state.ObjectForScripting != null)
                {
                    if (Credentials)
                        state.ObjectForScripting.LoginSession();
                    Browser.ObjectForScripting = state.ObjectForScripting;
                }
                Browser.Navigate(state.Urls);

                lastBrowserState = state;
            }
            catch (Exception e)
            {
                log.Error(string.Format("Failed to set TabPage url to '{0}' for plugin '{1}'", string.Join(",", state.Urls.ConvertAll(u => u.ToString()).ToArray()), PluginDescriptor.Name), e);
            }
        }
 public void onCancelClick()
 {
     state = BrowserState.Cancelled;
     selectedPath = "";
     gameObject.SetActive(false);
     Debug.Log("<Color=red>PATH: </Color>" + "NONE");
 }
	//===============================================================================
	//Increase alpha-channel of whole system 
	//===============================================================================
	void IncreaseAlpha()
	{
		if (m_alpha != alphaMax)
		{
			if (fadeMode == FadeMode.Continuously)
				ChangeAlpha (GO, startTime, shiftAlphaTime, alphaMin, alphaMax);
			else
			{
				m_alpha = alphaMax;
				SetAllMeshesVisibility(true);
			}
		}
		else
		{
			state = BrowserState.System; //next state
			current_subs_index = -1;
			DisableTransparency ();
		}
	}
	//===============================================================================
	//
	//===============================================================================
	void PrepareForZoomIn()
	{
		state = BrowserState.ZoomInSubsystem; //next state
		SetAllMeshesVisibility(false); //кроме выбранной //!!!
		DisableTransparency();
		FixTime();

		subFrom = mainPos;
		subTo = CalcCenterOfGameObject2(Subs.list[current_subs_index].gameObject); 

		//панорамирование нужно будет сбросить
		parallelFrom = orbitNav.transform.localPosition;
		parallelTo = new Vector3(0,0,0);

		distFrom = orbitNav.distance;
		//distTo = Mathf.Max(orbitNav.distanceMin, orbitNav.distance - zoomIncrement);
		distTo = Mathf.Max(orbitNav.distanceMin, Subs.list[current_subs_index].startCamDistance);

		camRotateFrom = orbitNav.transform.rotation;
		camRotateTo = Quaternion.Euler (Subs.list [current_subs_index].startCamRotation);
	}
Example #28
0
        private void CompleteClearSecret(BrowserState state)
        {
            if (state.Credentials == null)
                return;

            TriggerClearSecret(state);
            while (state.Credentials != null)
                Application.DoEvents();
        }
Example #29
0
 public void onSelectClick()
 {
     state = BrowserState.Selected;
     gameObject.SetActive(false);
     Debug.Log("<Color=red>PATH: </Color>" + selectedPath);
 }
Example #30
0
 private void TriggerClearSecret(BrowserState state)
 {
     Thread t = new Thread(ClearSecret);
     t.IsBackground = true;
     t.Start(state);
 }
	//===============================================================================
	//Move camera closer to selected subsystem
	//===============================================================================
	void ZoomInSub()
	{
		bool IsEnd = false;

		if (Time.time > startTime + shiftZoomTime) //если время кончилось
		{
			IsEnd = true;
			cameraHelper.transform.position = subTo;
			orbitNav.gameObject.transform.localPosition = parallelTo;
			orbitNav.cameraRotation.transform.localRotation = camRotateTo;
			orbitNav.Distance = distTo;
		}
		else
		{
			if ((cameraHelper.transform.position != subTo) ||
			    (orbitNav.gameObject.transform.localPosition != parallelTo) ||
			    (orbitNav.cameraRotation.transform.localRotation != camRotateTo) ||
			    (orbitNav.Distance != distTo)) {
				//Move(cameraHelper, startTime, shiftZoomTime, subFrom, subTo);
				//MoveLocal(orbitNav.gameObject, startTime, shiftZoomTime, parallelFrom, parallelTo);
				//ChangeDist(orbitNav, startTime, shiftZoomTime, distFrom, distTo);

				float t = (Time.time - startTime) / shiftZoomTime;
				cameraHelper.transform.position = Vector3.Lerp (subFrom, subTo, t);
				orbitNav.gameObject.transform.localPosition = Vector3.Lerp (parallelFrom, parallelTo, t);
				orbitNav.cameraRotation.transform.localRotation = Quaternion.Lerp (camRotateFrom, camRotateTo, t);
				orbitNav.Distance = Mathf.Lerp (distFrom, distTo, t);
			}
			else
				IsEnd = true;
		}
			
		if (IsEnd)
		{
			state = BrowserState.Subsystem; //next state
			isReady = true;
			bGUI.ReceiveEventSubsystem ();
			if (taskToPlayAnimationInSubsystem)
			{
				taskToPlayAnimationInSubsystem = false;
				bGUI.PlayAnimation ();
			}
		}
	}
	//===============================================================================
	// Go to system browsing
	//===============================================================================
	public void GoToSystem()
	{
		if (isReady == false) //browser is busy
			return;
		if (current_subs_index == -1) //no zoomed subs
			return;

		isReady = false;
		FixTime ();

		//switch point from and point to, start distance and finish distance
		SwithVector3Value (ref subTo, ref subFrom);
		//SwithVector3Value (ref parallelTo, ref parallelFrom);

		parallelFrom = orbitNav.gameObject.transform.localPosition;
		parallelTo = new Vector3 (0, 0, 0);

		distFrom = orbitNav.distance;
		distTo = startCamDistance; //Mathf.Min(orbitNav.distanceMax, orbitNav.distance + zoomIncrement);

		state = BrowserState.ZoomOutSubsystem; //next state
	}
	//===============================================================================
	//
	//===============================================================================
	void PrepareForIncreaseAlpha()
	{
		FixTime();
		EnableTransparency ();
		state = BrowserState.IncreaseAlpha; //next state
		SetAllMeshesVisibility(true); //кроме выбранной //!!!
	}
Example #34
0
 public Enumerator(BrowserMove <TEntity> move)
 {
     this.index = 0;
     this.move  = move;
     this.state = BrowserState.Continue;
 }