Commit de2afc87 authored by Thomas's avatar Thomas
Browse files

Remove obsolete code

parent adec6d7b
...@@ -10,8 +10,8 @@ namespace pEp.DPE ...@@ -10,8 +10,8 @@ namespace pEp.DPE
{ {
internal class DistributedPolicyEngine : IDistributedPolicyEngine internal class DistributedPolicyEngine : IDistributedPolicyEngine
{ {
private readonly static string DPE_FOLDER = Path.Combine(Globals.PEPUserFolder, "DPE"); private static readonly string DPE_FOLDER = Path.Combine(Globals.PEPUserFolder, "DPE");
public readonly static string DPE_TEMP_LOCATION = Path.Combine(DistributedPolicyEngine.DPE_FOLDER, "temp"); public static readonly string DPE_TEMP_LOCATION = Path.Combine(DistributedPolicyEngine.DPE_FOLDER, "temp");
private const string PATCH_EXTENSION = ".patch"; private const string PATCH_EXTENSION = ".patch";
private const string PATCH_MESSAGE_SUBJECT = "Configuration changes"; private const string PATCH_MESSAGE_SUBJECT = "Configuration changes";
public const string DPE_MESSAGE_CLASS = "IPM.Note.DPE"; public const string DPE_MESSAGE_CLASS = "IPM.Note.DPE";
...@@ -127,7 +127,6 @@ namespace pEp.DPE ...@@ -127,7 +127,6 @@ namespace pEp.DPE
public void Reject(Patch patch, PEPIdentity me) public void Reject(Patch patch, PEPIdentity me)
{ {
DPEWebClient.RejectPatch(patch, me); DPEWebClient.RejectPatch(patch, me);
this.DeletePatch(patch);
AdapterExtensions.ShowNotification("Patch rejected", patch.CommitMessage); AdapterExtensions.ShowNotification("Patch rejected", patch.CommitMessage);
} }
...@@ -137,9 +136,9 @@ namespace pEp.DPE ...@@ -137,9 +136,9 @@ namespace pEp.DPE
/// <param name="patchEvents">The patch events to subscribe to.</param> /// <param name="patchEvents">The patch events to subscribe to.</param>
public void Subscribe(PatchEvents patchEvents) public void Subscribe(PatchEvents patchEvents)
{ {
patchEvents.PatchAccepted += PatchEvents_PatchAccepted; patchEvents.PatchAccepted += this.PatchEvents_PatchAccepted;
patchEvents.PatchRejected += PatchEvents_PatchRejected; patchEvents.PatchRejected += this.PatchEvents_PatchRejected;
patchEvents.PatchSuggested += PatchEvents_PatchSuggested; patchEvents.PatchSuggested += this.PatchEvents_PatchSuggested;
} }
/// <summary> /// <summary>
...@@ -161,7 +160,6 @@ namespace pEp.DPE ...@@ -161,7 +160,6 @@ namespace pEp.DPE
public void Support(Patch patch, PEPIdentity me) public void Support(Patch patch, PEPIdentity me)
{ {
DPEWebClient.SupportPatch(patch, me); DPEWebClient.SupportPatch(patch, me);
this.DeletePatch(patch);
AdapterExtensions.ShowNotification("Patch supported", patch.CommitMessage); AdapterExtensions.ShowNotification("Patch supported", patch.CommitMessage);
} }
...@@ -171,67 +169,9 @@ namespace pEp.DPE ...@@ -171,67 +169,9 @@ namespace pEp.DPE
/// <param name="patchEvents">The patch events to unsubscribe from.</param> /// <param name="patchEvents">The patch events to unsubscribe from.</param>
public void Unsubscribe(PatchEvents patchEvents) public void Unsubscribe(PatchEvents patchEvents)
{ {
patchEvents.PatchAccepted -= PatchEvents_PatchAccepted; patchEvents.PatchAccepted -= this.PatchEvents_PatchAccepted;
patchEvents.PatchRejected -= PatchEvents_PatchRejected; patchEvents.PatchRejected -= this.PatchEvents_PatchRejected;
patchEvents.PatchSuggested -= PatchEvents_PatchSuggested; patchEvents.PatchSuggested -= this.PatchEvents_PatchSuggested;
}
/// <summary>
/// Deletes the patch from the disk.
/// </summary>
/// <param name="patch">The patch to delete.</param>
/// <returns>True if the patch was deleted or not found, otherwise false.</returns>
private bool DeletePatch(Patch patch)
{
try
{
string fileName = Path.Combine(DistributedPolicyEngine.DPE_FOLDER, patch.Id + DistributedPolicyEngine.PATCH_EXTENSION);
if (File.Exists(fileName))
{
File.Delete(fileName);
}
return true;
}
catch (Exception ex)
{
Log.Error("DeletePatch: Error occured. " + ex.ToString());
}
return false;
}
#endregion
#region Static methods
/// <summary>
/// Gets the patches that are currently saved to disk.
/// </summary>
/// <returns>The list of open patches or an empty list if none was found.</returns>
internal static List<Tuple<Patch, bool>> GetOpenPatches()
{
List<Tuple<Patch, bool>> patches = new List<Tuple<Patch, bool>>();
try
{
foreach (string file in Directory.GetFiles(DistributedPolicyEngine.DPE_FOLDER, "*" + DistributedPolicyEngine.PATCH_EXTENSION))
{
string xml = File.ReadAllText(file);
if ((Patch.Deserialize(xml) is Patch patch) &&
(patch != null))
{
patches.Add(new Tuple<Patch, bool>(patch, false));
}
}
}
catch (Exception ex)
{
Log.Error("GetPatches: Error getting patches. " + ex.ToString());
}
return patches;
} }
#endregion #endregion
......
...@@ -17,16 +17,18 @@ namespace pEp ...@@ -17,16 +17,18 @@ namespace pEp
/// </summary> /// </summary>
internal static class MailItemExtensions internal static class MailItemExtensions
{ {
public const string USER_PROPERTY_KEY_ORIG_ENTRY_ID = "origEntryID"; public const string USER_PROPERTY_KEY_DPE_PATCH_STATUS = "patchStatus";
public const string USER_PROPERTY_KEY_DPE_PATCH_EDIT_DATE = "patchEditDate";
public const string USER_PROPERTY_KEY_INSPECTOR_CLOSED = "inspectorClosed"; public const string USER_PROPERTY_KEY_INSPECTOR_CLOSED = "inspectorClosed";
public const string USER_PROPERTY_KEY_IS_INCOMING = "isIncoming"; public const string USER_PROPERTY_KEY_IS_INCOMING = "isIncoming";
public const string USER_PROPERTY_KEY_IS_MIRROR = "isMirror"; public const string USER_PROPERTY_KEY_IS_MIRROR = "isMirror";
public const string USER_PROPERTY_KEY_ORIG_ENTRY_ID = "origEntryID";
public const string USER_PROPERTY_KEY_PROCESSING_STATE = "processingState"; public const string USER_PROPERTY_KEY_PROCESSING_STATE = "processingState";
public const string USER_PROPERTY_KEY_REPLY_ACTION = "replyAction"; public const string USER_PROPERTY_KEY_REPLY_ACTION = "replyAction";
public const string UNKNOWN_SENDER = "unknown"; public const string UNKNOWN_SENDER = "unknown";
private static readonly object mutexCopiedItemsList = new object(); private static readonly object mutexCopiedItemsList = new object();
private static List<string> copiedItemsList = new List<string>(); private static readonly List<string> copiedItemsList = new List<string>();
/// <summary> /// <summary>
/// Enumeration defining the standard, setable pEp properties of an extended MailItem. /// Enumeration defining the standard, setable pEp properties of an extended MailItem.
...@@ -1190,7 +1192,6 @@ namespace pEp ...@@ -1190,7 +1192,6 @@ namespace pEp
/// <returns>True if it is an attached mail, otherwise false.</returns> /// <returns>True if it is an attached mail, otherwise false.</returns>
public static bool GetIsAttachedMail(this Outlook.MailItem omi, out string messageId) public static bool GetIsAttachedMail(this Outlook.MailItem omi, out string messageId)
{ {
messageId = null;
HeaderList headers = omi.GetParsedTransportMessageHeaders(); HeaderList headers = omi.GetParsedTransportMessageHeaders();
try try
......
...@@ -1614,7 +1614,6 @@ namespace pEp ...@@ -1614,7 +1614,6 @@ namespace pEp
// TODO: Check whether this method should be part of the engine? // TODO: Check whether this method should be part of the engine?
int unencryptedCount = 0; int unencryptedCount = 0;
pEpRating rating = pEpRating.pEpRatingUndefined; pEpRating rating = pEpRating.pEpRatingUndefined;
List<PEPIdentity> forceUnencryptedList = new List<PEPIdentity>();
PEPIdentity[] recipients; PEPIdentity[] recipients;
PEPMessage workingMessage; PEPMessage workingMessage;
......
...@@ -31,7 +31,7 @@ namespace pEp.UI.ViewModels ...@@ -31,7 +31,7 @@ namespace pEp.UI.ViewModels
MessageGroups = 5 MessageGroups = 5
} }
private PEPSettings pEpSettings; private readonly PEPSettings pEpSettings;
private int _AccountSettingsListSelectedIndex = -1; private int _AccountSettingsListSelectedIndex = -1;
private RelayCommand _CommandButtonAddGroup = null; private RelayCommand _CommandButtonAddGroup = null;
...@@ -45,9 +45,6 @@ namespace pEp.UI.ViewModels ...@@ -45,9 +45,6 @@ namespace pEp.UI.ViewModels
private RelayCommand _CommandButtonRefreshLogs = null; private RelayCommand _CommandButtonRefreshLogs = null;
private RelayCommand _CommandButtonResetPEPStore = null; private RelayCommand _CommandButtonResetPEPStore = null;
private RelayCommand _CommandButtonResetAllOwnKeys = null; private RelayCommand _CommandButtonResetAllOwnKeys = null;
private RelayCommand<IList<object>> _CommandOpenPatch = null;
private RelayCommand<IList<object>> _CommandRejectPatch = null;
private RelayCommand<IList<object>> _CommandSupportPatch = null;
private bool _IsAdvancedEnabled = false; private bool _IsAdvancedEnabled = false;
private string _LogEngine = null; private string _LogEngine = null;
private string _LogOutlook = null; private string _LogOutlook = null;
...@@ -78,12 +75,6 @@ namespace pEp.UI.ViewModels ...@@ -78,12 +75,6 @@ namespace pEp.UI.ViewModels
this.AccountSettingsList.Add(new AccountViewModel(accountSettings, this.CalculateDependentProperties)); this.AccountSettingsList.Add(new AccountViewModel(accountSettings, this.CalculateDependentProperties));
}); });
// Add patches
DistributedPolicyEngine.GetOpenPatches()?.ForEach((tuple) =>
{
this.Patches.Add(new PatchViewModel(tuple.Item1, tuple.Item2));
});
// Calculate dependent properties // Calculate dependent properties
this.calcDepPropIsEnabled = true; this.calcDepPropIsEnabled = true;
this.CalculateDependentProperties(); this.CalculateDependentProperties();
...@@ -305,55 +296,6 @@ namespace pEp.UI.ViewModels ...@@ -305,55 +296,6 @@ namespace pEp.UI.ViewModels
} }
} }
/// <summary>
/// Gets the command to open a patch.
/// </summary>
public RelayCommand<IList<object>> CommandOpenPatch
{
get
{
if (this._CommandOpenPatch == null)
{
this._CommandOpenPatch = new RelayCommand<IList<object>>(p => (p?.First() as PatchViewModel)?.OpenPatchDialog(PatchDialog.PatchAction.SupportOrRejectPatch));
}
return this._CommandOpenPatch;
}
}
/// <summary>
/// Gets the command to reject a patch.
/// </summary>
public RelayCommand<IList<object>> CommandRejectPatch
{
get
{
if (this._CommandRejectPatch == null)
{
this._CommandRejectPatch = new RelayCommand<IList<object>>(p => this.RejectPatch(p?.First() as PatchViewModel));
}
return this._CommandRejectPatch;
}
}
/// <summary>
/// Gets the command to support a patch.
/// </summary>
public RelayCommand<IList<object>> CommandSupportPatch
{
get
{
if (this._CommandSupportPatch == null)
{
this._CommandSupportPatch = new RelayCommand<IList<object>>(p => this.SupportPatch(p?.First() as PatchViewModel));
}
return this._CommandSupportPatch;
}
}
/// <summary> /// <summary>
/// Gets the list of projects that are used in pEp for Outlook and that /// Gets the list of projects that are used in pEp for Outlook and that
/// are being credited. /// are being credited.
...@@ -1113,37 +1055,6 @@ namespace pEp.UI.ViewModels ...@@ -1113,37 +1055,6 @@ namespace pEp.UI.ViewModels
} while (retry); } while (retry);
} }
/// <summary>
/// Opens the Patch dialog.
/// </summary>
/// <param name="patchViewModel">The patch view model that </param>
/// <param name="patchAction">The patch action to execute.</param>
/// <returns>The dialog result.</returns>
public System.Windows.Forms.DialogResult OpenPatchDialog(PatchViewModel patchViewModel, PatchDialog.PatchAction patchAction)
{
if (patchViewModel == null)
{
Log.ErrorAndFailInDebugMode("OpenPatchDialog: patch view model is null.");
}
System.Windows.Forms.DialogResult dialogResult = patchViewModel?.OpenPatchDialog(patchAction) ?? System.Windows.Forms.DialogResult.Cancel;
if (dialogResult != System.Windows.Forms.DialogResult.Cancel)
{
this.Patches.Clear();
// Add patches
DistributedPolicyEngine.GetOpenPatches()?.ForEach((tuple) =>
{
this.Patches.Add(new PatchViewModel(tuple.Item1, tuple.Item2));
});
this.OnPropertyChanged(nameof(this.Patches));
}
return dialogResult;
}
/// <summary> /// <summary>
/// Resets the logs. /// Resets the logs.
/// </summary> /// </summary>
...@@ -1179,43 +1090,6 @@ namespace pEp.UI.ViewModels ...@@ -1179,43 +1090,6 @@ namespace pEp.UI.ViewModels
} }
} }
/// <summary>
/// Removes the given patch from the list of patches.
/// </summary>
/// <param name="patchViewModel">The patch view model to remove.</param>
private void RemovePatch(PatchViewModel patchViewModel)
{
if (patchViewModel == null)
{
Log.ErrorAndFailInDebugMode("RemovePatch: patch view model is null.");
}
if (!this.Patches.Remove(patchViewModel))
{
Log.Error("RemovePatch: Could not remove patch.");
}
}
/// <summary>
/// Rejects the patch.
/// </summary>
/// <param name="patchViewModel">The patch's view model.</param>
private void RejectPatch(PatchViewModel patchViewModel)
{
patchViewModel?.RejectPatch();
this.RemovePatch(patchViewModel);
}
/// <summary>
/// Supports the patch.
/// </summary>
/// <param name="patchViewModel">The patch's view model.</param>
private void SupportPatch(PatchViewModel patchViewModel)
{
patchViewModel?.SupportPatch();
this.RemovePatch(patchViewModel);
}
#endregion #endregion
} }
} }
...@@ -976,52 +976,7 @@ ...@@ -976,52 +976,7 @@
FontSize="16" /> FontSize="16" />
<Separator /> <Separator />
<!--Patch management--> <!--New patch button-->
<ListBox Name="patchManagementListBox"
HorizontalContentAlignment="Stretch"
VerticalAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding Patches}"
MinHeight="300"
Margin="10,5" >
<ListBox.ContextMenu>
<ContextMenu DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Open"
Command="{Binding DataContext.CommandOpenPatch}"
CommandParameter="{Binding Path=SelectedItems}"/>
<MenuItem Header="Support"
Command="{Binding DataContext.CommandSupportPatch}"
CommandParameter="{Binding Path=SelectedItems}"/>
<MenuItem Header="Reject"
Command="{Binding DataContext.CommandRejectPatch}"
CommandParameter="{Binding Path=SelectedItems}"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<ContentControl MouseDoubleClick="ContentControl_MouseDoubleClick">
<Grid Background="{Binding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{Binding CommitMessage}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
Foreground="{Binding Foreground}"
Margin="10"/>
<TextBlock Grid.Column="1"
Text="{Binding LastUpdate}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
Foreground="{Binding Foreground}"
Margin="10"/>
</Grid>
</ContentControl>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="New patch" <Button Content="New patch"
Style="{StaticResource StyleButtonGray}" Style="{StaticResource StyleButtonGray}"
Margin="10,5,5,5" Margin="10,5,5,5"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment