virtual internal void OnNewConnection(INetworkNode Remote) { if (Remote == null) { return; } if (!Remotes.Contains(Remote)) { Remotes.Add(Remote); } if (NewConnection == null) { return; } Task.Run(() => { NewConnection?.Invoke(this, new InternetConnectionEventArgs { Local = this, Remote = Remote }); }); }
private void InitialiseTabRemotes(string preselectRemote = null) { // because the binding the same BindingList to multiple controls, // and changes in one of the bound control automatically get reflected // in the other control, which causes rather frustrating UX. // to address that, re-create binding lists for each individual control var repos = Repositories.RemoteRepositoryHistory.Repositories; try { // to stop the flicker binding the lists and // when the selected remote is getting reset and then selected again Url.BeginUpdate(); comboBoxPushUrl.BeginUpdate(); Remotes.BeginUpdate(); Url.DataSource = new BindingList <Repository>(repos); Url.DisplayMember = "Path"; Url.SelectedItem = null; comboBoxPushUrl.DataSource = new BindingList <Repository>(repos); comboBoxPushUrl.DisplayMember = "Path"; comboBoxPushUrl.SelectedItem = null; BindRemotes(preselectRemote); } finally { Remotes.EndUpdate(); Url.EndUpdate(); comboBoxPushUrl.EndUpdate(); } }
IEnumerable <IPackageRepository> GetSourceRepositories() { return(new[] { _userSpecifiedRepository, HostEnvironment.CurrentDirectoryRepository, HostEnvironment.SystemRepository } .Concat(Remotes.FetchRepositories()) .Concat(HostEnvironment.ProjectRepository) .NotNull()); }
public void AssignRemotes() { if (!Remotes.Any()) { Remotes.AddRange(Articulations.Where(a => !a.ExcludeFromRemote)); } }
public ValidationSettings() { FailAjaxRequestsWith(HttpStatusCode.BadRequest); Remotes .FindWith <RemoteRuleAttributeFilter>() .FindWith <RemoteFieldValidationRuleFilter>(); }
public void MoveRootKey(int newKey) { var diff = newKey - RootKey; Articulations = Articulations.Select(a => new Articulation(a.Name, a.OutputKS + diff, a.Channel, a.IsChannelRelative, a.Keyswitched, a.InputKS, a.MuteCC)).ToList(); Remotes = Remotes.Select(a => new Articulation(a.Name, a.OutputKS + diff, a.Channel, a.IsChannelRelative, a.Keyswitched, a.InputKS, a.MuteCC)).ToList(); RootKey = newKey; }
private void HandleDesktopLogin(byte[] message) { short length = BitConverter.ToInt16(message, 0); string msg = Encoding.UTF8.GetString(message, 2, length); //msg = this.DecryptDesktop(msg, "FORGEREMOTETIVITY"); byte[] bs = new byte[1]; //Server.s.Log(msg); if (msg.StartsWith(Protocal.ToString())) //TODO: make a better checker { msg = msg.Replace(string.Format("{0}: ", Protocal), string.Empty); } else { bs[0] = 3; SendData(0x40, bs); Server.s.Log("[Remote] A remote tried to connect with a different version."); return; } if (RemoteServer.tries >= 3) { bs[0] = 4; SendData(0x40, bs); Server.s.Log("[Remote] A remote tried to connect with exceeding incorrect credentials"); return; } if (RemoteServer.tries == 6) { bs[0] = 5; SendData(0x40, bs); Server.s.Log("[Remote] Remote was locked from the console, type \"/remote tryreset\" to reset the try count"); return; } if (HandleLogin(msg)) { bs[0] = 1; if (OnRemoteLogin != null) { OnRemoteLogin(this); } SendData(0x40, bs); Server.s.Log("[Remote] Remote Verified, passing controls to it!"); LoggedIn = true; if (Remotes != null) { Remotes.Add(this); } RegEvents(); //StartUpDesktop(); return; } bs[0] = 2; SendData(0x40, bs); Server.s.Log("[Remote] A Remote with incorrect information attempted to join."); RemoteServer.tries++; return; }
private void OnPeerDisconnected(PeerDisconnected data) { Notifications.Enqueue(new PeerDisconnectedNotification(data.Peer)); Peers.Remove(data.Peer); Remotes.Remove(data.Remote); DataMap?.Handle(data); Sender?.Remove(data.Peer); }
protected override IEnumerable <ICommandOutput> ExecuteCore() { // TODO: HACK HACK HACK IPackageRepository repo = Remotes.PublishRepositories(Remote).SelectMany(_ => _).FirstOrDefault(); if (repo == null) { yield return(new UnknownRemoteName(Remote)); foreach (var m in HintRemoteRepositories()) { yield return(m); } yield break; } var nukingRepo = repo.Feature <ISupportNuking>(); if (nukingRepo == null) { yield return(new Error("The remote repository {0} does not support nuking.", Remote)); yield break; } var packagesOfName = repo.PackagesByName[Name]; if (!packagesOfName.Any()) { yield return(new Error("The remote repository {0} does not contain any package called {1}.", Remote, Name)); yield break; } var packageToNuke = packagesOfName .Where(x => x.SemanticVersion.ToString().Equals(Version)) .FirstOrDefault(); if (packageToNuke == null) { yield return(new Error("The package {0} does not have a version {1} in the remote repository {2}.", Name, Version, Remote)); yield break; } nukingRepo.Nuke(packageToNuke); yield return(new Info("{0} {1} was successfully nuked from the remote repository {2}.", Name, Version, Remote)); yield return(new Success()); }
public void Serialize(IXunitSerializationInfo info) { info.AddValue(nameof(Description), Description); info.AddValue(nameof(Remotes), Remotes.Select(x => new XunitSerializableGitRemote(x)).ToArray()); info.AddValue(nameof(Configuration), new XunitSerializableGitHubIntegrationConfiguration(Configuration)); info.AddValue(nameof(ExpectedHost), ExpectedHost); info.AddValue(nameof(ExpectedOwner), ExpectedOwner); info.AddValue(nameof(ExpectedRepository), ExpectedRepository); }
public void Serialize(IXunitSerializationInfo info) { info.AddValue(nameof(Description), Description); info.AddValue(nameof(Remotes), Remotes.Select(x => new XunitSerializableGitRemote(x)).ToArray()); info.AddValue(nameof(Configuration), new XunitSerializableGitLabIntegrationConfiguration(Configuration)); info.AddValue(nameof(ExpectedHost), ExpectedHost); info.AddValue(nameof(ExpectedNamespace), ExpectedNamespace); info.AddValue(nameof(ExpectedProject), ExpectedProject); }
/// <summary> /// Updates all references of <see cref="ReferenceType.LocalBranch"/> or /// <see cref="ReferenceType.RemoteBranch"/> type. /// </summary> public void RefreshBranches() { var refs = Repository.Accessor.QueryReferences.Invoke( new QueryReferencesParameters( ReferenceType.LocalBranch | ReferenceType.RemoteBranch)); Heads.Refresh(refs.Heads); Remotes.Refresh(refs.Remotes); }
IEnumerable <ICommandOutput> SetRemoteRepositories() { _remoteRepositories = new[] { HostEnvironment.CurrentDirectoryRepository, HostEnvironment.SystemRepository } .Concat(Remotes.FetchRepositories()); if (HostEnvironment.ProjectRepository != null) { _remoteRepositories = _remoteRepositories.Concat(new[] { HostEnvironment.ProjectRepository }); } yield break; }
private void InitialiseTabRemotes(string preselectRemote = null) { // because the binding the same BindingList to multiple controls, // and changes in one of the bound control automatically get reflected // in the other control, which causes rather frustrating UX. // to address that, re-create binding lists for each individual control var repos = Repositories.RemoteRepositoryHistory.Repositories; try { // to stop the flicker binding the lists and // when the selected remote is getting reset and then selected again Url.BeginUpdate(); comboBoxPushUrl.BeginUpdate(); Remotes.BeginUpdate(); Url.DataSource = new BindingList <Repository>(repos); Url.DisplayMember = "Path"; Url.SelectedItem = null; comboBoxPushUrl.DataSource = new BindingList <Repository>(repos); comboBoxPushUrl.DisplayMember = "Path"; comboBoxPushUrl.SelectedItem = null; // we need to unwire and rewire the events to avoid excessive flickering Remotes.SelectedIndexChanged -= Remotes_SelectedIndexChanged; Remotes.DataSource = _gitRemoteController.Remotes; Remotes.DisplayMember = "Name"; Remotes.SelectedIndexChanged += Remotes_SelectedIndexChanged; Remotes.SelectedItem = null; if (_gitRemoteController.Remotes.Any()) { if (!string.IsNullOrEmpty(preselectRemote)) { Remotes.Text = preselectRemote; } // default fallback - if the preselection didn't work select the first available one if (Remotes.SelectedItem == null) { Remotes.SelectedItem = _gitRemoteController.Remotes.First(); } } else { RemoteName.Focus(); } } finally { Remotes.EndUpdate(); Url.EndUpdate(); comboBoxPushUrl.EndUpdate(); } }
public void GarageDoorTest() { Remotes remote = new Remotes(); GarageDoor door = new GarageDoor(); Assert.AreEqual(door.LightState, GarageDoor.LightStates.Off); Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.Down); DoorUpCommand doorUp = new DoorUpCommand(door); DoorDownCommand doorDown = new DoorDownCommand(door); remote.SetCommand(doorUp); remote.ButtonWasPressed(); // Make sure that the door went up and the light turned on Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.Up); Assert.AreEqual(door.LightState, GarageDoor.LightStates.On); remote.ButtonWasPressed(); // Make sure that the door stayed up and the light stayed on after a second door up command Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.Up); Assert.AreEqual(door.LightState, GarageDoor.LightStates.On); door.AddObstruction(); remote.SetCommand(doorDown); remote.ButtonWasPressed(); // Make sure the door did not start closing when an obstruction was in the way Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.Up); door.RemoveObstruction(); remote.ButtonWasPressed(); // Make sure that the door started ot go down when the button was pressed Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.GoingDown); door.AddObstruction(); remote.ButtonWasPressed(); // Make sure the door detected that something was in the way when is was coming down and went back up Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.Up); door.RemoveObstruction(); remote.ButtonWasPressed(); remote.ButtonWasPressed(); // Make sure that when there are no obstructions and the button is pressed twice that the door closes // and the light turns off Assert.AreEqual(door.DoorState, GarageDoor.DoorStates.Down); Assert.AreEqual(door.LightState, GarageDoor.LightStates.Off); }
IEnumerable <ICommandOutput> SetRemotes() { if (_remoteSet) { SelectedRemotes = string.IsNullOrEmpty(Remote) ? Remotes.FetchRepositories() : new[] { Remotes.FetchRepositories(Remote).First() } } ; yield break; } }
private void HandleMobileLogin(byte[] message) { short length = util.EndianBitConverter.Big.ToInt16(message, 0); string msg = Encoding.UTF8.GetString(message, 2, length); msg = DecryptMobile(msg, "FORGEREMOTETIVITY"); byte[] bs = new byte[1]; //Server.s.Log(msg); if (msg.StartsWith(Protocal.ToString())) //TODO: make a better checker { msg = msg.Replace(string.Format("{0}: ", Protocal), ""); } else { bs[0] = 0x3; SendData(0xb, bs); Server.s.Log("[Remote] A remote tried to connect with a different version."); } if (RemoteServer.tries >= 0x3) { bs[0] = 0x4; SendData(0xb, bs); Server.s.Log("[Remote] A remote tried to connect with exceeding incorrect credentials"); } if (RemoteServer.tries == 0x6) { bs[0] = 0x5; SendData(0xb, bs); Server.s.Log("[Remote] Remote was locked from the console, type \"/remote tryreset\" to reset the try count"); } if (HandleLogin(msg)) { bs[0] = 1; if (OnRemoteLogin != null) { OnRemoteLogin(this); } SendData(11, bs); GenerateKeyMobile(_keyMobile); Server.s.Log("[Remote] Remote Verified, passing controls to it!"); LoggedIn = true; Remotes.Add(this); regMobileEvents(); } else { bs[0] = 0x2; SendData(11, bs); Server.s.Log("[Remote] A Remote with incorrect information attempted to join."); RemoteServer.tries++; } }
private void FormPullLoad(object sender, EventArgs e) { Remotes.Select(); string branch = GitCommandHelpers.GetSelectedBranch(); Remotes.Text = GitCommandHelpers.GetSetting(string.Format("branch.{0}.remote", branch)); _NO_TRANSLATE_localBranch.Text = branch; Text = string.Format("Pull ({0})", Settings.WorkingDir); }
private void TriggerStartupCommands() { foreach (GenericRemote rem in Remotes) { foreach (GenericRemoteCommand com in rem.RemoteCommands) { if (com.TriggerOnStartUp) { Remotes.SimulateRemoteCommand(com); } } } }
private void FormPushLoad(object sender, EventArgs e) { RestorePosition("push"); Remotes.Select(); Text = string.Concat(_pushCaption.Text, " (", Settings.WorkingDir, ")"); PushAllTags.Checked = Settings.PushAllTags; var gitHoster = RepoHosts.TryGetGitHosterForCurrentWorkingDir(); _createPullRequestCB.Visible = gitHoster != null; }
private void FormPushLoad(object sender, EventArgs e) { RestorePosition("push"); Remotes.Select(); Remotes.Text = GitCommandHelpers.GetSetting(string.Format("branch.{0}.remote", _currentBranch)); RemotesUpdated(null, null); Text = string.Concat(_pushCaption.Text, " (", Settings.WorkingDir, ")"); PushAllTags.Checked = Settings.PushAllTags; var gitHoster = RepoHosts.TryGetGitHosterForCurrentWorkingDir(); _createPullRequestCB.Visible = gitHoster != null; }
public void SimpleRemoteTest() { Remotes remote = new Remotes(); Light light1 = new Light(); Light light2 = new Light(); Assert.AreEqual(light1.CurrentState, Light.States.Off); Assert.AreEqual(light2.CurrentState, Light.States.Off); LightOnCommand lightOn = new LightOnCommand(light1); remote.SetCommand(lightOn); remote.ButtonWasPressed(); // Make sure that only light 1 was turned on after pressing the button Assert.AreEqual(light1.CurrentState, Light.States.On); Assert.AreEqual(light2.CurrentState, Light.States.Off); }
private void OnAnnounced(TrackerAnnounced data) { foreach (NetworkAddress peer in data.Peers) { if (Remotes.Add(peer)) { if (Settings.Filter?.Accept(peer) != false) { Connector?.ConnectTo(Hash, peer); } else { Notifications.Enqueue(new PeerRejectedNotification(peer)); } } } }
/// <summary>Loads the specified references.</summary> /// <param name="refs">References data.</param> internal void Load(ReferencesData refs) { Verify.Argument.IsNotNull(refs, nameof(refs)); if (refs.Heads != null) { Heads.Load(refs.Heads); } if (refs.Remotes != null) { Remotes.Load(refs.Remotes); } if (refs.Tags != null) { Tags.Load(refs.Tags); } }
/// <summary>Updates cached references of specified types.</summary> /// <param name="referenceTypes">Reference types to update.</param> public void Refresh(ReferenceType referenceTypes) { var refs = Repository.Accessor.QueryReferences.Invoke( new QueryReferencesParameters(referenceTypes)); if ((referenceTypes & ReferenceType.LocalBranch) == ReferenceType.LocalBranch) { Heads.Refresh(refs.Heads); } if ((referenceTypes & ReferenceType.RemoteBranch) == ReferenceType.RemoteBranch) { Remotes.Refresh(refs.Remotes); } if ((referenceTypes & ReferenceType.Tag) == ReferenceType.Tag) { Tags.Refresh(refs.Tags); } }
private void BindRemotes(string preselectRemote) { // we need to unwire and rewire the events to avoid excessive flickering Remotes.SelectedIndexChanged -= Remotes_SelectedIndexChanged; Remotes.Items.Clear(); Remotes.Items.AddRange(UserGitRemotes.Select(remote => { var group = remote.Disabled ? _lvgDisabled : _lvgEnabled; var color = remote.Disabled ? SystemColors.GrayText : SystemColors.WindowText; return(new ListViewItem(group) { Text = remote.Name, Tag = remote, ForeColor = color }); }).ToArray()); Remotes.SelectedIndexChanged += Remotes_SelectedIndexChanged; Remotes.SelectedIndices.Clear(); if (UserGitRemotes.Any()) { if (!string.IsNullOrEmpty(preselectRemote)) { var lvi = Remotes.Items.Cast <ListViewItem>().FirstOrDefault(x => x.Text == preselectRemote); if (lvi != null) { lvi.Selected = true; flpnlRemoteManagement.Enabled = !((GitRemote)lvi.Tag).Disabled; } } // default fallback - if the preselection didn't work select the first available one if (Remotes.SelectedIndices.Count < 1) { var group = _lvgEnabled.Items.Count > 0 ? _lvgEnabled : _lvgDisabled; group.Items[0].Selected = true; } Remotes.FocusedItem = Remotes.SelectedItems[0]; Remotes.Select(); } else { RemoteName.Focus(); } }
private void InitialiseTabRemotes(string preselectRemote = null) { ThreadHelper.JoinableTaskFactory.Run(async() => { var repositoryHistory = await RepositoryHistoryManager.Remotes.LoadRecentHistoryAsync(); await this.SwitchToMainThreadAsync(); try { // because the binding the same BindingList to multiple controls, // and changes in one of the bound control automatically get reflected // in the other control, which causes rather frustrating UX. // to address that, re-create binding lists for each individual control // to stop the flicker binding the lists and // when the selected remote is getting reset and then selected again Url.BeginUpdate(); comboBoxPushUrl.BeginUpdate(); Remotes.BeginUpdate(); Url.DataSource = repositoryHistory.ToList(); Url.DisplayMember = nameof(Repository.Path); Url.SelectedItem = null; comboBoxPushUrl.DataSource = repositoryHistory.ToList(); comboBoxPushUrl.DisplayMember = nameof(Repository.Path); comboBoxPushUrl.SelectedItem = null; BindRemotes(preselectRemote); } finally { Remotes.EndUpdate(); if (Remotes.SelectedIndices.Count > 0) { Remotes.EnsureVisible(Remotes.SelectedIndices[0]); } Url.EndUpdate(); comboBoxPushUrl.EndUpdate(); } }); }
IEnumerable <IPackageRepository> GetRepositoryToList() { if (System) { if (HostEnvironment.SystemRepository != null) { yield return(HostEnvironment.SystemRepository); } yield break; } if (_remoteSet) { foreach (var fetch in Remotes.FetchRepositories(Remote)) { yield return(fetch); } yield break; } }
/// <summary>Gets the list of branches, containing specified <paramref name="revision"/>.</summary> /// <param name="revision">Revision which must be present in any resulting branch.</param> /// <returns>List of branches, containing specified <paramref name="revision"/>.</returns> /// <exception cref="ArgumentNullException"><paramref name="revision"/> == <c>null</c>.</exception> public IList <BranchBase> GetBranchesContaining(IRevisionPointer revision) { Verify.Argument.IsValidRevisionPointer(revision, Repository, nameof(revision)); var refs = Repository.Accessor.QueryBranches.Invoke( new QueryBranchesParameters(QueryBranchRestriction.All, BranchQueryMode.Contains, revision.Pointer)); var heads = refs.Heads; var remotes = refs.Remotes; var count = heads.Count + remotes.Count; if (count == 0) { return(new BranchBase[0]); } var res = new List <BranchBase>(count); lock (Heads.SyncRoot) { foreach (var head in heads) { var branch = Heads.TryGetItem(head.Name); if (branch != null) { res.Add(branch); } } } lock (Remotes.SyncRoot) { foreach (var remote in remotes) { var branch = Remotes.TryGetItem(remote.Name); if (branch != null) { res.Add(branch); } } } return(res); }
/// <summary> /// Returns a reference with a given name or <c>null</c>, /// if such reference does not exist. /// </summary> /// <param name="name">Reference name.</param> /// <returns>Reference with a given name or <c>null</c>, if such reference does not exist</returns> public Reference TryGetReference(string name) { var head = Heads.TryGetItem(name); if (head != null) { return(head); } var remote = Remotes.TryGetItem(name); if (remote != null) { return(remote); } var tag = Tags.TryGetItem(name); if (tag != null) { return(tag); } return(null); }