diff --git a/src/Greenshot.Base/Core/CoreConfiguration.cs b/src/Greenshot.Base/Core/CoreConfiguration.cs
index 580af8918..80ad3b719 100644
--- a/src/Greenshot.Base/Core/CoreConfiguration.cs
+++ b/src/Greenshot.Base/Core/CoreConfiguration.cs
@@ -388,89 +388,64 @@ namespace Greenshot.Base.Core
return ExperimentalFeatures != null && ExperimentalFeatures.Contains(experimentalFeature);
}
+ private string CreateOutputFilePath()
+ {
+ if (IniConfig.IsPortable)
+ {
+ string pafOutputFilePath = Path.Combine(Application.StartupPath, @"..\..\Documents\Pictures\Greenshots");
+ if (!Directory.Exists(pafOutputFilePath))
+ {
+ try
+ {
+ Directory.CreateDirectory(pafOutputFilePath);
+ return pafOutputFilePath;
+ }
+ catch (Exception ex)
+ {
+ // Problem creating directory, fallback to Desktop
+ LOG.Warn(ex);
+ }
+ }
+ else
+ {
+ return pafOutputFilePath;
+ }
+ }
+
+ return Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
+ }
+
///
/// Supply values we can't put as defaults
///
/// The property to return a default for
/// object with the default value for the supplied property
- public override object GetDefault(string property)
- {
- switch (property)
+ public override object GetDefault(string property) =>
+ property switch
{
- case nameof(ExcludePlugins):
- case nameof(IncludePlugins):
- return new List();
- case nameof(OutputFileAsFullpath):
- if (IniConfig.IsPortable)
- {
- return Path.Combine(Application.StartupPath, @"..\..\Documents\Pictures\Greenshots\dummy.png");
- }
-
- return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "dummy.png");
- case nameof(OutputFilePath):
- if (IniConfig.IsPortable)
- {
- string pafOutputFilePath = Path.Combine(Application.StartupPath, @"..\..\Documents\Pictures\Greenshots");
- if (!Directory.Exists(pafOutputFilePath))
- {
- try
- {
- Directory.CreateDirectory(pafOutputFilePath);
- return pafOutputFilePath;
- }
- catch (Exception ex)
- {
- LOG.Warn(ex);
- // Problem creating directory, fallback to Desktop
- }
- }
- else
- {
- return pafOutputFilePath;
- }
- }
-
- return Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
- case nameof(DWMBackgroundColor):
- return Color.Transparent;
- case nameof(ActiveTitleFixes):
- return new List
- {
- "Firefox",
- "IE",
- "Chrome"
- };
- case nameof(TitleFixMatcher):
- return new Dictionary
- {
- {
- "Firefox", " - Mozilla Firefox.*"
- },
- {
- "IE", " - (Microsoft|Windows) Internet Explorer.*"
- },
- {
- "Chrome", " - Google Chrome.*"
- }
- };
- case nameof(TitleFixReplacer):
- return new Dictionary
- {
- {
- "Firefox", string.Empty
- },
- {
- "IE", string.Empty
- },
- {
- "Chrome", string.Empty
- }
- };
- }
-
- return null;
- }
-
+ nameof(ExcludePlugins) => new List(),
+ nameof(IncludePlugins) => new List(),
+ nameof(OutputFileAsFullpath) => IniConfig.IsPortable ? Path.Combine(Application.StartupPath, @"..\..\Documents\Pictures\Greenshots\dummy.png") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "dummy.png"),
+ nameof(OutputFilePath) => CreateOutputFilePath(),
+ nameof(DWMBackgroundColor) => Color.Transparent,
+ nameof(ActiveTitleFixes) => new List {
+ "Firefox",
+ "IE",
+ "Chrome"
+ },
+ nameof(TitleFixMatcher) => new Dictionary {
+ { "Firefox", " - Mozilla Firefox.*" },
+ { "IE", " - (Microsoft|Windows) Internet Explorer.*" },
+ { "Chrome", " - Google Chrome.*" }
+ },
+ nameof(TitleFixReplacer) => new Dictionary {
+ { "Firefox", string.Empty },
+ { "IE", string.Empty },
+ { "Chrome", string.Empty }
+ },
+ _ => null
+ };
+
///
/// This method will be called before converting the property, making to possible to correct a certain value
/// Can be used when migration is needed
@@ -540,8 +515,9 @@ namespace Greenshot.Base.Core
OutputFileAutoReduceColors = false;
}
+ bool isUpgradeFrom12 = LastSaveWithVersion?.StartsWith("1.2") ?? false;
// Fix for excessive feed checking
- if (UpdateCheckInterval != 0 && UpdateCheckInterval <= 7 && LastSaveWithVersion.StartsWith("1.2"))
+ if (UpdateCheckInterval != 0 && UpdateCheckInterval <= 7 && isUpgradeFrom12)
{
UpdateCheckInterval = 14;
}
diff --git a/src/Greenshot.Plugin.Box/BoxConfiguration.cs b/src/Greenshot.Plugin.Box/BoxConfiguration.cs
index fdef95ae5..c745fe985 100644
--- a/src/Greenshot.Plugin.Box/BoxConfiguration.cs
+++ b/src/Greenshot.Plugin.Box/BoxConfiguration.cs
@@ -21,6 +21,7 @@
using System;
using System.Windows.Forms;
+using Greenshot.Base.Core;
using Greenshot.Base.Core.Enums;
using Greenshot.Base.IniFile;
using Greenshot.Plugin.Box.Forms;
@@ -75,5 +76,20 @@ namespace Greenshot.Plugin.Box
return false;
}
+
+ ///
+ /// Upgrade certain values
+ ///
+ public override void AfterLoad()
+ {
+ var coreConfiguration = IniConfig.GetIniSection();
+ bool isUpgradeFrom12 = coreConfiguration.LastSaveWithVersion?.StartsWith("1.2") ?? false;
+ // Clear token when we upgrade from 1.2 to 1.3 as it is no longer valid, discussed in #421
+ if (!isUpgradeFrom12) return;
+
+ // We have an upgrade, remove all previous credentials.
+ RefreshToken = null;
+ AccessToken = null;
+ }
}
}
\ No newline at end of file
diff --git a/src/Greenshot.Plugin.Dropbox/DropboxConfiguration.cs b/src/Greenshot.Plugin.Dropbox/DropboxConfiguration.cs
index b9dd8bf0c..d79db8686 100644
--- a/src/Greenshot.Plugin.Dropbox/DropboxConfiguration.cs
+++ b/src/Greenshot.Plugin.Dropbox/DropboxConfiguration.cs
@@ -21,6 +21,7 @@
using System;
using System.Windows.Forms;
+using Greenshot.Base.Core;
using Greenshot.Base.Core.Enums;
using Greenshot.Base.IniFile;
using Greenshot.Plugin.Dropbox.Forms;
@@ -69,5 +70,20 @@ namespace Greenshot.Plugin.Dropbox
return false;
}
+
+ ///
+ /// Upgrade certain values
+ ///
+ public override void AfterLoad()
+ {
+ var coreConfiguration = IniConfig.GetIniSection();
+ bool isUpgradeFrom12 = coreConfiguration.LastSaveWithVersion?.StartsWith("1.2") ?? false;
+ // Clear token when we upgrade from 1.2 to 1.3 as it is no longer valid, discussed in #421
+ if (!isUpgradeFrom12) return;
+
+ // We have an upgrade, remove all previous credentials.
+ RefreshToken = null;
+ AccessToken = null;
+ }
}
}
\ No newline at end of file
diff --git a/src/Greenshot.Plugin.Flickr/FlickrConfiguration.cs b/src/Greenshot.Plugin.Flickr/FlickrConfiguration.cs
index e4f602796..df5a428fa 100644
--- a/src/Greenshot.Plugin.Flickr/FlickrConfiguration.cs
+++ b/src/Greenshot.Plugin.Flickr/FlickrConfiguration.cs
@@ -20,6 +20,7 @@
*/
using System.Windows.Forms;
+using Greenshot.Base.Core;
using Greenshot.Base.Core.Enums;
using Greenshot.Base.IniFile;
using Greenshot.Plugin.Flickr.Forms;
@@ -86,5 +87,21 @@ namespace Greenshot.Plugin.Flickr
return false;
}
+
+ ///
+ /// Upgrade certain values
+ ///
+ public override void AfterLoad()
+ {
+ var coreConfiguration = IniConfig.GetIniSection();
+ bool isUpgradeFrom12 = coreConfiguration.LastSaveWithVersion?.StartsWith("1.2") ?? false;
+ // Clear token when we upgrade from 1.2 to 1.3 as it is no longer valid, discussed in #421
+ if (!isUpgradeFrom12) return;
+
+ // We have an upgrade, remove all previous credentials.
+ FlickrToken = null;
+ FlickrTokenSecret = null;
+ }
+
}
}
\ No newline at end of file
diff --git a/src/Greenshot.Plugin.Imgur/ImgurConfiguration.cs b/src/Greenshot.Plugin.Imgur/ImgurConfiguration.cs
index 3bb695672..3dc145d0b 100644
--- a/src/Greenshot.Plugin.Imgur/ImgurConfiguration.cs
+++ b/src/Greenshot.Plugin.Imgur/ImgurConfiguration.cs
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
+using Greenshot.Base.Core;
using Greenshot.Base.Core.Enums;
using Greenshot.Base.IniFile;
using Greenshot.Plugin.Imgur.Forms;
@@ -84,6 +85,22 @@ namespace Greenshot.Plugin.Imgur
public Dictionary runtimeImgurHistory = new Dictionary();
public int Credits { get; set; }
+ ///
+ /// Upgrade certain values
+ ///
+ public override void AfterLoad()
+ {
+ var coreConfiguration = IniConfig.GetIniSection();
+ bool isUpgradeFrom12 = coreConfiguration.LastSaveWithVersion?.StartsWith("1.2") ?? false;
+ // Clear token when we upgrade from 1.2 to 1.3 as it is no longer valid, discussed in #421
+ if (!isUpgradeFrom12) return;
+
+ // We have an upgrade, remove all previous credentials.
+ AccessToken = null;
+ RefreshToken = null;
+ AccessTokenExpires = default;
+ }
+
///
/// Supply values we can't put as defaults
///
@@ -92,7 +109,7 @@ namespace Greenshot.Plugin.Imgur
public override object GetDefault(string property) =>
property switch
{
- "ImgurUploadHistory" => new Dictionary(),
+ nameof(ImgurUploadHistory) => new Dictionary(),
_ => null
};