FEATURE-945: Added environment variables to the external command (also removed unused imports and made some variables readonly)

This commit is contained in:
Robin 2016-05-20 23:43:31 +02:00
parent 4f326c9c0e
commit d25021631e
90 changed files with 390 additions and 373 deletions

View file

@ -21,7 +21,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -22,7 +22,6 @@
using Greenshot.IniFile;
using GreenshotPlugin.Core;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Greenshot.Controls {

View file

@ -26,16 +26,12 @@ using Greenshot.Configuration;
using Greenshot.Helpers;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
using log4net;
namespace Greenshot.Destinations {
/// <summary>
/// Description of EmailDestination.
/// </summary>
public class EmailDestination : AbstractDestination {
private static ILog LOG = LogManager.GetLogger(typeof(EmailDestination));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
private static bool isActiveFlag;
private static string mapiClient;

View file

@ -19,7 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Drawing;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;

View file

@ -21,15 +21,12 @@
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin;
using Greenshot.Plugin.Drawing;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.Serialization;
using System.Windows.Forms;
using log4net;
namespace Greenshot.Drawing {
/// <summary>

View file

@ -22,7 +22,6 @@ using System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Core;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class DropShadowSettingsForm : BaseForm {

View file

@ -21,7 +21,6 @@
using System;
using System.Windows.Forms;
using Greenshot.IniFile;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
/// <summary>

View file

@ -22,7 +22,6 @@ using System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Core;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class TornEdgeSettingsForm : BaseForm {

View file

@ -34,7 +34,8 @@ This version has changes, compared to 1.2.8.12, for the following reported ticke
* BUG-1935: Delay when pasting and ShapeShifter from FlameFusion is running|
* BUG-1941: Error when creating speech bubble|
* BUG-1945: Failure starting Greenshot at system startup|
* BUG-1949: Can't delete Imgur upload|
* BUG-1949: Can't delete Imgur upload
* FEATURE-945: Added environment variables to the external command
Testing is not finished, use at your own risk...

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -95,14 +95,14 @@ namespace Confluence {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceConnector));
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.confluence.rpc.AuthenticationFailedException";
private const string V2_FAILED = "AXIS";
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
private string credentials = null;
private DateTime loggedInTime = DateTime.Now;
private bool loggedIn = false;
private ConfluenceSoapServiceService confluence;
private int timeout;
private readonly int timeout;
private string url;
private Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
private readonly Cache<string, RemotePage> pageCache = new Cache<string, RemotePage>(60 * config.Timeout);
public void Dispose() {
Dispose(true);
@ -143,9 +143,9 @@ namespace Confluence {
/// <returns>true if login was done sucessfully</returns>
private bool doLogin(string user, string password) {
try {
this.credentials = confluence.login(user, password);
this.loggedInTime = DateTime.Now;
this.loggedIn = true;
credentials = confluence.login(user, password);
loggedInTime = DateTime.Now;
loggedIn = true;
} catch (Exception e) {
// Check if confluence-v2 caused an error, use v1 instead
if (e.Message.Contains(V2_FAILED) && url.Contains("v2")) {
@ -157,8 +157,8 @@ namespace Confluence {
return false;
}
// Not an authentication issue
this.loggedIn = false;
this.credentials = null;
loggedIn = false;
credentials = null;
e.Data.Add("user", user);
e.Data.Add("url", url);
throw;

View file

@ -36,11 +36,11 @@ namespace GreenshotConfluencePlugin {
/// Description of ConfluenceDestination.
/// </summary>
public class ConfluenceDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceDestination));
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceDestination));
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
private static Image confluenceIcon = null;
private Confluence.Page page;
private static readonly Image confluenceIcon = null;
private readonly Page page;
public static bool IsInitialized {
get;
private set;
@ -63,7 +63,7 @@ namespace GreenshotConfluencePlugin {
public ConfluenceDestination() {
}
public ConfluenceDestination(Confluence.Page page) {
public ConfluenceDestination(Page page) {
this.page = page;
}
@ -105,17 +105,17 @@ namespace GreenshotConfluencePlugin {
if (ConfluencePlugin.ConfluenceConnectorNoLogin == null || !ConfluencePlugin.ConfluenceConnectorNoLogin.isLoggedIn) {
yield break;
}
List<Confluence.Page> currentPages = ConfluenceUtils.GetCurrentPages();
List<Page> currentPages = ConfluenceUtils.GetCurrentPages();
if (currentPages == null || currentPages.Count == 0) {
yield break;
}
foreach(Confluence.Page currentPage in currentPages) {
foreach(Page currentPage in currentPages) {
yield return new ConfluenceDestination(currentPage);
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
// force password check to take place before the pages load
if (!ConfluencePlugin.ConfluenceConnector.isLoggedIn) {
return exportInformation;

View file

@ -20,7 +20,6 @@
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.Windows.Automation;

View file

@ -40,7 +40,7 @@ namespace GreenshotConfluencePlugin {
}
public EnumDisplayer(Type type) {
this.Type = type;
Type = type;
}
public Type Type {
@ -49,15 +49,15 @@ namespace GreenshotConfluencePlugin {
if (!value.IsEnum) {
throw new ArgumentException("parameter is not an Enumerated type", "value");
}
this.type = value;
type = value;
}
}
public ReadOnlyCollection<string> DisplayNames {
get {
this.reverseValues = (IDictionary) Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(typeof(string),type));
reverseValues = (IDictionary) Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(typeof(string),type));
this.displayValues = (IDictionary)Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(type, typeof(string)));
displayValues = (IDictionary)Activator.CreateInstance(typeof(Dictionary<,>).GetGenericTypeDefinition().MakeGenericType(type, typeof(string)));
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Static);
foreach (var field in fields) {

View file

@ -18,7 +18,7 @@
* 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;
using System.Windows;
namespace GreenshotConfluencePlugin {
@ -26,7 +26,7 @@ namespace GreenshotConfluencePlugin {
/// Interaction logic for ConfluenceConfigurationForm.xaml
/// </summary>
public partial class ConfluenceConfigurationForm : Window {
private ConfluenceConfiguration config;
private readonly ConfluenceConfiguration config;
public ConfluenceConfiguration Config {
get {
return config;
@ -34,7 +34,7 @@ namespace GreenshotConfluencePlugin {
}
public ConfluenceConfigurationForm(ConfluenceConfiguration config) {
this.DataContext = config;
DataContext = config;
this.config = config;
InitializeComponent();
}

View file

@ -18,7 +18,7 @@
* 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;
using Confluence;
using System.Collections.Generic;
@ -28,11 +28,11 @@ namespace GreenshotConfluencePlugin {
/// </summary>
public partial class ConfluencePagePicker : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluencePagePicker));
private ConfluenceUpload confluenceUpload = null;
private readonly ConfluenceUpload confluenceUpload = null;
public ConfluencePagePicker(ConfluenceUpload confluenceUpload, List<Page> pagesToPick) {
this.confluenceUpload = confluenceUpload;
this.DataContext = pagesToPick;
DataContext = pagesToPick;
InitializeComponent();
}

View file

@ -18,20 +18,17 @@
* 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;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using Confluence;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
namespace GreenshotConfluencePlugin {
public partial class ConfluenceSearch : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceSearch));
private static ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
private ConfluenceUpload confluenceUpload;
private static readonly ConfluenceConfiguration config = IniConfig.GetIniSection<ConfluenceConfiguration>();
private readonly ConfluenceUpload confluenceUpload;
public List<Confluence.Space> Spaces {
get {
@ -39,7 +36,7 @@ namespace GreenshotConfluencePlugin {
}
}
private ObservableCollection<Confluence.Page> pages = new ObservableCollection<Confluence.Page>();
private readonly ObservableCollection<Confluence.Page> pages = new ObservableCollection<Confluence.Page>();
public ObservableCollection<Confluence.Page> Pages {
get {
return pages;
@ -48,14 +45,14 @@ namespace GreenshotConfluencePlugin {
public ConfluenceSearch(ConfluenceUpload confluenceUpload) {
this.confluenceUpload = confluenceUpload;
this.DataContext = this;
DataContext = this;
InitializeComponent();
if (config.SearchSpaceKey == null) {
this.SpaceComboBox.SelectedItem = Spaces[0];
SpaceComboBox.SelectedItem = Spaces[0];
} else {
foreach(Confluence.Space space in Spaces) {
if (space.Key.Equals(config.SearchSpaceKey)) {
this.SpaceComboBox.SelectedItem = space;
SpaceComboBox.SelectedItem = space;
}
}
}
@ -94,7 +91,7 @@ namespace GreenshotConfluencePlugin {
}
}
void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) {
void Page_Loaded(object sender, RoutedEventArgs e) {
SelectionChanged();
}

View file

@ -27,7 +27,6 @@ using System.Windows.Input;
using System.Windows.Threading;
using Confluence;
using GreenshotPlugin.Core;
namespace GreenshotConfluencePlugin {
/// <summary>
@ -35,12 +34,12 @@ namespace GreenshotConfluencePlugin {
/// </summary>
public partial class ConfluenceTreePicker : System.Windows.Controls.Page {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ConfluenceTreePicker));
private ConfluenceConnector confluenceConnector;
private ConfluenceUpload confluenceUpload;
private readonly ConfluenceConnector confluenceConnector;
private readonly ConfluenceUpload confluenceUpload;
private bool isInitDone = false;
public ConfluenceTreePicker(ConfluenceUpload confluenceUpload) {
this.confluenceConnector = ConfluencePlugin.ConfluenceConnector;
confluenceConnector = ConfluencePlugin.ConfluenceConnector;
this.confluenceUpload = confluenceUpload;
InitializeComponent();
}

View file

@ -100,12 +100,12 @@ namespace GreenshotConfluencePlugin {
}
public ConfluenceUpload(string filename) {
this.Filename = filename;
Filename = filename;
InitializeComponent();
this.DataContext = this;
updateSpaces();
if (PickerPage == null) {
PickerTab.Visibility = System.Windows.Visibility.Collapsed;
PickerTab.Visibility = Visibility.Collapsed;
SearchTab.IsSelected = true;
}
}

View file

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
namespace TranslationByMarkupExtension {
namespace TranslationByMarkupExtension {
public interface ITranslationProvider {
/// <summary>
/// Translates the specified key.

View file

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using GreenshotConfluencePlugin;
using GreenshotPlugin.Core;
using GreenshotPlugin.Core;
namespace TranslationByMarkupExtension {
/// <summary>

View file

@ -6,7 +6,7 @@ namespace TranslationByMarkupExtension {
public class TranslationData : IWeakEventListener, INotifyPropertyChanged {
#region Private Members
private string _key;
private readonly string _key;
#endregion

View file

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
namespace TranslationByMarkupExtension {
public class TranslationManager {

View file

@ -26,9 +26,9 @@ using GreenshotPlugin.Core;
namespace GreenshotDropboxPlugin {
class DropboxDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination));
private static DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
private DropboxPlugin plugin = null;
private readonly DropboxPlugin plugin = null;
public DropboxDestination(DropboxPlugin plugin) {
this.plugin = plugin;
}
@ -53,7 +53,7 @@ namespace GreenshotDropboxPlugin {
}
public override ExportInformation ExportCapture(bool manually, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
if (uploaded) {

View file

@ -73,7 +73,7 @@ namespace GreenshotDropboxPlugin {
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="pluginAttribute">My own attributes</param>
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
this.host = (IGreenshotHost)pluginHost;
host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Register configuration (don't need the configuration itself)
@ -83,7 +83,7 @@ namespace GreenshotDropboxPlugin {
itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
itemPlugInConfig.Tag = host;
itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick);
itemPlugInConfig.Click += new EventHandler(ConfigMenuClick);
itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox");
PluginUtils.AddToContextMenu(host, itemPlugInConfig);

View file

@ -31,7 +31,7 @@ namespace GreenshotDropboxPlugin {
/// </summary>
public class DropboxUtils {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxUtils));
private static DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
private DropboxUtils() {
}

View file

@ -18,7 +18,7 @@
* 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;
using GreenshotPlugin.Controls;
namespace GreenshotDropboxPlugin.Forms {

View file

@ -19,10 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Windows.Forms;
using GreenshotDropboxPlugin.Forms;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
namespace GreenshotDropboxPlugin {

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -61,12 +61,12 @@ namespace ExternalCommand {
public Dictionary<string, bool> runInbackground;
private const string MSPAINT = "MS Paint";
private static string paintPath;
private static bool hasPaint = false;
private static readonly string paintPath;
private static readonly bool hasPaint = false;
private const string PAINTDOTNET = "Paint.NET";
private static string paintDotNetPath;
private static bool hasPaintDotNet = false;
private static readonly string paintDotNetPath;
private static readonly bool hasPaintDotNet = false;
static ExternalCommandConfiguration() {
try {
paintPath = PluginUtils.GetExePath("pbrush.exe");

View file

@ -34,24 +34,24 @@ namespace ExternalCommand {
/// Description of OCRDestination.
/// </summary>
public class ExternalCommandDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
private static Regex URI_REGEXP = new Regex(@"((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)");
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private string presetCommand;
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
private static readonly Regex URI_REGEXP = new Regex(@"((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)");
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private readonly string _presetCommand;
public ExternalCommandDestination(string commando) {
this.presetCommand = commando;
_presetCommand = commando;
}
public override string Designation {
get {
return "External " + presetCommand.Replace(',','_');
return "External " + _presetCommand.Replace(',','_');
}
}
public override string Description {
get {
return presetCommand;
return _presetCommand;
}
}
@ -61,20 +61,20 @@ namespace ExternalCommand {
public override Image DisplayIcon {
get {
return IconCache.IconForCommand(presetCommand);
return IconCache.IconForCommand(_presetCommand);
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
if (presetCommand != null) {
if (!config.runInbackground.ContainsKey(presetCommand)) {
config.runInbackground.Add(presetCommand, true);
if (_presetCommand != null) {
if (!config.runInbackground.ContainsKey(_presetCommand)) {
config.runInbackground.Add(_presetCommand, true);
}
bool runInBackground = config.runInbackground[presetCommand];
bool runInBackground = config.runInbackground[_presetCommand];
string fullPath = captureDetails.Filename;
if (fullPath == null) {
fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
@ -83,17 +83,20 @@ namespace ExternalCommand {
string output;
string error;
if (runInBackground) {
Thread commandThread = new Thread(delegate() {
CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
Thread commandThread = new Thread(delegate()
{
CallExternalCommand(exportInformation, fullPath, out output, out error);
ProcessExport(exportInformation, surface);
});
commandThread.Name = "Running " + presetCommand;
commandThread.IsBackground = true;
})
{
Name = "Running " + _presetCommand,
IsBackground = true
};
commandThread.SetApartmentState(ApartmentState.STA);
commandThread.Start();
exportInformation.ExportMade = true;
} else {
CallExternalCommand(exportInformation, presetCommand, fullPath, out output, out error);
CallExternalCommand(exportInformation, fullPath, out output, out error);
ProcessExport(exportInformation, surface);
}
}
@ -105,15 +108,14 @@ namespace ExternalCommand {
/// Call the external command, parse for URI, place to clipboard and set the export information
/// </summary>
/// <param name="exportInformation"></param>
/// <param name="commando"></param>
/// <param name="fullPath"></param>
/// <param name="output"></param>
/// <param name="error"></param>
private void CallExternalCommand(ExportInformation exportInformation, string commando, string fullPath, out string output, out string error) {
private void CallExternalCommand(ExportInformation exportInformation, string fullPath, out string output, out string error) {
output = null;
error = null;
try {
if (CallExternalCommand(presetCommand, fullPath, out output, out error) == 0) {
if (CallExternalCommand(_presetCommand, fullPath, out output, out error) == 0) {
exportInformation.ExportMade = true;
if (!string.IsNullOrEmpty(output)) {
MatchCollection uriMatches = URI_REGEXP.Matches(output);
@ -121,7 +123,7 @@ namespace ExternalCommand {
if (config.OutputToClipboard) {
ClipboardHelper.SetClipboardData(output);
}
if (uriMatches != null && uriMatches.Count > 0) {
if (uriMatches.Count > 0) {
exportInformation.Uri = uriMatches[0].Groups[1].Value;
LOG.InfoFormat("Got URI : {0} ", exportInformation.Uri);
if (config.UriToClipboard) {
@ -156,13 +158,13 @@ namespace ExternalCommand {
try {
return CallExternalCommand(commando, fullPath, "runas", out output, out error);
} catch {
w32ex.Data.Add("commandline", config.commandlines[presetCommand]);
w32ex.Data.Add("arguments", config.arguments[presetCommand]);
w32ex.Data.Add("commandline", config.commandlines[_presetCommand]);
w32ex.Data.Add("arguments", config.arguments[_presetCommand]);
throw;
}
} catch (Exception ex) {
ex.Data.Add("commandline", config.commandlines[presetCommand]);
ex.Data.Add("arguments", config.arguments[presetCommand]);
ex.Data.Add("commandline", config.commandlines[_presetCommand]);
ex.Data.Add("arguments", config.arguments[_presetCommand]);
throw;
}
}
@ -182,8 +184,16 @@ namespace ExternalCommand {
output = null;
error = null;
if (!string.IsNullOrEmpty(commandline)) {
using (Process process = new Process()) {
process.StartInfo.FileName = commandline;
using (Process process = new Process())
{
// Fix variables
commandline = FilenameHelper.FillVariables(commandline, true);
commandline = FilenameHelper.FillCmdVariables(commandline, true);
arguments = FilenameHelper.FillVariables(arguments, false);
arguments = FilenameHelper.FillCmdVariables(arguments, false);
process.StartInfo.FileName = FilenameHelper.FillCmdVariables(commandline, true);
process.StartInfo.Arguments = FormatArguments(arguments, fullPath);
process.StartInfo.UseShellExecute = false;
if (config.RedirectStandardOutput) {
@ -200,13 +210,13 @@ namespace ExternalCommand {
process.WaitForExit();
if (config.RedirectStandardOutput) {
output = process.StandardOutput.ReadToEnd();
if (config.ShowStandardOutputInLog && output != null && output.Trim().Length > 0) {
if (config.ShowStandardOutputInLog && output.Trim().Length > 0) {
LOG.InfoFormat("Output:\n{0}", output);
}
}
if (config.RedirectStandardError) {
error = process.StandardError.ReadToEnd();
if (error != null && error.Trim().Length > 0) {
if (error.Trim().Length > 0) {
LOG.WarnFormat("Error:\n{0}", error);
}
}
@ -219,7 +229,7 @@ namespace ExternalCommand {
public static string FormatArguments(string arguments, string fullpath)
{
return String.Format(arguments, fullpath);
return string.Format(arguments, fullpath);
}
}
}

View file

@ -34,11 +34,11 @@ namespace ExternalCommand {
/// </summary>
public class ExternalCommandPlugin : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin));
private static CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private IGreenshotHost host;
private PluginAttribute myAttributes;
private ToolStripMenuItem itemPlugInRoot;
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private IGreenshotHost _host;
private PluginAttribute _myAttributes;
private ToolStripMenuItem _itemPlugInRoot;
public void Dispose() {
Dispose(true);
@ -47,16 +47,13 @@ namespace ExternalCommand {
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (itemPlugInRoot != null) {
itemPlugInRoot.Dispose();
itemPlugInRoot = null;
if (_itemPlugInRoot != null) {
_itemPlugInRoot.Dispose();
_itemPlugInRoot = null;
}
}
}
public ExternalCommandPlugin() {
}
public IEnumerable<IDestination> Destinations() {
foreach(string command in config.commands) {
yield return new ExternalCommandDestination(command);
@ -87,7 +84,10 @@ namespace ExternalCommand {
LOG.WarnFormat("Found missing commandline for {0}", command);
return false;
}
if (!File.Exists(config.commandlines[command])) {
string commandline = FilenameHelper.FillVariables(config.commandlines[command], true);
commandline = FilenameHelper.FillCmdVariables(commandline, true);
if (!File.Exists(commandline)) {
LOG.WarnFormat("Found 'invalid' commandline {0} for command {1}", config.commandlines[command], command);
return false;
}
@ -118,17 +118,17 @@ namespace ExternalCommand {
config.commands.Remove(command);
}
this.host = pluginHost;
this.myAttributes = myAttributes;
_host = pluginHost;
_myAttributes = myAttributes;
itemPlugInRoot = new ToolStripMenuItem();
itemPlugInRoot.Tag = host;
_itemPlugInRoot = new ToolStripMenuItem();
_itemPlugInRoot.Tag = _host;
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
OnLanguageChanged(this, null);
itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
_itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
Language.LanguageChanged += OnLanguageChanged;
coreConfig.PropertyChanged += OnIconSizeChanged;
return true;
@ -144,7 +144,7 @@ namespace ExternalCommand {
try {
string exePath = PluginUtils.GetExePath("cmd.exe");
if (exePath != null && File.Exists(exePath)) {
itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
_itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
}
} catch (Exception ex) {
LOG.Warn("Couldn't get the cmd.exe image", ex);
@ -153,13 +153,13 @@ namespace ExternalCommand {
}
private void OnLanguageChanged(object sender, EventArgs e) {
if (itemPlugInRoot != null) {
itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
if (_itemPlugInRoot != null) {
_itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
}
}
public virtual void Shutdown() {
LOG.Debug("Shutdown of " + myAttributes.Name);
LOG.Debug("Shutdown of " + _myAttributes.Name);
}
private void ConfigMenuClick(object sender, EventArgs eventArgs) {

View file

@ -1,5 +1,25 @@
using System;
using System.Collections.Generic;
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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;
using System.Drawing;
using System.IO;
using Greenshot.IniFile;
@ -7,8 +27,8 @@ using GreenshotPlugin.Core;
namespace ExternalCommand {
public static class IconCache {
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconCache));
public static Image IconForCommand(string commandName) {
Image icon = null;

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -30,7 +30,7 @@ namespace ExternalCommand {
/// </summary>
public partial class SettingsForm : ExternalCommandForm {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
public SettingsForm() {
//

View file

@ -24,44 +24,45 @@ using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace ExternalCommand {
/// <summary>
/// Description of SettingsFormDetail.
/// </summary>
public partial class SettingsFormDetail : ExternalCommandForm {
private string commando;
private int commandIndex;
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsFormDetail));
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private readonly string _commando;
private readonly int _commandIndex;
public SettingsFormDetail(string commando) {
InitializeComponent();
AcceptButton = buttonOk;
CancelButton = buttonCancel;
this.commando = commando;
_commando = commando;
if(commando != null) {
textBox_name.Text = commando;
textBox_commandline.Text = config.commandlines[commando];
textBox_arguments.Text = config.arguments[commando];
commandIndex = config.commands.FindIndex(delegate(string s) { return s == commando; });
_commandIndex = config.commands.FindIndex(delegate(string s) { return s == commando; });
} else {
textBox_arguments.Text = "\"{0}\"";
}
OKButtonState();
OkButtonState();
}
void ButtonOkClick(object sender, EventArgs e) {
string commandName = textBox_name.Text;
string commandLine = textBox_commandline.Text;
string arguments = textBox_arguments.Text;
if(commando != null) {
config.commands[commandIndex] = commandName;
config.commandlines.Remove(commando);
if(_commando != null) {
config.commands[_commandIndex] = commandName;
config.commandlines.Remove(_commando);
config.commandlines.Add(commandName, commandLine);
config.arguments.Remove(commando);
config.arguments.Remove(_commando);
config.arguments.Add(commandName, arguments);
} else {
config.commands.Add(commandName);
@ -71,15 +72,23 @@ namespace ExternalCommand {
}
void Button3Click(object sender, EventArgs e) {
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*";
openFileDialog.FilterIndex = 1;
openFileDialog.CheckFileExists = true;
openFileDialog.Multiselect = false;
OpenFileDialog openFileDialog = new OpenFileDialog
{
Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*",
FilterIndex = 1,
CheckFileExists = true,
Multiselect = false
};
string initialPath = null;
try {
try
{
initialPath = Path.GetDirectoryName(textBox_commandline.Text);
} catch { }
}
catch (Exception ex)
{
LOG.WarnFormat("Can't get the initial path via {0}", textBox_commandline.Text);
LOG.Warn("Exception: ", ex);
}
if(initialPath != null && Directory.Exists(initialPath)) {
openFileDialog.InitialDirectory = initialPath;
} else {
@ -92,7 +101,7 @@ namespace ExternalCommand {
}
}
private void OKButtonState() {
private void OkButtonState() {
// Assume OK
buttonOk.Enabled = true;
textBox_name.BackColor = Color.White;
@ -103,7 +112,7 @@ namespace ExternalCommand {
buttonOk.Enabled = false;
}
// Check if commandname is unique
if(commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text)) {
if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text)) {
buttonOk.Enabled = false;
textBox_name.BackColor = Color.Red;
}
@ -111,15 +120,27 @@ namespace ExternalCommand {
if(string.IsNullOrEmpty(textBox_commandline.Text)) {
buttonOk.Enabled = false;
}
if (!string.IsNullOrEmpty(textBox_commandline.Text))
{
// Added this to be more flexible, using the Greenshot var format
string cmdPath = FilenameHelper.FillVariables(textBox_commandline.Text, true);
// And also replace the "DOS" Variables
cmdPath = FilenameHelper.FillCmdVariables(cmdPath, true);
// Is the command available?
if(!string.IsNullOrEmpty(textBox_commandline.Text) && !File.Exists(textBox_commandline.Text)) {
if (!File.Exists(cmdPath))
{
buttonOk.Enabled = false;
textBox_commandline.BackColor = Color.Red;
}
}
// Are the arguments in a valid format?
try
{
ExternalCommandDestination.FormatArguments(textBox_arguments.Text, string.Empty);
string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false);
arguments = FilenameHelper.FillCmdVariables(arguments, false);
ExternalCommandDestination.FormatArguments(arguments, string.Empty);
}
catch
{
@ -129,16 +150,16 @@ namespace ExternalCommand {
}
private void textBox_name_TextChanged(object sender, EventArgs e) {
OKButtonState();
OkButtonState();
}
private void textBox_commandline_TextChanged(object sender, EventArgs e) {
OKButtonState();
OkButtonState();
}
private void textBox_arguments_TextChanged(object sender, EventArgs e)
{
OKButtonState();
OkButtonState();
}
}

View file

@ -27,7 +27,7 @@ using log4net;
namespace GreenshotFlickrPlugin {
public class FlickrDestination : AbstractDestination {
private static ILog LOG = LogManager.GetLogger(typeof(FlickrDestination));
private FlickrPlugin plugin;
private readonly FlickrPlugin plugin;
public FlickrDestination(FlickrPlugin plugin) {
this.plugin = plugin;
}

View file

@ -34,7 +34,7 @@ namespace GreenshotFlickrPlugin {
/// </summary>
public class FlickrUtils {
private static readonly ILog LOG = LogManager.GetLogger(typeof(FlickrUtils));
private static FlickrConfiguration config = IniConfig.GetIniSection<FlickrConfiguration>();
private static readonly FlickrConfiguration config = IniConfig.GetIniSection<FlickrConfiguration>();
private const string FLICKR_API_BASE_URL = "https://api.flickr.com/services/";
private const string FLICKR_UPLOAD_URL = FLICKR_API_BASE_URL + "upload/";
// OAUTH

View file

@ -19,7 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using GreenshotPlugin.Controls;
namespace GreenshotFlickrPlugin.Forms {

View file

@ -18,12 +18,8 @@
* 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;
using System.Drawing;
using System.Windows.Forms;
using GreenshotFlickrPlugin.Forms;
using GreenshotPlugin.Core;
namespace GreenshotFlickrPlugin {
/// <summary>

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -19,7 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using GreenshotPlugin.Controls;
namespace GreenshotImgurPlugin {

View file

@ -33,8 +33,8 @@ namespace GreenshotImgurPlugin {
/// </summary>
public partial class ImgurHistory : ImgurForm {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurHistory));
private GreenshotColumnSorter columnSorter;
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
private readonly GreenshotColumnSorter columnSorter;
private static readonly ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
private static ImgurHistory instance;
public static void ShowHistory() {
@ -48,7 +48,7 @@ namespace GreenshotImgurPlugin {
}
private ImgurHistory() {
this.ManualLanguageApply = true;
ManualLanguageApply = true;
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
@ -57,7 +57,7 @@ namespace GreenshotImgurPlugin {
CancelButton = finishedButton;
// Init sorting
columnSorter = new GreenshotColumnSorter();
this.listview_imgur_uploads.ListViewItemSorter = columnSorter;
listview_imgur_uploads.ListViewItemSorter = columnSorter;
columnSorter.SortColumn = 3;
columnSorter.Order = SortOrder.Descending;
redraw();
@ -66,7 +66,7 @@ namespace GreenshotImgurPlugin {
}
ApplyLanguage();
if (config.Credits > 0) {
this.Text = this.Text + " (" + config.Credits + " credits)";
Text = Text + " (" + config.Credits + " credits)";
}
}
@ -169,7 +169,7 @@ namespace GreenshotImgurPlugin {
private void FinishedButtonClick(object sender, EventArgs e)
{
this.Hide();
Hide();
}
private void OpenButtonClick(object sender, EventArgs e) {
@ -197,7 +197,7 @@ namespace GreenshotImgurPlugin {
}
// Perform the sort with these new sort options.
this.listview_imgur_uploads.Sort();
listview_imgur_uploads.Sort();
}

View file

@ -19,9 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using GreenshotPlugin.Controls;
namespace GreenshotImgurPlugin {
/// <summary>

View file

@ -31,7 +31,7 @@ namespace GreenshotImgurPlugin {
public class ImgurDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurDestination));
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
private ImgurPlugin plugin = null;
private readonly ImgurPlugin plugin = null;
public ImgurDestination(ImgurPlugin plugin) {
this.plugin = plugin;
@ -57,7 +57,7 @@ namespace GreenshotImgurPlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
exportInformation.ExportMade = plugin.Upload(captureDetails, surface, out uploadURL);
exportInformation.Uri = uploadURL;

View file

@ -80,7 +80,7 @@ namespace GreenshotImgurPlugin {
/// <param name="pluginAttribute">My own attributes</param>
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
this.host = (IGreenshotHost)pluginHost;
host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Get configuration

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -29,21 +29,21 @@ using Jira;
namespace GreenshotJiraPlugin {
public partial class JiraForm : Form {
private JiraConnector jiraConnector;
private readonly JiraConnector jiraConnector;
private JiraIssue selectedIssue;
private GreenshotColumnSorter columnSorter;
private JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
private readonly GreenshotColumnSorter columnSorter;
private readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
public JiraForm(JiraConnector jiraConnector) {
InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
Icon = GreenshotResources.getGreenshotIcon();
AcceptButton = uploadButton;
CancelButton = cancelButton;
initializeComponentText();
this.columnSorter = new GreenshotColumnSorter();
this.jiraListView.ListViewItemSorter = columnSorter;
columnSorter = new GreenshotColumnSorter();
jiraListView.ListViewItemSorter = columnSorter;
this.jiraConnector = jiraConnector;
@ -60,9 +60,9 @@ namespace GreenshotJiraPlugin {
}
private void initializeComponentText() {
this.label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
this.label_comment.Text = Language.GetString("jira", LangKey.label_comment);
this.label_filename.Text = Language.GetString("jira", LangKey.label_filename);
label_jirafilter.Text = Language.GetString("jira", LangKey.label_jirafilter);
label_comment.Text = Language.GetString("jira", LangKey.label_comment);
label_filename.Text = Language.GetString("jira", LangKey.label_filename);
}
private void updateForm() {
@ -188,7 +188,7 @@ namespace GreenshotJiraPlugin {
}
// Perform the sort with these new sort options.
this.jiraListView.Sort();
jiraListView.Sort();
}
void JiraKeyTextChanged(object sender, EventArgs e) {

View file

@ -18,7 +18,7 @@
* 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;
using GreenshotPlugin.Controls;
namespace GreenshotJiraPlugin {

View file

@ -18,9 +18,6 @@
* 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;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace GreenshotJiraPlugin {
/// <summary>

View file

@ -33,8 +33,8 @@ namespace Jira {
#region transport classes
public class JiraFilter {
public JiraFilter(string name, string id) {
this.Name = name;
this.Id = id;
Name = name;
Id = id;
}
public string Name {
get;
@ -48,15 +48,15 @@ namespace Jira {
public class JiraIssue {
public JiraIssue(string key, DateTime? created, string reporter, string assignee, string project, string summary, string description, string environment, string [] attachmentNames) {
this.Key = key;
this.Created = created;
this.Reporter = reporter;
this.Assignee = assignee;
this.Project = project;
this.Summary = summary;
this.Description = description;
this.Environment = environment;
this.AttachmentNames = attachmentNames;
Key = key;
Created = created;
Reporter = reporter;
Assignee = assignee;
Project = project;
Summary = summary;
Description = description;
Environment = environment;
AttachmentNames = attachmentNames;
}
public string Key {
get;
@ -100,17 +100,17 @@ namespace Jira {
public class JiraConnector : IDisposable {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraConnector));
private const string AUTH_FAILED_EXCEPTION_NAME = "com.atlassian.jira.rpc.exception.RemoteAuthenticationException";
private static JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
public const string DEFAULT_POSTFIX = "/rpc/soap/jirasoapservice-v2?wsdl";
private string credentials;
private DateTime loggedInTime = DateTime.Now;
private bool loggedIn;
private JiraSoapServiceService jira;
private int timeout;
private readonly int timeout;
private string url;
private Cache<string, JiraIssue> jiraCache = new Cache<string, JiraIssue>(60 * config.Timeout);
private Cache<string, RemoteUser> userCache = new Cache<string, RemoteUser>(60 * config.Timeout);
private bool suppressBackgroundForm = false;
private readonly Cache<string, JiraIssue> jiraCache = new Cache<string, JiraIssue>(60 * config.Timeout);
private readonly Cache<string, RemoteUser> userCache = new Cache<string, RemoteUser>(60 * config.Timeout);
private readonly bool suppressBackgroundForm = false;
public void Dispose() {
Dispose(true);
@ -134,8 +134,8 @@ namespace Jira {
}
public JiraConnector(bool suppressBackgroundForm) {
this.url = config.Url;
this.timeout = config.Timeout;
url = config.Url;
timeout = config.Timeout;
this.suppressBackgroundForm = suppressBackgroundForm;
createService();
}
@ -171,13 +171,13 @@ namespace Jira {
ThreadStart jiraLogin = delegate {
LOG.DebugFormat("Loggin in");
try {
this.credentials = jira.login(user, password);
credentials = jira.login(user, password);
} catch (Exception) {
if (!url.EndsWith("wsdl")) {
url = url + "/rpc/soap/jirasoapservice-v2?wsdl";
// recreate the service with the new url
createService();
this.credentials = jira.login(user, password);
credentials = jira.login(user, password);
// Worked, store the url in the configuration
config.Url = url;
IniConfig.Save();
@ -187,8 +187,8 @@ namespace Jira {
}
LOG.DebugFormat("Logged in");
this.loggedInTime = DateTime.Now;
this.loggedIn = true;
loggedInTime = DateTime.Now;
loggedIn = true;
};
// Here we do it
@ -204,8 +204,8 @@ namespace Jira {
return false;
}
// Not an authentication issue
this.loggedIn = false;
this.credentials = null;
loggedIn = false;
credentials = null;
e.Data.Add("user", user);
e.Data.Add("url", url);
throw;

View file

@ -35,10 +35,10 @@ namespace GreenshotJiraPlugin {
/// Description of JiraDestination.
/// </summary>
public class JiraDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
private static JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
private JiraPlugin jiraPlugin = null;
private JiraIssue jira = null;
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(JiraDestination));
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
private readonly JiraPlugin jiraPlugin = null;
private readonly JiraIssue jira = null;
public JiraDestination(JiraPlugin jiraPlugin) {
this.jiraPlugin = jiraPlugin;
@ -100,7 +100,7 @@ namespace GreenshotJiraPlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surfaceToUpload, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
if (jira != null) {

View file

@ -101,7 +101,7 @@ namespace GreenshotJiraPlugin {
/// <param name="pluginAttribute">My own attributes</param>
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
this.host = (IGreenshotHost)pluginHost;
host = (IGreenshotHost)pluginHost;
jiraPluginAttributes = myAttributes;
// Register configuration (don't need the configuration itself)

View file

@ -30,7 +30,7 @@ namespace GreenshotJiraPlugin {
/// </summary>
public class JiraUtils {
private static readonly Regex JIRA_KEY_REGEX = new Regex(@"/browse/([A-Z0-9]+\-[0-9]+)");
private static JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
private static readonly JiraConfiguration config = IniConfig.GetIniSection<JiraConfiguration>();
public static List<JiraIssue> GetCurrentJiras() {
// Make sure we suppress the login

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -43,12 +43,12 @@ namespace Greenshot.Interop {
/// <summary>
/// Type of the COM object, set on constructor after getting the COM reference
/// </summary>
private Type _COMType;
private readonly Type _COMType;
/// <summary>
/// The type of which method calls are intercepted and executed on the COM object.
/// </summary>
private Type _InterceptType;
private readonly Type _InterceptType;
#endregion
[DllImport("ole32.dll")]
@ -214,9 +214,9 @@ namespace Greenshot.Interop {
/// </param>
private COMWrapper(object comObject, Type type)
: base(type) {
this._COMObject = comObject;
this._COMType = comObject.GetType();
this._InterceptType = type;
_COMObject = comObject;
_COMType = comObject.GetType();
_InterceptType = type;
}
#endregion
@ -228,14 +228,14 @@ namespace Greenshot.Interop {
/// sure that the COM object is still cleaned up.
/// </summary>
~COMWrapper() {
this.Dispose(false);
Dispose(false);
}
/// <summary>
/// Cleans up the COM object.
/// </summary>
public void Dispose() {
this.Dispose(true);
Dispose(true);
GC.SuppressFinalize(this);
}
@ -247,17 +247,17 @@ namespace Greenshot.Interop {
/// <see cref="IDisposable"/> interface.
/// </param>
private void Dispose(bool disposing) {
if (disposing && null != this._COMObject) {
if (Marshal.IsComObject(this._COMObject)) {
if (disposing && null != _COMObject) {
if (Marshal.IsComObject(_COMObject)) {
try {
while (Marshal.ReleaseComObject(this._COMObject) > 0);
while (Marshal.ReleaseComObject(_COMObject) > 0);
} catch (Exception) {
//LOG.WarnFormat("Problem releasing {0}", _COMType);
//LOG.Warn("Error: ", ex);
}
}
this._COMObject = null;
_COMObject = null;
}
}
@ -272,7 +272,7 @@ namespace Greenshot.Interop {
/// The full name of the intercepted type.
/// </returns>
public override string ToString() {
return this._InterceptType.FullName;
return _InterceptType.FullName;
}
/// <summary>
@ -282,7 +282,7 @@ namespace Greenshot.Interop {
/// The hash code of the wrapped object.
/// </returns>
public override int GetHashCode() {
return this._COMObject.GetHashCode();
return _COMObject.GetHashCode();
}
/// <summary>
@ -298,7 +298,7 @@ namespace Greenshot.Interop {
if (null != value && RemotingServices.IsTransparentProxy(value)) {
COMWrapper wrapper = RemotingServices.GetRealProxy(value) as COMWrapper;
if (null != wrapper) {
return this._COMObject == wrapper._COMObject;
return _COMObject == wrapper._COMObject;
}
}
@ -469,15 +469,15 @@ namespace Greenshot.Interop {
ParameterInfo parameter;
if ("Dispose" == methodName && 0 == argCount && typeof(void) == returnType) {
this.Dispose();
Dispose();
} else if ("ToString" == methodName && 0 == argCount && typeof(string) == returnType) {
returnValue = this.ToString();
} else if ("GetType" == methodName && 0 == argCount && typeof(System.Type) == returnType) {
returnValue = this._InterceptType;
returnValue = ToString();
} else if ("GetType" == methodName && 0 == argCount && typeof(Type) == returnType) {
returnValue = _InterceptType;
} else if ("GetHashCode" == methodName && 0 == argCount && typeof(int) == returnType) {
returnValue = this.GetHashCode();
returnValue = GetHashCode();
} else if ("Equals" == methodName && 1 == argCount && typeof(bool) == returnType) {
returnValue = this.Equals(callMessage.Args[0]);
returnValue = Equals(callMessage.Args[0]);
} else if (1 == argCount && typeof(void) == returnType && (methodName.StartsWith("add_") || methodName.StartsWith("remove_"))) {
bool removeHandler = methodName.StartsWith("remove_");
methodName = methodName.Substring(removeHandler ? 7 : 4);
@ -487,8 +487,8 @@ namespace Greenshot.Interop {
return new ReturnMessage(new ArgumentNullException("handler"), callMessage);
}
} else {
invokeObject = this._COMObject;
invokeType = this._COMType;
invokeObject = _COMObject;
invokeType = _COMType;
if (methodName.StartsWith("get_")) {
// Property Get
@ -565,7 +565,7 @@ namespace Greenshot.Interop {
if (returnType.IsInterface) {
// Wrap the returned value in an intercepting COM wrapper
if (Marshal.IsComObject(returnValue)) {
returnValue = COMWrapper.Wrap(returnValue, returnType);
returnValue = Wrap(returnValue, returnType);
}
} else if (returnType.IsEnum) {
// Convert to proper Enum type

View file

@ -26,7 +26,7 @@ namespace Greenshot.Interop {
/// </summary>
[AttributeUsage(AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class ComProgIdAttribute : Attribute {
private string _value;
private readonly string _value;
/// <summary>
/// Extracts the attribute from the specified type.

View file

@ -21,7 +21,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,

View file

@ -33,7 +33,7 @@ namespace GreenshotOCR {
private static OCRConfiguration config = IniConfig.GetIniSection<OCRConfiguration>();
private const int MIN_WIDTH = 130;
private const int MIN_HEIGHT = 130;
private OcrPlugin plugin;
private readonly OcrPlugin plugin;
public override string Designation {
get {
@ -62,7 +62,7 @@ namespace GreenshotOCR {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
exportInformation.ExportMade = plugin.DoOCR(surface) != null;
return exportInformation;
}

View file

@ -21,7 +21,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Greenshot.IniFile;
@ -61,7 +60,7 @@ namespace GreenshotOCR {
/// OCR Plugin Greenshot
/// </summary>
public class OcrPlugin : IGreenshotPlugin {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OcrPlugin));
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OcrPlugin));
private const string CONFIG_FILENAME = "ocr-config.properties";
private string OCR_COMMAND;
private static IGreenshotHost host;

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -19,15 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace GreenshotOCR {
/// <summary>
/// Description of SettingsForm.
/// </summary>
public partial class SettingsForm : OCRForm {
private OCRConfiguration config;
private readonly OCRConfiguration config;
public SettingsForm(string [] languages, OCRConfiguration config) {
//

View file

@ -18,16 +18,13 @@
* 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;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
@ -38,8 +35,8 @@ namespace GreenshotOfficePlugin {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExcelDestination));
private const int ICON_APPLICATION = 0;
private const int ICON_WORKBOOK = 1;
private static string exePath = null;
private string workbookName = null;
private static readonly string exePath = null;
private readonly string workbookName = null;
static ExcelDestination() {
exePath = PluginUtils.GetExePath("EXCEL.EXE");
@ -107,7 +104,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
bool createdFile = false;
string imageFile = captureDetails.Filename;
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {

View file

@ -29,11 +29,11 @@ using System.IO;
namespace GreenshotOfficePlugin {
public class OneNoteDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
private const int ICON_APPLICATION = 0;
public const string DESIGNATION = "OneNote";
private static string exePath = null;
private OneNotePage page = null;
private static readonly string exePath = null;
private readonly OneNotePage page = null;
static OneNoteDestination() {
exePath = PluginUtils.GetExePath("ONENOTE.EXE");
@ -99,7 +99,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
if (page == null) {
try {

View file

@ -34,18 +34,18 @@ namespace GreenshotOfficePlugin {
/// Description of OutlookDestination.
/// </summary>
public class OutlookDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookDestination));
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OutlookDestination));
private const int ICON_APPLICATION = 0;
private const int ICON_MEETING = 2;
private static Image mailIcon = GreenshotPlugin.Core.GreenshotResources.getImage("Email.Image");
private static OfficeConfiguration conf = IniConfig.GetIniSection<OfficeConfiguration>();
private static string exePath = null;
private static bool isActiveFlag = false;
private static string mapiClient = "Microsoft Outlook";
private static readonly Image mailIcon = GreenshotResources.getImage("Email.Image");
private static readonly OfficeConfiguration conf = IniConfig.GetIniSection<OfficeConfiguration>();
private static readonly string exePath = null;
private static readonly bool isActiveFlag = false;
private static readonly string mapiClient = "Microsoft Outlook";
public const string DESIGNATION = "Outlook";
private string outlookInspectorCaption;
private OlObjectClass outlookInspectorType;
private readonly string outlookInspectorCaption;
private readonly OlObjectClass outlookInspectorType;
static OutlookDestination() {
if (EmailConfigHelper.HasOutlook()) {
@ -142,7 +142,7 @@ namespace GreenshotOfficePlugin {
/// <param name="captureDetails"></param>
/// <returns></returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
// Outlook logic
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {

View file

@ -18,16 +18,13 @@
* 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;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using Greenshot.Plugin;
using Greenshot.Interop.Office;
using Greenshot.IniFile;
using System.Text.RegularExpressions;
namespace GreenshotOfficePlugin {
@ -39,8 +36,8 @@ namespace GreenshotOfficePlugin {
private const int ICON_APPLICATION = 0;
private const int ICON_PRESENTATION = 1;
private static string exePath = null;
private string presentationName = null;
private static readonly string exePath = null;
private readonly string presentationName = null;
static PowerpointDestination() {
exePath = PluginUtils.GetExePath("POWERPNT.EXE");
@ -109,7 +106,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string tmpFile = captureDetails.Filename;
Size imageSize = Size.Empty;
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {

View file

@ -33,11 +33,11 @@ namespace GreenshotOfficePlugin {
/// Description of EmailDestination.
/// </summary>
public class WordDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordDestination));
private const int ICON_APPLICATION = 0;
private const int ICON_DOCUMENT = 1;
private static string exePath = null;
private string documentCaption = null;
private static readonly string exePath = null;
private readonly string documentCaption = null;
static WordDestination() {
exePath = PluginUtils.GetExePath("WINWORD.EXE");
@ -51,7 +51,7 @@ namespace GreenshotOfficePlugin {
}
public WordDestination(string wordCaption) {
this.documentCaption = wordCaption;
documentCaption = wordCaption;
}
public override string Designation {
@ -104,7 +104,7 @@ namespace GreenshotOfficePlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string tmpFile = captureDetails.Filename;
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$")) {
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());

View file

@ -20,10 +20,7 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using Greenshot.Interop;
using System.Drawing;
using GreenshotOfficePlugin;
using Greenshot.IniFile;

View file

@ -20,7 +20,6 @@
*/
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using System;

View file

@ -24,13 +24,7 @@ using System.Text;
using System.IO;
using Microsoft.Win32;
using Greenshot.Interop;
using Greenshot.Interop.IE;
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using GreenshotOfficePlugin;
using Greenshot.IniFile;

View file

@ -20,9 +20,6 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using Greenshot.Interop;
using GreenshotOfficePlugin;
using Greenshot.IniFile;
@ -30,7 +27,7 @@ namespace Greenshot.Interop.Office {
public class WordExporter {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(WordExporter));
private static Version wordVersion = null;
private static OfficeConfiguration config = IniConfig.GetIniSection<OfficeConfiguration>();
private static readonly OfficeConfiguration config = IniConfig.GetIniSection<OfficeConfiguration>();
/// <summary>
/// Check if the used version is higher than Office 2003

View file

@ -601,11 +601,11 @@ namespace Greenshot.Interop.Office {
[FieldOffset(0)]
public uint propTag;
[FieldOffset(4)]
public uint alignPad;
public readonly uint alignPad;
[FieldOffset(8)]
public IntPtr Value;
[FieldOffset(8)]
public long filler;
public readonly long filler;
}
/// <summary>
@ -770,7 +770,7 @@ namespace Greenshot.Interop.Office {
Marshal.FreeHGlobal(propValue.Value);
IMAPIProp mapiProp = (IMAPIProp)Marshal.GetTypedObjectForIUnknown(IUnknown, typeof(IMAPIProp));
return mapiProp.SaveChanges(4) == 0;
} catch (System.Exception ex) {
} catch (Exception ex) {
LOG.Error(ex);
return false;
} finally {

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -18,10 +18,6 @@
* 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;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using GreenshotPlugin.Controls;
namespace GreenshotPhotobucketPlugin {
/// <summary>

View file

@ -33,8 +33,8 @@ namespace GreenshotPhotobucketPlugin {
public class PhotobucketDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PhotobucketDestination));
private static PhotobucketConfiguration config = IniConfig.GetIniSection<PhotobucketConfiguration>();
private PhotobucketPlugin plugin = null;
private string albumPath = null;
private readonly PhotobucketPlugin plugin = null;
private readonly string albumPath = null;
/// <summary>
/// Create a Photobucket destination, which also has the path to the album in it
@ -97,7 +97,7 @@ namespace GreenshotPhotobucketPlugin {
/// <param name="captureDetails"></param>
/// <returns></returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
bool uploaded = plugin.Upload(captureDetails, surface, albumPath, out uploadURL);
if (uploaded) {

View file

@ -74,7 +74,7 @@ namespace GreenshotPhotobucketPlugin {
/// <param name="pluginAttribute">My own attributes</param>
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
this.host = (IGreenshotHost)pluginHost;
host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Get configuration

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following

View file

@ -17,13 +17,6 @@
* 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;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
namespace GreenshotPicasaPlugin {
/// <summary>

View file

@ -28,7 +28,7 @@ namespace GreenshotPicasaPlugin {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PicasaDestination));
private static PicasaConfiguration config = IniConfig.GetIniSection<PicasaConfiguration>();
private PicasaPlugin plugin = null;
private readonly PicasaPlugin plugin = null;
public PicasaDestination(PicasaPlugin plugin) {
this.plugin = plugin;
}
@ -53,7 +53,7 @@ namespace GreenshotPicasaPlugin {
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
ExportInformation exportInformation = new ExportInformation(Designation, Description);
string uploadURL = null;
bool uploaded = plugin.Upload(captureDetails, surface, out uploadURL);
if (uploaded) {

View file

@ -73,7 +73,7 @@ namespace GreenshotPicasaPlugin {
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
/// <param name="pluginAttribute">My own attributes</param>
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
this.host = (IGreenshotHost)pluginHost;
host = (IGreenshotHost)pluginHost;
Attributes = myAttributes;
// Get configuration
@ -84,7 +84,7 @@ namespace GreenshotPicasaPlugin {
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
itemPlugInRoot.Tag = host;
itemPlugInRoot.Image = (Image)resources.GetObject("Picasa");
itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
@ -127,7 +127,7 @@ namespace GreenshotPicasaPlugin {
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.UploadFormat, config.UploadJpegQuality);
try {
string url = null;
new PleaseWaitForm().ShowAndWait(PicasaPlugin.Attributes.Name, Language.GetString("picasa", LangKey.communication_wait),
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("picasa", LangKey.communication_wait),
delegate() {
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
string contentType = "image/" + config.UploadFormat.ToString();

View file

@ -22,7 +22,6 @@ using Greenshot.IniFile;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
using System;
using System.Net;
using System.Xml;
namespace GreenshotPicasaPlugin {

View file

@ -22,7 +22,6 @@
using Greenshot.Plugin;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information

View file

@ -441,7 +441,7 @@ namespace GreenshotPlugin.Controls {
if (hotkey.LastIndexOf('+') > 0) {
hotkey = hotkey.Remove(0,hotkey.LastIndexOf('+')+1).Trim();
}
key = (Keys)Keys.Parse(typeof(Keys), hotkey);
key = (Keys)Enum.Parse(typeof(Keys), hotkey);
}
return key;
}

View file

@ -74,9 +74,12 @@ namespace GreenshotPlugin.Core {
get {
List<TV> elements = new List<TV>();
lock (lockObject)
{
foreach (TV element in internalCache.Values) {
elements.Add(element);
}
}
foreach (TV element in elements) {
yield return element;
}
@ -105,9 +108,13 @@ namespace GreenshotPlugin.Core {
/// </summary>
/// <param name="key"></param>
/// <returns>true if the cache contains the key</returns>
public bool Contains(TK key) {
public bool Contains(TK key)
{
lock (lockObject)
{
return internalCache.ContainsKey(key);
}
}
/// <summary>
/// Add a value to the cache

View file

@ -26,7 +26,7 @@ namespace GreenshotPlugin.Core {
private long lastCheck;
private readonly long waitTime;
public EventDelay(long ticks) {
this.waitTime = ticks;
waitTime = ticks;
}
public bool Check() {

View file

@ -38,6 +38,7 @@ namespace GreenshotPlugin.Core {
// The parameter format is a single alpha followed by the value belonging to the parameter, e.g. :
// ${capturetime:d"yyyy-MM-dd HH_mm_ss"}
private static readonly Regex VAR_REGEXP = new Regex(@"\${(?<variable>[^:}]+)[:]?(?<parameters>[^}]*)}", RegexOptions.Compiled);
private static readonly Regex CMD_VAR_REGEXP = new Regex(@"%(?<variable>[^%]+)%", RegexOptions.Compiled);
private static readonly Regex SPLIT_REGEXP = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
private const int MAX_TITLE_LENGTH = 80;
@ -74,7 +75,7 @@ namespace GreenshotPlugin.Core {
/// <summary>
/// Remove invalid characters from the path
/// </summary>
/// <param name="fullpath">string with the full path to a file</param>
/// <param name="path">string with the full path to a file</param>
/// <returns>string with the full path to a file, without invalid characters</returns>
public static string MakePathSafe(string path) {
// Make the path save!
@ -389,6 +390,51 @@ namespace GreenshotPlugin.Core {
return replaceValue;
}
/// <summary>
/// "Simply" fill the pattern with environment variables
/// </summary>
/// <param name="pattern">String with pattern %var%</param>
/// <param name="filenameSafeMode">true to make sure everything is filenamesafe</param>
/// <returns>Filled string</returns>
public static string FillCmdVariables(string pattern, bool filenameSafeMode)
{
IDictionary processVars = null;
IDictionary userVars = null;
IDictionary machineVars = null;
try
{
processVars = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Process);
}
catch (Exception e)
{
LOG.Error("Error retrieving EnvironmentVariableTarget.Process", e);
}
try
{
userVars = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User);
}
catch (Exception e)
{
LOG.Error("Error retrieving EnvironmentVariableTarget.User", e);
}
try
{
machineVars = Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine);
}
catch (Exception e)
{
LOG.Error("Error retrieving EnvironmentVariableTarget.Machine", e);
}
return CMD_VAR_REGEXP.Replace(pattern,
delegate (Match m) {
return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
}
);
}
/// <summary>
/// "Simply" fill the pattern with environment variables
/// </summary>

View file

@ -101,7 +101,7 @@ namespace GreenshotPlugin.Core {
/// </summary>
public class SpecialFolderPatternConverter : PatternConverter {
override protected void Convert(TextWriter writer, object state) {
Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), base.Option, true);
Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true);
writer.Write(Environment.GetFolderPath(specialFolder));
}
}

View file

@ -1032,7 +1032,7 @@ Greenshot received information from CloudServiceName. You can close this browser
// Get response object.
using (HttpListenerResponse response = context.Response) {
// Write a "close" response.
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(ClosePageResponse.Replace("CloudServiceName", _cloudServiceName));
byte[] buffer = Encoding.UTF8.GetBytes(ClosePageResponse.Replace("CloudServiceName", _cloudServiceName));
// Write to response stream.
response.ContentLength64 = buffer.Length;
using (var stream = response.OutputStream) {

View file

@ -110,6 +110,8 @@ namespace GreenshotPlugin.Core {
public static Image GetCachedExeIcon(string path, int index) {
string cacheKey = string.Format("{0}:{1}", path, index);
Image returnValue;
lock (exeIconCache)
{
if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
lock (exeIconCache) {
if (!exeIconCache.TryGetValue(cacheKey, out returnValue)) {
@ -120,6 +122,7 @@ namespace GreenshotPlugin.Core {
}
}
}
}
return returnValue;
}

View file

@ -85,10 +85,10 @@ namespace GreenshotPlugin.Core {
}
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
this._file = file;
_file = file;
DateTime.TryParse(pubdate, out _pubdate);
this._link = link;
this._directLink = directLink;
_link = link;
_directLink = directLink;
}
}
/// <summary>