Merge CASAManager and CASATray code
This commit is contained in:
parent
8b3efa584c
commit
386865fbed
@ -28,7 +28,7 @@
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE"
|
||||
DefineConstants = "W32"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
@ -48,7 +48,7 @@
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE"
|
||||
DefineConstants = "W32"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
@ -99,47 +99,45 @@
|
||||
Project = "{E21DD887-22F4-4935-9851-409715F663B0}"
|
||||
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
|
||||
/>
|
||||
<Reference
|
||||
Name = "pango-sharp"
|
||||
AssemblyName = "pango-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\pango-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "rsvg-sharp"
|
||||
AssemblyName = "rsvg-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\rsvg-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
/>
|
||||
<Reference
|
||||
Name = "atk-sharp"
|
||||
AssemblyName = "atk-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\atk-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
HintPath = "..\extern\w32\gtk-sharp-2.0\atk-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "gdk-sharp"
|
||||
AssemblyName = "gdk-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\gdk-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
HintPath = "..\extern\w32\gtk-sharp-2.0\gdk-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "glade-sharp"
|
||||
AssemblyName = "glade-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\glade-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
HintPath = "..\extern\w32\gtk-sharp-2.0\glade-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "glib-sharp"
|
||||
AssemblyName = "glib-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\glib-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
HintPath = "..\extern\w32\gtk-sharp-2.0\glib-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "gtk-sharp"
|
||||
AssemblyName = "gtk-sharp"
|
||||
HintPath = "C:\GTK\2.6\lib\gtk-sharp-2.0\gtk-sharp.dll"
|
||||
AssemblyFolderKey = "hklm\gtk-sharp"
|
||||
HintPath = "..\extern\w32\gtk-sharp-2.0\gtk-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "pango-sharp"
|
||||
AssemblyName = "pango-sharp"
|
||||
HintPath = "..\extern\w32\gtk-sharp-2.0\pango-sharp.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Windows.Forms"
|
||||
AssemblyName = "System.Windows.Forms"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Drawing"
|
||||
AssemblyName = "System.Drawing"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
@ -150,11 +148,21 @@
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "CasaTray.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Common.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "CommonGUI.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "Firefox.cs"
|
||||
SubType = "Code"
|
||||
@ -200,6 +208,23 @@
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "TrayLib.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\CASA_16.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\CASA_32.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\CASA_48.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\casa-1.5.glade"
|
||||
BuildAction = "None"
|
||||
@ -233,11 +258,15 @@
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\novell-logo.png"
|
||||
RelPath = "images\notify1.ico"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\Readme.txt"
|
||||
RelPath = "images\notifyLocked.ico"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
<File
|
||||
RelPath = "images\novell-logo.png"
|
||||
BuildAction = "Content"
|
||||
/>
|
||||
</Include>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP LastOpenVersion = "7.10.3077" >
|
||||
<Build>
|
||||
<Settings ReferencePath = "" >
|
||||
<Settings ReferencePath = "D:\casa\extern\w32\gtk-sharp-2.0\" >
|
||||
<Config
|
||||
Name = "Debug"
|
||||
EnableASPDebugging = "false"
|
||||
@ -11,7 +11,7 @@
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartArguments = "tray"
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
|
@ -21,9 +21,7 @@ using Novell.CASA.MiCasa.Communication;
|
||||
|
||||
|
||||
public class CasaMain
|
||||
{
|
||||
|
||||
|
||||
{
|
||||
public MiCasa objMiCasa = null;
|
||||
public Firefox objFirefox = null;
|
||||
public Mozilla objMozilla = null;
|
||||
@ -90,6 +88,8 @@ public class CasaMain
|
||||
#endregion
|
||||
|
||||
|
||||
public static CasaTray mCasaTray = null;
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// MAIN
|
||||
@ -105,8 +105,13 @@ public class CasaMain
|
||||
Common.ReadPlatform();
|
||||
|
||||
Application.Init();
|
||||
|
||||
new CasaMain(args);
|
||||
|
||||
if (Common.IsTrayAvailable() && Common.IsArgSet(args, Common.ARG_SHOW_TRAY_ICON))
|
||||
{
|
||||
mCasaTray = new CasaTray();
|
||||
}
|
||||
else
|
||||
new CasaMain(args);
|
||||
|
||||
Application.Run();
|
||||
|
||||
@ -209,6 +214,12 @@ public class CasaMain
|
||||
(notebookStores.GetNthPage(Common.STORE_GNOMEKEYRING)).Visible = Common.IS_GNOMEKEYRING;
|
||||
|
||||
notebookStores.CurrentPage = Common.STORE_MICASA;
|
||||
|
||||
if (MiCASAStore.IsLocked())
|
||||
LockGUI();
|
||||
else
|
||||
UnlockGUI();
|
||||
|
||||
windowMain.Show();
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.InitializeGUI() - END");
|
||||
@ -325,13 +336,13 @@ public class CasaMain
|
||||
{
|
||||
dialogLoginReprompt.Destroy();
|
||||
dialogLogin.Destroy();
|
||||
Application.Quit();
|
||||
HandleQuit();
|
||||
}
|
||||
|
||||
public void closebuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
dialogLogin.Destroy();
|
||||
Application.Quit();
|
||||
HandleQuit();
|
||||
}
|
||||
|
||||
|
||||
@ -339,7 +350,7 @@ public class CasaMain
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.OnDialogLoginDeleted() - BEGIN");
|
||||
|
||||
Gtk.Application.Quit();
|
||||
HandleQuit();
|
||||
args.RetVal = true;
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.OnDialogLoginDeleted() - END");
|
||||
@ -457,14 +468,7 @@ public class CasaMain
|
||||
}
|
||||
else
|
||||
{
|
||||
mmiLockSecrets.Sensitive = true;
|
||||
mmiUnlockSecrets.Sensitive = false;
|
||||
mmiDestroySecrets.Sensitive = true;
|
||||
notebookStores.Sensitive = true;
|
||||
mmiRefresh.Sensitive = true;
|
||||
mmiDebug.Sensitive = true;
|
||||
mmiOptions.Sensitive = true;
|
||||
mmiEdit.Sensitive = true;
|
||||
UnlockGUI();
|
||||
}
|
||||
|
||||
|
||||
@ -626,8 +630,7 @@ public class CasaMain
|
||||
Logger.DbgLog("GUI:CasaMain.QuitApplication() - BEGIN");
|
||||
|
||||
windowMain.Destroy();
|
||||
|
||||
Gtk.Application.Quit();
|
||||
HandleQuit();
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.QuitApplication() - END");
|
||||
}
|
||||
@ -699,16 +702,39 @@ public class CasaMain
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.NewKeyValue() - END");
|
||||
}
|
||||
|
||||
|
||||
|
||||
///#######################################################################
|
||||
/// UI handling
|
||||
|
||||
public void OnLockMiCASASecrets(object sender, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.NewKeyValue() - START");
|
||||
Logger.DbgLog("GUI:CasaMain.OnLockMiCASASecrets() - START");
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_LOCK_STORE);
|
||||
LockGUI();
|
||||
Logger.DbgLog("GUI:CasaMain.NewKeyValue() - END");
|
||||
if (mCasaTray != null)
|
||||
mCasaTray.UpdateTrayIcon(true);
|
||||
Logger.DbgLog("GUI:CasaMain.OnLockMiCASASecrets() - END");
|
||||
}
|
||||
|
||||
private void LockGUI()
|
||||
public void OnUnLockMiCASASecrets(object sender, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.OnUnLockMiCASASecrets() - START");
|
||||
CommonGUI cg = new CommonGUI();
|
||||
cg.HandleUnlock(this, mCasaTray);
|
||||
Logger.DbgLog("GUI:CasaMain.OnUnLockMiCASASecrets() - END");
|
||||
}
|
||||
|
||||
public void OnDestroyMiCASASecrets(object sender, EventArgs args)
|
||||
{
|
||||
Logger.DbgLog("GUI:CasaMain.OnDestroyMiCASASecrets() - START");
|
||||
CommonGUI.menuDestroyMiCasa_Activated(sender, args);
|
||||
Logger.DbgLog("GUI:CasaMain.OnDestroyMiCASASecrets() - END");
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal void LockGUI()
|
||||
{
|
||||
mmiLockSecrets.Sensitive = false;
|
||||
mmiUnlockSecrets.Sensitive = true;
|
||||
@ -720,6 +746,18 @@ public class CasaMain
|
||||
mmiOptions.Sensitive = false;
|
||||
mmiEdit.Sensitive = false;
|
||||
}
|
||||
|
||||
internal void UnlockGUI()
|
||||
{
|
||||
mmiLockSecrets.Sensitive = true;
|
||||
mmiUnlockSecrets.Sensitive = false;
|
||||
mmiDestroySecrets.Sensitive = true;
|
||||
notebookStores.Sensitive = true;
|
||||
mmiRefresh.Sensitive = true;
|
||||
mmiDebug.Sensitive = true;
|
||||
mmiOptions.Sensitive = true;
|
||||
mmiEdit.Sensitive = true;
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
@ -1035,13 +1073,15 @@ public class CasaMain
|
||||
public void on_dialogSingleInstance_delete_event(object obj, DeleteEventArgs args)
|
||||
{
|
||||
dialogSingleInstance.Destroy();
|
||||
Application.Quit();
|
||||
HandleQuit();
|
||||
//Application.Quit();
|
||||
}
|
||||
|
||||
public void on_buttonSIClose_clicked(object obj, EventArgs args)
|
||||
{
|
||||
dialogSingleInstance.Destroy();
|
||||
Application.Quit();
|
||||
HandleQuit();
|
||||
//Application.Quit();
|
||||
}
|
||||
|
||||
///#######################################################################
|
||||
@ -1055,12 +1095,31 @@ public class CasaMain
|
||||
Logger.DbgLog("GUI:CasaMain.OnWindowMainDeleted() - BEGIN");
|
||||
|
||||
windowMain.Destroy();
|
||||
Gtk.Application.Quit ();
|
||||
HandleQuit();
|
||||
//Gtk.Application.Quit ();
|
||||
args.RetVal = true;
|
||||
|
||||
Logger.DbgLog("GUI:CasaMain.OnWindowMainDeleted() - END");
|
||||
}
|
||||
|
||||
private void HandleQuit()
|
||||
{
|
||||
if (mCasaTray != null)
|
||||
{
|
||||
mCasaTray.CasaManagerQuit();
|
||||
return;
|
||||
}
|
||||
else
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
///#######################################################################
|
||||
/// WINDOW MAIN FOCUS
|
||||
///
|
||||
internal void Focus()
|
||||
{
|
||||
windowMain.Present();
|
||||
}
|
||||
}
|
||||
}
|
||||
///###########################################################################
|
||||
|
268
c_gui/CasaTray.cs
Normal file
268
c_gui/CasaTray.cs
Normal file
@ -0,0 +1,268 @@
|
||||
|
||||
using Gtk;
|
||||
using Glade;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
using Novell.CASA;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
public class CasaTray
|
||||
{
|
||||
|
||||
|
||||
#if W32
|
||||
private static System.Windows.Forms.NotifyIcon notifyIcon;
|
||||
public static System.Drawing.Icon m_iconNormal;
|
||||
public static System.Drawing.Icon m_iconLocked;
|
||||
#endif
|
||||
|
||||
private static CasaMain mCasaMain = null;
|
||||
|
||||
public CasaTray()
|
||||
{
|
||||
|
||||
#if W32
|
||||
Stream s = null;
|
||||
notifyIcon = new System.Windows.Forms.NotifyIcon();
|
||||
try
|
||||
{
|
||||
s = File.OpenRead("../images/notify1.ico");
|
||||
m_iconNormal = new System.Drawing.Icon(s);
|
||||
notifyIcon.Icon = m_iconNormal;
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
//MessageBox.Show("File 'notify.ico' cannot be found", "Error");
|
||||
Console.WriteLine(e.ToString());
|
||||
Console.WriteLine("File 'notify.ico' cannot be found");
|
||||
return;
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
if (s != null)
|
||||
{
|
||||
s.Close();
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
s = File.OpenRead("../images/notifyLocked.ico");
|
||||
m_iconLocked = new System.Drawing.Icon(s);
|
||||
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("File 'notifyLocked.ico' cannot be found");
|
||||
return;
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
if (s != null)
|
||||
{
|
||||
s.Close();
|
||||
}
|
||||
}
|
||||
//notifyIcon.Click +=new EventHandler(notifyIcon_Click);
|
||||
notifyIcon.DoubleClick +=new EventHandler(notifyIcon_DoubleClick);
|
||||
notifyIcon.MouseUp +=new System.Windows.Forms.MouseEventHandler(notifyIcon_MouseUp);
|
||||
notifyIcon.Text = "CASA Manager";
|
||||
notifyIcon.Visible = true;
|
||||
#endif
|
||||
#if W32
|
||||
/* in order to receive signals, we need a eventbox, because Gtk.Image doesn't receive signals */
|
||||
EventBox eb = new EventBox();
|
||||
eb.Add(new Image(Stock.MissingImage, IconSize.Menu)); // using stock icon
|
||||
// hooking event
|
||||
eb.ButtonPressEvent += new ButtonPressEventHandler (this.OnImageClick);
|
||||
|
||||
|
||||
Egg.TrayIcon icon = new Egg.TrayIcon("Test");
|
||||
icon.Add(eb);
|
||||
// showing the trayicon
|
||||
icon.ShowAll();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ShowContextMenu()
|
||||
{
|
||||
Menu popupMenu = new Menu(); // creates the menu
|
||||
|
||||
MenuItem miSep = new MenuItem();
|
||||
MenuItem miSep2 = new MenuItem();
|
||||
MenuItem miSep3 = new MenuItem();
|
||||
|
||||
ImageMenuItem menuLaunchGUI = new ImageMenuItem ("Launch CASAManager");
|
||||
Image appimg = new Image(Stock.New, IconSize.Menu);
|
||||
menuLaunchGUI.Image = appimg; // sets the menu item's image
|
||||
menuLaunchGUI.Activated +=new EventHandler(menuLaunchGUI_Activated);
|
||||
popupMenu.Add(menuLaunchGUI);
|
||||
popupMenu.Add(miSep);
|
||||
|
||||
ImageMenuItem menuLockMiCasa = new ImageMenuItem ("Lock Secrets");
|
||||
|
||||
//appimg = new Image(Stock.Close, IconSize.Menu);
|
||||
appimg = new Image("gtk-dialog-authentication", IconSize.Menu);
|
||||
menuLockMiCasa.Image = appimg; // sets the menu item's image
|
||||
menuLockMiCasa.Activated +=new EventHandler(menuLockMiCasa_Activated);
|
||||
|
||||
ImageMenuItem menuUnLockMiCasa = new ImageMenuItem ("Unlock Secrets...");
|
||||
appimg = new Image(Stock.Open, IconSize.Menu);
|
||||
menuUnLockMiCasa.Image = appimg; // sets the menu item's image
|
||||
menuUnLockMiCasa.Activated +=new EventHandler(menuLockMiCasa_Activated);
|
||||
|
||||
if (MiCASAStore.IsLocked())
|
||||
{
|
||||
menuLockMiCasa.Sensitive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
menuUnLockMiCasa.Sensitive = false;
|
||||
}
|
||||
|
||||
popupMenu.Add(menuLockMiCasa);
|
||||
popupMenu.Add(menuUnLockMiCasa);
|
||||
|
||||
popupMenu.Add(miSep2);
|
||||
|
||||
ImageMenuItem menuDestroyMiCasa = new ImageMenuItem ("Destroy Secrets");
|
||||
appimg = new Image(Stock.Delete, IconSize.Menu);
|
||||
menuDestroyMiCasa.Image = appimg; // sets the menu item's image
|
||||
menuDestroyMiCasa.Activated +=new EventHandler(menuDestroyMiCasa_Activated);
|
||||
popupMenu.Add(menuDestroyMiCasa);
|
||||
|
||||
ImageMenuItem menuOptionsMiCasa = new ImageMenuItem ("Options ....");
|
||||
menuOptionsMiCasa.Sensitive = false;
|
||||
popupMenu.Add(menuOptionsMiCasa);
|
||||
|
||||
popupMenu.Add(miSep3);
|
||||
|
||||
// creates a menu item with no image as default
|
||||
ImageMenuItem menuPopup1 = new ImageMenuItem ("Exit");
|
||||
appimg = new Image(Stock.Quit, IconSize.Menu);
|
||||
menuPopup1.Image = appimg; // sets the menu item's image
|
||||
popupMenu.Add(menuPopup1); // adds the menu item to the menu
|
||||
|
||||
// hooks a event when the user clicks the icon
|
||||
menuPopup1.Activated += new EventHandler(this.OnPopupClick);
|
||||
popupMenu.ShowAll(); // shows everything
|
||||
|
||||
// pops up the actual menu when the user right clicks
|
||||
//popupMenu.Popup(null, null, null, IntPtr.Zero, args.Event.Button, args.Event.Time);
|
||||
|
||||
popupMenu.Popup();
|
||||
}
|
||||
|
||||
private void OnImageClick (object o, ButtonPressEventArgs args) // handler for mouse click
|
||||
{
|
||||
if (args.Event.Button == 3) //right click
|
||||
{
|
||||
ShowContextMenu();
|
||||
}
|
||||
}
|
||||
private void OnPopupClick(object o, EventArgs args)
|
||||
{
|
||||
Application.Quit(); // quits the application when the users clicks the popup menu
|
||||
}
|
||||
#if W32
|
||||
private void notifyIcon_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
||||
ShowContextMenu();
|
||||
}
|
||||
#endif
|
||||
|
||||
public void CasaManagerQuit()
|
||||
{
|
||||
mCasaMain = null;
|
||||
}
|
||||
|
||||
private void menuLaunchGUI_Activated(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (mCasaMain == null)
|
||||
mCasaMain = new CasaMain(null);
|
||||
else
|
||||
mCasaMain.Focus();
|
||||
|
||||
/*
|
||||
// launch the GUI
|
||||
Process myProcess = new Process();
|
||||
#if W32
|
||||
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("CASAManager.exe");
|
||||
#else
|
||||
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("mono");
|
||||
myProcessStartInfo.Arguments = "/opt/novell/CASA/bin/CASAManager.exe";
|
||||
#endif
|
||||
myProcessStartInfo.UseShellExecute = false;
|
||||
myProcessStartInfo.RedirectStandardOutput = true;
|
||||
myProcess.StartInfo = myProcessStartInfo;
|
||||
myProcess.Start();
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void menuLockMiCasa_Activated(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (MiCASAStore.IsLocked())
|
||||
{
|
||||
//if( false == miCASA.IsSecretPersistent(1,"") )
|
||||
CommonGUI cg = new CommonGUI();
|
||||
cg.HandleUnlock(mCasaMain, this);
|
||||
|
||||
//UpdateTrayIcon(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_LOCK_STORE);
|
||||
if (mCasaMain != null)
|
||||
mCasaMain.LockGUI();
|
||||
UpdateTrayIcon(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public bool IsMasterPasswordSet()
|
||||
{
|
||||
string MICASA_PASSCODE_BY_MASTER_PASSWD_FILE = "/.miCASAPCByMPasswd";
|
||||
string fileName = Environment.GetEnvironmentVariable("HOME")+MICASA_PASSCODE_BY_MASTER_PASSWD_FILE;
|
||||
return (File.Exists(fileName));
|
||||
}
|
||||
*/
|
||||
|
||||
private void notifyIcon_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
menuLockMiCasa_Activated(sender, e);
|
||||
}
|
||||
|
||||
private void menuDestroyMiCasa_Activated(object sender, EventArgs e)
|
||||
{
|
||||
CommonGUI.menuDestroyMiCasa_Activated(sender, e);
|
||||
}
|
||||
|
||||
internal void UpdateTrayIcon(bool StoreIsLocked)
|
||||
{
|
||||
#if W32
|
||||
if (StoreIsLocked)
|
||||
notifyIcon.Icon = m_iconLocked;
|
||||
else
|
||||
notifyIcon.Icon = m_iconNormal;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@ -82,6 +82,10 @@ public class Common
|
||||
INDEX_NATIVEINFO_SYNCTYPE = 3,
|
||||
INDEX_NATIVEINFO_MODIFIEDTIME = 4;
|
||||
|
||||
///##############################################################
|
||||
/// ARG CONSTANTS
|
||||
public static string ARG_SHOW_TRAY_ICON = "tray";
|
||||
|
||||
///##############################################################
|
||||
/// ERROR CODES
|
||||
|
||||
@ -228,7 +232,31 @@ public class Common
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsTrayAvailable()
|
||||
{
|
||||
if (true == IS_LINUX)
|
||||
return true;
|
||||
else if (true == IS_WINDOWS)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsArgSet(string[] args, string argToCheck)
|
||||
{
|
||||
if (args != null)
|
||||
{
|
||||
for (int i=0; i<args.Length; i++)
|
||||
{
|
||||
if (argToCheck.Equals(args[i].ToLower()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
180
c_gui/CommonGUI.cs
Normal file
180
c_gui/CommonGUI.cs
Normal file
@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
using Novell.CASA;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CommonGUI.
|
||||
/// </summary>
|
||||
public class CommonGUI
|
||||
{
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Label label86,
|
||||
label88;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entryMasterPassword1,
|
||||
entryMasterPassword2,
|
||||
entryMasterPassword3,
|
||||
entryMasterPassword4;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogLogin;
|
||||
|
||||
Gtk.Window mainWindow = new Window("Test");
|
||||
|
||||
private CasaMain mCasaInstance = null;
|
||||
private CasaTray mTrayInstance = null;
|
||||
|
||||
public CommonGUI()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HandleUnlock dialog
|
||||
/// </summary>
|
||||
public void HandleUnlock(CasaMain managerInstance, CasaTray trayInstance)
|
||||
{
|
||||
|
||||
mCasaInstance = managerInstance;
|
||||
mTrayInstance = trayInstance;
|
||||
|
||||
|
||||
//Logger.DbgLog("GUI:CasaMain.Login() - IsMasterPasswordSet returned false");
|
||||
#if W32
|
||||
Glade.XML gxmlTemp = new Glade.XML ("../images/casa-1.5.glade", "dialogLogin", null);
|
||||
#endif
|
||||
#if LINUX
|
||||
Glade.XML gxmlTemp = new Glade.XML ("/opt/novell/CASA/images/casa-1.5.glade", "dialogLogin", null);
|
||||
#endif
|
||||
gxmlTemp.Autoconnect (this);
|
||||
//dialogLogin.TransientFor = windowMain;
|
||||
|
||||
label86.Text = "Enter your Master Password to unlock your secrets";
|
||||
entryMasterPassword3.Text="";
|
||||
label88.Hide();
|
||||
entryMasterPassword4.Hide();
|
||||
dialogLogin.SetPosition(Gtk.WindowPosition.Center);
|
||||
dialogLogin.Destroyed += new EventHandler(dialogLogin_Destroyed);
|
||||
dialogLogin.Show();
|
||||
}
|
||||
|
||||
internal static void menuDestroyMiCasa_Activated(object sender, EventArgs e)
|
||||
{
|
||||
// prompt user
|
||||
MessageDialog md=new MessageDialog(null,Gtk.DialogFlags.Modal,
|
||||
Gtk.MessageType.Warning,
|
||||
Gtk.ButtonsType.OkCancel,
|
||||
"This will destroy all of your miCASA secrets.\r\nAre you sure?");
|
||||
|
||||
md.SetPosition(Gtk.WindowPosition.Center);
|
||||
md.Response +=new ResponseHandler(md_Response);
|
||||
md.Modal = true;
|
||||
md.Show();
|
||||
}
|
||||
|
||||
|
||||
private static void md_Response(object o, ResponseArgs args)
|
||||
{
|
||||
if (args.ResponseId.Equals(Gtk.ResponseType.Ok))
|
||||
{
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_REMOVE_ALL_SECRETS);
|
||||
}
|
||||
|
||||
MessageDialog md = (MessageDialog)o;
|
||||
if (md != null)
|
||||
{
|
||||
md.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void md_Response2(object o, ResponseArgs args)
|
||||
{
|
||||
MessageDialog md = (MessageDialog)o;
|
||||
if (md != null)
|
||||
{
|
||||
md.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void okbuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
|
||||
{
|
||||
// unlock it
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_UNLOCK_STORE, entryMasterPassword3.Text);
|
||||
dialogLogin.Destroy();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// prompt user
|
||||
MessageDialog md=new MessageDialog(mainWindow,Gtk.DialogFlags.Modal,
|
||||
Gtk.MessageType.Warning,
|
||||
Gtk.ButtonsType.Ok,
|
||||
"Master Password entered is incorrect");
|
||||
|
||||
md.Response +=new ResponseHandler(md_Response2);
|
||||
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
|
||||
md.Modal = true;
|
||||
md.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void closebuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
|
||||
|
||||
public void OnDialogLoginDeleted(object obj, DeleteEventArgs args)
|
||||
{
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
|
||||
{
|
||||
if( true == entryMasterPassword4.Visible )
|
||||
entryMasterPassword4.HasFocus = true;
|
||||
else if( "" != entryMasterPassword3.Text )
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword4_activate(object obj, EventArgs args)
|
||||
{
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
private void dialogLogin_Destroyed(object sender, EventArgs e)
|
||||
{
|
||||
bool bStoreLocked = MiCASAStore.IsLocked();
|
||||
if (mCasaInstance != null)
|
||||
{
|
||||
if (bStoreLocked)
|
||||
mCasaInstance.LockGUI();
|
||||
else
|
||||
mCasaInstance.UnlockGUI();
|
||||
}
|
||||
|
||||
if (mTrayInstance != null)
|
||||
{
|
||||
if (bStoreLocked)
|
||||
mTrayInstance.UpdateTrayIcon(true);
|
||||
else
|
||||
mTrayInstance.UpdateTrayIcon(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
243
c_gui/TrayLib.cs
Normal file
243
c_gui/TrayLib.cs
Normal file
@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Gtk;
|
||||
using Gdk;
|
||||
|
||||
namespace Egg
|
||||
{
|
||||
public class TrayIcon : Plug
|
||||
{
|
||||
int stamp;
|
||||
Orientation orientation;
|
||||
|
||||
int selection_atom;
|
||||
int manager_atom;
|
||||
int system_tray_opcode_atom;
|
||||
int orientation_atom;
|
||||
IntPtr manager_window;
|
||||
FilterFunc filter;
|
||||
|
||||
public TrayIcon (string name)
|
||||
{
|
||||
Title = name;
|
||||
stamp = 1;
|
||||
orientation = Orientation.Horizontal;
|
||||
AddEvents ((int)EventMask.PropertyChangeMask);
|
||||
filter = new FilterFunc (ManagerFilter);
|
||||
}
|
||||
|
||||
protected override void OnRealized ()
|
||||
{
|
||||
base.OnRealized ();
|
||||
Display display = Screen.Display;
|
||||
IntPtr xdisplay = gdk_x11_display_get_xdisplay (display.Handle);
|
||||
selection_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_S" + Screen.Number.ToString (), false);
|
||||
manager_atom = XInternAtom (xdisplay, "MANAGER", false);
|
||||
system_tray_opcode_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_OPCODE", false);
|
||||
orientation_atom = XInternAtom (xdisplay, "_NET_SYSTEM_TRAY_ORIENTATION", false);
|
||||
UpdateManagerWindow ();
|
||||
//Screen.RootWindow.AddFilter (filter);
|
||||
}
|
||||
|
||||
protected override void OnUnrealized ()
|
||||
{
|
||||
if (manager_window != IntPtr.Zero)
|
||||
{
|
||||
Gdk.Window gdkwin = Gdk.Window.LookupForDisplay (Display, (uint)manager_window);
|
||||
//gdkwin.RemoveFilter (filter);
|
||||
}
|
||||
|
||||
//Screen.RootWindow.RemoveFilter (filter);
|
||||
base.OnUnrealized ();
|
||||
}
|
||||
|
||||
private void UpdateManagerWindow ()
|
||||
{
|
||||
IntPtr xdisplay = gdk_x11_display_get_xdisplay (Display.Handle);
|
||||
if (manager_window != IntPtr.Zero)
|
||||
{
|
||||
Gdk.Window gdkwin = Gdk.Window.LookupForDisplay (Display, (uint)manager_window);
|
||||
//gdkwin.RemoveFilter (filter);
|
||||
}
|
||||
|
||||
XGrabServer (xdisplay);
|
||||
|
||||
manager_window = XGetSelectionOwner (xdisplay, selection_atom);
|
||||
if (manager_window != IntPtr.Zero)
|
||||
XSelectInput (xdisplay, manager_window, EventMask.StructureNotifyMask | EventMask.PropertyChangeMask);
|
||||
XUngrabServer (xdisplay);
|
||||
XFlush (xdisplay);
|
||||
|
||||
if (manager_window != IntPtr.Zero)
|
||||
{
|
||||
Gdk.Window gdkwin = Gdk.Window.LookupForDisplay (Display, (uint)manager_window);
|
||||
//gdkwin.AddFilter (filter);
|
||||
SendDockRequest ();
|
||||
GetOrientationProperty ();
|
||||
}
|
||||
}
|
||||
|
||||
private void SendDockRequest ()
|
||||
{
|
||||
SendManagerMessage (SystemTrayMessage.RequestDock, manager_window, Id, 0, 0);
|
||||
}
|
||||
|
||||
private void SendManagerMessage (SystemTrayMessage message, IntPtr window, uint data1, uint data2, uint data3)
|
||||
{
|
||||
XClientMessageEvent ev = new XClientMessageEvent ();
|
||||
IntPtr display;
|
||||
|
||||
ev.type = XEventName.ClientMessage;
|
||||
ev.window = window;
|
||||
ev.message_type = (IntPtr)system_tray_opcode_atom;
|
||||
ev.format = 32;
|
||||
ev.ptr1 = gdk_x11_get_server_time (GdkWindow.Handle);
|
||||
ev.ptr2 = (IntPtr)message;
|
||||
ev.ptr3 = (IntPtr)data1;
|
||||
ev.ptr4 = (IntPtr)data2;
|
||||
ev.ptr5 = (IntPtr)data3;
|
||||
|
||||
display = gdk_x11_display_get_xdisplay (Display.Handle);
|
||||
gdk_error_trap_push ();
|
||||
XSendEvent (display, manager_window, false, EventMask.NoEventMask, ref ev);
|
||||
gdk_error_trap_pop ();
|
||||
}
|
||||
|
||||
private FilterReturn ManagerFilter (IntPtr xevent, Event evnt)
|
||||
{
|
||||
//TODO: Implement;
|
||||
return FilterReturn.Continue;
|
||||
}
|
||||
|
||||
private void GetOrientationProperty ()
|
||||
{
|
||||
//TODO: Implement;
|
||||
}
|
||||
|
||||
[DllImport ("gdk-x11-2.0")]
|
||||
static extern IntPtr gdk_x11_display_get_xdisplay (IntPtr display);
|
||||
[DllImport ("gdk-x11-2.0")]
|
||||
static extern IntPtr gdk_x11_get_server_time (IntPtr window);
|
||||
[DllImport ("gdk-x11-2.0")]
|
||||
static extern void gdk_error_trap_push ();
|
||||
[DllImport ("gdk-x11-2.0")]
|
||||
static extern void gdk_error_trap_pop ();
|
||||
|
||||
[DllImport ("libX11", EntryPoint="XInternAtom")]
|
||||
extern static int XInternAtom(IntPtr display, string atom_name, bool only_if_exists);
|
||||
[DllImport ("libX11")]
|
||||
extern static void XGrabServer (IntPtr display);
|
||||
[DllImport ("libX11")]
|
||||
extern static void XUngrabServer (IntPtr display);
|
||||
[DllImport ("libX11")]
|
||||
extern static int XFlush (IntPtr display);
|
||||
[DllImport ("libX11")]
|
||||
extern static IntPtr XGetSelectionOwner (IntPtr display, int atom);
|
||||
[DllImport ("libX11")]
|
||||
extern static IntPtr XSelectInput (IntPtr window, IntPtr display, EventMask mask);
|
||||
[DllImport ("libX11", EntryPoint="XSendEvent")]
|
||||
extern static int XSendEvent(IntPtr display, IntPtr window, bool propagate, EventMask event_mask, ref XClientMessageEvent send_event);
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum EventMask
|
||||
{
|
||||
NoEventMask = 0,
|
||||
KeyPressMask = 1<<0,
|
||||
KeyReleaseMask = 1<<1,
|
||||
ButtonPressMask = 1<<2,
|
||||
ButtonReleaseMask = 1<<3,
|
||||
EnterWindowMask = 1<<4,
|
||||
LeaveWindowMask = 1<<5,
|
||||
PointerMotionMask = 1<<6,
|
||||
PointerMotionHintMask = 1<<7,
|
||||
Button1MotionMask = 1<<8,
|
||||
Button2MotionMask = 1<<9,
|
||||
Button3MotionMask = 1<<10,
|
||||
Button4MotionMask = 1<<11,
|
||||
Button5MotionMask = 1<<12,
|
||||
ButtonMotionMask = 1<<13,
|
||||
KeymapStateMask = 1<<14,
|
||||
ExposureMask = 1<<15,
|
||||
VisibilityChangeMask = 1<<16,
|
||||
StructureNotifyMask = 1<<17,
|
||||
ResizeRedirectMask = 1<<18,
|
||||
SubstructureNotifyMask = 1<<19,
|
||||
SubstructureRedirectMask= 1<<20,
|
||||
FocusChangeMask = 1<<21,
|
||||
PropertyChangeMask = 1<<22,
|
||||
ColormapChangeMask = 1<<23,
|
||||
OwnerGrabButtonMask = 1<<24
|
||||
}
|
||||
|
||||
internal enum SystemTrayMessage
|
||||
{
|
||||
RequestDock,
|
||||
BeginMessage,
|
||||
CancelMessage
|
||||
}
|
||||
|
||||
internal enum SystemTrayOrientation
|
||||
{
|
||||
Horz,
|
||||
Vert
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct XClientMessageEvent
|
||||
{
|
||||
internal XEventName type;
|
||||
internal IntPtr serial;
|
||||
internal bool send_event;
|
||||
internal IntPtr display;
|
||||
internal IntPtr window;
|
||||
internal IntPtr message_type;
|
||||
internal int format;
|
||||
internal IntPtr ptr1;
|
||||
internal IntPtr ptr2;
|
||||
internal IntPtr ptr3;
|
||||
internal IntPtr ptr4;
|
||||
internal IntPtr ptr5;
|
||||
}
|
||||
|
||||
internal enum XEventName
|
||||
{
|
||||
KeyPress = 2,
|
||||
KeyRelease = 3,
|
||||
ButtonPress = 4,
|
||||
ButtonRelease = 5,
|
||||
MotionNotify = 6,
|
||||
EnterNotify = 7,
|
||||
LeaveNotify = 8,
|
||||
FocusIn = 9,
|
||||
FocusOut = 10,
|
||||
KeymapNotify = 11,
|
||||
Expose = 12,
|
||||
GraphicsExpose = 13,
|
||||
NoExpose = 14,
|
||||
VisibilityNotify = 15,
|
||||
CreateNotify = 16,
|
||||
DestroyNotify = 17,
|
||||
UnmapNotify = 18,
|
||||
MapNotify = 19,
|
||||
MapRequest = 20,
|
||||
ReparentNotify = 21,
|
||||
ConfigureNotify = 22,
|
||||
ConfigureRequest = 23,
|
||||
GravityNotify = 24,
|
||||
ResizeRequest = 25,
|
||||
CirculateNotify = 26,
|
||||
CirculateRequest = 27,
|
||||
PropertyNotify = 28,
|
||||
SelectionClear = 29,
|
||||
SelectionRequest = 30,
|
||||
SelectionNotify = 31,
|
||||
ColormapNotify = 32,
|
||||
ClientMessage = 33,
|
||||
MappingNotify = 34,
|
||||
TimerNotify = 100,
|
||||
|
||||
LASTEvent
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
BIN
c_gui/images/notify1.ico
Normal file
BIN
c_gui/images/notify1.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
c_gui/images/notifyLocked.ico
Normal file
BIN
c_gui/images/notifyLocked.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -1,5 +1,7 @@
|
||||
OBJS=\
|
||||
CasaMain \
|
||||
CasaTray \
|
||||
TrayLib \
|
||||
Firefox \
|
||||
GnomeKeyring \
|
||||
KdeWallet \
|
||||
@ -9,4 +11,5 @@ OBJS=\
|
||||
Store \
|
||||
StoreDataInterface \
|
||||
StorePolicyInterface \
|
||||
CommonGUI \
|
||||
Common
|
||||
|
@ -1,5 +1,7 @@
|
||||
SRC=\
|
||||
CasaMain.cs \
|
||||
CasaTray.cs \
|
||||
TrayLib.cs \
|
||||
Firefox.cs \
|
||||
GnomeKeyring.cs \
|
||||
KdeWallet.cs \
|
||||
@ -9,5 +11,6 @@ SRC=\
|
||||
Store.cs \
|
||||
StoreDataInterface.cs \
|
||||
StorePolicyInterface.cs \
|
||||
CommonGUI.cs \
|
||||
Common.cs
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user