mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Hacked the Imgur plugin to partly work with the version 3, so AnonymousAccess works. Added a more rough filtering for the language issues, fixed an update check, fixed a problem when closing the history and updated the readme.txt
This commit is contained in:
parent
213b332a66
commit
45c0e1efed
8 changed files with 59 additions and 39 deletions
|
@ -11,7 +11,8 @@ All details to our tickets can be found here: https://greenshot.atlassian.net
|
|||
|
||||
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
|
||||
* BUG-1835: Imgur: uploads were cancelled due to a timeout which was set too small
|
||||
* BUG-1833: Imgur: API-Key issues when using anonymous uploads
|
||||
|
||||
|
||||
1.2.6.7-359dcf3 RELEASE
|
||||
|
|
|
@ -117,6 +117,7 @@ namespace GreenshotImgurPlugin
|
|||
this.finishedButton.TabIndex = 11;
|
||||
this.finishedButton.Text = "Finished";
|
||||
this.finishedButton.UseVisualStyleBackColor = true;
|
||||
this.finishedButton.Click += new System.EventHandler(this.FinishedButtonClick);
|
||||
//
|
||||
// clipboardButton
|
||||
//
|
||||
|
|
|
@ -167,6 +167,11 @@ namespace GreenshotImgurPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
private void FinishedButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
private void OpenButtonClick(object sender, EventArgs e) {
|
||||
if (listview_imgur_uploads.SelectedItems != null && listview_imgur_uploads.SelectedItems.Count > 0) {
|
||||
for (int i = 0; i < listview_imgur_uploads.SelectedItems.Count; i++) {
|
||||
|
|
|
@ -30,8 +30,10 @@ namespace GreenshotImgurPlugin {
|
|||
/// </summary>
|
||||
[IniSection("Imgur", Description="Greenshot Imgur Plugin configuration")]
|
||||
public class ImgurConfiguration : IniSection {
|
||||
[IniProperty("ImgurApiUrl", Description="Url to Imgur system.", DefaultValue="http://api.imgur.com/2")]
|
||||
[IniProperty("ImgurApiUrl", Description="Url to Imgur system.", DefaultValue= "http://api.imgur.com/2")]
|
||||
public string ImgurApiUrl;
|
||||
[IniProperty("ImgurApi3Url", Description = "Url to Imgur system.", DefaultValue = "https://api.imgur.com/3")]
|
||||
public string ImgurApi3Url;
|
||||
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
|
|
|
@ -143,10 +143,15 @@ namespace GreenshotImgurPlugin
|
|||
try {
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(response);
|
||||
XmlNodeList nodes = doc.GetElementsByTagName("hash");
|
||||
XmlNodeList nodes = doc.GetElementsByTagName("id");
|
||||
if(nodes.Count > 0) {
|
||||
imgurInfo.Hash = nodes.Item(0).InnerText;
|
||||
}
|
||||
nodes = doc.GetElementsByTagName("hash");
|
||||
if (nodes.Count > 0)
|
||||
{
|
||||
imgurInfo.Hash = nodes.Item(0).InnerText;
|
||||
}
|
||||
nodes = doc.GetElementsByTagName("deletehash");
|
||||
if(nodes.Count > 0) {
|
||||
imgurInfo.DeleteHash = nodes.Item(0).InnerText;
|
||||
|
|
|
@ -33,7 +33,8 @@ 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 = "8116a978913f3cf5dfc8e1117a055056";
|
||||
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>();
|
||||
|
||||
/// <summary>
|
||||
|
@ -57,9 +58,9 @@ namespace GreenshotImgurPlugin {
|
|||
continue;
|
||||
}
|
||||
try {
|
||||
ImgurInfo imgurInfo = ImgurUtils.RetrieveImgurInfo(hash, config.ImgurUploadHistory[hash]);
|
||||
ImgurInfo imgurInfo = RetrieveImgurInfo(hash, config.ImgurUploadHistory[hash]);
|
||||
if (imgurInfo != null) {
|
||||
ImgurUtils.RetrieveImgurThumbnail(imgurInfo);
|
||||
RetrieveImgurThumbnail(imgurInfo);
|
||||
config.runtimeImgurHistory.Add(hash, imgurInfo);
|
||||
} else {
|
||||
LOG.DebugFormat("Deleting not found ImgUr {0} from config.", hash);
|
||||
|
@ -95,7 +96,7 @@ namespace GreenshotImgurPlugin {
|
|||
/// </summary>
|
||||
/// <param name="webRequest"></param>
|
||||
private static void SetClientId(HttpWebRequest webRequest) {
|
||||
webRequest.Headers.Add("Authorization", "Client-ID " + ImgurCredentials.CONSUMER_KEY);
|
||||
webRequest.Headers.Add("Authorization", "Client-ID " + IMGUR_ANONYMOUS_API_KEY);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -121,9 +122,9 @@ namespace GreenshotImgurPlugin {
|
|||
string responseString = null;
|
||||
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.ImgurApiUrl + "/upload.xml?" + NetworkHelper.GenerateQueryParameters(otherParameters), HTTPMethod.POST);
|
||||
webRequest.ContentType = "image/" + outputSettings.Format.ToString();
|
||||
//otherParameters.Add("key", IMGUR_ANONYMOUS_API_KEY);
|
||||
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(config.ImgurApi3Url + "/upload.xml?" + NetworkHelper.GenerateQueryParameters(otherParameters), HTTPMethod.POST);
|
||||
webRequest.ContentType = "image/" + outputSettings.Format;
|
||||
webRequest.ServicePoint.Expect100Continue = false;
|
||||
|
||||
SetClientId(webRequest);
|
||||
|
@ -193,7 +194,7 @@ namespace GreenshotImgurPlugin {
|
|||
return;
|
||||
}
|
||||
LOG.InfoFormat("Retrieving Imgur image for {0} with url {1}", imgurInfo.Hash, imgurInfo.SmallSquare);
|
||||
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(imgurInfo.SmallSquare, HTTPMethod.GET);
|
||||
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(string.Format(SMALL_URL_PATTERN, imgurInfo.Hash), HTTPMethod.GET);
|
||||
webRequest.ServicePoint.Expect100Continue = false;
|
||||
SetClientId(webRequest);
|
||||
using (WebResponse response = webRequest.GetResponse()) {
|
||||
|
@ -304,7 +305,7 @@ namespace GreenshotImgurPlugin {
|
|||
|
||||
// Update the credits in the config, this is shown in a form
|
||||
int credits = 0;
|
||||
if (int.TryParse(nameValues["X-RateLimit-Remaining"], out credits)) {
|
||||
if (nameValues.ContainsKey("X-RateLimit-Remaining") && int.TryParse(nameValues["X-RateLimit-Remaining"], out credits)) {
|
||||
config.Credits = credits;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,39 +29,39 @@ using log4net;
|
|||
|
||||
namespace GreenshotPlugin.Core {
|
||||
public class SourceforgeFile {
|
||||
private string file;
|
||||
private readonly string _file;
|
||||
public string File {
|
||||
get {return file;}
|
||||
get {return _file;}
|
||||
}
|
||||
private DateTime pubdate;
|
||||
private readonly DateTime _pubdate;
|
||||
public DateTime Pubdate {
|
||||
get {return pubdate;}
|
||||
get {return _pubdate;}
|
||||
}
|
||||
private string link;
|
||||
private readonly string _link;
|
||||
public string Link {
|
||||
get {return link;}
|
||||
get {return _link;}
|
||||
}
|
||||
private string directLink;
|
||||
private readonly string _directLink;
|
||||
public string DirectLink {
|
||||
get {return directLink;}
|
||||
get {return _directLink;}
|
||||
}
|
||||
private Version version;
|
||||
private Version _version;
|
||||
public Version Version {
|
||||
get {return version;}
|
||||
get {return _version;}
|
||||
set {
|
||||
version = value;
|
||||
_version = value;
|
||||
}
|
||||
}
|
||||
private string language;
|
||||
private string _language;
|
||||
public string Language {
|
||||
get {return language;}
|
||||
set {language = value;}
|
||||
get {return _language;}
|
||||
set {_language = value;}
|
||||
}
|
||||
|
||||
public bool isExe {
|
||||
get {
|
||||
if (file != null) {
|
||||
return file.ToLower().EndsWith(".exe");
|
||||
if (_file != null) {
|
||||
return _file.ToLower().EndsWith(".exe");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
public bool isUnstable {
|
||||
get {
|
||||
if (file != null) {
|
||||
return file.ToLower().Contains("unstable");
|
||||
if (_file != null) {
|
||||
return _file.ToLower().Contains("unstable");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -78,18 +78,18 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
public bool isReleaseCandidate {
|
||||
get {
|
||||
if (file != null) {
|
||||
return Regex.IsMatch(file.ToLower(), "rc[0-9]+");
|
||||
if (_file != null) {
|
||||
return Regex.IsMatch(_file.ToLower(), "rc[0-9]+");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
|
||||
this.file = file;
|
||||
this.pubdate = DateTime.Parse(pubdate);
|
||||
this.link = link;
|
||||
this.directLink = directLink;
|
||||
this._file = file;
|
||||
DateTime.TryParse(pubdate, out _pubdate);
|
||||
this._link = link;
|
||||
this._directLink = directLink;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
|
||||
namespace GreenshotPlugin.Core
|
||||
{
|
||||
|
@ -31,11 +32,15 @@ namespace GreenshotPlugin.Core
|
|||
/// </summary>
|
||||
public class WmInputLangChangeRequestFilter : IMessageFilter
|
||||
{
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(WmInputLangChangeRequestFilter));
|
||||
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
if (m.Msg == (int)WindowsMessages.WM_INPUTLANGCHANGEREQUEST || m.Msg == (int)WindowsMessages.WM_INPUTLANGCHANGE)
|
||||
WindowsMessages message = (WindowsMessages)m.Msg;
|
||||
if (message == WindowsMessages.WM_INPUTLANGCHANGEREQUEST || message == WindowsMessages.WM_INPUTLANGCHANGE)
|
||||
{
|
||||
return m.LParam.ToInt64() > 0x7FFFFFFF;
|
||||
LOG.WarnFormat("Filtering: {0}, {1:X} - {2:X} - {3:X}", message, m.LParam.ToInt64(), m.WParam.ToInt64(), m.HWnd.ToInt64());
|
||||
return (m.LParam.ToInt64() | 0xFFFFFFFF) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue