mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Updated csproj files, so we don't have to migrate every time. Added a fix for BUG-1863: Cannot get access to deleted object, and added some small code quality chances. [skip ci]
This commit is contained in:
parent
63e360e254
commit
4f9d6eb865
21 changed files with 112 additions and 54 deletions
|
@ -471,14 +471,20 @@ namespace GreenshotPlugin.Core {
|
|||
isHttpError = (int)response.StatusCode >= 300;
|
||||
if (isHttpError)
|
||||
{
|
||||
LOG.ErrorFormat("HTTP error {0} with content: {1}", response.StatusCode, responseData);
|
||||
LOG.ErrorFormat("HTTP error {0}", response.StatusCode);
|
||||
}
|
||||
DebugHeaders(response);
|
||||
responseData = GetResponseAsString(response);
|
||||
} catch (WebException e) {
|
||||
if (isHttpError)
|
||||
{
|
||||
LOG.ErrorFormat("HTTP response {0}", responseData);
|
||||
}
|
||||
}
|
||||
catch (WebException e) {
|
||||
response = (HttpWebResponse) e.Response;
|
||||
HttpStatusCode statusCode = response.StatusCode;
|
||||
if (response != null) {
|
||||
LOG.ErrorFormat("HTTP error {0}", response.StatusCode);
|
||||
LOG.ErrorFormat("HTTP error {0}", statusCode);
|
||||
string errorContent = GetResponseAsString(response);
|
||||
if (alsoReturnContentOnError)
|
||||
{
|
||||
|
@ -487,6 +493,10 @@ namespace GreenshotPlugin.Core {
|
|||
LOG.ErrorFormat("Content: {0}", errorContent);
|
||||
}
|
||||
LOG.Error("WebException: ", e);
|
||||
if (statusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
throw new UnauthorizedAccessException(e.Message);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -499,7 +499,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// Authorize the token by showing the dialog
|
||||
/// </summary>
|
||||
/// <returns>The request token.</returns>
|
||||
private String GetAuthorizeToken() {
|
||||
private string GetAuthorizeToken() {
|
||||
if (string.IsNullOrEmpty(Token)) {
|
||||
Exception e = new Exception("The request token is not set");
|
||||
throw e;
|
||||
|
@ -532,7 +532,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;
|
||||
|
@ -663,39 +663,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) {
|
||||
|
|
|
@ -97,7 +97,7 @@ 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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue