mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Added "credits left" for Imgur to the form, this might give us a better idea of why the upload sometimes takes so long.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2006 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e654c38eb8
commit
480b32f586
4 changed files with 27 additions and 2 deletions
|
@ -155,7 +155,7 @@ namespace GreenshotImgurPlugin
|
|||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.listview_imgur_uploads);
|
||||
this.Name = "ImgurHistory";
|
||||
this.Text = "ImgurHistory";
|
||||
this.LanguageKey = "imgur.history";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImgurHistoryFormClosing);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace GreenshotImgurPlugin {
|
|||
/// <summary>
|
||||
/// Description of ImgurHistory.
|
||||
/// </summary>
|
||||
public partial class ImgurHistory : Form {
|
||||
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>();
|
||||
|
@ -48,6 +48,7 @@ namespace GreenshotImgurPlugin {
|
|||
}
|
||||
|
||||
private ImgurHistory() {
|
||||
this.ManualLanguageApply = true;
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
@ -63,6 +64,10 @@ namespace GreenshotImgurPlugin {
|
|||
if (listview_imgur_uploads.Items.Count > 0) {
|
||||
listview_imgur_uploads.Items[0].Selected = true;
|
||||
}
|
||||
ApplyLanguage();
|
||||
if (config.Credits > 0) {
|
||||
this.Text = this.Text + " (" + config.Credits + " credits)";
|
||||
}
|
||||
}
|
||||
|
||||
private void redraw() {
|
||||
|
|
|
@ -49,6 +49,10 @@ namespace GreenshotImgurPlugin {
|
|||
|
||||
// Not stored, only run-time!
|
||||
public Dictionary<string, ImgurInfo> runtimeImgurHistory = new Dictionary<string, ImgurInfo>();
|
||||
public int Credits {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supply values we can't put as defaults
|
||||
|
|
|
@ -160,6 +160,7 @@ namespace GreenshotImgurPlugin {
|
|||
}
|
||||
string responseString;
|
||||
using (WebResponse response = webRequest.GetResponse()) {
|
||||
LogCredits(response);
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
StreamReader responseReader = new StreamReader(responseStream);
|
||||
responseString = responseReader.ReadToEnd();
|
||||
|
@ -181,6 +182,7 @@ namespace GreenshotImgurPlugin {
|
|||
webRequest.ServicePoint.Expect100Continue = false;
|
||||
|
||||
using (WebResponse response = webRequest.GetResponse()) {
|
||||
LogCredits(response);
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
imgurInfo.Image = Image.FromStream(responseStream);
|
||||
}
|
||||
|
@ -196,6 +198,7 @@ namespace GreenshotImgurPlugin {
|
|||
string responseString;
|
||||
try {
|
||||
using (WebResponse response = webRequest.GetResponse()) {
|
||||
LogCredits(response);
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
StreamReader responseReader = new StreamReader(responseStream);
|
||||
responseString = responseReader.ReadToEnd();
|
||||
|
@ -227,6 +230,7 @@ namespace GreenshotImgurPlugin {
|
|||
|
||||
string responseString;
|
||||
using (WebResponse response = webRequest.GetResponse()) {
|
||||
LogCredits(response);
|
||||
Stream responseStream = response.GetResponseStream();
|
||||
StreamReader responseReader = new StreamReader(responseStream);
|
||||
responseString = responseReader.ReadToEnd();
|
||||
|
@ -245,5 +249,17 @@ namespace GreenshotImgurPlugin {
|
|||
config.ImgurUploadHistory.Remove(imgurInfo.Hash);
|
||||
imgurInfo.Image = null;
|
||||
}
|
||||
|
||||
private static void LogCredits(WebResponse response) {
|
||||
try {
|
||||
int credits = 0;
|
||||
if (int.TryParse(response.Headers["X-RateLimit-Remaining"], out credits)) {
|
||||
config.Credits = credits;
|
||||
}
|
||||
LOG.InfoFormat("X-RateLimit-Limit={0}", response.Headers["X-RateLimit-Limit"]);
|
||||
LOG.InfoFormat("X-RateLimit-Remaining={0}", response.Headers["X-RateLimit-Remaining"]);
|
||||
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue