mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
0.5 Rc1 - Reimplement port change+tray, fix IPT+SSC. Installer fixes.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Win32;
|
||||
using Jackett;
|
||||
using Jackett.Utils;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -27,13 +29,19 @@ namespace JackettTray
|
||||
toolStripMenuItemWebUI.Click += toolStripMenuItemWebUI_Click;
|
||||
toolStripMenuItemShutdown.Click += toolStripMenuItemShutdown_Click;
|
||||
|
||||
//if (Server.IsFirstRun)
|
||||
// AutoStart = true;
|
||||
Engine.Server.Initalize();
|
||||
|
||||
if (!Engine.ServiceConfig.ServiceExists())
|
||||
{
|
||||
// We are not installed as a service so just the web server too and run from the tray.
|
||||
Engine.Logger.Info("Starting server from tray");
|
||||
Engine.Server.Start();
|
||||
}
|
||||
}
|
||||
|
||||
void toolStripMenuItemWebUI_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Process.Start("http://127.0.0.1:" + Server.Port);
|
||||
Process.Start("http://127.0.0.1:" + Engine.Server.Config.Port);
|
||||
}
|
||||
|
||||
void toolStripMenuItemShutdown_Click(object sender, EventArgs e)
|
||||
@@ -83,12 +91,82 @@ namespace JackettTray
|
||||
|
||||
private void CreateShortcut()
|
||||
{
|
||||
/* var appPath = Assembly.GetExecutingAssembly().Location;
|
||||
|
||||
var appPath = Assembly.GetExecutingAssembly().Location;
|
||||
var shell = new IWshRuntimeLibrary.WshShell();
|
||||
var shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(ShortcutPath);
|
||||
shortcut.Description = Assembly.GetExecutingAssembly().GetName().Name;
|
||||
shortcut.TargetPath = appPath;
|
||||
shortcut.Save();*/
|
||||
shortcut.Save();
|
||||
}
|
||||
|
||||
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (Engine.ServiceConfig.ServiceExists())
|
||||
{
|
||||
backgroundMenuItem.Visible = true;
|
||||
serviceControlMenuItem.Visible = true;
|
||||
toolStripSeparator1.Visible = true;
|
||||
toolStripSeparator2.Visible = true;
|
||||
if (Engine.ServiceConfig.ServiceRunning())
|
||||
{
|
||||
serviceControlMenuItem.Text = "Stop background service";
|
||||
} else
|
||||
{
|
||||
serviceControlMenuItem.Text = "Start background service";
|
||||
}
|
||||
|
||||
toolStripMenuItemShutdown.Text = "Close tray icon";
|
||||
} else
|
||||
{
|
||||
backgroundMenuItem.Visible = false;
|
||||
serviceControlMenuItem.Visible = false;
|
||||
toolStripSeparator1.Visible = false;
|
||||
toolStripSeparator2.Visible = false;
|
||||
toolStripMenuItemShutdown.Text = "Shutdown";
|
||||
}
|
||||
}
|
||||
|
||||
private void serviceControlMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var consolePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "JackettConsole.exe");
|
||||
|
||||
if (Engine.ServiceConfig.ServiceRunning())
|
||||
{
|
||||
if (ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
Engine.ServiceConfig.Stop();
|
||||
|
||||
} else
|
||||
{
|
||||
try
|
||||
{
|
||||
Engine.ProcessService.StartProcessAndLog(consolePath, "/stop", true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Failed to get admin rights to stop the service.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ServerUtil.IsUserAdministrator())
|
||||
{
|
||||
Engine.ServiceConfig.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Engine.ProcessService.StartProcessAndLog(consolePath, "/start", true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Failed to get admin rights to start the service.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user