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
Commits
1faf3e0a
Commit
1faf3e0a
authored
Feb 22, 2021
by
Thomas
Browse files
Renaming and reordering
parent
586db39c
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
146 deletions
+100
-146
CryptableMailItem.cs
CryptableMailItem.cs
+9
-15
Extensions/MailItemExtensions.cs
Extensions/MailItemExtensions.cs
+4
-43
MAPIHelper.cs
MAPIHelper.cs
+15
-4
Mapi.cs
Mapi.cs
+66
-66
MsgProcessor.cs
MsgProcessor.cs
+3
-9
PEPAttachment.cs
PEPAttachment.cs
+2
-8
Wrappers/WatchedWindow.cs
Wrappers/WatchedWindow.cs
+1
-1
No files found.
CryptableMailItem.cs
View file @
1faf3e0a
...
...
@@ -1752,7 +1752,7 @@ namespace pEp
if
(
Globals
.
ThisAddIn
.
Settings
.
EnableNativeMethods
&&
result
.
PropertiesToSet
.
Count
>
0
)
{
if
(
mailItem
.
Set
MAPI
Properties
(
result
.
PropertiesToSet
))
if
(
mailItem
.
SetProperties
Native
(
result
.
PropertiesToSet
))
{
saveItem
=
true
;
}
...
...
@@ -1770,25 +1770,19 @@ namespace pEp
{
if
(
Globals
.
ThisAddIn
.
Settings
.
EnableNativeMethods
)
{
saveItem
=
Mapi
.
SetMAPIProperties
(
attachment
,
new
MapiProperty
.
MapiProp
[]
{
MapiProperty
.
PidTagAttachmentHidden
,
MapiProperty
.
PidTagAttachFlags
},
new
object
[]
{
true
,
4
});
saveItem
=
Mapi
.
SetPropertiesNative
(
attachment
,
new
MAPIProperties
{
{
MapiProperty
.
PidTagAttachmentHidden
,
true
},
{
MapiProperty
.
PidTagAttachFlags
,
4
}
});
}
else
{
saveItem
=
(
MapiHelper
.
SetProperties
(
attachment
,
new
MAPIProperties
saveItem
=
MapiHelper
.
SetProperties
(
attachment
,
new
MAPIProperties
{
{
MapiProperty
.
PidTagAttachmentHidden
,
true
},
{
MapiProperty
.
PidTagAttachFlags
,
4
}
})
==
null
)
;
});
}
attachment
=
null
;
...
...
@@ -2197,7 +2191,7 @@ namespace pEp
internal
class
ProcessingResult
{
public
pEpRating
Rating
{
get
;
set
;
}
=
pEpRating
.
pEpRatingUndefined
;
public
Dictionary
<
MapiProperty
.
MapiProp
,
object
>
PropertiesToSet
{
get
;
set
;
}
=
new
Dictionary
<
MapiProperty
.
MapiProp
,
object
>
();
public
MAPIProperties
PropertiesToSet
{
get
;
set
;
}
=
new
MAPIProperties
();
public
bool
HiddenAttachments
=
false
;
}
}
...
...
Extensions/MailItemExtensions.cs
View file @
1faf3e0a
...
...
@@ -3252,51 +3252,12 @@ namespace pEp
/// Sets the given MAPI properties on the Outlook mail item using native p/invoke methods.
/// </summary>
/// <param name="omi">The Outlook mail item to process with.</param>
/// <param name="
p
roperties">The MAPI properties to set.</param>
/// <param name="
mapiP
roperties">The MAPI properties to set.</param>
/// <returns>True if the method succeeds, otherwise false.</returns>
public
static
bool
Set
MAPI
Properties
(
this
Outlook
.
MailItem
omi
,
Dictionary
<
MapiProperty
.
MapiProp
,
object
>
p
roperties
)
public
static
bool
SetProperties
Native
(
this
Outlook
.
MailItem
omi
,
MAPIProperties
mapiP
roperties
)
{
bool
success
=
false
;
int
count
=
properties
?.
Count
??
0
;
if
(
count
>
0
)
{
try
{
// Create the necessary arrays
MapiProperty
.
MapiProp
[]
props
=
new
MapiProperty
.
MapiProp
[
count
];
object
[]
values
=
new
object
[
count
];
int
i
=
0
;
foreach
(
var
kvPair
in
properties
)
{
props
[
i
]
=
kvPair
.
Key
;
values
[
i
]
=
kvPair
.
Value
;
}
// Use the adequate method
if
(
count
==
1
)
{
success
=
Mapi
.
SetMAPIProperty
(
omi
,
props
[
0
],
values
[
0
]);
}
else
{
success
=
Mapi
.
SetMAPIProperties
(
omi
,
props
,
values
);
}
}
catch
(
Exception
ex
)
{
success
=
false
;
Log
.
Error
(
"MailItemExtensions.SetMAPIProperties: Error occured. "
+
ex
.
ToString
());
}
}
else
{
Log
.
Verbose
(
"MailItemExtensions.SetMAPIProperties: No properties found."
);
}
return
success
;
return
Mapi
.
SetPropertiesNative
(
omi
,
mapiProperties
);
}
/// <summary>
...
...
MAPIHelper.cs
View file @
1faf3e0a
...
...
@@ -168,9 +168,9 @@ namespace pEp
/// </summary>
/// <param name="attachment">The Outlook attachment to set the properties to.</param>
/// <param name="properties">The properties to set.</param>
/// <returns>
Null
if successful o
r a dictionary of MAPI properties and their returned error messages
.</returns>
public
static
Dictionary
<
string
,
object
>
SetProperties
(
Outlook
.
Attachment
attachment
,
MAPIProperties
properties
)
/// <returns>
True
if successful
,
o
therwise false
.</returns>
public
static
bool
SetProperties
(
Outlook
.
Attachment
attachment
,
MAPIProperties
properties
)
{
dynamic
result
=
null
;
Outlook
.
PropertyAccessor
propertyAccessor
=
null
;
...
...
@@ -179,18 +179,29 @@ namespace pEp
{
propertyAccessor
=
attachment
.
PropertyAccessor
;
result
=
MapiHelper
.
SetProperties
(
propertyAccessor
,
properties
);
if
(
result
is
Dictionary
<
string
,
object
>
errors
)
{
foreach
(
var
error
in
errors
)
{
Log
.
Error
(
"SetProperties: Error setting attachment property {0} : {1}"
,
error
.
Key
,
error
.
Value
);
}
return
false
;
}
}
catch
(
Exception
ex
)
{
result
=
null
;
Log
.
Error
(
"SetProperties: Error occured. "
+
ex
.
ToString
());
return
false
;
}
finally
{
propertyAccessor
=
null
;
}
return
result
;
return
true
;
}
/// <summary>
...
...
Mapi.cs
View file @
1faf3e0a
This diff is collapsed.
Click to expand it.
MsgProcessor.cs
View file @
1faf3e0a
...
...
@@ -843,7 +843,7 @@ namespace pEp
/// <summary>
/// Any MAPI properties to set.
/// </summary>
public
Dictionary
<
MapiProperty
.
MapiProp
,
object
>
PropertiesToSet
;
public
MAPIProperties
PropertiesToSet
;
/// <summary>
/// Default constructor.
...
...
@@ -856,22 +856,16 @@ namespace pEp
this
.
ProcessedMessage
=
null
;
this
.
ProcessedRating
=
pEpRating
.
pEpRatingUndefined
;
this
.
ProcessedStatus
=
Globals
.
ReturnStatus
.
Success
;
this
.
PropertiesToSet
=
new
Dictionary
<
MapiProperty
.
MapiProp
,
object
>
();
this
.
PropertiesToSet
=
new
MAPIProperties
();
}
/// <summary>
/// Constructs a new ProcessingCompletedEventArgs with the given arguments.
/// </summary>
/// <param name="rating">The rating after the processing completes.</param>
public
ProcessingCompletedEventArgs
(
pEpRating
rating
)
public
ProcessingCompletedEventArgs
(
pEpRating
rating
)
:
this
()
{
this
.
EntryId
=
null
;
this
.
IsMirror
=
false
;
this
.
ProcessedDecryptionFlags
=
pEpDecryptFlags
.
pEpDecryptFlagsNone
;
this
.
ProcessedMessage
=
null
;
this
.
ProcessedRating
=
rating
;
this
.
ProcessedStatus
=
Globals
.
ReturnStatus
.
Success
;
this
.
PropertiesToSet
=
new
Dictionary
<
MapiProperty
.
MapiProp
,
object
>();
}
}
...
...
PEPAttachment.cs
View file @
1faf3e0a
...
...
@@ -898,15 +898,9 @@ namespace pEp
}
// Set all properties
if
(
MapiHelper
.
SetProperties
(
newAttachment
,
propertiesToSet
)
is
Dictionary
<
string
,
object
>
errors
)
if
(
MapiHelper
.
SetProperties
(
newAttachment
,
propertiesToSet
)
==
false
)
{
foreach
(
var
error
in
errors
)
{
if
(
error
.
Value
!=
null
)
{
Log
.
Error
(
"PEPAttachment.AddTo: Error setting MAPI property {0}: {1}"
,
error
.
Key
,
(
error
.
Value
as
int
?)?.
ToString
(
"X2"
)
??
"<null>"
);
}
}
Log
.
Error
(
"PEPAttachment.AddTo: Error setting one or more MAPI properties."
);
}
// Delete temp directory for attachments
...
...
Wrappers/WatchedWindow.cs
View file @
1faf3e0a
...
...
@@ -1127,7 +1127,7 @@ namespace pEp
// Set MAPI properties if needed
if
(
e
.
PropertiesToSet
?.
Count
>
0
)
{
this
.
CurrentMailItem
?.
Set
MAPI
Properties
(
e
.
PropertiesToSet
);
this
.
CurrentMailItem
?.
SetProperties
Native
(
e
.
PropertiesToSet
);
}
Log
.
Verbose
(
"MailItem_ProcessingComplete: Status bar updated with rating "
+
Enum
.
GetName
(
typeof
(
pEpRating
),
e
.
ProcessedRating
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment