Skip to content

Commit

Permalink
Add logout buttons for GOG and Humble (tkashkin#40)
Browse files Browse the repository at this point in the history
Add NSIS installer support (tkashkin#96)


Former-commit-id: d18ac39
  • Loading branch information
tkashkin committed Oct 31, 2018
1 parent 1ebf530 commit 71e8803
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/data/Game.vala
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ namespace GameHub.Data

public abstract class Installer
{
private static string NSIS_INSTALLER_DESCRIPTION = "Nullsoft Installer";

public class Part: Object
{
public string id { get; construct set; }
Expand Down Expand Up @@ -228,6 +230,7 @@ namespace GameHub.Data

uint f = 0;
bool windows_installer = false;
bool nsis_installer = false;
foreach(var file in files)
{
var path = file.get_path();
Expand All @@ -237,6 +240,15 @@ namespace GameHub.Data

var type = yield guess_type(file, f > 0);

if(type == InstallerType.WINDOWS_EXECUTABLE)
{
var desc = yield Utils.run_thread({"file", "-b", path});
if(desc != null && desc.length > 0 && NSIS_INSTALLER_DESCRIPTION in desc)
{
type = InstallerType.WINDOWS_NSIS_INSTALLER;
}
}

string[]? cmd = null;

switch(type)
Expand All @@ -248,6 +260,7 @@ namespace GameHub.Data
break;

case InstallerType.ARCHIVE:
case InstallerType.WINDOWS_NSIS_INSTALLER:
cmd = {"file-roller", path, "-e", game.install_dir.get_path()}; // extract with file-roller
break;

Expand Down Expand Up @@ -275,11 +288,20 @@ namespace GameHub.Data
yield tool.install(game, file);
}
}
else if(type == InstallerType.WINDOWS_NSIS_INSTALLER)
{
nsis_installer = true;
}
f++;
}

try
{
if(nsis_installer)
{
FSUtils.rm(game.install_dir.get_path(), "\\$*DIR", "-rf"); // remove anything like $PLUGINSDIR
}

string? dirname = null;
FileInfo? finfo = null;
var enumerator = yield game.install_dir.enumerate_children_async("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS);
Expand Down Expand Up @@ -390,7 +412,7 @@ namespace GameHub.Data

public enum InstallerType
{
UNKNOWN, EXECUTABLE, WINDOWS_EXECUTABLE, GOG_PART, ARCHIVE;
UNKNOWN, EXECUTABLE, WINDOWS_EXECUTABLE, GOG_PART, ARCHIVE, WINDOWS_NSIS_INSTALLER;

public static InstallerType from_mime(string type)
{
Expand Down
17 changes: 16 additions & 1 deletion src/ui/dialogs/SettingsDialog/tabs/GOG.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs
{
private Settings.Auth.GOG gog_auth;
private Box enabled_box;
private Button logout_btn;

public GOG(SettingsDialog dlg)
{
Expand All @@ -42,11 +43,24 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs

add_separator();


add_file_chooser(_("Games directory"), FileChooserAction.SELECT_FOLDER, paths.gog_games, v => { paths.gog_games = v; dialog.show_restart_message(); });

//add_cache_directory(_("Installers cache"), FSUtils.Paths.GOG.Installers);

add_separator();

logout_btn = new Button.with_label(_("Logout"));
logout_btn.halign = Align.END;
add_widget(logout_btn);

logout_btn.clicked.connect(() => {
gog_auth.authenticated = false;
gog_auth.access_token = "";
gog_auth.refresh_token = "";
update();
dialog.show_restart_message();
});

update();
}

Expand All @@ -55,6 +69,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs
this.foreach(w => {
if(w != enabled_box) w.sensitive = gog_auth.enabled;
});
logout_btn.sensitive = gog_auth.enabled && gog_auth.authenticated && gog_auth.access_token.length > 0;
}

}
Expand Down
15 changes: 15 additions & 0 deletions src/ui/dialogs/SettingsDialog/tabs/Humble.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs
{
private Settings.Auth.Humble humble_auth;
private Box enabled_box;
private Button logout_btn;

public Humble(SettingsDialog dlg)
{
Expand All @@ -49,6 +50,19 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs

//add_cache_directory(_("Installers cache"), FSUtils.Paths.Humble.Installers);

add_separator();

logout_btn = new Button.with_label(_("Logout"));
logout_btn.halign = Align.END;
add_widget(logout_btn);

logout_btn.clicked.connect(() => {
humble_auth.authenticated = false;
humble_auth.access_token = "";
update();
dialog.show_restart_message();
});

update();
}

Expand All @@ -57,6 +71,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog.Tabs
this.foreach(w => {
if(w != enabled_box) w.sensitive = humble_auth.enabled;
});
logout_btn.sensitive = humble_auth.enabled && humble_auth.authenticated && humble_auth.access_token.length > 0;
}

}
Expand Down

0 comments on commit 71e8803

Please sign in to comment.