Fix most warnings.

This commit is contained in:
Dean Herbert
2017-03-07 10:59:19 +09:00
parent 9106c45858
commit 0cad5d7d41
168 changed files with 504 additions and 473 deletions

View File

@ -20,10 +20,10 @@ namespace osu.Game.Online.API
private OAuth authentication;
public string Endpoint = @"https://new.ppy.sh";
const string client_id = @"5";
const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
private const string client_id = @"5";
private const string client_secret = @"FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk";
ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
private ConcurrentQueue<APIRequest> queue = new ConcurrentQueue<APIRequest>();
public Scheduler Scheduler = new Scheduler();
@ -38,22 +38,15 @@ namespace osu.Game.Online.API
public string Token
{
get { return authentication.Token?.ToString(); }
set
{
if (string.IsNullOrEmpty(value))
authentication.Token = null;
else
authentication.Token = OAuthToken.Parse(value);
}
set { authentication.Token = string.IsNullOrEmpty(value) ? null : OAuthToken.Parse(value); }
}
protected bool HasLogin => Token != null || (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password));
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable (should dispose of this or at very least keep a reference).
private Thread thread;
Logger log;
private Logger log;
public APIAccess()
{
@ -88,22 +81,22 @@ namespace osu.Game.Online.API
/// <summary>
/// Number of consecutive requests which failed due to network issues.
/// </summary>
int failureCount = 0;
private int failureCount;
private void run()
{
while (true)
while (thread.IsAlive)
{
switch (State)
{
case APIState.Failing:
//todo: replace this with a ping request.
log.Add($@"In a failing state, waiting a bit before we try again...");
log.Add(@"In a failing state, waiting a bit before we try again...");
Thread.Sleep(5000);
if (queue.Count == 0)
{
log.Add($@"Queueing a ping request");
Queue(new ListChannelsRequest() { Timeout = 5000 });
log.Add(@"Queueing a ping request");
Queue(new ListChannelsRequest { Timeout = 5000 });
}
break;
case APIState.Offline:
@ -131,7 +124,7 @@ namespace osu.Game.Online.API
var userReq = new GetUserRequest();
userReq.Success += (u) => {
userReq.Success += u => {
LocalUser.Value = u;
//we're connected!
State = APIState.Online;
@ -291,7 +284,7 @@ namespace osu.Game.Online.API
if (failOldRequests)
{
APIRequest req;
while (queue.TryDequeue(out req))
while (oldQueue.TryDequeue(out req))
req.Fail(new Exception(@"Disconnected from server"));
}
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Online.API
private void onSuccess()
{
Success?.Invoke((WebRequest as JsonWebRequest<T>).ResponseObject);
Success?.Invoke(((JsonWebRequest<T>)WebRequest).ResponseObject);
}
public new event APISuccessHandler<T> Success;

View File

@ -48,7 +48,7 @@ namespace osu.Game.Online.API
try
{
string[] parts = value.Split('/');
return new OAuthToken()
return new OAuthToken
{
AccessToken = parts[0],
AccessTokenExpiry = long.Parse(parts[1], NumberFormatInfo.InvariantInfo),

View File

@ -9,8 +9,8 @@ namespace osu.Game.Online.API.Requests
{
public class GetMessagesRequest : APIRequest<List<Message>>
{
List<Channel> channels;
long? since;
private List<Channel> channels;
private long? since;
public GetMessagesRequest(List<Channel> channels, long? sinceId)
{

View File

@ -1,55 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Diagnostics;
using System.Security;
using osu.Framework.Extensions;
namespace osu.Game.Online.API
{
internal class SecurePassword
{
private readonly SecureString storage = new SecureString();
private readonly Representation representation;
//todo: move this to a central constants file.
private const string password_entropy = @"cu24180ncjeiu0ci1nwui";
public SecurePassword(string input, bool encrypted = false)
{
//if (encrypted)
//{
// string rep;
// input = DPAPI.Decrypt(input, password_entropy, out rep);
// Enum.TryParse(rep, out representation);
//}
//else
{
representation = Representation.Raw;
}
foreach (char c in input)
storage.AppendChar(c);
storage.MakeReadOnly();
}
internal string Get(Representation request = Representation.Raw)
{
Debug.Assert(representation == request);
switch (request)
{
default:
return storage.UnsecureRepresentation();
//case Representation.Encrypted:
// return DPAPI.Encrypt(DPAPI.KeyType.UserKey, storage.UnsecureRepresentation(), password_entropy, representation.ToString());
}
}
}
enum Representation
{
Raw,
Encrypted
}
}