Skip to content

Commit

Permalink
Fixing the submodule with latest from FeroxRev.
Browse files Browse the repository at this point in the history
  • Loading branch information
dddbliss committed Aug 2, 2016
1 parent 7cd55a1 commit 79149d8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "FeroxRev"]
path = FeroxRev
url = https://github.com/NecronomiconCoding/NecroBot-Rocket-API
url = https://github.com/NECROBOTIO/NecroBot-Rocket-API
branch = master
2 changes: 1 addition & 1 deletion FeroxRev
26 changes: 9 additions & 17 deletions PoGo.NecroBot.Logic/Common/ApiFailureStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,16 @@ private async void DoLogin()
{
try
{
switch (_session.Settings.AuthType)
if (_session.Settings.AuthType != AuthType.Google || _session.Settings.AuthType != AuthType.Ptc)
{
case AuthType.Ptc:
await
_session.Client.Login.DoPtcLogin(_session.Settings.PtcUsername,
_session.Settings.PtcPassword);
break;
case AuthType.Google:
await
_session.Client.Login.DoGoogleLogin(_session.Settings.GoogleUsername,
_session.Settings.GooglePassword);
break;
default:
_session.EventDispatcher.Send(new ErrorEvent
{
Message = _session.Translation.GetTranslation(TranslationString.WrongAuthType)
});
break;
await _session.Client.Login.DoLogin();
}
else
{
_session.EventDispatcher.Send(new ErrorEvent
{
Message = _session.Translation.GetTranslation(TranslationString.WrongAuthType)
});
}
}
catch (AggregateException ae)
Expand Down
28 changes: 9 additions & 19 deletions PoGo.NecroBot.Logic/State/LoginState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,16 @@ public async Task<IState> Execute(ISession session, CancellationToken cancellati

try
{
switch (session.Settings.AuthType)
if (session.Settings.AuthType != AuthType.Google || session.Settings.AuthType != AuthType.Ptc)
{
case AuthType.Ptc:
await
session.Client.Login.DoPtcLogin(session.Settings.PtcUsername,
session.Settings.PtcPassword);
break;
case AuthType.Google:
await
session.Client.Login.DoGoogleLogin(session.Settings.GoogleUsername,
session.Settings.GooglePassword);
break;
default:
session.EventDispatcher.Send(new ErrorEvent
{
Message = session.Translation.GetTranslation(TranslationString.WrongAuthType)
});
return null;
await session.Client.Login.DoLogin();
}
else
{
session.EventDispatcher.Send(new ErrorEvent
{
Message = session.Translation.GetTranslation(TranslationString.WrongAuthType)
});
}
}
catch (AggregateException ae)
Expand All @@ -64,8 +56,6 @@ public async Task<IState> Execute(ISession session, CancellationToken cancellati
{
Message = session.Translation.GetTranslation(TranslationString.TryingAgainIn, 20)
});
await Task.Delay(20000, cancellationToken);
return this;
}
catch (AccountNotVerifiedException)
{
Expand Down
3 changes: 2 additions & 1 deletion PoGo.NecroBot.Logic/State/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public Session(ISettings settings, ILogicSettings logicSettings)

public void Reset(ISettings settings, ILogicSettings logicSettings)
{
Client = new Client(Settings) {AuthType = settings.AuthType};
ApiFailureStrategy _apiStrategy = new ApiFailureStrategy(this);
Client = new Client(Settings, _apiStrategy);
// ferox wants us to set this manually
Inventory = new Inventory(Client, logicSettings);
Navigation = new Navigation(Client);
Expand Down
35 changes: 22 additions & 13 deletions PoGo.NecroBot.Logic/Tasks/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,37 @@ public Login(ISession session)
_session = session;
}

public void DoLogin()
public async void DoLogin()
{
try
{
if (_session.Client.AuthType == AuthType.Ptc)
if (_session.Settings.AuthType != AuthType.Google || _session.Settings.AuthType != AuthType.Ptc)
{
try
{
_session.Client.Login.DoPtcLogin(_session.Settings.PtcUsername, _session.Settings.PtcPassword)
.Wait();
}
catch (AggregateException ae)
{
throw ae.Flatten().InnerException;
}
await _session.Client.Login.DoLogin();
}
else
{
_session.Client.Login.DoGoogleLogin(_session.Settings.GoogleUsername,
_session.Settings.GooglePassword).Wait();
_session.EventDispatcher.Send(new ErrorEvent
{
Message = _session.Translation.GetTranslation(TranslationString.WrongAuthType)
});
}
}
catch (AggregateException ae)
{
throw ae.Flatten().InnerException;
}
catch (Exception ex) when (ex is PtcOfflineException || ex is AccessTokenExpiredException)
{
_session.EventDispatcher.Send(new ErrorEvent
{
Message = _session.Translation.GetTranslation(TranslationString.PtcOffline)
});
_session.EventDispatcher.Send(new NoticeEvent
{
Message = _session.Translation.GetTranslation(TranslationString.TryingAgainIn, 20)
});
}
catch (PtcOfflineException)
{
_session.EventDispatcher.Send(new ErrorEvent
Expand Down

1 comment on commit 79149d8

@miracho
Copy link

@miracho miracho commented on 79149d8 Aug 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how i use this update?

Please sign in to comment.