2006-01-19 00:34:21 +01:00
|
|
|
/***********************************************************************
|
|
|
|
*
|
2006-01-31 23:01:47 +01:00
|
|
|
* Copyright (C) 2005-2006 Novell, Inc. 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.
|
|
|
|
*
|
|
|
|
***********************************************************************/
|
|
|
|
|
2005-10-12 17:27:21 +02:00
|
|
|
using System;
|
|
|
|
using Gtk;
|
|
|
|
using Glade;
|
|
|
|
|
|
|
|
using Novell.CASA;
|
|
|
|
using Novell.CASA.MiCasa.Common;
|
|
|
|
using Novell.CASA.MiCasa.Communication;
|
|
|
|
|
2005-10-13 21:56:58 +02:00
|
|
|
#if W32
|
|
|
|
using Microsoft.Win32;
|
|
|
|
#endif
|
2005-10-12 17:27:21 +02:00
|
|
|
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
|
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-02-01 17:50:36 +01:00
|
|
|
Glade.XML gxmlTemp = new Glade.XML ("/opt/novell/CASA/images/casa.glade", "dialogLogin", null);
|
2005-10-12 17:27:21 +02:00
|
|
|
#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();
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2005-10-13 21:56:58 +02:00
|
|
|
#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());
|
|
|
|
Console.Write(e.ToString());
|
|
|
|
//return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2005-10-12 17:27:21 +02:00
|
|
|
}
|
|
|
|
}
|