/// <summary>Click event handler of the Zeptair Connect item in the menu of the task tray.</summary> /// <param name="sender">Sender Object.</param> /// <param name="e">Event parameters.</param> private void menuItemZeptConnect_Click(object sender, EventArgs e) { Zeptair.Lib.Common.ConfParam zeptConf = ZeptConf(true); UpdateZeptMenus(true, zeptConf); if (zeptConf.ServerAddress == null || zeptConf.ServerAddress.Length <= 0 || zeptConf.ServerPort <= 0) { bool ret = CommonUtil.StartProcessWithCallback( Path.Combine(CommonUtil.GetAppPath(), @"ZeptairClientConf.exe"), @"/default=tbiServerInfo", this, new EventHandler(zeptConfProcess_Exited) ); _notifyIcon.ContextMenu = null; if (!ret) { UpdateZeptMenus(false, zeptConf); } return; } if (!_DoStartZeptair()) { UpdateZeptMenus(false, zeptConf); return; } }
public Zeptair.Lib.Common.ConfParam ZeptConf(bool reload) { if (_zeptConf == null || reload) { _zeptConf = Zeptair.Lib.Common.ConfParam.Load(); } return(_zeptConf); }
/// <summary>Event handler of Exit from Zeptair Client Configuration.</summary> /// <param name="sender">Sender Object.</param> /// <param name="e">Event parameters.</param> private void zeptConfProcess_Exited(object sender, EventArgs e) { _notifyIcon.ContextMenu = _contextMenu; Zeptair.Lib.Common.ConfParam zeptConf = ZeptConf(true); UpdateZeptMenus(IsZeptSvcStarted(), zeptConf); /* * License-Key RE-Validation */ LicKeyInfo licKeyInfo = LicKeyParser.Parse(zeptConf.LicenseKey); if (licKeyInfo == null || licKeyInfo.GetErrorMsg() != null) { _hasValidZeptLicKey = false; #if true _menuItemZeptConnect.Enabled = false; #else System.Windows.Forms.MessageBox.Show( Properties.Resources.ERR_CANNOT_CONFIRM_VALID_LIC_KEY, TaskMain.APP_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error ); this.HideNotifyIcon(); Environment.Exit(0); #endif } else { _hasValidZeptLicKey = true; _menuItemZeptConnect.Enabled = true; } if (this.IsZeptSvcStarted()) { if (zeptConf.ServerAddress == null || zeptConf.ServerAddress.Length <= 0 || zeptConf.ServerPort <= 0) { System.Windows.Forms.MessageBox.Show( Properties.Resources.ERR_ZEPT_SVC_START_CANCELED, TaskMain.APP_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error ); this.UpdateZeptMenus(false, zeptConf); return; } if (!_DoStartZeptair()) { UpdateZeptMenus(false, zeptConf); return; } } }
/// <summary>Initialize.</summary> public static void Init() { _self = new TaskMain(); /* * IPC */ RemotingConfiguration.Configure(Path.Combine(ThetisCore.Lib.Def.COMMON_CONFIG_ROOT_DIR, @"remotingTask.config"), false); IpcTaskService ipcTaskService = new IpcTaskService(); ipcTaskService.RssTargetInfosUpdated += _self.ipcTaskService_RssTargetInfosUpdated; RemotingServices.Marshal(ipcTaskService, "ipcTaskService"); #if ZEPTAIR Zeptair.Lib.Common.ConfParam zeptConf = TaskMain.Instance.ZeptConf(false); /* * License-Key Validation */ LicKeyInfo licKeyInfo = LicKeyParser.Parse(zeptConf.LicenseKey); if (licKeyInfo == null || licKeyInfo.GetErrorMsg() != null) { _self._hasValidZeptLicKey = false; #if true _self._menuItemZeptConnect.Enabled = false; #else CommonUtil.StartProcessWithCallback( Path.Combine(CommonUtil.GetAppPath(), @"ZeptairClientConf.exe"), @"/default=tbiLicenseKey /edit", _self, new EventHandler(_self.zeptConfProcess_Exited) ); #endif } else { _self._hasValidZeptLicKey = true; } #endif _self._rssManager = new RssManager(); if (_self._rssManager.LoadWatchers()) { _self._rssManager.Start(); } //else // Process.Start("ThetisCoreConf.exe"); #if ZEPTAIR _self._zeptDistManager = new ZeptDistManager(); _self._zeptDistManager.Init(zeptConf.AcceptCmd); #endif }
public void RestartZeptDist(bool reloadZeptConf) { if (reloadZeptConf) { Zeptair.Lib.Common.ConfParam zeptConf = this.ZeptConf(true); _zeptDistManager.StopAll(); _zeptDistManager.Init(zeptConf.AcceptCmd); } _rssManager.RestartZeptDist(); }
/// <summary>Update Menus about Zeptair Client.</summary> /// <param name="sw">Flag whether Zeptair Client Sevice is (being) started.</param> /// <param name="zeptConf">Zeptair Client Configuration parameters.</param> public void UpdateZeptMenus(bool sw, Zeptair.Lib.Common.ConfParam zeptConf) { _menuItemZeptConnect.Visible = !sw; if (zeptConf.HideSettingsMenu) { _menuItemZeptSettings.Visible = false; } else { _menuItemZeptSettings.Visible = !sw; } _menuItemZeptDisconnect.Visible = sw; }
/// <summary>Click event handler of the Zeptair Disconnect item in the menu of the task tray.</summary> /// <param name="sender">Sender Object.</param> /// <param name="e">Event parameters.</param> private void menuItemZeptDisconnect_Click(object sender, EventArgs e) { Zeptair.Lib.Common.ConfParam zeptConf = ZeptConf(false); UpdateZeptMenus(false, zeptConf); if (!ClientServiceAgent.OnStop()) { System.Windows.Forms.MessageBox.Show( Properties.Resources.ERR_FAILED_TO_DISABLE_SVC, TaskMain.APP_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error ); UpdateZeptMenus(true, zeptConf); } }
/// <summary>Constructor</summary> private TaskMain() { _CheckProcessDuplicated(); #if ZEPTAIR Zeptair.Lib.Common.ConfParam zeptConf = ZeptConf(true); #endif _contextMenu = new ContextMenu(); int itemIdx = 0; MenuItem menuItemNavi = new MenuItem(); menuItemNavi.Index = itemIdx; menuItemNavi.Text = Properties.Resources.MENU_NAVI_PANEL; menuItemNavi.Click += new System.EventHandler(menuItemNavi_Click); itemIdx++; _menuItemSettings = new MenuItem(); _menuItemSettings.Index = itemIdx; _menuItemSettings.Text = Properties.Resources.MENU_RSS_SETTINGS; _menuItemSettings.Click += new System.EventHandler(menuItemSettings_Click); itemIdx++; MenuItem menuItemBrowser = new MenuItem(); menuItemBrowser.Index = itemIdx; #if ZEPTAIR // menuItemBrowser.Text = Properties.Resources.MENU_ZEPT_BROWSER; menuItemBrowser.Text = Properties.Resources.MENU_THETIS_BROWSER; #else menuItemBrowser.Text = Properties.Resources.MENU_THETIS_BROWSER; #endif menuItemBrowser.Click += new System.EventHandler(menuItemBrowser_Click); itemIdx++; MenuItem menuItemSeparator1 = new MenuItem(); menuItemSeparator1.Index = itemIdx; itemIdx++; #if ZEPTAIR _menuItemZeptConnect = new MenuItem(); _menuItemZeptConnect.Index = itemIdx; _menuItemZeptConnect.Text = Properties.Resources.MENU_ZEPT_CONNECT; _menuItemZeptConnect.Click += new System.EventHandler(menuItemZeptConnect_Click); itemIdx++; _menuItemZeptSettings = new MenuItem(); _menuItemZeptSettings.Index = itemIdx; _menuItemZeptSettings.Text = Properties.Resources.MENU_ZEPT_SETTINGS; _menuItemZeptSettings.Click += new System.EventHandler(menuItemZeptSettings_Click); if (zeptConf.HideSettingsMenu) { _menuItemZeptSettings.Visible = false; } itemIdx++; _menuItemZeptDisconnect = new MenuItem(); _menuItemZeptDisconnect.Index = itemIdx; _menuItemZeptDisconnect.Text = Properties.Resources.MENU_ZEPT_DISCONNECT; _menuItemZeptDisconnect.Click += new System.EventHandler(menuItemZeptDisconnect_Click); _menuItemZeptDisconnect.Visible = false; // Hide as default itemIdx++; #endif MenuItem menuItemExit = new MenuItem(); menuItemExit.Index = itemIdx; menuItemExit.Text = Properties.Resources.MENU_EXIT; menuItemExit.Click += new System.EventHandler(menuItemExit_Click); itemIdx++; _contextMenu.MenuItems.AddRange( new MenuItem[] { menuItemNavi, _menuItemSettings, // new MenuItem("-"), // menuItemBrowser, #if ZEPTAIR new MenuItem("-"), _menuItemZeptConnect, _menuItemZeptSettings, _menuItemZeptDisconnect, #endif new MenuItem("-"), menuItemExit } ); _notifyIcon = new NotifyIcon(); _notifyIcon.Icon = Properties.Resources.AppIcon; _notifyIcon.Text = TaskMain.APP_TITLE + @" v" + CommonUtil.TrimVersion(Application.ProductVersion); _notifyIcon.ContextMenu = _contextMenu; _notifyIcon.MouseDown += new System.Windows.Forms.MouseEventHandler(notifyIcon_MouseDown); _notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(notifyIcon_MouseDoubleClick); _notifyIcon.Visible = true; #if ZEPTAIR this.tmrZeptSvcWatcher = new System.Windows.Forms.Timer(); this.tmrZeptSvcWatcher.Interval = 2000; this.tmrZeptSvcWatcher.Tick += new System.EventHandler(this.tmrZeptSvcWatcher_Tick); this.tmrZeptSvcWatcher.Enabled = true; #endif }
/// <summary>Updates Task tray Icon.</summary> private void UpdateTaskTrayIcon() { int act_state = ClientServiceAgent.ACT_STATE_UNKNOWN; int icon_state = ClientServiceAgent.ICON_STATE_UNKNOWN; if (!ClientServiceAgent.GetCurrentState(ref act_state, ref icon_state)) { return; } Zeptair.Lib.Common.ConfParam zeptConf = ZeptConf(false); if (act_state != ClientServiceAgent.ACT_STATE_AUTH_FAILED) { _dispAuthFailed = false; } switch (act_state) { case ClientServiceAgent.ACT_STATE_FOR_AUTH: this.UpdateZeptMenus(true, zeptConf); break; case ClientServiceAgent.ACT_STATE_ON: this.UpdateZeptMenus(true, zeptConf); break; case ClientServiceAgent.ACT_STATE_OFF: this.UpdateZeptMenus(false, zeptConf); break; case ClientServiceAgent.ACT_STATE_AUTH_FAILED: this.UpdateZeptMenus(false, zeptConf); if (!_dispAuthFailed) { _dispAuthFailed = true; System.Windows.Forms.MessageBox.Show( Properties.Resources.ERR_ON_START_AUTH_FAILED, TaskMain.APP_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error ); } break; default: break; } _notifyIcon.Icon = Properties.Resources.AppIcon; switch (icon_state) { case ClientServiceAgent.ICON_STATE_DISABLED: _notifyIcon.Icon = Properties.Resources.AppIcon; break; case ClientServiceAgent.ICON_STATE_ACTIVATED: _notifyIcon.Icon = Properties.Resources.activated; break; case ClientServiceAgent.ICON_STATE_STANDBY: _notifyIcon.Icon = Properties.Resources.standby; break; case ClientServiceAgent.ICON_STATE_UNDEFINED1: _notifyIcon.Icon = Properties.Resources.undefined; break; case ClientServiceAgent.ICON_STATE_UNDEFINED2: _notifyIcon.Icon = Properties.Resources.undefined; break; case ClientServiceAgent.ICON_STATE_UNAVAILABLE: _notifyIcon.Icon = Properties.Resources.unavailable; break; case ClientServiceAgent.ICON_STATE_UNKNOWN: break; case ClientServiceAgent.ICON_STATE_RETRY1: break; case ClientServiceAgent.ICON_STATE_RETRY2: break; default: break; } }