Find and Replace feature added. Resolve conflicts on Import added.
This commit is contained in:
@@ -178,6 +178,7 @@
|
||||
<Compile Include="FileChooser.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FindAndReplace.cs" />
|
||||
<Compile Include="Firefox.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -2247,7 +2247,15 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
PersistentPolicyDialog ppd = new PersistentPolicyDialog();
|
||||
ppd.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public void on_mmiFindAndReplace_activate(object obj, EventArgs args)
|
||||
{
|
||||
objMiCasa.FindAndReplaceValues();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ********************************************************************
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
*
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
@@ -151,8 +153,12 @@ namespace Novell.CASA.GUI
|
||||
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
|
||||
{
|
||||
// unlock it
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_UNLOCK_STORE, entryMasterPassword3.Text);
|
||||
dialogLogin.Destroy();
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_UNLOCK_STORE, entryMasterPassword3.Text);
|
||||
m_bPasswordVerified = true;
|
||||
dialogLogin.Destroy();
|
||||
|
||||
//signal now
|
||||
m_bIsVerifing = false;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -214,7 +220,9 @@ namespace Novell.CASA.GUI
|
||||
mTrayInstance.UpdateTrayIcon(true);
|
||||
else
|
||||
mTrayInstance.UpdateTrayIcon(false);
|
||||
}
|
||||
}
|
||||
|
||||
m_bIsVerifing = false;
|
||||
}
|
||||
|
||||
// remember MP until functions
|
||||
@@ -282,7 +290,12 @@ namespace Novell.CASA.GUI
|
||||
/// <summary>
|
||||
/// VerifyMasterPasswordWithUser dialog
|
||||
/// </summary>
|
||||
public void VerifyMasterPasswordWithUser()
|
||||
///
|
||||
|
||||
private bool m_bPasswordVerified = false;
|
||||
private bool m_bIsVerifing = true;
|
||||
|
||||
public bool VerifyMasterPasswordWithUser()
|
||||
{
|
||||
|
||||
//Logger.DbgLog("GUI:CasaMain.Login() - IsMasterPasswordSet returned false");
|
||||
@@ -303,7 +316,16 @@ namespace Novell.CASA.GUI
|
||||
//dialogLogin.SetPosition(Gtk.WindowPosition.Center);
|
||||
dialogLogin.Destroyed += new EventHandler(dialogLogin_Destroyed);
|
||||
dialogLogin.Modal = true;
|
||||
dialogLogin.Show();
|
||||
dialogLogin.Show();
|
||||
|
||||
while (m_bIsVerifing)
|
||||
{
|
||||
// Flush pending events to keep the GUI reponsive
|
||||
while (Gtk.Application.EventsPending())
|
||||
Gtk.Application.RunIteration();
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
return m_bPasswordVerified;
|
||||
}
|
||||
|
||||
public static void DisplayMessage(Gtk.MessageType messageType, String sMessage)
|
||||
|
||||
@@ -26,9 +26,7 @@ namespace Novell.CASA.GUI
|
||||
private int m_iAction = 1;
|
||||
public const int ACTION_OPEN = 1;
|
||||
public const int ACTION_SAVE = 2;
|
||||
public const int ACTION_CHOOSE_DIR = 3;
|
||||
|
||||
Thread tChooserThread = null;
|
||||
public const int ACTION_CHOOSE_DIR = 3;
|
||||
|
||||
|
||||
#region Glade Widgets
|
||||
|
||||
397
CASA/gui/FindAndReplace.cs
Normal file
397
CASA/gui/FindAndReplace.cs
Normal file
@@ -0,0 +1,397 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Gtk;
|
||||
using Glade;
|
||||
|
||||
namespace Novell.CASA.GUI
|
||||
{
|
||||
class FindAndReplace
|
||||
{
|
||||
#region Glade Widgets
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView tvResults;
|
||||
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogFindAndReplace,
|
||||
dialogLogin;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button bttnFind,
|
||||
bttnReplaceAll,
|
||||
bttnApply,
|
||||
bttnCancel,
|
||||
bttnRevert,
|
||||
bttnOk;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entryFind,
|
||||
entryNewValue,
|
||||
entryMasterPassword3,
|
||||
entryMasterPassword4;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.CheckButton cbShowValues;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Label label86,
|
||||
label88,
|
||||
labelRememberFor,
|
||||
labelSeconds;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.SpinButton spinbuttonRememberFor;
|
||||
|
||||
#endregion
|
||||
|
||||
private TreeModel m_tmCASA;
|
||||
private TreeStore m_tsCASA;
|
||||
private TreeStore tsResults;
|
||||
private Store m_store;
|
||||
|
||||
private int m_iRememberSeconds = 5;
|
||||
|
||||
public FindAndReplace(Store store, TreeModel tmCASA, TreeStore tsCASA)
|
||||
{
|
||||
m_store = store;
|
||||
m_tmCASA = tmCASA;
|
||||
m_tsCASA = tsCASA;
|
||||
}
|
||||
|
||||
public void ShowDialog()
|
||||
{
|
||||
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogFindAndReplace", null);
|
||||
gxmlTemp.Autoconnect(this);
|
||||
|
||||
dialogFindAndReplace.SetPosition(WindowPosition.CenterOnParent);
|
||||
|
||||
tvResults.AppendColumn("SecretID", new Gtk.CellRendererText(), "text", 0);
|
||||
tvResults.AppendColumn("Key", new Gtk.CellRendererText(), "text", 1);
|
||||
tvResults.AppendColumn("Value", new Gtk.CellRendererText(), "text", 2);
|
||||
|
||||
tvResults.Selection.Mode = SelectionMode.Multiple;
|
||||
|
||||
// 0:secretID, 1:Key, 2:Value****, 3:ValueClear, 4:dirtyBit
|
||||
tsResults = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(bool));
|
||||
tvResults.Model = tsResults;
|
||||
|
||||
// hook up event handles
|
||||
bttnApply.Clicked += new EventHandler(bttnApply_Clicked);
|
||||
bttnCancel.Clicked += new EventHandler(bttnCancel_Clicked);
|
||||
bttnRevert.Clicked += new EventHandler(bttnRevert_Clicked);
|
||||
bttnFind.Clicked += new EventHandler(bttnFind_Clicked);
|
||||
bttnOk.Clicked += new EventHandler(bttnOk_Clicked);
|
||||
bttnReplaceAll.Clicked += new EventHandler(bttnReplaceAll_Clicked);
|
||||
|
||||
cbShowValues.Toggled += new EventHandler(cbShowValues_Toggled);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void okbuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
|
||||
if (0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text))
|
||||
{
|
||||
tvResults.RemoveColumn(tvResults.GetColumn(2));
|
||||
tvCol = new TreeViewColumn("Value", new CellRendererText(), "text", 3);
|
||||
tvResults.InsertColumn(tvCol, 2);
|
||||
|
||||
// get seconds to remember
|
||||
//m_sRememberFor = spinbuttonRememberFor.Text;
|
||||
|
||||
//if (m_sRememberFor != null)
|
||||
//{
|
||||
// DateTime dtNow = DateTime.Now;
|
||||
// m_iRememberSeconds = int.Parse(m_sRememberFor);
|
||||
// CommonGUI.SetRememberMPUntil(dtNow.AddSeconds(m_iRememberSeconds));
|
||||
//}
|
||||
|
||||
// save off remember time if user changed it
|
||||
//string sSaveTimed = m_config.GetConfigSetting(CommonGUI.REMEMBER_SETTING, "5");
|
||||
//if (!sSaveTimed.Equals(m_sRememberFor))
|
||||
// {
|
||||
// m_config.SetConfigSetting(CommonGUI.REMEMBER_SETTING, m_sRememberFor);
|
||||
// m_config.WriteConfig();
|
||||
//}
|
||||
|
||||
dialogLogin.Destroy();
|
||||
|
||||
//if (m_iRememberSeconds > 0)
|
||||
// StartRememberTimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
// warn user
|
||||
CommonGUI.DisplayMessage(MessageType.Warning, "Master Password incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword3_activate(object obj, EventArgs args)
|
||||
{
|
||||
if ("" != entryMasterPassword3.Text)
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
public void on_entryMasterPassword4_activate(object obj, EventArgs args)
|
||||
{
|
||||
okbuttonLogin_clicked(obj, args);
|
||||
}
|
||||
|
||||
|
||||
public void on_helpbuttonAuthentication_clicked(object obj, EventArgs args)
|
||||
{
|
||||
Common.ShowHelpUrl("CASAMasterPasswordAuthentication.htm");
|
||||
}
|
||||
|
||||
|
||||
void cbShowValues_Toggled(object sender, EventArgs e)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
|
||||
if ((true == cbShowValues.Active)
|
||||
&& (CommonGUI.GetRememberMPUntil().CompareTo(DateTime.Now) > 0))
|
||||
{
|
||||
// set and start the timer if needed
|
||||
TimeSpan ts = CommonGUI.GetRememberMPUntil().Subtract(DateTime.Now);
|
||||
m_iRememberSeconds = ts.Seconds;
|
||||
//StartRememberTimer();
|
||||
|
||||
// display the values
|
||||
tvResults.RemoveColumn(tvResults.GetColumn(2));
|
||||
tvCol = new TreeViewColumn("Value", new CellRendererText(), "text", 3);
|
||||
tvResults.InsertColumn(tvCol, 2);
|
||||
}
|
||||
else if (true == cbShowValues.Active)
|
||||
{
|
||||
// prompt user for MasterPassword
|
||||
|
||||
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogLogin", null);
|
||||
gxmlTemp.Autoconnect(this);
|
||||
dialogLogin.TransientFor = dialogFindAndReplace;
|
||||
|
||||
label86.Text = "Enter your Master Password to view values";
|
||||
entryMasterPassword3.Text = "";
|
||||
entryMasterPassword3.HasFocus = true;
|
||||
label88.Hide();
|
||||
entryMasterPassword4.Hide();
|
||||
|
||||
labelRememberFor.Visible = false;
|
||||
labelSeconds.Visible = false;
|
||||
spinbuttonRememberFor.Visible = false;
|
||||
//spinbuttonRememberFor.Text = m_config.GetConfigSetting(CommonGUI.REMEMBER_SETTING, m_sRememberFor);
|
||||
|
||||
//dialogLogin.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
tvResults.RemoveColumn(tvResults.GetColumn(2));
|
||||
tvCol = new TreeViewColumn("Value", new CellRendererText(), "text", 2);
|
||||
tvResults.InsertColumn(tvCol, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void closebuttonLogin_clicked(object abj, EventArgs args)
|
||||
{
|
||||
cbShowValues.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
}
|
||||
|
||||
|
||||
public void OnDialogLoginDeleted(object obj, DeleteEventArgs args)
|
||||
{
|
||||
cbShowValues.Active = false;
|
||||
dialogLogin.Destroy();
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void bttnOk_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if (bttnApply.Sensitive)
|
||||
{
|
||||
bttnApply_Clicked(sender, e);
|
||||
}
|
||||
CloseDialog();
|
||||
}
|
||||
|
||||
void bttnFind_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
if (entryFind.Text != null && entryFind.Text.Length > 0)
|
||||
{
|
||||
DoFind();
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonGUI.DisplayMessage(MessageType.Error, "You must enter a value to find");
|
||||
}
|
||||
}
|
||||
|
||||
void bttnRevert_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
// show cancel
|
||||
bttnCancel.Visible = true;
|
||||
|
||||
// hide revert
|
||||
bttnRevert.Visible = false;
|
||||
|
||||
bttnApply.Sensitive = bttnOk.Sensitive = false;
|
||||
|
||||
// reload
|
||||
DoFind();
|
||||
}
|
||||
|
||||
void bttnCancel_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
CloseDialog();
|
||||
}
|
||||
|
||||
void bttnApply_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
TreeIter iter;
|
||||
|
||||
// iterate thru store, update all values with dirtybit=true
|
||||
if (tsResults.GetIterFirst(out iter))
|
||||
{
|
||||
do
|
||||
{
|
||||
bool bDirty = (bool)tsResults.GetValue(iter, 4);
|
||||
if (bDirty)
|
||||
{
|
||||
String sID = (string)tsResults.GetValue(iter, 0);
|
||||
String sKey = (string)tsResults.GetValue(iter, 1);
|
||||
String sValue = (string)tsResults.GetValue(iter, 3);
|
||||
|
||||
if (StoreDataInterface.ModifyCASASecretKey(sID, sKey, sValue))
|
||||
{
|
||||
Console.WriteLine("Updating {0} : {1} : {2}", sID, sKey, sValue);
|
||||
}
|
||||
|
||||
// Update CASAManager view
|
||||
m_store.AggregateStore();
|
||||
|
||||
}
|
||||
} while (tsResults.IterNext(ref iter));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// hide revert
|
||||
bttnRevert.Visible = false;
|
||||
bttnCancel.Visible = true;
|
||||
|
||||
bttnApply.Sensitive = false;
|
||||
bttnOk.Sensitive = false;
|
||||
|
||||
}
|
||||
|
||||
private void CloseDialog()
|
||||
{
|
||||
if (dialogFindAndReplace != null)
|
||||
{
|
||||
dialogFindAndReplace.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private void DoFind()
|
||||
{
|
||||
|
||||
string selected = null;
|
||||
string[] keys = null,
|
||||
values = null;
|
||||
|
||||
// clear current vies
|
||||
tsResults.Clear();
|
||||
|
||||
// iterate thru CASA TreeStore, finding matches
|
||||
TreeIter iter;
|
||||
|
||||
if (m_tsCASA.GetIterFirst(out iter))
|
||||
{
|
||||
do
|
||||
{
|
||||
selected = (string)m_tmCASA.GetValue(iter, 0);
|
||||
keys = (string[])m_tmCASA.GetValue(iter, 1);
|
||||
values = (string[])m_tmCASA.GetValue(iter, 2);
|
||||
|
||||
// add matches to the results
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
if ((entryFind.Text.Equals("*")) ||
|
||||
(values[i].IndexOf(entryFind.Text) > -1))
|
||||
{
|
||||
tsResults.AppendValues(selected, keys[i], "*******", values[i], false);
|
||||
}
|
||||
}
|
||||
} while (m_tsCASA.IterNext(ref iter));
|
||||
|
||||
//tvResults.Selection.SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
void bttnReplaceAll_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
TreePath[] treePaths = tvResults.Selection.GetSelectedRows();
|
||||
TreeIter iter;
|
||||
|
||||
if (entryNewValue.Text == null || entryNewValue.Text.Length == 0)
|
||||
{
|
||||
CommonGUI.DisplayMessage(MessageType.Warning, "Enter a new value");
|
||||
return;
|
||||
}
|
||||
|
||||
if (treePaths.Length == 0)
|
||||
{
|
||||
CommonGUI.DisplayMessage(MessageType.Warning, "You must select at least one row");
|
||||
return;
|
||||
}
|
||||
|
||||
if (entryNewValue.Text != null && entryNewValue.Text.Length > 0)
|
||||
{
|
||||
// iterate thru those to change
|
||||
for (int i = 0; i < treePaths.Length; i++)
|
||||
{
|
||||
if (tsResults.GetIter(out iter, treePaths[i]))
|
||||
{
|
||||
string sCurrentValue = (string)tsResults.GetValue(iter, 3);
|
||||
|
||||
// change if newValue is different
|
||||
if (!sCurrentValue.Equals(entryNewValue.Text))
|
||||
{
|
||||
tsResults.SetValue(iter, 2, entryNewValue.Text);
|
||||
tsResults.SetValue(iter, 3, entryNewValue.Text);
|
||||
|
||||
// set the dirty bit
|
||||
tsResults.SetValue(iter, 4, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bttnApply.Sensitive = bttnOk.Sensitive = true;
|
||||
|
||||
bttnRevert.Visible = true;
|
||||
bttnCancel.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private bool bTimerActive = false;
|
||||
public void StartRememberTimer()
|
||||
{
|
||||
if (!bTimerActive)
|
||||
{
|
||||
GLib.Timeout.Add((uint)(m_iRememberSeconds * 1000), new GLib.TimeoutHandler(update_gui));
|
||||
bTimerActive = true;
|
||||
}
|
||||
}
|
||||
* */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
using Gtk;
|
||||
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
@@ -14,16 +17,33 @@ namespace Novell.CASA.GUI
|
||||
Config m_config = null;
|
||||
public MiCasa m_objMiCasa = null;
|
||||
string sFile = null;
|
||||
byte[] buffer = null;
|
||||
|
||||
[Glade.Widget]
|
||||
byte[] buffer = null;
|
||||
TreeStore tsConflicts;
|
||||
|
||||
SecretStore m_ss = null;
|
||||
StringCollection m_scConflicts;
|
||||
|
||||
#region GladeWidgets
|
||||
[Glade.Widget]
|
||||
Gtk.Entry entryMasterPassword;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Dialog dialogImport,
|
||||
dialogLogin;
|
||||
|
||||
public ImportSecrets(Config config, MiCasa objMiCasa)
|
||||
dialogLogin,
|
||||
dialogResolveConflict;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.TreeView tvConflicts;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.Button bttnImport,
|
||||
bttnIgnore;
|
||||
|
||||
[Glade.Widget]
|
||||
Gtk.CheckButton cbShowValues;
|
||||
#endregion
|
||||
|
||||
public ImportSecrets(Config config, MiCasa objMiCasa)
|
||||
{
|
||||
m_config = config;
|
||||
m_objMiCasa = objMiCasa;
|
||||
@@ -75,7 +95,20 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
ImportXMLSecrets addSecrets = new ImportXMLSecrets(null, null, sFile);
|
||||
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_ADD_XML_SECRETS, null, null, null, addSecrets);
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
|
||||
// check for conflicts
|
||||
if (m_ss == null)
|
||||
m_ss = SecretStore.getInstance();
|
||||
|
||||
m_scConflicts = m_ss.enumerateSecretIDs(SecretStore.SSCS_CONFLICT_KEYCHAIN);
|
||||
if (m_scConflicts.Count > 0)
|
||||
{
|
||||
HandleConficts(m_ss, m_scConflicts);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonGUI.DisplayMessage(Gtk.MessageType.Info, "Import complete");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,7 +137,7 @@ namespace Novell.CASA.GUI
|
||||
|
||||
gxmlTemp.Autoconnect (this);
|
||||
dialogImport.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("windowMain");;
|
||||
dialogImport.Modal = true;
|
||||
dialogImport.Modal = true;
|
||||
dialogImport.Show();
|
||||
}
|
||||
|
||||
@@ -166,6 +199,218 @@ namespace Novell.CASA.GUI
|
||||
{
|
||||
dialogImport.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleConficts(SecretStore store, StringCollection scConflicts)
|
||||
{
|
||||
|
||||
bool bShowConflictDialog = false;
|
||||
|
||||
// 0:secretID, 1:keyID, 2:importValue, 3:currentValue
|
||||
tsConflicts = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));
|
||||
|
||||
StringEnumerator sEnum = scConflicts.GetEnumerator();
|
||||
{
|
||||
while (sEnum.MoveNext())
|
||||
{
|
||||
string sSecretID = sEnum.Current;
|
||||
Secret currentSecret = store.getSecret(sSecretID);
|
||||
|
||||
string sConflictSecretID;
|
||||
if (sSecretID.StartsWith("SS_CredSet"))
|
||||
{
|
||||
sConflictSecretID = sSecretID.Substring(11);
|
||||
}
|
||||
else
|
||||
{
|
||||
sConflictSecretID = sSecretID;
|
||||
}
|
||||
Secret conflictSecret = store.getSecret(SecretStore.SSCS_CONFLICT_KEYCHAIN, 0, sConflictSecretID, Secret.SS_CREDSET, "");
|
||||
|
||||
// add this conflict to the treestore
|
||||
NameValueCollection nvcConflict = conflictSecret.getKeyValueCollection();
|
||||
NameValueCollection nvcCurrent = currentSecret.getKeyValueCollection();
|
||||
for (int i = 0; i < nvcConflict.Count; i++)
|
||||
{
|
||||
String sConflictKey = nvcConflict.GetKey(i);
|
||||
String sConflictValue = nvcConflict.Get(sConflictKey);
|
||||
String sCurrentValue = nvcCurrent.Get(sConflictKey);
|
||||
|
||||
if (sCurrentValue != null)
|
||||
{
|
||||
if (sCurrentValue != sConflictValue)
|
||||
{
|
||||
tsConflicts.AppendValues(sSecretID, sConflictKey, sConflictValue, sCurrentValue, "*********");
|
||||
bShowConflictDialog = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tsConflicts.AppendValues(sSecretID, sConflictKey, sConflictValue, "", "*********");
|
||||
bShowConflictDialog = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bShowConflictDialog == true)
|
||||
{
|
||||
// show dialog
|
||||
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogResolveConflict", null);
|
||||
gxmlTemp.Autoconnect(this);
|
||||
|
||||
dialogResolveConflict.SetPosition(WindowPosition.CenterOnParent);
|
||||
|
||||
tvConflicts.AppendColumn("SecretID", new Gtk.CellRendererText(), "text", 0);
|
||||
tvConflicts.AppendColumn("Key", new Gtk.CellRendererText(), "text", 1);
|
||||
if (cbShowValues.Active)
|
||||
{
|
||||
tvConflicts.AppendColumn("Import value", new Gtk.CellRendererText(), "text", 2);
|
||||
tvConflicts.AppendColumn("Current value", new Gtk.CellRendererText(), "text", 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
tvConflicts.AppendColumn("Import value", new Gtk.CellRendererText(), "text", 4);
|
||||
tvConflicts.AppendColumn("Current value", new Gtk.CellRendererText(), "text", 4);
|
||||
}
|
||||
|
||||
tvConflicts.Selection.Mode = SelectionMode.Multiple;
|
||||
|
||||
// hook up event handlers
|
||||
bttnImport.Clicked += new EventHandler(bttnImport_Clicked);
|
||||
bttnIgnore.Clicked += new EventHandler(bttnIgnore_Clicked);
|
||||
cbShowValues.Toggled += new EventHandler(cbShowValues_Toggled);
|
||||
|
||||
tvConflicts.Model = tsConflicts;
|
||||
dialogResolveConflict.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearConflicts();
|
||||
CommonGUI.DisplayMessage(MessageType.Info, "Import complete");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cbShowValues_Toggled(object sender, EventArgs e)
|
||||
{
|
||||
TreeViewColumn tvCol;
|
||||
|
||||
if (cbShowValues.Active)
|
||||
{
|
||||
// verify MasterPassword
|
||||
CommonGUI cg = new CommonGUI();
|
||||
if (cg.VerifyMasterPasswordWithUser())
|
||||
{
|
||||
tvConflicts.RemoveColumn(tvConflicts.GetColumn(3));
|
||||
tvConflicts.RemoveColumn(tvConflicts.GetColumn(2));
|
||||
|
||||
// add columns
|
||||
tvCol = new TreeViewColumn("Import value", new CellRendererText(), "text", 2);
|
||||
tvConflicts.InsertColumn(tvCol, 2);
|
||||
|
||||
tvCol = new TreeViewColumn("Current value", new CellRendererText(), "text", 3);
|
||||
tvConflicts.InsertColumn(tvCol, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
cbShowValues.Active = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tvConflicts.RemoveColumn(tvConflicts.GetColumn(3));
|
||||
tvConflicts.RemoveColumn(tvConflicts.GetColumn(2));
|
||||
|
||||
// add columns
|
||||
tvCol = new TreeViewColumn("Import value", new CellRendererText(), "text", 4);
|
||||
tvConflicts.InsertColumn(tvCol, 2);
|
||||
|
||||
tvCol = new TreeViewColumn("Current value", new CellRendererText(), "text", 4);
|
||||
tvConflicts.InsertColumn(tvCol, 3);
|
||||
}
|
||||
}
|
||||
|
||||
void bttnIgnore_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
ClearConflicts();
|
||||
dialogResolveConflict.Destroy();
|
||||
}
|
||||
|
||||
void bttnImport_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
DoImport();
|
||||
}
|
||||
|
||||
void DoImport()
|
||||
{
|
||||
// get selected rows
|
||||
TreePath[] treePaths = tvConflicts.Selection.GetSelectedRows();
|
||||
TreeIter iter;
|
||||
|
||||
if (treePaths.Length > 0)
|
||||
{
|
||||
// iterate thru those to change
|
||||
for (int i = 0; i < treePaths.Length; i++)
|
||||
{
|
||||
if (tsConflicts.GetIter(out iter, treePaths[i]))
|
||||
{
|
||||
string sSecretID = (string)tsConflicts.GetValue(iter, 0);
|
||||
string sKey = (string)tsConflicts.GetValue(iter, 1);
|
||||
string sNewValue = (string)tsConflicts.GetValue(iter, 2);
|
||||
string sCurValue = (string)tsConflicts.GetValue(iter, 3);
|
||||
|
||||
if ((sCurValue == null) || (sCurValue.Length == 0))
|
||||
{
|
||||
StoreDataInterface.AddCASASecretKey(sSecretID, sKey, sNewValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
StoreDataInterface.ModifyCASASecretKey(sSecretID, sKey, sNewValue);
|
||||
}
|
||||
|
||||
tsConflicts.SetValue(iter, 3, sNewValue);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < treePaths.Length; i++)
|
||||
{
|
||||
if (tsConflicts.GetIter(out iter, treePaths[i]))
|
||||
{
|
||||
tsConflicts.Remove(ref iter);
|
||||
}
|
||||
}
|
||||
|
||||
// refresh the store
|
||||
//ClearConflicts();
|
||||
m_objMiCasa.AggregateStore();
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonGUI.DisplayMessage(MessageType.Error, "Select the values you want to import");
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearConflicts()
|
||||
{
|
||||
// enumerate thru conflicts, clearing each one
|
||||
if (m_ss != null)
|
||||
{
|
||||
if (m_scConflicts != null)
|
||||
{
|
||||
StringEnumerator sEnum = m_scConflicts.GetEnumerator();
|
||||
while (sEnum.MoveNext())
|
||||
{
|
||||
string sSecretID = (string)sEnum.Current;
|
||||
if (sSecretID.StartsWith("SS_CredSet"))
|
||||
{
|
||||
sSecretID = sSecretID.Substring(11);
|
||||
}
|
||||
m_ss.removeSecret(0, SecretStore.SSCS_CONFLICT_KEYCHAIN, null, sSecretID, Secret.SS_CREDSET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tsConflicts.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ CSFILES =$(srcdir)/AssemblyInfo.cs \
|
||||
$(srcdir)/ExportSecrets.cs \
|
||||
$(srcdir)/FileChooser.cs \
|
||||
$(srcdir)/ImportSecrets.cs \
|
||||
$(srcdir)/FindAndReplace.cs \
|
||||
$(srcdir)/Firefox.cs \
|
||||
$(srcdir)/GnomeKeyring.cs \
|
||||
$(srcdir)/KdeWallet.cs \
|
||||
|
||||
@@ -132,7 +132,7 @@ public class MiCasa : Store
|
||||
/// SecretID TreeStore
|
||||
tvSecretIDMiCasa = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDMiCasa");
|
||||
tsSecretIDMiCasa = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]));
|
||||
tvSecretIDMiCasa.AppendColumn("Secret ID",new CellRendererText(),"text",0);
|
||||
tvSecretIDMiCasa.AppendColumn("Secret ID",new CellRendererText(),"text",0);
|
||||
tvSecretIDMiCasa.Model = tsSecretIDMiCasa;
|
||||
tsSecretIDMiCasa.SetSortColumnId(0, Gtk.SortType.Ascending);
|
||||
tvSecretIDMiCasa.RowActivated += new RowActivatedHandler(OntvSecretIDMiCasaRowActivated);
|
||||
@@ -985,8 +985,14 @@ public class MiCasa : Store
|
||||
public void on_helpbuttonLinkKeys_clicked(object obj, EventArgs args)
|
||||
{
|
||||
Common.ShowHelpUrl("LinkingSecrets.htm");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
internal void FindAndReplaceValues()
|
||||
{
|
||||
FindAndReplace fr = new FindAndReplace(this, tvSecretIDMiCasa.Model, tsSecretIDMiCasa);
|
||||
fr.ShowDialog();
|
||||
}
|
||||
|
||||
///#######################################################################
|
||||
// DELETE SECRET
|
||||
|
||||
@@ -987,9 +987,7 @@ namespace Novell.CASA.GUI {
|
||||
//Console.WriteLine("EXECUTING OPERATION_ADD_SECRET:Adding"+ccfSecretPath);//FIXME:Remove this line
|
||||
ad.SetSecret(lastChild,operation,storeIDentifier); //and set it
|
||||
}
|
||||
}//STORE_KDEWALLET
|
||||
|
||||
|
||||
}//STORE_KDEWALLET
|
||||
}
|
||||
else if( Common.OPERATION_ADD_KEY == operation )
|
||||
{
|
||||
@@ -1015,7 +1013,66 @@ namespace Novell.CASA.GUI {
|
||||
}
|
||||
|
||||
return( Common.STATUS_SUCCESS );
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ModifyCASASecretKey(string SecretID, string keyID, string sValue)
|
||||
{
|
||||
return ModifySecretKey(Common.STORE_MICASA, "Default", SecretID, keyID, sValue);
|
||||
}
|
||||
|
||||
private static bool ModifySecretKey(int StoreID, string keyChainID, string SecretID, string keyID, string sValue)
|
||||
{
|
||||
string ccfSecretPath = "//CCF/miCASA/Keychain[@ID='" + keyChainID + "']/Secret[@ID='" + SecretID + "']/Key[@ID='" + keyID + "']";
|
||||
|
||||
//For Modify operation get to the Node in the tree which needs to be modified
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keylist = root.SelectNodes(ccfSecretPath);
|
||||
foreach ( XmlNode key in keylist )
|
||||
{
|
||||
key.ChildNodes[0].InnerText = sValue;
|
||||
ad.SetSecret(key.ParentNode, Common.OPERATION_MODIFY_KEY, StoreID);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Make this store independant
|
||||
public static bool AddCASASecretKey(string SecretID, string keyID, string sValue)
|
||||
{
|
||||
XmlElement newKeyElement;
|
||||
string ccfKeyChainPath = "//CCF/miCASA/Keychain[@ID='Default']/Secret[@ID='" + SecretID + "']";
|
||||
string ccfSecretPath = "";
|
||||
|
||||
//Create the Key element
|
||||
newKeyElement = ccfDoc.CreateElement(CCFXML_ELEMENT_KEY);
|
||||
newKeyElement.SetAttribute(CCFXML_ATTRIBUTE_ID, keyID);
|
||||
XmlElement newValue = ccfDoc.CreateElement(CCFXML_ELEMENT_VALUE);
|
||||
newValue.InnerText = sValue;
|
||||
newKeyElement.AppendChild(newValue);
|
||||
|
||||
XmlNode root = ccfDoc.DocumentElement;
|
||||
XmlNodeList keyNodeList = root.SelectNodes(ccfKeyChainPath);
|
||||
XmlNode keyNode = keyNodeList.Item(0);
|
||||
XmlNode lastChild = keyNode.LastChild;
|
||||
keyNode.InsertBefore(newKeyElement, lastChild);
|
||||
try
|
||||
{
|
||||
int errcode = ad.SetSecret(keyNode, Common.OPERATION_ADD_KEY, Common.STORE_MICASA);
|
||||
if (errcode == Common.STATUS_SUCCESS)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///#######################################################################
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user