Skip to content

Commit

Permalink
Debug logging
Browse files Browse the repository at this point in the history
Small UI fixes


Former-commit-id: 2d315c0
  • Loading branch information
tkashkin committed Jun 26, 2018
1 parent 644c93b commit 5aed992
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/data/sources/gog/GOG.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace GameHub.Data.Sources.GOG
wnd.finished.connect(code =>
{
user_auth_code = code;
debug("[Auth] GOG auth code: %s", code);
Idle.add(get_auth_code.callback);
});

Expand Down Expand Up @@ -110,6 +111,10 @@ namespace GameHub.Data.Sources.GOG
settings.access_token = user_token ?? "";
settings.refresh_token = user_refresh_token ?? "";

debug("[Auth] GOG access token: %s", user_token);
debug("[Auth] GOG refresh token: %s", user_refresh_token);
debug("[Auth] GOG user id: %s", user_id);

return user_token != null;
}

Expand All @@ -120,6 +125,8 @@ namespace GameHub.Data.Sources.GOG
return false;
}

debug("[Auth] Refreshing GOG access token with refresh token: %s", user_refresh_token);

var url = @"https://auth.gog.com/token?client_id=$(CLIENT_ID)&client_secret=$(CLIENT_SECRET)&grant_type=refresh_token&refresh_token=$(user_refresh_token)";
var root = (yield Parser.parse_remote_json_file_async(url)).get_object();
user_token = root.get_string_member("access_token");
Expand All @@ -129,6 +136,10 @@ namespace GameHub.Data.Sources.GOG
settings.access_token = user_token ?? "";
settings.refresh_token = user_refresh_token ?? "";

debug("[Auth] GOG access token: %s", user_token);
debug("[Auth] GOG refresh token: %s", user_refresh_token);
debug("[Auth] GOG user id: %s", user_id);

token_needs_refresh = false;

return user_token != null;
Expand Down
1 change: 1 addition & 0 deletions src/data/sources/humble/Humble.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace GameHub.Data.Sources.Humble
{
user_token = token;
settings.access_token = user_token ?? "";
debug("[Auth] Humble access token: %s", token);
Idle.add(get_token.callback);
});

Expand Down
2 changes: 2 additions & 0 deletions src/data/sources/steam/Steam.vala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace GameHub.Data.Sources.Steam
user_id = uid;
user_name = users.get_object_member(uid).get_string_member("PersonaName");

debug("[Auth] SteamID: %s, PersonaName: %s", user_id, user_name);

result = true;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/data/sources/steam/SteamGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace GameHub.Data.Sources.Steam

metadata_tries++;

print("[Steam app %s] Checking for linux compatibility [%d]...\n", id, metadata_tries);
debug("[Steam] <app %s> Checking for compatibility [%d]...\n", id, metadata_tries);

var url = @"https://store.steampowered.com/api/appdetails?appids=$(id)";
var root = yield Parser.parse_remote_json_file_async(url);
Expand All @@ -50,13 +50,13 @@ namespace GameHub.Data.Sources.Steam
{
if(metadata_tries > 2)
{
print("[Steam app %s] No data, %d tries failed, assuming no linux support\n", id, metadata_tries);
debug("[Steam] <app %s> No data, %d tries failed, assuming no linux support\n", id, metadata_tries);
_is_for_linux = false;
GamesDB.get_instance().add_unsupported_game(source, id);
return _is_for_linux;
}

print("[Steam app %s] No data, sleeping for 2.5s\n", id);
debug("[Steam] <app %s> No data, sleeping for 2.5s\n", id);
yield Utils.sleep_async(2500);
return yield is_for_linux();
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/views/WelcomeView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ namespace GameHub.UI.Views
if(all_authenticated)
{
open_games_grid();
return;
}
else
{
Expand Down
6 changes: 5 additions & 1 deletion src/ui/windows/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ namespace GameHub.UI.Windows
{
view.attach_to_window(this);
stack.add(view);
if(show) stack.set_visible_child(view);
if(show)
{
stack.set_visible_child(view);
view.show();
}
stack_updated();
}

Expand Down
13 changes: 11 additions & 2 deletions src/ui/windows/WebAuthWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace GameHub.UI.Windows

set_modal(true);

debug("[WebAuth/%s] Authenticating at `%s`; success_url_prefix: `%s`; success_cookie_name: `%s`", source, url, success_url_prefix, success_cookie_name);

webview = new WebView();

var cookies_file = FSUtils.expand(FSUtils.Paths.Cache.Cookies);
Expand All @@ -45,16 +47,21 @@ namespace GameHub.UI.Windows
titlebar.subtitle = uri.split("?")[0];
titlebar.tooltip_text = uri;

debug("[WebAuth/%s] URI: `%s`", source, uri);

if(!is_finished && success_cookie_name != null)
{
webview.web_context.get_cookie_manager().get_cookies.begin(uri, null, (obj, res) => {
var cookies = webview.web_context.get_cookie_manager().get_cookies.end(res);
foreach(var cookie in cookies)
{
debug("[WebAuth/%s] [Cookie] `%s`=`%s`", source, cookie.name, cookie.value);
if(!is_finished && cookie.name == success_cookie_name && !cookie.value.contains("\"") && (success_url_prefix == null || uri.has_prefix(success_url_prefix)))
{
is_finished = true;
finished(cookie.value);
var token = cookie.value;
debug("[WebAuth/%s] Finished with result `%s`", source, token);
finished(token);
destroy();
break;
}
Expand All @@ -64,7 +71,9 @@ namespace GameHub.UI.Windows
else if(!is_finished && success_url_prefix != null && uri.has_prefix(success_url_prefix))
{
is_finished = true;
finished(uri.substring(success_url_prefix.length));
var token = uri.substring(success_url_prefix.length);
debug("[WebAuth/%s] Finished with result `%s`", source, token);
finished(token);
destroy();
}
});
Expand Down

0 comments on commit 5aed992

Please sign in to comment.