Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Windows
pEp for Outlook
Compare Revisions
39923e109f54d90c01ed9c5e09d0c9176ed2a023...f2485c0eaf3350018b6c0dfa72a4deaca539c12d
Commits (6)
Extend CustomMessageBox
· c2b7bb3f
Thomas
authored
Jul 16, 2021
c2b7bb3f
Adjust group encryption methods to latest adapter changes
· 001e7f41
Thomas
authored
Jul 16, 2021
001e7f41
Merge remote-tracking branch 'origin/OUT-789' into OUT-789
· 5cb19f25
Thomas
authored
Jul 16, 2021
5cb19f25
Refactor CustomMessageBox
· 7ac301e0
Thomas
authored
Jul 19, 2021
7ac301e0
Use Close() method of base viewmodel
· ae1dfd18
Thomas
authored
Jul 19, 2021
ae1dfd18
Log error if a MAPI property can't be added to collection.
· f2485c0e
Thomas
authored
Jul 19, 2021
f2485c0e
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
408 additions
and
178 deletions
+408
-178
CryptableMailItem.cs
CryptableMailItem.cs
+10
-17
MAPIProperties.cs
MAPIProperties.cs
+21
-0
UI/DialogHost.cs
UI/DialogHost.cs
+10
-0
UI/Models/CustomMessageBox.cs
UI/Models/CustomMessageBox.cs
+135
-0
UI/Models/Dialog.cs
UI/Models/Dialog.cs
+3
-1
UI/Models/MessageGroup.cs
UI/Models/MessageGroup.cs
+7
-37
UI/Models/OptionsDialog.cs
UI/Models/OptionsDialog.cs
+41
-70
UI/ViewModels/CustomMessageBoxViewModel.cs
UI/ViewModels/CustomMessageBoxViewModel.cs
+102
-0
UI/ViewModels/DialogHostViewModel.cs
UI/ViewModels/DialogHostViewModel.cs
+13
-4
UI/ViewModels/HandshakeViewModel.cs
UI/ViewModels/HandshakeViewModel.cs
+2
-4
UI/ViewModels/MessageGroupInviteViewModel.cs
UI/ViewModels/MessageGroupInviteViewModel.cs
+1
-1
UI/ViewModels/MessageGroupViewModel.cs
UI/ViewModels/MessageGroupViewModel.cs
+1
-1
UI/ViewModels/OptionsViewModel.cs
UI/ViewModels/OptionsViewModel.cs
+2
-10
UI/ViewModels/WizardViewModelBase.cs
UI/ViewModels/WizardViewModelBase.cs
+4
-5
UI/Views/CustomMessageBoxView.xaml
UI/Views/CustomMessageBoxView.xaml
+24
-25
UI/Views/CustomMessageBoxView.xaml.cs
UI/Views/CustomMessageBoxView.xaml.cs
+18
-0
UI/Views/DialogHostView.xaml
UI/Views/DialogHostView.xaml
+3
-0
UI/Views/DialogHostView.xaml.cs
UI/Views/DialogHostView.xaml.cs
+6
-0
pEpForOutlook.csproj
pEpForOutlook.csproj
+5
-3
No files found.
CryptableMailItem.cs
View file @
f2485c0e
using
MimeKit
;
using
pEp.UI
;
using
pEp.UI.
View
s
;
using
pEp.UI.
Model
s
;
using
pEpCOMServerAdapterLib
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Outlook
=
Microsoft
.
Office
.
Interop
.
Outlook
;
...
...
@@ -1253,22 +1252,16 @@ namespace pEp
(
message
.
IsSecure
==
false
)
&&
(
CryptableMailItem
.
mixedConfigWarning
==
null
))
{
// Dialogs have to be opened from the UI thread
CryptableMailItem
.
mixedConfigWarning
=
new
CustomMessageBox
(
Properties
.
Resources
.
Message_TitleWarning
,
string
.
Format
(
Properties
.
Resources
.
MixedConfigWarning_MessageText
,
this
.
internalMailItem
.
GetMyselfIdentity
().
Address
),
Properties
.
Resources
.
Options_OKText
,
CustomMessageBox
.
CustomMessageBoxOptions
.
DoNotShowAgainCheckBox
);
DialogHost
.
UIThreadDispatcher
?.
Invoke
(()
=>
{
// Create the message box and show it
CryptableMailItem
.
mixedConfigWarning
=
new
CustomMessageBox
{
ButtonCancelText
=
null
,
ButtonConfirmText
=
Properties
.
Resources
.
Options_OKText
,
MessageBoxText
=
string
.
Format
(
Properties
.
Resources
.
MixedConfigWarning_MessageText
,
this
.
internalMailItem
.
GetMyselfIdentity
().
Address
),
Title
=
Properties
.
Resources
.
Message_TitleWarning
,
IsDoNotShowAgainVisible
=
true
};
CryptableMailItem
.
mixedConfigWarning
.
ShowDialog
();
// Check if user selected the 'Do not show again' checkbox
Globals
.
ThisAddIn
.
Settings
.
ShowMixedConfigWarning
=
!
CryptableMailItem
.
mixedConfigWarning
.
IsDoNotShowAgainChecked
;
new
DialogHost
(
CryptableMailItem
.
mixedConfigWarning
).
ShowAsOutlookChild
(
true
);
Globals
.
ThisAddIn
.
Settings
.
ShowMixedConfigWarning
=
!
CryptableMailItem
.
mixedConfigWarning
.
DoNotShowAgain
;
if
(
Globals
.
ThisAddIn
.
Settings
.
ShowMixedConfigWarning
)
{
// Even if 'Do not show again' hasn't been selected, wait 5 minutes for next dialog
...
...
@@ -1301,7 +1294,7 @@ namespace pEp
if
(
processedMessage
.
Attachments
.
Count
==
hiddenAttachmentsCount
)
{
// Note: The documented MAPI property PidLidSmartNoAttach (0x8514000B) doesn't work for some reason
result
.
PropertiesToSet
.
Add
(
MapiProperty
.
PidTagSmartNoAttach2
,
true
);
result
.
PropertiesToSet
.
Try
Add
(
MapiProperty
.
PidTagSmartNoAttach2
,
true
);
}
}
...
...
MAPIProperties.cs
View file @
f2485c0e
...
...
@@ -132,6 +132,27 @@ namespace pEp
return
added
;
}
/// <summary>
/// Tries to add a given MAPI property value and logs any errors.
/// </summary>
/// <param name="mapiProperty">The MAPI property to add.</param>
/// <param name="value">The MAPI property value.</param>
/// <returns>True if the MAPI property was successfully added. Otherwise false.</returns>
internal
bool
TryAdd
(
MapiProperty
.
MapiProp
mapiProperty
,
object
value
)
{
try
{
this
.
Add
(
mapiProperty
,
value
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"TryAdd: Error adding property {0}. {1}"
,
mapiProperty
.
Name
,
ex
);
return
false
;
}
return
true
;
}
/// <summary>
/// Gets a PEPMessage property value from the dictionary.
/// </summary>
...
...
UI/DialogHost.cs
View file @
f2485c0e
...
...
@@ -75,6 +75,16 @@ namespace pEp.UI
this
.
Text
=
Properties
.
Resources
.
Options_FormText
;
}
break
;
case
Dialog
.
Type
.
CustomMessageBox
:
{
this
.
Text
=
(
dialog
as
CustomMessageBox
)?.
Title
;
}
break
;
case
Dialog
.
Type
.
InputMessageBox
:
{
// this.Text = (dialog as InputMessageBox)?.Title;
}
break
;
default
:
{
Log
.
Error
(
"DialogHost: Dialog type {0} not implemented. "
,
Enum
.
GetName
(
typeof
(
Dialog
.
Type
),
dialog
.
DialogType
));
...
...
UI/CustomMessageBox.
xaml.
cs
→
UI/
Models/
CustomMessageBox.cs
View file @
f2485c0e
using
System.ComponentModel
;
using
System.Runtime.CompilerServices
;
using
System.Windows
;
using
System
;
using
System.Windows.Forms
;
namespace
pEp.UI
namespace
pEp.UI
.Models
{
/// <summary>
/// Interaction logic for CustomMessageBox.xaml
/// </summary>
internal
partial
class
CustomMessageBox
:
Window
,
INotifyPropertyChanged
internal
class
CustomMessageBox
:
Dialog
{
private
bool
_IsDoNotShowAgainChecked
=
false
;
[
Flags
]
public
enum
CustomMessageBoxOptions
{
None
=
0
,
NoCancelButton
=
1
,
RedAndGreenButtons
=
2
,
DoNotShowAgainCheckBox
=
4
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
CustomMessageBox
()
:
base
(
Dialog
.
Type
.
CustomMessageBox
)
{
}
/// <summary>
///
Primary constructor
///
Constructor for informative message box with only a Confirm button.
/// </summary>
public
CustomMessageBox
()
/// <param name="title">The title of this message box.</param>
/// <param name="messageBoxText">The message box text.</param>
/// <param name="confirmButtonText">The Confirm button text.</param>
/// <param name="messageBoxOptions">Optional message box options.</param>
public
CustomMessageBox
(
string
title
,
string
messageBoxText
,
string
confirmButtonText
,
CustomMessageBoxOptions
messageBoxOptions
=
CustomMessageBoxOptions
.
NoCancelButton
)
:
this
(
title
,
messageBoxText
,
null
,
confirmButtonText
,
(
messageBoxOptions
|=
CustomMessageBoxOptions
.
NoCancelButton
))
{
InitializeComponent
();
this
.
DataContext
=
this
;
}
/// <summary>
///
Gets or sets the text of the Cancel but
to
n
.
///
Complete construc
to
r
.
/// </summary>
public
string
ButtonCancelText
{
get
;
set
;
}
/// <param name="title">The title of this message box.</param>
/// <param name="messageBoxText">The message box text.</param>
/// <param name="cancelButtonText">The Cancel button text.</param>
/// <param name="confirmButtonText">The Confirm button text.</param>
/// <param name="messageBoxOptions">Optional message box options.</param>
public
CustomMessageBox
(
string
title
,
string
messageBoxText
,
string
cancelButtonText
,
string
confirmButtonText
,
CustomMessageBoxOptions
messageBoxOptions
=
CustomMessageBoxOptions
.
None
)
:
this
()
{
this
.
Title
=
title
;
this
.
MessageBoxText
=
messageBoxText
;
this
.
CancelButtonText
=
cancelButtonText
;
this
.
ConfirmButtonText
=
confirmButtonText
;
this
.
MessageBoxOptions
=
messageBoxOptions
;
}
/// <summary>
/// Gets or sets the text of the C
onfirm
button.
/// Gets or sets the text of the C
ancel
button.
/// </summary>
public
string
Button
Confirm
Text
{
get
;
set
;
}
public
string
Cancel
ButtonText
{
get
;
}
/// <summary>
///
The command to execute when the Cancel button is clicked
.
///
Gets or sets the text of the Confirm button
.
/// </summary>
public
RelayCommand
CommandButtonCancel
{
get
{
return
new
RelayCommand
(
p
=>
{
this
.
DialogResult
=
false
;
this
.
Close
();
});
}
}
public
string
ConfirmButtonText
{
get
;
}
/// <summary>
///
T
he
command to execute when the Confirm button is clicked
.
///
W
he
ther to show this custom message box again
.
/// </summary>
public
RelayCommand
CommandButtonConfirm
{
get
{
return
new
RelayCommand
(
p
=>
{
this
.
DialogResult
=
true
;
this
.
Close
();
});
}
}
public
bool
DoNotShowAgain
{
get
;
set
;
}
/// <summary>
/// Gets
w
he
ther
/// Gets
t
he
message box text.
/// </summary>
public
bool
IsDoNotShowAgainChecked
{
get
=>
this
.
_IsDoNotShowAgainChecked
;
set
{
this
.
_IsDoNotShowAgainChecked
=
value
;
this
.
OnPropertyChanged
();
}
}
public
string
MessageBoxText
{
get
;
}
/// <summary>
/// Gets or sets whether the 'Do not show again' checkbox
/// is visible.
/// Gets the options of this message box.
/// </summary>
public
bool
IsDoNotShowAgainVisible
{
get
;
set
;
}
=
false
;
public
CustomMessageBoxOptions
MessageBoxOptions
{
get
;
}
/// <summary>
/// Ge
ts or sets the text in the input field.
/// Ge
hts the title of the MessageBox
/// </summary>
public
string
MessageBoxText
{
get
;
s
et
;
}
public
string
Title
{
g
et
;
}
/// <summary>
/// Event handler for when the given property changed.
/// </summary>
/// <param name="propertyName">The name of the property that changed its value.</param>
protected
virtual
void
OnPropertyChanged
([
CallerMemberName
]
string
propertyName
=
null
)
{
this
.
PropertyChanged
?.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
propertyName
));
}
#
region
Static
methods
/// <summary>
/// Shows the message box as dialog.
...
...
@@ -102,19 +95,15 @@ namespace pEp.UI
/// <param name="titleText">The text to display in the title of this message box.</param>
/// <param name="cancelButtonText">The text to display in the Cancel button.</param>
/// <param name="confirmButtonText">The text to display in the Confirm button.</param>
/// <param name="messageBoxOptions">Optional message box options.</param>
/// <returns>True if the dialog has been accepted (confirmed), otherwise false.</returns>
public
static
bool
ShowDialog
(
string
messageBoxText
,
string
titleText
,
string
cancelButtonText
,
string
confirmButtonText
)
public
static
bool
ShowDialog
(
string
messageBoxText
,
string
titleText
,
string
cancelButtonText
,
string
confirmButtonText
,
CustomMessageBox
.
CustomMessageBoxOptions
messageBoxOptions
=
CustomMessageBox
.
CustomMessageBoxOptions
.
None
)
{
return
new
CustomMessageBox
{
ButtonCancelText
=
cancelButtonText
,
ButtonConfirmText
=
confirmButtonText
,
MessageBoxText
=
messageBoxText
,
Title
=
titleText
}.
ShowDialog
()
??
false
;
return
CustomMessageBox
.
ShowDialog
(
messageBoxText
,
titleText
,
cancelButtonText
,
confirmButtonText
,
out
_
,
messageBoxOptions
);
}
/// <summary>
...
...
@@ -125,24 +114,22 @@ namespace pEp.UI
/// <param name="cancelButtonText">The text to display in the Cancel button.</param>
/// <param name="confirmButtonText">The text to display in the Confirm button.</param>
/// <param name="doNotShowAgain">Whether to show the message box again.</param>
/// <param name="messageBoxOptions">Optional message box options.</param>
/// <returns>True if the dialog has been accepted (confirmed), otherwise false.</returns>
public
static
bool
ShowDialog
(
string
messageBoxText
,
public
static
bool
ShowDialog
(
string
messageBoxText
,
string
titleText
,
string
cancelButtonText
,
string
confirmButtonText
,
out
bool
doNotShowAgain
)
out
bool
doNotShowAgain
,
CustomMessageBox
.
CustomMessageBoxOptions
messageBoxOptions
=
CustomMessageBox
.
CustomMessageBoxOptions
.
DoNotShowAgainCheckBox
)
{
CustomMessageBox
messageBox
=
new
CustomMessageBox
{
ButtonCancelText
=
cancelButtonText
,
ButtonConfirmText
=
confirmButtonText
,
MessageBoxText
=
messageBoxText
,
Title
=
titleText
,
IsDoNotShowAgainChecked
=
true
};
bool
result
=
messageBox
.
ShowDialog
()
??
false
;
doNotShowAgain
=
messageBox
.
IsDoNotShowAgainChecked
;
return
result
;
messageBoxOptions
|=
CustomMessageBox
.
CustomMessageBoxOptions
.
DoNotShowAgainCheckBox
;
CustomMessageBox
customMessageBox
=
new
CustomMessageBox
(
titleText
,
messageBoxText
,
cancelButtonText
,
confirmButtonText
,
messageBoxOptions
);
DialogResult
dialogResult
=
new
DialogHost
(
customMessageBox
).
ShowAsOutlookChild
(
true
);
doNotShowAgain
=
customMessageBox
.
DoNotShowAgain
;
return
(
dialogResult
==
DialogResult
.
OK
);
}
#
endregion
}
}
\ No newline at end of file
}
UI/Models/Dialog.cs
View file @
f2485c0e
...
...
@@ -13,7 +13,9 @@
IntroTutorial
,
ForceProtection
,
GroupInvite
,
Options
Options
,
CustomMessageBox
,
InputMessageBox
}
/// <summary>
...
...
UI/Models/MessageGroup.cs
View file @
f2485c0e
...
...
@@ -3,20 +3,6 @@ using System.Collections.Generic;
namespace
pEp.UI.Models
{
public
struct
pEpMember
{
public
pEpCOMServerAdapterLib
.
pEpIdentity
ident
;
public
bool
joined
;
}
public
struct
pEpGroup
{
public
pEpCOMServerAdapterLib
.
pEpIdentity
groupIdentity
;
public
pEpCOMServerAdapterLib
.
pEpIdentity
manager
;
public
pEpMember
[]
members
;
public
bool
active
;
};
internal
class
MessageGroup
{
/// <summary>
...
...
@@ -32,7 +18,7 @@ namespace pEp.UI.Models
/// <summary>
/// The group members.
/// </summary>
public
List
<
pEp
Member
>
GroupMembers
{
get
;
}
=
new
List
<
pEp
Member
>();
public
List
<
pEp
Identity
>
GroupMembers
{
get
;
}
=
new
List
<
pEp
Identity
>();
/// <summary>
/// Gets or sets the pEp rating of this group.
...
...
@@ -52,17 +38,15 @@ namespace pEp.UI.Models
}
/// <summary>
///
Secondary constructor
.
///
Constructor for message group with existing members
.
/// </summary>
/// <param name="groupIdentity">The group identity.</param>
/// <param name="groupManager">The group manager.</param>
/// <param name="groupMembers">The group members.</param>
public
MessageGroup
(
pEpGroup
group
)
:
this
(
group
.
groupIdentity
,
group
.
manager
)
/// <param name="groupMembers">The group manager.</param>
public
MessageGroup
(
pEpIdentity
groupIdentity
,
pEpIdentity
groupManager
,
List
<
pEpIdentity
>
groupMembers
)
:
this
(
groupIdentity
,
groupManager
)
{
foreach
(
pEpMember
groupMember
in
group
.
members
)
{
this
.
GroupMembers
.
Add
(
groupMember
);
}
this
.
GroupMembers
=
groupMembers
;
}
/// <summary>
...
...
@@ -71,9 +55,7 @@ namespace pEp.UI.Models
/// <returns>The group rating.</returns>
private
pEpRating
GetGroupRating
()
{
pEpRating
groupRating
=
pEpRating
.
pEpRatingUndefined
;
AdapterExtensions
.
ExecuteAndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupRating
(
this
.
GroupIdentity
,
this
.
GroupManager
,
out
groupRating
));
return
groupRating
;
return
AdapterExtensions
.
ExecuteWithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupRating
(
this
.
GroupIdentity
,
this
.
GroupManager
))
as
pEpRating
?
??
pEpRating
.
pEpRatingUndefined
;
}
/// <summary>
...
...
@@ -86,17 +68,5 @@ namespace pEp.UI.Models
groupIdentity
.
UserName
=
name
;
this
.
GroupIdentity
=
groupIdentity
;
}
/// <summary>
/// Creates a new message group.
/// </summary>
/// <param name="groupIdentity">The identity object representing the group.</param>
/// <param name="groupManager">The group manager.</param>
/// <param name="memberList">The list of members.</param>
/// <returns></returns>
public
static
void
Create
(
pEpIdentity
groupIdentity
,
pEpIdentity
groupManager
,
List
<
pEpIdentity
>
memberList
)
{
AdapterExtensions
.
ExecuteAndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupCreate
(
groupIdentity
,
groupManager
,
memberList
.
ToArray
()));
}
}
}
UI/Models/OptionsDialog.cs
View file @
f2485c0e
...
...
@@ -17,7 +17,6 @@ namespace pEp.UI.Models
public
OptionsViewModel
.
OptionPages
StartPage
{
get
;
}
/// <summary>
/// Primary constructor.
/// </summary>
...
...
@@ -38,13 +37,13 @@ namespace pEp.UI.Models
}
// Get groups the user is subscribed to
if
(
this
.
GetSubscribedGroups
()
is
List
<
MessageGroup
>
subscribedGroups
)
{
foreach
(
var
messageGroup
in
subscribedGroups
)
{
this
.
SubscribedGroups
.
Add
(
new
MessageGroupViewModel
(
messageGroup
));
}
}
//
if (this.GetSubscribedGroups() is List<MessageGroup> subscribedGroups)
//
{
//
foreach (var messageGroup in subscribedGroups)
//
{
//
this.SubscribedGroups.Add(new MessageGroupViewModel(messageGroup));
//
}
//
}
}
/// <summary>
...
...
@@ -55,17 +54,30 @@ namespace pEp.UI.Models
{
var
messageGroups
=
new
List
<
MessageGroup
>();
//if (AdapterExtensions.ExecuteAndLogError(() => ThisAddIn.PEPEngine.GroupQueryGroups()) is pEpIdentity[] groups)
//{
// foreach (var group in groups)
// {
// pEpIdentity manager = AdapterExtensions.ExecuteAndLogError(() => ThisAddIn.PEPEngine.GroupQueryManager(group));
// pEpIdentity[] members = AdapterExtensions.ExecuteAndLogError(() => ThisAddIn.PEPEngine.GroupQueryMembers(group));
if
(
AdapterExtensions
.
ExecuteAndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupQueryGroups
())
is
pEpIdentity
[]
groups
)
{
foreach
(
var
groupIdentity
in
groups
)
{
try
{
// Get group manager
pEpIdentity
groupManager
=
(
pEpIdentity
)
AdapterExtensions
.
ExecuteWithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupQueryManager
(
groupIdentity
));
Log
.
Verbose
(
"GetManagedGroupe: Retrieved group manager "
+
groupManager
.
Address
);
// Get group members
pEpIdentity
[]
members
=
(
pEpIdentity
[])
AdapterExtensions
.
ExecuteWithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupQueryMembers
(
groupIdentity
));
Log
.
Verbose
(
"GetManagedGroupe: Retrieved group {0} group members"
+
members
.
Length
);
// Add group
messageGroups
.
Add
(
new
MessageGroup
(
groupIdentity
,
groupManager
,
members
.
ToList
()));
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"GetManagedGroups: Error querying groups. "
+
ex
.
ToString
());
}
// messageGroups.Add(new MessageGroup(group, manager, members));
// }
//}
messageGroups
=
this
.
CreateDummyList
();
}
}
return
messageGroups
;
}
...
...
@@ -74,10 +86,10 @@ namespace pEp.UI.Models
/// Gets a list of groups the user is part of from the adapter.
/// </summary>
/// <returns>The groups that the user is subscribed to.</returns>
private
List
<
MessageGroup
>
GetSubscribedGroups
()
{
return
this
.
CreateDummyList
();
}
//
private List<MessageGroup> GetSubscribedGroups()
//
{
//
return this.CreateDummyList();
//
}
/// <summary>
/// Updates the settings and synchronize changes.
...
...
@@ -121,7 +133,7 @@ namespace pEp.UI.Models
{
if
(
this
.
ManagedGroups
.
Any
(
mg
=>
mg
.
GroupIdentity
.
Address
==
group
.
GroupIdentity
.
Address
)
==
false
)
{
AdapterExtensions
.
Execute
AndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupDissolve
(
group
.
GroupIdentity
,
group
.
GroupManager
));
AdapterExtensions
.
Execute
WithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupDissolve
(
group
.
GroupIdentity
,
group
.
GroupManager
));
}
});
...
...
@@ -143,19 +155,19 @@ namespace pEp.UI.Models
// Remove members
group
?.
GroupMembers
?.
ForEach
((
member
)
=>
{
if
(
messageGroupViewModel
.
GroupMembers
?.
Any
(
a
=>
a
.
PEPIdentity
.
Address
.
Equals
(
member
.
ident
.
Address
))
==
false
)
if
(
messageGroupViewModel
.
GroupMembers
?.
Any
(
a
=>
a
.
PEPIdentity
.
Address
.
Equals
(
member
.
Address
))
==
false
)
{
AdapterExtensions
.
Execute
AndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupRemoveMember
(
group
.
GroupIdentity
,
member
.
ident
));
AdapterExtensions
.
Execute
WithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupRemoveMember
(
group
.
GroupIdentity
,
member
));
}
});
// Invite new members
messageGroupViewModel
.
GroupMembers
?.
ToList
()?.
ForEach
((
member
)
=>
{
if
(
group
.
GroupMembers
?.
Any
(
a
=>
a
.
ident
.
Address
.
Equals
(
member
.
PEPIdentity
.
Address
))
==
false
)
if
(
group
.
GroupMembers
?.
Any
(
a
=>
a
.
Address
.
Equals
(
member
.
PEPIdentity
.
Address
))
==
false
)
{
pEpIdentity
newGroupMember
=
member
.
PEPIdentity
.
ToCOMType
();
AdapterExtensions
.
Execute
AndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupInviteMember
(
group
.
GroupIdentity
,
newGroupMember
));
AdapterExtensions
.
Execute
WithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupInviteMember
(
group
.
GroupIdentity
,
newGroupMember
));
}
});
}
...
...
@@ -176,12 +188,12 @@ namespace pEp.UI.Models
try
{
// First try to create the group
ThisAddIn
.
PEPEngine
.
GroupCreate
(
group
.
GroupIdentity
,
group
.
GroupManager
,
memberlist
.
ToArray
());
AdapterExtensions
.
ExecuteWithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupCreate
(
group
.
GroupIdentity
,
group
.
GroupManager
,
memberlist
.
ToArray
())
)
;
// Only invite members if group was created successfully
memberlist
.
ForEach
((
member
)
=>
{
AdapterExtensions
.
Execute
AndLogError
(()
=>
ThisAddIn
.
PEPEngine
.
GroupInviteMember
(
group
.
GroupIdentity
,
member
));
AdapterExtensions
.
Execute
WithPassphraseCheck
(()
=>
ThisAddIn
.
PEPEngine
.
GroupInviteMember
(
group
.
GroupIdentity
,
member
));
});
}
catch
(
Exception
ex
)
...
...
@@ -191,46 +203,5 @@ namespace pEp.UI.Models
}
});
}
private
List
<
MessageGroup
>
CreateDummyList
()
{
return
new
List
<
MessageGroup
>
{
new
MessageGroup
(
new
pEpIdentity
{
Address
=
"gi1@peptest.ch"
,
UserName
=
"Test 1"
},
new
pEpIdentity
{
Address
=
"groupManager@peptest.ch"
})
{
GroupMembers
=
{
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test2@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test3@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test4@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test5@peptest.ch"
}
}
}
},
new
MessageGroup
(
new
pEpIdentity
{
Address
=
"gi2@peptest.ch"
,
UserName
=
"Test 2"
},
new
pEpIdentity
{
Address
=
"groupManager@peptest.ch"
})
{
GroupMembers
=
{
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test1@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test6@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test7@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test8@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test9@peptest.ch"
}
}
}
},
new
MessageGroup
(
new
pEpIdentity
{
Address
=
"gi3@peptest.ch"
,
UserName
=
"Test 3"
},
new
pEpIdentity
{
Address
=
"groupManager@peptest.ch"
})
{
GroupMembers
=
{
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test1@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test2@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test5@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test8@peptest.ch"
}
},
new
pEpMember
{
ident
=
new
pEpIdentity
{
Address
=
"test9@peptest.ch"
}
}
}
}
};
}
}
}
UI/ViewModels/CustomMessageBoxViewModel.cs
0 → 100644
View file @
f2485c0e
using
pEp.UI.Models
;
using
System
;
using
System.Windows
;
namespace
pEp.UI.ViewModels
{
internal
class
CustomMessageBoxViewModel
:
DialogHostViewModel
{
private
CustomMessageBox
customMessageBox
;
public
CustomMessageBoxViewModel
(
CustomMessageBox
dialog
,
Action
closeDialogAction
)
:
base
(
dialog
,
closeDialogAction
)
{
this
.
customMessageBox
=
dialog
;
if
(
customMessageBox
.
MessageBoxOptions
.
HasFlag
(
CustomMessageBox
.
CustomMessageBoxOptions
.
RedAndGreenButtons
))
{
this
.
CancelButtonStyle
=
Globals
.
ResourceDict
[
"StyleButtonRed"
]
as
Style
;
this
.
ConfirmButtonStyle
=
Globals
.
ResourceDict
[
"StyleButtonGreen"
]
as
Style
;
}
else
{
this
.
CancelButtonStyle
=
Globals
.
ResourceDict
[
"StyleButtonGray"
]
as
Style
;
this
.
ConfirmButtonStyle
=
Globals
.
ResourceDict
[
"StyleButtonGray"
]
as
Style
;
}
}
/// <summary>
/// Gets or sets the text of the Cancel button.
/// </summary>
public
string
CancelButtonText
=>
this
.
customMessageBox
.
CancelButtonText
;
/// <summary>
/// Gets the style of the Cancel button.
/// </summary>
public
Style
CancelButtonStyle
{
get
;
}
/// <summary>
/// Gets or sets the text of the Confirm button.
/// </summary>
public
string
ConfirmButtonText
=>
this
.
customMessageBox
.
ConfirmButtonText
;
/// <summary>
/// Gets the style of the Confirm button.
/// </summary>
public
Style
ConfirmButtonStyle
{
get
;
}
/// <summary>
/// The command to execute when the Cancel button is clicked.
/// </summary>
public
RelayCommand
CancelButtonCommand
{
get
{
return
new
RelayCommand
(
p
=>
base
.
Close
(
false
));
}
}
/// <summary>
/// The command to execute when the Confirm button is clicked.
/// </summary>
public
RelayCommand
ConfirmButtonCommand
{
get
{
return
new
RelayCommand
(
p
=>
base
.
Close
(
true
));
}
}
/// <summary>
/// Whether the Cancel button is visible.
/// </summary>
public
bool
IsCancelButtonVisible
=>
(
this
.
customMessageBox
.
MessageBoxOptions
.
HasFlag
(
CustomMessageBox
.
CustomMessageBoxOptions
.
NoCancelButton
)
==
false
);
/// <summary>
/// Gets or sets whether the 'Do not show again' checkbox is checked.
/// </summary>
public
bool
IsDoNotShowAgainChecked
{
get
=>
this
.
customMessageBox
.
DoNotShowAgain
;
set
{
this
.
customMessageBox
.
DoNotShowAgain
=
value
;
this
.
OnPropertyChanged
();
}
}
/// <summary>
/// Gets or sets whether the 'Do not show again' checkbox is visible.
/// </summary>
public
bool
IsDoNotShowAgainVisible
=>
this
.
customMessageBox
.
MessageBoxOptions
.
HasFlag
(
CustomMessageBox
.
CustomMessageBoxOptions
.
DoNotShowAgainCheckBox
);
/// <summary>
/// Gets the message box text.
/// </summary>
public
string
MessageBoxText
=>
this
.
customMessageBox
.
MessageBoxText
;
/// <summary>
/// Gehts the title of the MessageBox
/// </summary>
public
string
Title
=>
this
.
customMessageBox
.
Title
;
}
}
UI/ViewModels/DialogHostViewModel.cs
View file @
f2485c0e
...
...
@@ -10,7 +10,7 @@ namespace pEp.UI.ViewModels
/// <summary>
/// The action to close the dialog window.
/// </summary>
p
ublic
Action
C
loseDialogAction
{
get
;
}
p
rivate
readonly
Action
c
loseDialogAction
=
null
;
/// <summary>
/// The dialog object.
...
...
@@ -20,7 +20,7 @@ namespace pEp.UI.ViewModels
/// <summary>
/// The result of the dialog.
/// </summary>
public
bool
?
DialogResult
{
get
;
set
;
}
public
bool
?
DialogResult
{
get
;
private
set
;
}
/// <summary>
/// Command for when the Close button is being clicked.
...
...
@@ -31,7 +31,7 @@ namespace pEp.UI.ViewModels
{
if
(
this
.
_CommandButtonClose
==
null
)
{
this
.
_CommandButtonClose
=
new
RelayCommand
(
p
=>
this
.
C
loseDialogAction
?.
Invoke
());
this
.
_CommandButtonClose
=
new
RelayCommand
(
p
=>
this
.
c
loseDialogAction
?.
Invoke
());
}
return
this
.
_CommandButtonClose
;
...
...
@@ -45,7 +45,16 @@ namespace pEp.UI.ViewModels
public
DialogHostViewModel
(
Dialog
dialog
,
Action
closeDialogAction
)
{
this
.
Dialog
=
dialog
;
this
.
CloseDialogAction
=
closeDialogAction
;
this
.
closeDialogAction
=
closeDialogAction
;
}
/// <summary>
/// Invokes the Close action and closes the parent dialog.
/// </summary>
public
void
Close
(
bool
?
dialogResult
)
{
this
.
DialogResult
=
dialogResult
;
this
.
closeDialogAction
?.
Invoke
();
}
}
}
UI/ViewModels/HandshakeViewModel.cs
View file @
f2485c0e
...
...
@@ -421,8 +421,7 @@ namespace pEp.UI.ViewModels
// Update the view
if
(
this
.
Parent
.
Dialog
.
DialogType
==
Dialog
.
Type
.
ForceProtection
)
{
this
.
Parent
.
DialogResult
=
false
;
this
.
Parent
.
CloseDialogAction
.
Invoke
();
this
.
Parent
.
Close
(
false
);
}
else
{
...
...
@@ -456,8 +455,7 @@ namespace pEp.UI.ViewModels
// Update the view
if
(
this
.
Parent
.
Dialog
.
DialogType
==
Dialog
.
Type
.
ForceProtection
)
{
this
.
Parent
.
DialogResult
=
true
;
this
.
Parent
.
CloseDialogAction
.
Invoke
();
this
.
Parent
.
Close
(
true
);
}
else
{
...
...
UI/ViewModels/MessageGroupInviteViewModel.cs
View file @
f2485c0e
...
...
@@ -37,7 +37,7 @@ namespace pEp.UI.ViewModels
{
if
(
this
.
_CancelCommand
==
null
)
{
this
.
_CancelCommand
=
new
RelayCommand
(
p
=>
this
.
Close
DialogAction
?.
Invoke
(
));
this
.
_CancelCommand
=
new
RelayCommand
(
p
=>
base
.
Close
(
false
));
}
return
this
.
_CancelCommand
;
...
...
UI/ViewModels/MessageGroupViewModel.cs
View file @
f2485c0e
...
...
@@ -99,7 +99,7 @@ namespace pEp.UI.ViewModels
foreach
(
var
member
in
messageGroup
.
GroupMembers
)
{
this
.
GroupMembers
.
Add
(
new
MessageGroupMemberViewModel
(
this
,
new
PEPIdentity
(
member
.
ident
.
Address
)));
this
.
GroupMembers
.
Add
(
new
MessageGroupMemberViewModel
(
this
,
new
PEPIdentity
(
member
)));
}
}
...
...
UI/ViewModels/OptionsViewModel.cs
View file @
f2485c0e
...
...
@@ -128,11 +128,7 @@ namespace pEp.UI.ViewModels
{
if
(
this
.
_CommandButtonCancel
==
null
)
{
this
.
_CommandButtonCancel
=
new
RelayCommand
(
p
=>
{
this
.
DialogResult
=
null
;
this
.
CloseDialogAction
.
Invoke
();
});
this
.
_CommandButtonCancel
=
new
RelayCommand
(
p
=>
base
.
Close
(
null
));
}
return
this
.
_CommandButtonCancel
;
...
...
@@ -216,11 +212,7 @@ namespace pEp.UI.ViewModels
{
if
(
this
.
_CommandButtonOK
==
null
)
{
this
.
_CommandButtonOK
=
new
RelayCommand
(
p
=>
{
this
.
DialogResult
=
true
;
this
.
CloseDialogAction
.
Invoke
();
});
this
.
_CommandButtonOK
=
new
RelayCommand
(
p
=>
base
.
Close
(
true
));
}
return
this
.
_CommandButtonOK
;
...
...
UI/ViewModels/WizardViewModelBase.cs
View file @
f2485c0e
...
...
@@ -241,8 +241,7 @@ namespace pEp.UI.ViewModels
/// </summary>
private
void
CancelDialog
()
{
this
.
DialogResult
=
null
;
this
.
CloseDialogAction
?.
Invoke
();
base
.
Close
(
null
);
}
/// <summary>
...
...
@@ -269,7 +268,7 @@ namespace pEp.UI.ViewModels
{
if
(
this
.
IsLastPage
)
{
this
.
Close
DialogAction
?.
Invoke
(
);
base
.
Close
(
true
);
}
else
{
...
...
@@ -311,8 +310,8 @@ namespace pEp.UI.ViewModels
{
Log
.
Error
(
"RejectHandshake: Error delivering handshake result. "
+
ex
.
ToString
());
}
this
.
DialogResult
=
false
;
this
.
Close
DialogAction
?.
Invoke
(
);
base
.
Close
(
false
);
}
break
;
case
Dialog
.
Type
.
IntroTutorial
:
...
...
UI/CustomMessageBox.xaml
→
UI/
Views/
CustomMessageBox
View
.xaml
View file @
f2485c0e
<Window x:Class="pEp.UI.CustomMessageBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:pEp.UI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:p="clr-namespace:pEp.Properties"
x:ClassModifier="internal"
Icon="pack://application:,,,/pEp;component/Resources/ImageLogoIcon.png"
mc:Ignorable="d"
Width="480"
WindowStartupLocation="CenterScreen"
SizeToContent="Height"
Background="WhiteSmoke"
ResizeMode="NoResize">
<Window.Resources>
<UserControl x:Class="pEp.UI.Views.CustomMessageBoxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:core="clr-namespace:System;assembly=mscorlib"
xmlns:p="clr-namespace:pEp.Properties"
xmlns:local="clr-namespace:pEp.UI"
x:ClassModifier="internal"
mc:Ignorable="d"
Width="480"
Background="WhiteSmoke">
<UserControl.Resources>
<ResourceDictionary>
<!-- Dictionary -->
<ResourceDictionary.MergedDictionaries>
...
...
@@ -26,7 +23,7 @@
<BooleanToVisibilityConverter />
</local:ValueConverterGroup>
</ResourceDictionary>
</
Window
.Resources>
</
UserControl
.Resources>
<StackPanel Margin="10">
...
...
@@ -39,17 +36,19 @@
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right">
<Button Style="{StaticResource StyleButtonGray}"
<Button Name="ConfirmButton"
Style="{Binding ConfirmButtonStyle}"
HorizontalAlignment="Center"
Margin="5,5,0,5"
Content="{Binding ButtonConfirmText}"
Command="{Binding CommandButtonConfirm}"/>
<Button Style="{StaticResource StyleButtonGray}"
Content="{Binding ConfirmButtonText}"
Command="{Binding ConfirmButtonCommand}"/>
<Button Name="CancelButton"
Style="{Binding CancelButtonStyle}"
HorizontalAlignment="Center"
Margin="5,5,0,5"
Content="{Binding
Button
CancelText}"
Command="{Binding C
ommand
ButtonC
ancel
}"
Visibility="{Binding
ButtonCancelText
, Mode=OneWay, Converter={StaticResource
IsStringNotEmpty
ToVisibility}}" />
Content="{Binding Cancel
Button
Text}"
Command="{Binding C
ancel
ButtonC
ommand
}"
Visibility="{Binding
IsCancelButtonVisible
, Mode=OneWay, Converter={StaticResource
Bool
ToVisibility}}" />
</StackPanel>
<CheckBox Content="{x:Static p:Resources.CustomMessageBoxDoNotShowAgain}"
...
...
@@ -59,4 +58,4 @@
Visibility="{Binding IsDoNotShowAgainVisible, Converter={StaticResource BoolToVisibility}}"/>
</StackPanel>
</
Window
>
</
UserControl
>
UI/Views/CustomMessageBoxView.xaml.cs
0 → 100644
View file @
f2485c0e
using
System.Windows.Controls
;
namespace
pEp.UI.Views
{
/// <summary>
/// Interaction logic for CustomMessageBoxView.xaml
/// </summary>
internal
partial
class
CustomMessageBoxView
:
UserControl
{
/// <summary>
/// Primary constructor.
/// </summary>
public
CustomMessageBoxView
()
{
InitializeComponent
();
}
}
}
\ No newline at end of file
UI/Views/DialogHostView.xaml
View file @
f2485c0e
...
...
@@ -25,5 +25,8 @@
<DataTemplate DataType="{x:Type vm:OptionsViewModel}">
<v:OptionsView />
</DataTemplate>
<DataTemplate DataType="{x:Type vm:CustomMessageBoxViewModel}">
<v:CustomMessageBoxView />
</DataTemplate>
</UserControl.Resources>
</UserControl>
UI/Views/DialogHostView.xaml.cs
View file @
f2485c0e
...
...
@@ -31,6 +31,12 @@ namespace pEp.UI.Views
// Assign the necessary ViewModel according to the dialog type.
switch
(
dialog
.
DialogType
)
{
case
Dialog
.
Type
.
CustomMessageBox
:
{
Debug
.
Assert
(
dialog
is
CustomMessageBox
);
this
.
Content
=
new
CustomMessageBoxViewModel
(
dialog
as
CustomMessageBox
,
closeDialogAction
);
}
break
;
case
Dialog
.
Type
.
Handshake
:
{
Debug
.
Assert
(
dialog
is
HandshakeDialog
);
...
...
pEpForOutlook.csproj
View file @
f2485c0e
...
...
@@ -406,8 +406,10 @@
<DependentUpon>
Resources.tr.resx
</DependentUpon>
</Compile>
<Compile
Include=
"Sequoia.cs"
/>
<Compile
Include=
"UI\CustomMessageBox.xaml.cs"
>
<DependentUpon>
CustomMessageBox.xaml
</DependentUpon>
<Compile
Include=
"UI\Models\CustomMessageBox.cs"
/>
<Compile
Include=
"UI\ViewModels\CustomMessageBoxViewModel.cs"
/>
<Compile
Include=
"UI\Views\CustomMessageBoxView.xaml.cs"
>
<DependentUpon>
CustomMessageBoxView.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"UI\DialogHost.cs"
>
<SubType>
Form
</SubType>
...
...
@@ -664,7 +666,7 @@
<Resource
Include=
"Resources\ImagePrivacyStatusYellow.png"
/>
</ItemGroup>
<ItemGroup>
<Page
Include=
"UI\CustomMessageBox.xaml"
>
<Page
Include=
"UI\
Views\
CustomMessageBox
View
.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
...
...