2006-01-19 00:34:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
2006-02-01 18:48:29 +01:00
|
|
|
* Copyright (C) 2005-2006 Novell, Inc. All Rights Reserved.
|
2006-01-19 00:34:21 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2006-01-31 23:01:47 +01:00
|
|
|
* Library Lesser General Public License for more details.
|
2006-01-19 00:34:21 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-01-31 23:01:47 +01:00
|
|
|
* License along with this library; if not, Novell, Inc.
|
2006-01-19 00:34:21 +01:00
|
|
|
*
|
|
|
|
* To contact Novell about this file by physical or electronic mail,
|
|
|
|
* you may find current contact information at www.novell.com.
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
2006-03-07 14:54:44 +01:00
|
|
|
using System;
|
2005-10-12 17:27:21 +02:00
|
|
|
using Gtk;
|
2006-03-07 14:54:44 +01:00
|
|
|
using Glade;
|
|
|
|
|
2005-10-12 17:27:21 +02:00
|
|
|
using Novell.CASA;
|
|
|
|
using Novell.CASA.MiCasa.Common;
|
2006-03-07 14:54:44 +01:00
|
|
|
using Novell.CASA.MiCasa.Communication;
|
|
|
|
|
|
|
|
#if W32
|
|
|
|
using Microsoft.Win32;
|
|
|
|
#endif
|
|
|
|
namespace Novell.CASA.GUI
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Summary description for CommonGUI.
|
|
|
|
/// </summary>
|
|
|
|
public class CommonGUI
|
|
|
|
{
|
2005-10-12 17:27:21 +02:00
|
|
|
|
|
|
|
[Glade.Widget]
|
|
|
|
Gtk.Label label86,
|
|
|
|
label88;
|
|
|
|
|
|
|
|
[Glade.Widget]
|
2006-03-07 14:54:44 +01:00
|
|
|
Gtk.Entry entryMasterPassword3,
|
2005-10-12 17:27:21 +02:00
|
|
|
entryMasterPassword4;
|
|
|
|
|
|
|
|
[Glade.Widget]
|
2006-03-07 14:54:44 +01:00
|
|
|
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
|
2005-10-12 17:27:21 +02:00
|
|
|
/// </summary>
|
|
|
|
public void HandleUnlock(CasaMain managerInstance, CasaTray trayInstance)
|
|
|
|
{
|
|
|
|
|
|
|
|
mCasaInstance = managerInstance;
|
|
|
|
mTrayInstance = trayInstance;
|
|
|
|
|
|
|
|
|
|
|
|
//Logger.DbgLog("GUI:CasaMain.Login() - IsMasterPasswordSet returned false");
|
|
|
|
#if W32
|
2006-02-01 17:50:36 +01:00
|
|
|
Glade.XML gxmlTemp = new Glade.XML ("../images/casa.glade", "dialogLogin", null);
|
2005-10-12 17:27:21 +02:00
|
|
|
#endif
|
|
|
|
#if LINUX
|
2006-03-07 14:54:44 +01:00
|
|
|
Glade.XML gxmlTemp = new Glade.XML (Common.GladeFile, "dialogLogin", null);
|
2005-10-12 17:27:21 +02:00
|
|
|
#endif
|
2006-03-07 14:54:44 +01:00
|
|
|
|
2005-10-12 17:27:21 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2005-11-11 16:38:05 +01:00
|
|
|
public void on_helpbuttonAuthentication_clicked(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
Common.ShowHelpUrl("CASAMasterPasswordAuthentication.htm");
|
|
|
|
}
|
|
|
|
|
2005-10-13 21:56:58 +02:00
|
|
|
internal void menuDestroyMiCasa_Activated(CasaMain casaMain, CasaTray tray)
|
2005-10-12 17:27:21 +02:00
|
|
|
{
|
2005-10-13 21:56:58 +02:00
|
|
|
mCasaInstance = casaMain;
|
|
|
|
mTrayInstance = tray;
|
|
|
|
|
2005-10-12 17:27:21 +02:00
|
|
|
// 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;
|
2005-10-13 21:56:58 +02:00
|
|
|
md.SetIconFromFile(Common.CASAICONS);
|
2005-10-12 17:27:21 +02:00
|
|
|
md.Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 21:56:58 +02:00
|
|
|
private void md_Response(object o, ResponseArgs args)
|
2005-10-12 17:27:21 +02:00
|
|
|
{
|
|
|
|
if (args.ResponseId.Equals(Gtk.ResponseType.Ok))
|
|
|
|
{
|
2005-10-13 21:56:58 +02:00
|
|
|
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_REMOVE_ALL_SECRETS);
|
|
|
|
if (mCasaInstance != null)
|
|
|
|
mCasaInstance.objMiCasa.AggregateStore();
|
2005-10-12 17:27:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2005-10-13 21:56:58 +02:00
|
|
|
MessageDialog md=new MessageDialog(
|
|
|
|
mainWindow,Gtk.DialogFlags.Modal,
|
2005-10-12 17:27:21 +02:00
|
|
|
Gtk.MessageType.Warning,
|
|
|
|
Gtk.ButtonsType.Ok,
|
|
|
|
"Master Password entered is incorrect");
|
|
|
|
|
|
|
|
md.Response +=new ResponseHandler(md_Response2);
|
|
|
|
md.SetPosition(Gtk.WindowPosition.CenterOnParent);
|
2005-10-13 21:56:58 +02:00
|
|
|
md.Modal = true;
|
|
|
|
md.SetIconFromFile(Common.CASAICONS);
|
2005-10-12 17:27:21 +02:00
|
|
|
md.Show();
|
|
|
|
}
|
|
|
|
}
|
2005-10-13 21:56:58 +02:00
|
|
|
|
2005-10-12 17:27:21 +02:00
|
|
|
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);
|
2006-03-07 14:54:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if W32
|
|
|
|
internal static string ReadRegKey(RegistryKey rk, string sSubKey, string KeyName)
|
|
|
|
{
|
|
|
|
// Opening the registry key
|
|
|
|
// RegistryKey rk = Registry.Users;
|
|
|
|
// Open a subKey as read-only
|
|
|
|
RegistryKey sk1 = rk.OpenSubKey(sSubKey);
|
|
|
|
// If the RegistrySubKey doesn't exist -> (null)
|
|
|
|
if ( sk1 == null )
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// If the RegistryKey exists I get its value
|
|
|
|
// or null is returned.
|
|
|
|
return (string)sk1.GetValue(KeyName.ToUpper());
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
//ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static void WriteRegKey(RegistryKey rk, string sSubKey, string KeyName, string sKeyValue)
|
|
|
|
{
|
|
|
|
RegistryKey sk1 = rk.OpenSubKey(sSubKey, true);
|
|
|
|
// If the RegistrySubKey doesn't exist -> (null)
|
|
|
|
if ( sk1 == null )
|
|
|
|
{
|
|
|
|
//return null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// If the RegistryKey exists I get its value
|
|
|
|
// or null is returned.
|
|
|
|
sk1.SetValue(KeyName, sKeyValue);
|
|
|
|
sk1.Close();
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
sk1.Close();
|
|
|
|
//ShowErrorMessage(e, "Reading registry " + KeyName.ToUpper());
|
2006-03-08 06:07:52 +01:00
|
|
|
//Console.Write(e.ToString());
|
2006-03-30 17:42:33 +02:00
|
|
|
Logger.DbgLog("GUI:CommonGUI.WriteRegKey EXCEPTION: \n" + e.ToString());
|
2006-03-07 14:54:44 +01:00
|
|
|
//return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|