mirror of
https://github.com/greenshot/greenshot.git
synced 2025-03-12 05:25:25 -07:00
BUG-2743: Cleanup of MAPI & Outlook logic, removed the check on "HKEY_LOCAL_MACHINE\SOFTWARE(\WOW6432Node)\Microsoft\Windows Messaging Subsystem" with the MAPI value in favor of the HKEY_LOCAL_MACHINE\SOFTWARE(\WOW6432Node)\Clients\Mail where the default value contains the name, this should hopefully solve some issues.
This commit is contained in:
parent
eadd1a7cac
commit
3adf9e9a51
Greenshot
GreenshotOfficePlugin/Destinations
GreenshotPlugin/Core
@ -26,6 +26,7 @@ using Greenshot.Configuration;
|
||||
using Greenshot.Helpers;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Interfaces;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
@ -39,12 +40,9 @@ namespace Greenshot.Destinations {
|
||||
|
||||
static EmailDestination() {
|
||||
// Logic to decide what email implementation we use
|
||||
if (!EmailConfigHelper.HasMapi()) return;
|
||||
|
||||
_isActiveFlag = false;
|
||||
_mapiClient = EmailConfigHelper.GetMapiClient();
|
||||
_mapiClient = RegistryHive.LocalMachine.ReadKey64Or32(@"Clients\Mail");
|
||||
if (!string.IsNullOrEmpty(_mapiClient)) {
|
||||
// Active as we have a mapi client, can be disabled later
|
||||
// Active as we have a MAPI client, can be disabled later
|
||||
_isActiveFlag = true;
|
||||
}
|
||||
}
|
||||
@ -66,11 +64,9 @@ namespace Greenshot.Destinations {
|
||||
if (_isActiveFlag) {
|
||||
// Disable if the office plugin is installed and the client is outlook
|
||||
// TODO: Change this! It always creates an exception, as the plugin has not been loaded the type is not there :(
|
||||
Type outlookdestination = Type.GetType("GreenshotOfficePlugin.OutlookDestination,GreenshotOfficePlugin");
|
||||
if (outlookdestination != null) {
|
||||
if (_mapiClient.ToLower().Contains("microsoft outlook")) {
|
||||
_isActiveFlag = false;
|
||||
}
|
||||
var outlookDestination = Type.GetType("GreenshotOfficePlugin.OutlookDestination,GreenshotOfficePlugin", false);
|
||||
if (outlookDestination != null && _mapiClient.ToLower().Contains("microsoft outlook")) {
|
||||
_isActiveFlag = false;
|
||||
}
|
||||
}
|
||||
return base.IsActive && _isActiveFlag;
|
||||
|
@ -80,15 +80,7 @@ namespace Greenshot.Helpers {
|
||||
|
||||
// Store the list of currently active windows, so we can make sure we show the email window later!
|
||||
var windowsBefore = WindowDetails.GetVisibleWindows();
|
||||
//bool isEmailSend = false;
|
||||
//if (EmailConfigHelper.HasOutlook() && (CoreConfig.OutputEMailFormat == EmailFormat.OUTLOOK_HTML || CoreConfig.OutputEMailFormat == EmailFormat.OUTLOOK_TXT)) {
|
||||
// isEmailSend = OutlookExporter.ExportToOutlook(tmpFile, captureDetails);
|
||||
//}
|
||||
if (/*!isEmailSend &&*/ EmailConfigHelper.HasMapi()) {
|
||||
// Fallback to MAPI
|
||||
// Send the email
|
||||
SendImage(tmpFile, captureDetails.Title);
|
||||
}
|
||||
SendImage(tmpFile, captureDetails.Title);
|
||||
WindowDetails.ActiveNewerWindows(windowsBefore);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ using GreenshotPlugin.IniFile;
|
||||
using GreenshotPlugin.Interfaces;
|
||||
using GreenshotPlugin.Interfaces.Plugin;
|
||||
using Microsoft.Office.Interop.Outlook;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace GreenshotOfficePlugin.Destinations {
|
||||
/// <summary>
|
||||
@ -47,23 +48,40 @@ namespace GreenshotOfficePlugin.Destinations {
|
||||
private const string MapiClient = "Microsoft Outlook";
|
||||
private readonly string _outlookInspectorCaption;
|
||||
private readonly OlObjectClass _outlookInspectorType;
|
||||
private readonly OutlookEmailExporter _outlookEmailExporter = new OutlookEmailExporter();
|
||||
private readonly OutlookEmailExporter _outlookEmailExporter = new();
|
||||
|
||||
static OutlookDestination() {
|
||||
if (EmailConfigHelper.HasOutlook()) {
|
||||
if (HasOutlook()) {
|
||||
IsActiveFlag = true;
|
||||
}
|
||||
ExePath = PluginUtils.GetExePath("OUTLOOK.EXE");
|
||||
if (ExePath != null && File.Exists(ExePath)) {
|
||||
WindowDetails.AddProcessToExcludeFromFreeze("outlook");
|
||||
} else {
|
||||
ExePath = null;
|
||||
ExePath = GetOutlookExePath();
|
||||
}
|
||||
if (ExePath == null) {
|
||||
IsActiveFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static string GetOutlookExePath() => RegistryHive.LocalMachine.ReadKey64Or32(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
|
||||
|
||||
/// <summary>
|
||||
/// Check if Outlook is installed
|
||||
/// </summary>
|
||||
/// <returns>Returns true if outlook is installed</returns>
|
||||
private static bool HasOutlook()
|
||||
{
|
||||
string outlookPath = GetOutlookExePath();
|
||||
if (outlookPath == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return File.Exists(outlookPath);
|
||||
}
|
||||
|
||||
public OutlookDestination() {
|
||||
}
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
/// Description of EmailConfigHelper.
|
||||
/// </summary>
|
||||
public static class EmailConfigHelper {
|
||||
|
||||
public static string GetMapiClient() => RegistryHive.LocalMachine.ReadKey64Or32(@"Clients\Mail");
|
||||
|
||||
public static bool HasMapi()
|
||||
{
|
||||
var value = RegistryHive.LocalMachine.ReadKey64Or32(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0");
|
||||
return "1".Equals(value);
|
||||
}
|
||||
|
||||
public static string GetOutlookExePath() => RegistryHive.LocalMachine.ReadKey64Or32(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
|
||||
|
||||
/// <summary>
|
||||
/// Check if Outlook is installed
|
||||
/// </summary>
|
||||
/// <returns>Returns true if outlook is installed</returns>
|
||||
public static bool HasOutlook() {
|
||||
string outlookPath = GetOutlookExePath();
|
||||
if (outlookPath == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return File.Exists(outlookPath);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user