Merge pull request #3 from greenshot/1.2

Merge from release/1.2 to master
This commit is contained in:
Robin Krom 2015-12-26 22:37:27 +01:00
commit 8941d5ad4b
32 changed files with 500 additions and 260 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}</ProjectGuid>
@ -18,7 +18,8 @@
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">

View file

@ -83,10 +83,15 @@ namespace Greenshot.Help
private static HttpStatusCode? GetHttpStatus(string url) {
try {
HttpWebRequest req = NetworkHelper.CreateWebRequest(url);
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
return res.StatusCode;
} catch(WebException e) {
if(e.Response != null) return ((HttpWebResponse)e.Response).StatusCode;
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
{
return res.StatusCode;
}
} catch (WebException e) {
if (e.Response != null)
{
return ((HttpWebResponse)e.Response).StatusCode;
}
return null;
}
}

View file

@ -213,7 +213,7 @@ namespace Greenshot.Helpers {
/// </summary>
/// <param name="pluginFiles"></param>
/// <param name="path"></param>
private void findPluginsOnPath(List<string> pluginFiles, String path) {
private void findPluginsOnPath(List<string> pluginFiles, string path) {
if (Directory.Exists(path)) {
try {
foreach (string pluginFile in Directory.GetFiles(path, "*.gsp", SearchOption.AllDirectories)) {

View file

@ -34,21 +34,20 @@ namespace Greenshot.Experimental {
/// Description of RssFeedHelper.
/// </summary>
public static class UpdateHelper {
private static ILog LOG = LogManager.GetLogger(typeof(UpdateHelper));
private static readonly ILog LOG = LogManager.GetLogger(typeof(UpdateHelper));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
private const string STABLE_DOWNLOAD_LINK = "http://getgreenshot.org/downloads/";
private const string VERSION_HISTORY_LINK = "http://getgreenshot.org/version-history/";
private static object lockObject = new object();
private static SourceforgeFile latestGreenshot;
private static SourceforgeFile currentGreenshot;
private static string downloadLink = STABLE_DOWNLOAD_LINK;
private static readonly object LockObject = new object();
private static SourceforgeFile _latestGreenshot;
private static string _downloadLink = STABLE_DOWNLOAD_LINK;
/// <summary>
/// Is an update check needed?
/// </summary>
/// <returns>bool true if yes</returns>
public static bool IsUpdateCheckNeeded() {
lock (lockObject) {
lock (LockObject) {
if (conf.UpdateCheckInterval == 0) {
return false;
}
@ -60,7 +59,7 @@ namespace Greenshot.Experimental {
return false;
}
LOG.DebugFormat("Update check is due, last check was {0} check needs to be made after {1} (which is one {2} later)", conf.LastUpdateCheck, checkTime, conf.UpdateCheckInterval);
if (!SourceForgeHelper.isRSSModifiedAfter(conf.LastUpdateCheck)) {
if (!SourceForgeHelper.IsRSSModifiedAfter(conf.LastUpdateCheck)) {
LOG.DebugFormat("RSS feed has not been updated since after {0}", conf.LastUpdateCheck);
return false;
}
@ -73,18 +72,18 @@ namespace Greenshot.Experimental {
/// Read the RSS feed to see if there is a Greenshot update
/// </summary>
public static void CheckAndAskForUpdate() {
lock (lockObject) {
lock (LockObject) {
Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version;
// Test like this:
// currentVersion = new Version("0.8.1.1198");
try {
latestGreenshot = null;
_latestGreenshot = null;
ProcessRSSInfo(currentVersion);
if (latestGreenshot != null) {
if (_latestGreenshot != null) {
MainForm.Instance.NotifyIcon.BalloonTipClicked += HandleBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClosed += CleanupBalloonTipClick;
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, "'" + latestGreenshot.File + "'"), ToolTipIcon.Info);
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, "'" + _latestGreenshot.File + "'"), ToolTipIcon.Info);
}
conf.LastUpdateCheck = DateTime.Now;
} catch (Exception e) {
@ -100,14 +99,14 @@ namespace Greenshot.Experimental {
private static void HandleBalloonTipClick(object sender, EventArgs e) {
try {
if (latestGreenshot != null) {
if (_latestGreenshot != null) {
// "Direct" download link
// Process.Start(latestGreenshot.Link);
// Go to getgreenshot.org
Process.Start(downloadLink);
Process.Start(_downloadLink);
}
} catch (Exception) {
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, downloadLink), Language.GetString(LangKey.error));
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, _downloadLink), Language.GetString(LangKey.error));
} finally {
CleanupBalloonTipClick(sender, e);
}
@ -158,18 +157,17 @@ namespace Greenshot.Experimental {
int versionCompare = rssFile.Version.CompareTo(currentVersion);
if (versionCompare > 0) {
LOG.DebugFormat("Found newer Greenshot '{0}' with version {1} published at {2} : {3}", file, rssFile.Version, rssFile.Pubdate.ToLocalTime(), rssFile.Link);
if (latestGreenshot == null || rssFile.Version.CompareTo(latestGreenshot.Version) > 0) {
latestGreenshot = rssFile;
if (_latestGreenshot == null || rssFile.Version.CompareTo(_latestGreenshot.Version) > 0) {
_latestGreenshot = rssFile;
if (rssFile.isReleaseCandidate || rssFile.isUnstable) {
downloadLink = VERSION_HISTORY_LINK;
_downloadLink = VERSION_HISTORY_LINK;
} else {
downloadLink = STABLE_DOWNLOAD_LINK;
_downloadLink = STABLE_DOWNLOAD_LINK;
}
}
} else if (versionCompare < 0) {
LOG.DebugFormat("Skipping older greenshot with version {0}", rssFile.Version);
} else if (versionCompare == 0) {
currentGreenshot = rssFile;
LOG.DebugFormat("Found current version as exe {0} with version {1} published at {2} : {3}", file, rssFile.Version, rssFile.Pubdate.ToLocalTime(), rssFile.Link);
}
}

View file

@ -9,6 +9,31 @@ All details to our tickets can be found here: https://greenshot.atlassian.net
@DETAILVERSION@
There were some major issues with the authenticated (non anonymous) uploads to Imgur.
After contacting Imgur they told us that their old API was deprecated or disabled, unfortunately this was not communicated.
Although we are working hard on Greenshot 1.3, where we changed most of the Imgur code already, we can't release it.
We did see a need to fix the imgur uploads, so in this release we quickly updated the Imgur API.
This should resolve a lot of tickets that were reported to us.
Additionally our website http://getgreenshot.org is hosted by sourceforge and they seem to have a lot of stability problems.
Due to these problems a bug in the Greenshot update check manifested itself and causes Greenshot to get slow or even stop responding.
In this version we fix the bug in the update check, and we are also working on a solution for the instability with our website.
Here is the list of chances:
Bugs Resolved:
BUG-1527 / BUG-1848 / BUG-1850 / BUG-1851 / BUG-1859 : Greenshot stops responding, hangs or crashes
BUG-1843 / BUG-1844 / BUG-1846 : Imgur problems with authenticated uploads
BUG-1864: Imgur link wasn't copied to the clipboard
Features:
FEATURE-896: Use Imgur with HTTPS (with changing the Imgur API from V2 to V3 this was already required for the upload anyway.)
1.2.7.2-342a506 RELEASE
Bugs Resolved:
* BUG-1809: OverflowException when changing the windows input language
* BUG-1835: Imgur: uploads were cancelled due to a timeout which was set too small

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{697CF066-9077-4F22-99D9-D989CCE7282B}</ProjectGuid>
@ -14,6 +14,11 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<NoWarn>1685</NoWarn>
<NoWarn>1685</NoWarn>
<ProjectGuid>{C3052651-598A-44E2-AAB3-2E41311D50F9}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>GreenshotConfluencePlugin</RootNamespace>
@ -15,6 +15,11 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}</ProjectGuid>
@ -14,6 +14,11 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{47F23C86-604E-4CC3-8767-B3D4088F30BB}</ProjectGuid>
@ -14,6 +14,11 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -125,7 +125,7 @@ namespace GreenshotFlickrPlugin
_config.ShowConfigDialog();
}
public bool Upload(ICaptureDetails captureDetails, ISurface surface, out String uploadUrl) {
public bool Upload(ICaptureDetails captureDetails, ISurface surface, out string uploadUrl) {
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, false);
uploadUrl = null;
try {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}</ProjectGuid>
@ -15,6 +15,10 @@
<RunPostBuildEvent>Always</RunPostBuildEvent>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}</ProjectGuid>
@ -17,7 +17,8 @@
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -18,6 +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.Collections.Generic;
using System.Windows.Forms;
using Greenshot.IniFile;
@ -41,14 +43,26 @@ namespace GreenshotImgurPlugin {
public int UploadJpegQuality;
[IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
public bool UploadReduceColors;
[IniProperty("CopyLinkToClipboard", Description = "Copy the link, which one is controlled by the UsePageLink, on the clipboard", DefaultValue = "True")]
public bool CopyLinkToClipboard;
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
public bool UsePageLink;
[IniProperty("AnonymousAccess", Description = "Use anonymous access to Imgur", DefaultValue="true")]
public bool AnonymousAccess;
[IniProperty("ImgurToken", Description = "The Imgur token", Encrypted=true, ExcludeIfNull=true)]
public string ImgurToken;
[IniProperty("ImgurTokenSecret", Description = "The Imgur token secret", Encrypted=true, ExcludeIfNull=true)]
public string ImgurTokenSecret;
[IniProperty("RefreshToken", Description = "Imgur refresh Token", Encrypted = true, ExcludeIfNull = true)]
public string RefreshToken;
/// <summary>
/// AccessToken, not stored
/// </summary>
public string AccessToken;
/// <summary>
/// AccessTokenExpires, not stored
/// </summary>
public DateTimeOffset AccessTokenExpires;
[IniProperty("AddTitle", Description = "Is the title passed on to Imgur", DefaultValue = "False")]
public bool AddTitle;
[IniProperty("AddFilename", Description = "Is the filename passed on to Imgur", DefaultValue = "False")]

View file

@ -29,10 +29,11 @@ namespace GreenshotImgurPlugin
/// </summary>
public class ImgurInfo : IDisposable {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurInfo));
private string hash;
public string Hash {
get {return hash;}
set {hash = value;}
public string Hash
{
get;
set;
}
private string deleteHash;
@ -40,57 +41,58 @@ namespace GreenshotImgurPlugin
get {return deleteHash;}
set {
deleteHash = value;
deletePage = "http://imgur.com/delete/" + value;
DeletePage = "https://imgur.com/delete/" + value;
}
}
private string title;
public string Title {
get {return title;}
set {title = value;}
public string Title
{
get;
set;
}
private string imageType;
public string ImageType {
get {return imageType;}
set {imageType = value;}
public string ImageType
{
get;
set;
}
private DateTime timestamp;
public DateTime Timestamp {
get {return timestamp;}
set {timestamp = value;}
public DateTime Timestamp
{
get;
set;
}
private string original;
public string Original {
get {return original;}
set {original = value;}
public string Original
{
get;
set;
}
private string page;
public string Page {
get {return page;}
set {page = value;}
public string Page
{
get;
set;
}
private string smallSquare;
public string SmallSquare {
get {return smallSquare;}
set {smallSquare = value;}
public string SmallSquare
{
get;
set;
}
private string largeThumbnail;
public string LargeThumbnail {
get {return largeThumbnail;}
set {largeThumbnail = value;}
public string LargeThumbnail
{
get;
set;
}
private string deletePage;
public string DeletePage {
get {return deletePage;}
set {deletePage = value;}
public string DeletePage
{
get;
set;
}
private Image image;
public Image Image {
get {return image;}
@ -166,48 +168,43 @@ namespace GreenshotImgurPlugin
}
nodes = doc.GetElementsByTagName("datetime");
if(nodes.Count > 0) {
try
// Version 3 has seconds since Epoch
double secondsSince;
if (double.TryParse(nodes.Item(0).InnerText, out secondsSince))
{
imgurInfo.Timestamp = DateTime.Parse(nodes.Item(0).InnerText);
}
catch (Exception)
{
// Version 3 has seconds since Epoch
double secondsSince;
if (double.TryParse(nodes.Item(0).InnerText, out secondsSince))
{
var epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
imgurInfo.Timestamp = epoch.AddSeconds(secondsSince).DateTime;
}
var epoch = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
imgurInfo.Timestamp = epoch.AddSeconds(secondsSince).DateTime;
}
}
nodes = doc.GetElementsByTagName("original");
if(nodes.Count > 0) {
imgurInfo.Original = nodes.Item(0).InnerText;
if (nodes.Count > 0)
{
imgurInfo.Original = nodes.Item(0).InnerText.Replace("http:", "https:");
}
// Version 3 API only has Link
nodes = doc.GetElementsByTagName("link");
if (nodes.Count > 0)
{
imgurInfo.Original = nodes.Item(0).InnerText;
imgurInfo.Original = nodes.Item(0).InnerText.Replace("http:", "https:");
}
nodes = doc.GetElementsByTagName("imgur_page");
if (nodes.Count > 0)
{
imgurInfo.Page = nodes.Item(0).InnerText;
imgurInfo.Page = nodes.Item(0).InnerText.Replace("http:", "https:");
}
else
{
// Version 3 doesn't have a page link in the response
imgurInfo.Page = string.Format("http://imgur.com/{0}", imgurInfo.Hash);
imgurInfo.Page = string.Format("https://imgur.com/{0}", imgurInfo.Hash);
}
nodes = doc.GetElementsByTagName("small_square");
if(nodes.Count > 0) {
imgurInfo.SmallSquare = nodes.Item(0).InnerText;
}
nodes = doc.GetElementsByTagName("large_thumbnail");
if(nodes.Count > 0) {
imgurInfo.LargeThumbnail = nodes.Item(0).InnerText;
if(nodes.Count > 0)
{
imgurInfo.LargeThumbnail = nodes.Item(0).InnerText.Replace("http:", "https:");
}
} catch(Exception e) {
LOG.ErrorFormat("Could not parse Imgur response due to error {0}, response was: {1}", e.Message, response);

View file

@ -194,17 +194,27 @@ namespace GreenshotImgurPlugin {
imgurInfo.Image = ImageHelper.CreateThumbnail(tmpImage, 90, 90);
}
IniConfig.Save();
try {
if (config.UsePageLink) {
uploadURL = imgurInfo.Page;
ClipboardHelper.SetClipboardData(imgurInfo.Page);
} else {
uploadURL = imgurInfo.Original;
ClipboardHelper.SetClipboardData(imgurInfo.Original);
if (config.UsePageLink)
{
uploadURL = imgurInfo.Page;
}
else
{
uploadURL = imgurInfo.Original;
}
if (!string.IsNullOrEmpty(uploadURL) && config.CopyLinkToClipboard)
{
try
{
ClipboardHelper.SetClipboardData(uploadURL);
}
catch (Exception ex)
{
LOG.Error("Can't write to clipboard: ", ex);
uploadURL = null;
}
} catch (Exception ex) {
LOG.Error("Can't write to clipboard: ", ex);
uploadURL = null;
}
return true;
}

View file

@ -33,38 +33,39 @@ namespace GreenshotImgurPlugin {
/// </summary>
public static class ImgurUtils {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurUtils));
private const string IMGUR_ANONYMOUS_API_KEY = "60e8838e21d6b66";
private const string SMALL_URL_PATTERN = "http://i.imgur.com/{0}s.png";
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
private const string SmallUrlPattern = "http://i.imgur.com/{0}s.jpg";
private static readonly ImgurConfiguration Config = IniConfig.GetIniSection<ImgurConfiguration>();
private const string AuthUrlPattern = "https://api.imgur.com/oauth2/authorize?response_type=code&client_id={ClientId}&redirect_uri={RedirectUrl}&state={State}";
private const string TokenUrl = "https://api.imgur.com/oauth2/token";
/// <summary>
/// Load the complete history of the imgur uploads, with the corresponding information
/// </summary>
public static void LoadHistory() {
if (config.runtimeImgurHistory.Count == config.ImgurUploadHistory.Count) {
if (Config.runtimeImgurHistory.Count == Config.ImgurUploadHistory.Count) {
return;
}
// Load the ImUr history
List<string> hashes = new List<string>();
foreach(string hash in config.ImgurUploadHistory.Keys) {
foreach(string hash in Config.ImgurUploadHistory.Keys) {
hashes.Add(hash);
}
bool saveNeeded = false;
foreach(string hash in hashes) {
if (config.runtimeImgurHistory.ContainsKey(hash)) {
if (Config.runtimeImgurHistory.ContainsKey(hash)) {
// Already loaded
continue;
}
try {
ImgurInfo imgurInfo = RetrieveImgurInfo(hash, config.ImgurUploadHistory[hash]);
ImgurInfo imgurInfo = RetrieveImgurInfo(hash, Config.ImgurUploadHistory[hash]);
if (imgurInfo != null) {
RetrieveImgurThumbnail(imgurInfo);
config.runtimeImgurHistory.Add(hash, imgurInfo);
Config.runtimeImgurHistory.Add(hash, imgurInfo);
} else {
LOG.DebugFormat("Deleting not found ImgUr {0} from config.", hash);
config.ImgurUploadHistory.Remove(hash);
Config.ImgurUploadHistory.Remove(hash);
saveNeeded = true;
}
} catch (WebException wE) {
@ -74,7 +75,7 @@ namespace GreenshotImgurPlugin {
// Image no longer available
if (response.StatusCode == HttpStatusCode.Redirect) {
LOG.InfoFormat("ImgUr image for hash {0} is no longer available", hash);
config.ImgurUploadHistory.Remove(hash);
Config.ImgurUploadHistory.Remove(hash);
redirected = true;
}
}
@ -96,7 +97,7 @@ namespace GreenshotImgurPlugin {
/// </summary>
/// <param name="webRequest"></param>
private static void SetClientId(HttpWebRequest webRequest) {
webRequest.Headers.Add("Authorization", "Client-ID " + IMGUR_ANONYMOUS_API_KEY);
webRequest.Headers.Add("Authorization", "Client-ID " + ImgurCredentials.CONSUMER_KEY);
}
/// <summary>
@ -109,21 +110,20 @@ namespace GreenshotImgurPlugin {
/// <param name="filename">Filename</param>
/// <returns>ImgurInfo with details</returns>
public static ImgurInfo UploadToImgur(ISurface surfaceToUpload, SurfaceOutputSettings outputSettings, string title, string filename) {
IDictionary<string, object> uploadParameters = new Dictionary<string, object>();
IDictionary<string, object> otherParameters = new Dictionary<string, object>();
// add title
if (title != null && config.AddTitle) {
if (title != null && Config.AddTitle) {
otherParameters.Add("title", title);
}
// add filename
if (filename != null && config.AddFilename) {
if (filename != null && Config.AddFilename) {
otherParameters.Add("name", filename);
}
string responseString = null;
if (config.AnonymousAccess) {
string responseString;
if (Config.AnonymousAccess) {
// add key, we only use the other parameters for the AnonymousAccess
//otherParameters.Add("key", IMGUR_ANONYMOUS_API_KEY);
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(config.ImgurApi3Url + "/upload.xml?" + NetworkHelper.GenerateQueryParameters(otherParameters), HTTPMethod.POST);
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(Config.ImgurApi3Url + "/upload.xml?" + NetworkHelper.GenerateQueryParameters(otherParameters), HTTPMethod.POST);
webRequest.ContentType = "image/" + outputSettings.Format;
webRequest.ServicePoint.Expect100Continue = false;
@ -144,40 +144,38 @@ namespace GreenshotImgurPlugin {
throw;
}
} else {
OAuthSession oAuth = new OAuthSession(ImgurCredentials.CONSUMER_KEY, ImgurCredentials.CONSUMER_SECRET);
oAuth.BrowserSize = new Size(650, 500);
oAuth.CallbackUrl = "http://getgreenshot.org";
oAuth.AccessTokenUrl = "http://api.imgur.com/oauth/access_token";
oAuth.AuthorizeUrl = "http://api.imgur.com/oauth/authorize";
oAuth.RequestTokenUrl = "http://api.imgur.com/oauth/request_token";
oAuth.LoginTitle = "Imgur authorization";
oAuth.Token = config.ImgurToken;
oAuth.TokenSecret = config.ImgurTokenSecret;
if (string.IsNullOrEmpty(oAuth.Token)) {
if (!oAuth.Authorize()) {
return null;
}
if (!string.IsNullOrEmpty(oAuth.Token)) {
config.ImgurToken = oAuth.Token;
}
if (!string.IsNullOrEmpty(oAuth.TokenSecret)) {
config.ImgurTokenSecret = oAuth.TokenSecret;
}
IniConfig.Save();
}
try {
var oauth2Settings = new OAuth2Settings();
oauth2Settings.AuthUrlPattern = AuthUrlPattern;
oauth2Settings.TokenUrl = TokenUrl;
oauth2Settings.RedirectUrl = "https://imgur.com";
oauth2Settings.CloudServiceName = "Imgur";
oauth2Settings.ClientId = ImgurCredentials.CONSUMER_KEY;
oauth2Settings.ClientSecret = ImgurCredentials.CONSUMER_SECRET;
oauth2Settings.AuthorizeMode = OAuth2AuthorizeMode.EmbeddedBrowser;
oauth2Settings.BrowserSize = new Size(680, 880);
// Copy the settings from the config, which is kept in memory and on the disk
oauth2Settings.RefreshToken = Config.RefreshToken;
oauth2Settings.AccessToken = Config.AccessToken;
oauth2Settings.AccessTokenExpires = Config.AccessTokenExpires;
try
{
var webRequest = OAuth2Helper.CreateOAuth2WebRequest(HTTPMethod.POST, Config.ImgurApi3Url + "/upload.xml", oauth2Settings);
otherParameters.Add("image", new SurfaceContainer(surfaceToUpload, outputSettings, filename));
responseString = oAuth.MakeOAuthRequest(HTTPMethod.POST, "http://api.imgur.com/2/account/images.xml", uploadParameters, otherParameters, null);
} catch (Exception ex) {
LOG.Error("Upload to imgur gave an exeption: ", ex);
throw;
} finally {
if (oAuth.Token != null) {
config.ImgurToken = oAuth.Token;
}
if (oAuth.TokenSecret != null) {
config.ImgurTokenSecret = oAuth.TokenSecret;
}
NetworkHelper.WriteMultipartFormData(webRequest, otherParameters);
responseString = NetworkHelper.GetResponseAsString(webRequest);
}
finally
{
// Copy the settings back to the config, so they are stored.
Config.RefreshToken = oauth2Settings.RefreshToken;
Config.AccessToken = oauth2Settings.AccessToken;
Config.AccessTokenExpires = oauth2Settings.AccessTokenExpires;
Config.IsDirty = true;
IniConfig.Save();
}
}
@ -194,15 +192,17 @@ namespace GreenshotImgurPlugin {
return;
}
LOG.InfoFormat("Retrieving Imgur image for {0} with url {1}", imgurInfo.Hash, imgurInfo.SmallSquare);
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(string.Format(SMALL_URL_PATTERN, imgurInfo.Hash), HTTPMethod.GET);
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(string.Format(SmallUrlPattern, imgurInfo.Hash), HTTPMethod.GET);
webRequest.ServicePoint.Expect100Continue = false;
SetClientId(webRequest);
using (WebResponse response = webRequest.GetResponse()) {
LogRateLimitInfo(response);
Stream responseStream = response.GetResponseStream();
imgurInfo.Image = Image.FromStream(responseStream);
if (responseStream != null)
{
imgurInfo.Image = Image.FromStream(responseStream);
}
}
return;
}
/// <summary>
@ -212,7 +212,7 @@ namespace GreenshotImgurPlugin {
/// <param name="deleteHash"></param>
/// <returns>ImgurInfo</returns>
public static ImgurInfo RetrieveImgurInfo(string hash, string deleteHash) {
string url = config.ImgurApiUrl + "/image/" + hash;
string url = Config.ImgurApiUrl + "/image/" + hash;
LOG.InfoFormat("Retrieving Imgur info for {0} with url {1}", hash, url);
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(url, HTTPMethod.GET);
webRequest.ServicePoint.Expect100Continue = false;
@ -247,7 +247,7 @@ namespace GreenshotImgurPlugin {
LOG.InfoFormat("Deleting Imgur image for {0}", imgurInfo.DeleteHash);
try {
string url = config.ImgurApiUrl + "/delete/" + imgurInfo.DeleteHash;
string url = Config.ImgurApiUrl + "/delete/" + imgurInfo.DeleteHash;
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(url, HTTPMethod.GET);
webRequest.ServicePoint.Expect100Continue = false;
SetClientId(webRequest);
@ -268,8 +268,8 @@ namespace GreenshotImgurPlugin {
}
}
// Make sure we remove it from the history, if no error occured
config.runtimeImgurHistory.Remove(imgurInfo.Hash);
config.ImgurUploadHistory.Remove(imgurInfo.Hash);
Config.runtimeImgurHistory.Remove(imgurInfo.Hash);
Config.ImgurUploadHistory.Remove(imgurInfo.Hash);
imgurInfo.Image = null;
}
@ -304,9 +304,9 @@ namespace GreenshotImgurPlugin {
LogHeader(nameValues, "X-RateLimit-ClientRemaining");
// Update the credits in the config, this is shown in a form
int credits = 0;
int credits;
if (nameValues.ContainsKey("X-RateLimit-Remaining") && int.TryParse(nameValues["X-RateLimit-Remaining"], out credits)) {
config.Credits = credits;
Config.Credits = credits;
}
}
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{19FEEF09-313F-43C7-819D-F1BCA782B08B}</ProjectGuid>
@ -17,7 +17,8 @@
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
@ -37,7 +38,9 @@
<Compile Include="Forms\JiraForm.Designer.cs">
<DependentUpon>JiraForm.cs</DependentUpon>
</Compile>
<Compile Include="Forms\JiraFormBase.cs" />
<Compile Include="Forms\JiraFormBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SettingsForm.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@ -20,6 +20,11 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugType>full</DebugType>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{C6988EE8-2FEE-4349-9F09-F9628A0D8965}</ProjectGuid>
@ -17,7 +17,8 @@
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -15,6 +15,11 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>

View file

@ -31,7 +31,6 @@ namespace GreenshotOfficePlugin {
public class OfficePlugin : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OfficePlugin));
public static PluginAttribute Attributes;
private IGreenshotHost host;
public void Dispose() {
Dispose(true);
@ -42,11 +41,8 @@ namespace GreenshotOfficePlugin {
//if (disposing) {}
}
public OfficePlugin() {
}
public IEnumerable<IDestination> Destinations() {
IDestination destination = null;
IDestination destination;
try {
destination = new ExcelDestination();
} catch {
@ -100,12 +96,10 @@ namespace GreenshotOfficePlugin {
/// <summary>
/// Implementation of the IGreenshotPlugin.Initialize
/// </summary>
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
/// <param name="pluginAttribute">My own attributes</param>
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="myAttributes">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;
Attributes = myAttributes;
return true;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{9C0ECC4C-7807-4111-916A-4F57BB29788A}</ProjectGuid>
@ -14,6 +14,11 @@
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{1893A2E4-A78A-4713-A8E7-E70058DABEE0}</ProjectGuid>
@ -13,9 +13,12 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>Always</RunPostBuildEvent>
<FileUpgradeFlags />
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -77,12 +77,18 @@ namespace GreenshotPlugin.Core {
Uri url = new Uri(baseUri, new Uri("favicon.ico"));
try {
HttpWebRequest request = CreateWebRequest(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (request.HaveResponse) {
using (Stream responseStream = response.GetResponseStream()) {
if (responseStream != null) {
using (Image image = Image.FromStream(responseStream)) {
return (image.Height > 16 && image.Width > 16) ? new Bitmap(image, 16, 16) : new Bitmap(image);
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
if (request.HaveResponse)
{
using (Stream responseStream = response.GetResponseStream())
{
if (responseStream != null)
{
using (Image image = Image.FromStream(responseStream))
{
return (image.Height > 16 && image.Width > 16) ? new Bitmap(image, 16, 16) : new Bitmap(image);
}
}
}
}
@ -424,6 +430,32 @@ namespace GreenshotPlugin.Core {
return GetResponseAsString(webRequest, false);
}
/// <summary>
/// Read the response as string
/// </summary>
/// <param name="response"></param>
/// <returns>string or null</returns>
private static string GetResponseAsString(HttpWebResponse response)
{
string responseData = null;
if (response == null)
{
return null;
}
using (response)
{
Stream responseStream = response.GetResponseStream();
if (responseStream != null)
{
using (StreamReader reader = new StreamReader(responseStream, true))
{
responseData = reader.ReadToEnd();
}
}
}
return responseData;
}
/// <summary>
///
/// </summary>
@ -431,40 +463,54 @@ namespace GreenshotPlugin.Core {
/// <returns></returns>
public static string GetResponseAsString(HttpWebRequest webRequest, bool alsoReturnContentOnError) {
string responseData = null;
try {
HttpWebResponse response = (HttpWebResponse) webRequest.GetResponse();
HttpWebResponse response = null;
bool isHttpError = false;
try {
response = (HttpWebResponse)webRequest.GetResponse();
LOG.InfoFormat("Response status: {0}", response.StatusCode);
bool isHttpError = (int) response.StatusCode >= 300;
DebugHeaders(response);
Stream responseStream = response.GetResponseStream();
if (responseStream != null) {
using (StreamReader reader = new StreamReader(responseStream, true)) {
responseData = reader.ReadToEnd();
}
if (isHttpError) {
LOG.ErrorFormat("HTTP error {0} with content: {1}", response.StatusCode, responseData);
}
}
} catch (WebException e) {
HttpWebResponse response = (HttpWebResponse) e.Response;
if (response != null) {
isHttpError = (int)response.StatusCode >= 300;
if (isHttpError)
{
LOG.ErrorFormat("HTTP error {0}", response.StatusCode);
using (Stream responseStream = response.GetResponseStream()) {
if (responseStream != null) {
using (StreamReader streamReader = new StreamReader(responseStream, true)) {
string errorContent = streamReader.ReadToEnd();
if (alsoReturnContentOnError) {
return errorContent;
}
LOG.ErrorFormat("Content: {0}", errorContent);
}
}
}
DebugHeaders(response);
responseData = GetResponseAsString(response);
if (isHttpError)
{
LOG.ErrorFormat("HTTP response {0}", responseData);
}
}
catch (WebException e) {
response = (HttpWebResponse) e.Response;
HttpStatusCode statusCode = HttpStatusCode.Unused;
if (response != null) {
statusCode = response.StatusCode;
LOG.ErrorFormat("HTTP error {0}", statusCode);
string errorContent = GetResponseAsString(response);
if (alsoReturnContentOnError)
{
return errorContent;
}
LOG.ErrorFormat("Content: {0}", errorContent);
}
LOG.Error("WebException: ", e);
if (statusCode == HttpStatusCode.Unauthorized)
{
throw new UnauthorizedAccessException(e.Message);
}
throw;
}
finally
{
if (response != null)
{
if (isHttpError)
{
LOG.ErrorFormat("HTTP error {0} with content: {1}", response.StatusCode, responseData);
}
response.Close();
}
}
return responseData;
}
@ -477,9 +523,11 @@ namespace GreenshotPlugin.Core {
try {
HttpWebRequest webRequest = CreateWebRequest(uri);
webRequest.Method = HTTPMethod.HEAD.ToString();
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
LOG.DebugFormat("RSS feed was updated at {0}", webResponse.LastModified);
return webResponse.LastModified;
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
LOG.DebugFormat("RSS feed was updated at {0}", webResponse.LastModified);
return webResponse.LastModified;
}
} catch (Exception wE) {
LOG.WarnFormat("Problem requesting HTTP - HEAD on uri {0}", uri);
LOG.Warn(wE.Message);

View file

@ -476,7 +476,8 @@ namespace GreenshotPlugin.Core {
/// <summary>
/// Get the request token using the consumer key and secret. Also initializes tokensecret
/// </summary>
private void GetRequestToken() {
/// <returns>response, this doesn't need to be used!!</returns>
private string GetRequestToken() {
IDictionary<string, object> parameters = new Dictionary<string, object>();
foreach(var value in _requestTokenParameters) {
parameters.Add(value);
@ -493,15 +494,17 @@ namespace GreenshotPlugin.Core {
TokenSecret = _requestTokenResponseParameters[OAUTH_TOKEN_SECRET_KEY];
}
}
return response;
}
/// <summary>
/// Authorize the token by showing the dialog
/// </summary>
/// <param name="requestTokenResponse">Pass the response from the server's request token, so if there is something wrong we can show it.</param>
/// <returns>The request token.</returns>
private String GetAuthorizeToken() {
private string GetAuthorizeToken(string requestTokenResponse) {
if (string.IsNullOrEmpty(Token)) {
Exception e = new Exception("The request token is not set");
Exception e = new Exception("The request token is not set, service responded with: " + requestTokenResponse);
throw e;
}
LOG.DebugFormat("Opening AuthorizationLink: {0}", AuthorizationLink);
@ -532,7 +535,7 @@ namespace GreenshotPlugin.Core {
/// Get the access token
/// </summary>
/// <returns>The access token.</returns>
private String GetAccessToken() {
private string GetAccessToken() {
if (string.IsNullOrEmpty(Token) || (CheckVerifier && string.IsNullOrEmpty(Verifier))) {
Exception e = new Exception("The request token and verifier were not set");
throw e;
@ -567,13 +570,14 @@ namespace GreenshotPlugin.Core {
TokenSecret = null;
Verifier = null;
LOG.Debug("Creating Token");
try {
GetRequestToken();
string requestTokenResponse;
try {
requestTokenResponse = GetRequestToken();
} catch (Exception ex) {
LOG.Error(ex);
throw new NotSupportedException("Service is not available: " + ex.Message);
}
if (string.IsNullOrEmpty(GetAuthorizeToken())) {
if (string.IsNullOrEmpty(GetAuthorizeToken(requestTokenResponse))) {
LOG.Debug("User didn't authenticate!");
return false;
}
@ -663,39 +667,36 @@ namespace GreenshotPlugin.Core {
}
try {
Sign(method, signUrl, parametersToSign);
// Join all parameters
IDictionary<string, object> newParameters = new Dictionary<string, object>();
foreach(var parameter in parametersToSign) {
foreach (var parameter in parametersToSign) {
newParameters.Add(parameter);
}
if (additionalParameters != null) {
foreach(var parameter in additionalParameters) {
foreach (var parameter in additionalParameters) {
newParameters.Add(parameter);
}
}
return MakeRequest(method, requestURL, headers, newParameters, postData);
} catch (WebException wEx) {
lastException = wEx;
if (wEx.Response != null) {
HttpWebResponse response = wEx.Response as HttpWebResponse;
if (response != null && response.StatusCode == HttpStatusCode.Unauthorized) {
Token = null;
TokenSecret = null;
// Remove oauth keys, so they aren't added double
List<string> keysToDelete = new List<string>();
foreach (string parameterKey in parametersToSign.Keys) {
if (parameterKey.StartsWith(OAUTH_PARAMETER_PREFIX)) {
keysToDelete.Add(parameterKey);
}
}
foreach(string keyToDelete in keysToDelete) {
parametersToSign.Remove(keyToDelete);
}
continue;
} catch (UnauthorizedAccessException uaEx) {
lastException = uaEx;
Token = null;
TokenSecret = null;
// Remove oauth keys, so they aren't added double
List<string> keysToDelete = new List<string>();
foreach (string parameterKey in parametersToSign.Keys)
{
if (parameterKey.StartsWith(OAUTH_PARAMETER_PREFIX))
{
keysToDelete.Add(parameterKey);
}
}
throw;
foreach (string keyToDelete in keysToDelete)
{
parametersToSign.Remove(keyToDelete);
}
continue;
}
}
if (lastException != null) {

View file

@ -97,15 +97,21 @@ namespace GreenshotPlugin.Core {
/// </summary>
public class SourceForgeHelper {
private static ILog LOG = LogManager.GetLogger(typeof(SourceForgeHelper));
private const String RSSFEED = "http://getgreenshot.org/project-feed/";
private const string RSSFEED = "http://getgreenshot.org/project-feed/";
/// <summary>
/// This is using the HTTP HEAD Method to check if the RSS Feed is modified after the supplied date
/// </summary>
/// <param name="updateTime">DateTime</param>
/// <returns>true if the feed is newer</returns>
public static bool isRSSModifiedAfter(DateTime updateTime) {
public static bool IsRSSModifiedAfter(DateTime updateTime) {
DateTime lastModified = NetworkHelper.GetLastModified(new Uri(RSSFEED));
if (lastModified == DateTime.MinValue)
{
// Time could not be read, just take now and add one hour to it.
// This assist BUG-1850
lastModified = DateTime.Now.AddHours(1);
}
return updateTime.CompareTo(lastModified) < 0;
}

View file

@ -1490,7 +1490,7 @@ namespace GreenshotPlugin.Core {
/// </summary>
/// <param name="hWnd">IntPtr with the windows handle</param>
/// <returns>String with ClassName</returns>
public static String GetClassName(IntPtr hWnd) {
public static string GetClassName(IntPtr hWnd) {
StringBuilder classNameBuilder = new StringBuilder(260, 260);
User32.GetClassName(hWnd, classNameBuilder, classNameBuilder.Capacity);
return classNameBuilder.ToString();

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\CommonProject.properties" />
<PropertyGroup>
<ProjectGuid>{5B924697-4DCD-4F98-85F1-105CB84B7341}</ProjectGuid>
@ -14,6 +14,11 @@
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>

View file

@ -142,8 +142,6 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public static extern bool ShowScrollBar(IntPtr hwnd, ScrollBarDirection scrollBar, bool show);
[DllImport("user32", SetLastError = true)]
public static extern int SetScrollPos(IntPtr hWnd, Orientation nBar, int nPos, bool bRedraw);
[DllImport("user32", SetLastError=true)]
public static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
[DllImport("user32", SetLastError = true)]
public static extern RegionResult GetWindowRgn(IntPtr hWnd, SafeHandle hRgn);
[DllImport("user32", SetLastError = true)]

View file

@ -1,10 +1,11 @@
version: 1.2.7.{build}
version: 1.2.8.{build}
branches:
only:
- 1.2
skip_tags: true
configuration: Release
platform: Any CPU
shallow_clone: true
clone_depth: 1
assembly_info:
patch: true
@ -26,9 +27,9 @@ environment:
credentials_flickr_consumer_secret:
secure: 9TthlljPHXWPkDDeG3uiFVJ9YJwHZOV0ZsojaIBBuvw=
credentials_imgur_consumer_key:
secure: z8S4QZ3/InPe3dgCf0CNyS0VGKuRyjjP8WMAq+AkK5OZJxZcbIxwobjgelE5CWYL
secure: XRTg1Ecs6ER9m4779CJAng==
credentials_imgur_consumer_secret:
secure: ovfXJRorkkKUzbMXuZ4m0U6KF4icngmS+nzSljXJGSKfhI+GNXbMNa//mKYfTCXI
secure: gcCp/gJF8vqmnCUPKyb04H8Oz9mWmiB00U5X7iI/DGr5mxjoCG1khc6/zn6aSSqn
credentials_photobucket_consumer_key:
secure: oo9GD1Y8dkrli6hMfnnYsw==
credentials_photobucket_consumer_secret:
@ -81,4 +82,4 @@ notifications:
- jens@getgreenshot.org
on_build_success: true
on_build_failure: true
on_build_status_changed: false
on_build_status_changed: false

92
appveyor13.yml Normal file
View file

@ -0,0 +1,92 @@
version: 1.3.0.{build}
branches:
only:
- 1.3
skip_tags: true
configuration: Release
platform: Any CPU
shallow_clone: true
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}-$(build_type)-$(APPVEYOR_REPO_COMMIT)'
environment:
credentials_box_client_id:
secure: 8MKxTOowo2fat6cNXGbFfvn6typiEtmCKsrptrWiEFUEoKlT1DUn40iGNcIELRA1
credentials_box_client_secret:
secure: hJhzDVJuGd/WMnoSXhosvOM/1PGcYlKbtQjA6xyrmnmZcqCTMzqIdA6JXlo/V2Br
credentials_dropbox_consumer_key:
secure: Da/6KY1cu9CUM3iOqSpcUw==
credentials_dropbox_consumer_secret:
secure: KkyKyUY+buT/MZagXDP4cw==
credentials_flickr_consumer_key:
secure: fY8s0OkOMYwCjSZoL/6yZcP8xeT6J2EJLjbUMI5lAW42S5QT2U2B41KrmeP2NpnQ
credentials_flickr_consumer_secret:
secure: 9TthlljPHXWPkDDeG3uiFVJ9YJwHZOV0ZsojaIBBuvw=
credentials_imgur_consumer_key:
secure: XRTg1Ecs6ER9m4779CJAng==
credentials_imgur_consumer_secret:
secure: gcCp/gJF8vqmnCUPKyb04H8Oz9mWmiB00U5X7iI/DGr5mxjoCG1khc6/zn6aSSqn
credentials_photobucket_consumer_key:
secure: oo9GD1Y8dkrli6hMfnnYsw==
credentials_photobucket_consumer_secret:
secure: GiNPoe9klM/YkoHIA/YHqOYrIaYwSFK7Ph9m8jT9uPP1l6+Hd5K8dVMw5DNa50oG
credentials_picasa_consumer_key:
secure: bjKXhFZkDqaq98XBrz5oQKQfT8CLpuv2ZAiBIwkzloaAPUs97b5yx6h/xFaE4NLS
credentials_picasa_consumer_secret:
secure: yNptTpmJWypbu9alOQtetxU66drr2FKxoPflNgRJdag=
build_type: ALPHA
before_build:
- nuget restore
- ps: Build/prebuild.ps1
build:
project: greenshot.sln
verbosity: normal
after_build:
- ps: Build/build.ps1
test: off
artifacts:
- path: AssemblyDir\Greenshot*INSTALLER*.exe
name: Installer
- path: AssemblyDir\Greenshot*paf.exe
name: Portable
- path: AssemblyDir\Greenshot-NO*.zip
name: Zip
- path: Build\additional_files\readme.txt
name: Readme
- path: AssemblyDir\Greenshot-DEBUGSYMBOLS*.zip
name: DEBUGSYMBOLS
deploy:
- provider: GitHub
tag: Greenshot-$(build_type)-$(APPVEYOR_BUILD_VERSION)
description:
auth_token:
secure: h0R+O/UoDM5Fy9XBfpRWLxFdR4a6CS+hDxr/MUeiRSviAmUsSlvsGSyOG6KiAVrL
prerelease: true
on:
build_type: RELEASE_CANDIDATE
- provider: GitHub
tag: Greenshot-$(build_type)-$(APPVEYOR_BUILD_VERSION)
description:
auth_token:
secure: h0R+O/UoDM5Fy9XBfpRWLxFdR4a6CS+hDxr/MUeiRSviAmUsSlvsGSyOG6KiAVrL
prerelease: true
on:
build_type: BETA
- provider: GitHub
tag: Greenshot-$(build_type)-$(APPVEYOR_BUILD_VERSION)
auth_token:
secure: h0R+O/UoDM5Fy9XBfpRWLxFdR4a6CS+hDxr/MUeiRSviAmUsSlvsGSyOG6KiAVrL
on:
build_type: RELEASE
notifications:
- provider: Email
to:
- robin@getgreenshot.org
- jens@getgreenshot.org
- thomas@getgreenshot.org
on_build_success: true
on_build_failure: true
on_build_status_changed: true

View file

@ -290,5 +290,3 @@ PackagePortable
echo "Generating Debug Symbols ZIP"
PackageDbgSymbolsZip
echo "build successful, tagging with $fileversion"
TagCode