public void Execute() { MainWindow form = Program.Form; if (form.InvokeRequired) { form.Invoke(new ExecuteDelegate(Execute)); } else { if (!Program.Connected) { TransmissionDaemonDescriptor descriptor = Program.DaemonDescriptor; Program.Log( $"({OtherStrings.Info}) {OtherStrings.ConnectedTo}", $"{OtherStrings.Host}={Program.Settings.Current.Host}, " + $"{OtherStrings.Version}={descriptor.Version}, " + $"{OtherStrings.Revision}={descriptor.Revision}, " + $"{OtherStrings.RpcVersion}={(descriptor.RpcVersion > 0 ? descriptor.RpcVersion.ToString() : "unspecified")}, " + $"{OtherStrings.RpcVersionMinimum}={(descriptor.RpcVersionMin > 0 ? descriptor.RpcVersionMin.ToString() : "unspecified")}"); Program.Connected = true; form.RefreshIfNotRefreshing(); if (Program.UploadQueue.Count > 0) { form.Upload(Program.UploadQueue.ToArray(), Program.UploadPrompt); Program.UploadQueue.Clear(); } } else { form.SetAltSpeedButtonState(Toolbox.ToBool(Program.DaemonDescriptor.SessionData[ProtocolConstants.FIELD_ALTSPEEDENABLED])); } } }
public SessionCommand(JsonObject response, WebHeaderCollection headers) { TransmissionDaemonDescriptor descriptor = new TransmissionDaemonDescriptor(); JsonObject arguments = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS]; if (arguments.Contains("version")) { ParseVersionAndRevisionResponse((string)arguments["version"], descriptor); } else if (headers.Get("Server") != null) { descriptor.Version = 1.40; } else { descriptor.Version = 1.39; } if (arguments.Contains("rpc-version")) { descriptor.RpcVersion = Toolbox.ToInt(arguments["rpc-version"]); } if (arguments.Contains("rpc-version-minimum")) { descriptor.RpcVersionMin = Toolbox.ToInt(arguments["rpc-version-minimum"]); } descriptor.SessionData = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS]; Program.DaemonDescriptor = descriptor; }
public void Execute() { MainWindow form = Program.Form; if (form.InvokeRequired) { form.Invoke(new ExecuteDelegate(this.Execute)); } else { if (!Program.Connected) { TransmissionDaemonDescriptor descriptor = Program.DaemonDescriptor; Program.Log( String.Format("({0}) {1}", OtherStrings.Info, OtherStrings.ConnectedTo), String.Format("{0}={1}, {2}={3}, {4}={5}, {6}={7}, {8}={9}", new object[] { OtherStrings.Host, Program.Settings.Current.Host, OtherStrings.Version, descriptor.Version, OtherStrings.Revision, descriptor.Revision, OtherStrings.RpcVersion, descriptor.RpcVersion > 0 ? descriptor.RpcVersion.ToString() : "unspecified", OtherStrings.RpcVersionMinimum, descriptor.RpcVersionMin > 0 ? descriptor.RpcVersionMin.ToString() : "unspecified" })); Program.Connected = true; form.RefreshIfNotRefreshing(); if (Program.UploadQueue.Count > 0) { form.Upload(Program.UploadQueue.ToArray(), Program.UploadPrompt); Program.UploadQueue.Clear(); } } else { form.SetAltSpeedButtonState(Toolbox.ToBool(Program.DaemonDescriptor.SessionData[ProtocolConstants.FIELD_ALTSPEEDENABLED])); } } }
public SessionCommand(JsonObject response, WebHeaderCollection headers) { TransmissionDaemonDescriptor descriptor = new TransmissionDaemonDescriptor(); JsonObject arguments = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS]; if (arguments.Contains("version")) ParseVersionAndRevisionResponse((string)arguments["version"], descriptor); else if (headers.Get("Server") != null) descriptor.Version = 1.40; else descriptor.Version = 1.39; if (arguments.Contains("rpc-version")) descriptor.RpcVersion = Toolbox.ToInt(arguments["rpc-version"]); if (arguments.Contains("rpc-version-minimum")) descriptor.RpcVersionMin = Toolbox.ToInt(arguments["rpc-version-minimum"]); descriptor.SessionData = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS]; Program.DaemonDescriptor = descriptor; }
private void ParseVersionAndRevisionResponse(string str, TransmissionDaemonDescriptor descriptor) { try { for (int i = 0; i < str.Length; i++) { if ((str[i] < '0' || str[i] > '9') && str[i] != '.') { descriptor.Version = Double.Parse(str.Substring(0, i), Toolbox.NumberFormat); descriptor.Trunk = str[i] == '+'; break; } } } catch { } try { int spaceIndex = str.IndexOf(' '); descriptor.Revision = int.Parse(str.Substring(spaceIndex + 2, str.Length - spaceIndex - 3)); } catch { } }
private void ParseVersionAndRevisionResponse(string str, TransmissionDaemonDescriptor descriptor) { try { for (int i = 0; i < str.Length; i++) { if ((str[i] < (int)'0' || str[i] > (int)'9') && str[i] != (int)'.') { descriptor.Version = Double.Parse(str.Substring(0, i), Toolbox.NUMBER_FORMAT); descriptor.Trunk = str[i] == (int)'+'; break; } } } catch { } try { int spaceIndex = str.IndexOf(' '); descriptor.Revision = Int32.Parse(str.Substring(spaceIndex + 2, str.Length - spaceIndex - 3)); } catch { } }