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:
|
Bugs Resolved:
|
||||||
* BUG-1809: OverflowException when changing the windows input language
|
* 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
|
1.2.6.7-359dcf3 RELEASE
|
||||||
|
|
|
@ -117,6 +117,7 @@ namespace GreenshotImgurPlugin
|
||||||
this.finishedButton.TabIndex = 11;
|
this.finishedButton.TabIndex = 11;
|
||||||
this.finishedButton.Text = "Finished";
|
this.finishedButton.Text = "Finished";
|
||||||
this.finishedButton.UseVisualStyleBackColor = true;
|
this.finishedButton.UseVisualStyleBackColor = true;
|
||||||
|
this.finishedButton.Click += new System.EventHandler(this.FinishedButtonClick);
|
||||||
//
|
//
|
||||||
// clipboardButton
|
// clipboardButton
|
||||||
//
|
//
|
||||||
|
|
|
@ -167,6 +167,11 @@ namespace GreenshotImgurPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FinishedButtonClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Hide();
|
||||||
|
}
|
||||||
|
|
||||||
private void OpenButtonClick(object sender, EventArgs e) {
|
private void OpenButtonClick(object sender, EventArgs e) {
|
||||||
if (listview_imgur_uploads.SelectedItems != null && listview_imgur_uploads.SelectedItems.Count > 0) {
|
if (listview_imgur_uploads.SelectedItems != null && listview_imgur_uploads.SelectedItems.Count > 0) {
|
||||||
for (int i = 0; i < listview_imgur_uploads.SelectedItems.Count; i++) {
|
for (int i = 0; i < listview_imgur_uploads.SelectedItems.Count; i++) {
|
||||||
|
|
|
@ -30,9 +30,11 @@ namespace GreenshotImgurPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[IniSection("Imgur", Description="Greenshot Imgur Plugin configuration")]
|
[IniSection("Imgur", Description="Greenshot Imgur Plugin configuration")]
|
||||||
public class ImgurConfiguration : IniSection {
|
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;
|
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")]
|
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||||
public OutputFormat UploadFormat;
|
public OutputFormat UploadFormat;
|
||||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||||
|
|
|
@ -143,10 +143,15 @@ namespace GreenshotImgurPlugin
|
||||||
try {
|
try {
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.LoadXml(response);
|
doc.LoadXml(response);
|
||||||
XmlNodeList nodes = doc.GetElementsByTagName("hash");
|
XmlNodeList nodes = doc.GetElementsByTagName("id");
|
||||||
if(nodes.Count > 0) {
|
if(nodes.Count > 0) {
|
||||||
imgurInfo.Hash = nodes.Item(0).InnerText;
|
imgurInfo.Hash = nodes.Item(0).InnerText;
|
||||||
}
|
}
|
||||||
|
nodes = doc.GetElementsByTagName("hash");
|
||||||
|
if (nodes.Count > 0)
|
||||||
|
{
|
||||||
|
imgurInfo.Hash = nodes.Item(0).InnerText;
|
||||||
|
}
|
||||||
nodes = doc.GetElementsByTagName("deletehash");
|
nodes = doc.GetElementsByTagName("deletehash");
|
||||||
if(nodes.Count > 0) {
|
if(nodes.Count > 0) {
|
||||||
imgurInfo.DeleteHash = nodes.Item(0).InnerText;
|
imgurInfo.DeleteHash = nodes.Item(0).InnerText;
|
||||||
|
|
|
@ -33,7 +33,8 @@ namespace GreenshotImgurPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ImgurUtils {
|
public static class ImgurUtils {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(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>();
|
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -57,9 +58,9 @@ namespace GreenshotImgurPlugin {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ImgurInfo imgurInfo = ImgurUtils.RetrieveImgurInfo(hash, config.ImgurUploadHistory[hash]);
|
ImgurInfo imgurInfo = RetrieveImgurInfo(hash, config.ImgurUploadHistory[hash]);
|
||||||
if (imgurInfo != null) {
|
if (imgurInfo != null) {
|
||||||
ImgurUtils.RetrieveImgurThumbnail(imgurInfo);
|
RetrieveImgurThumbnail(imgurInfo);
|
||||||
config.runtimeImgurHistory.Add(hash, imgurInfo);
|
config.runtimeImgurHistory.Add(hash, imgurInfo);
|
||||||
} else {
|
} else {
|
||||||
LOG.DebugFormat("Deleting not found ImgUr {0} from config.", hash);
|
LOG.DebugFormat("Deleting not found ImgUr {0} from config.", hash);
|
||||||
|
@ -95,7 +96,7 @@ namespace GreenshotImgurPlugin {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="webRequest"></param>
|
/// <param name="webRequest"></param>
|
||||||
private static void SetClientId(HttpWebRequest webRequest) {
|
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>
|
/// <summary>
|
||||||
|
@ -121,9 +122,9 @@ namespace GreenshotImgurPlugin {
|
||||||
string responseString = null;
|
string responseString = null;
|
||||||
if (config.AnonymousAccess) {
|
if (config.AnonymousAccess) {
|
||||||
// add key, we only use the other parameters for the AnonymousAccess
|
// add key, we only use the other parameters for the AnonymousAccess
|
||||||
otherParameters.Add("key", IMGUR_ANONYMOUS_API_KEY);
|
//otherParameters.Add("key", IMGUR_ANONYMOUS_API_KEY);
|
||||||
HttpWebRequest webRequest = NetworkHelper.CreateWebRequest(config.ImgurApiUrl + "/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.ToString();
|
webRequest.ContentType = "image/" + outputSettings.Format;
|
||||||
webRequest.ServicePoint.Expect100Continue = false;
|
webRequest.ServicePoint.Expect100Continue = false;
|
||||||
|
|
||||||
SetClientId(webRequest);
|
SetClientId(webRequest);
|
||||||
|
@ -193,7 +194,7 @@ namespace GreenshotImgurPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG.InfoFormat("Retrieving Imgur image for {0} with url {1}", imgurInfo.Hash, imgurInfo.SmallSquare);
|
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;
|
webRequest.ServicePoint.Expect100Continue = false;
|
||||||
SetClientId(webRequest);
|
SetClientId(webRequest);
|
||||||
using (WebResponse response = webRequest.GetResponse()) {
|
using (WebResponse response = webRequest.GetResponse()) {
|
||||||
|
@ -304,7 +305,7 @@ namespace GreenshotImgurPlugin {
|
||||||
|
|
||||||
// Update the credits in the config, this is shown in a form
|
// Update the credits in the config, this is shown in a form
|
||||||
int credits = 0;
|
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;
|
config.Credits = credits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,39 +29,39 @@ using log4net;
|
||||||
|
|
||||||
namespace GreenshotPlugin.Core {
|
namespace GreenshotPlugin.Core {
|
||||||
public class SourceforgeFile {
|
public class SourceforgeFile {
|
||||||
private string file;
|
private readonly string _file;
|
||||||
public string File {
|
public string File {
|
||||||
get {return file;}
|
get {return _file;}
|
||||||
}
|
}
|
||||||
private DateTime pubdate;
|
private readonly DateTime _pubdate;
|
||||||
public DateTime Pubdate {
|
public DateTime Pubdate {
|
||||||
get {return pubdate;}
|
get {return _pubdate;}
|
||||||
}
|
}
|
||||||
private string link;
|
private readonly string _link;
|
||||||
public string Link {
|
public string Link {
|
||||||
get {return link;}
|
get {return _link;}
|
||||||
}
|
}
|
||||||
private string directLink;
|
private readonly string _directLink;
|
||||||
public string DirectLink {
|
public string DirectLink {
|
||||||
get {return directLink;}
|
get {return _directLink;}
|
||||||
}
|
}
|
||||||
private Version version;
|
private Version _version;
|
||||||
public Version Version {
|
public Version Version {
|
||||||
get {return version;}
|
get {return _version;}
|
||||||
set {
|
set {
|
||||||
version = value;
|
_version = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private string language;
|
private string _language;
|
||||||
public string Language {
|
public string Language {
|
||||||
get {return language;}
|
get {return _language;}
|
||||||
set {language = value;}
|
set {_language = value;}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool isExe {
|
public bool isExe {
|
||||||
get {
|
get {
|
||||||
if (file != null) {
|
if (_file != null) {
|
||||||
return file.ToLower().EndsWith(".exe");
|
return _file.ToLower().EndsWith(".exe");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ namespace GreenshotPlugin.Core {
|
||||||
|
|
||||||
public bool isUnstable {
|
public bool isUnstable {
|
||||||
get {
|
get {
|
||||||
if (file != null) {
|
if (_file != null) {
|
||||||
return file.ToLower().Contains("unstable");
|
return _file.ToLower().Contains("unstable");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -78,18 +78,18 @@ namespace GreenshotPlugin.Core {
|
||||||
|
|
||||||
public bool isReleaseCandidate {
|
public bool isReleaseCandidate {
|
||||||
get {
|
get {
|
||||||
if (file != null) {
|
if (_file != null) {
|
||||||
return Regex.IsMatch(file.ToLower(), "rc[0-9]+");
|
return Regex.IsMatch(_file.ToLower(), "rc[0-9]+");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
|
public SourceforgeFile(string file, string pubdate, string link, string directLink) {
|
||||||
this.file = file;
|
this._file = file;
|
||||||
this.pubdate = DateTime.Parse(pubdate);
|
DateTime.TryParse(pubdate, out _pubdate);
|
||||||
this.link = link;
|
this._link = link;
|
||||||
this.directLink = directLink;
|
this._directLink = directLink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
using GreenshotPlugin.UnmanagedHelpers;
|
using GreenshotPlugin.UnmanagedHelpers;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
namespace GreenshotPlugin.Core
|
namespace GreenshotPlugin.Core
|
||||||
{
|
{
|
||||||
|
@ -31,11 +32,15 @@ namespace GreenshotPlugin.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WmInputLangChangeRequestFilter : IMessageFilter
|
public class WmInputLangChangeRequestFilter : IMessageFilter
|
||||||
{
|
{
|
||||||
|
private static readonly ILog LOG = LogManager.GetLogger(typeof(WmInputLangChangeRequestFilter));
|
||||||
|
|
||||||
public bool PreFilterMessage(ref Message m)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue