Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 52 additions & 28 deletions Engines/Wine/Shortcuts/Reader/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,32 +67,56 @@ var _WineShortcutReader = function(shortcut) {
}
};

/* exported ShortcutReader */
var ShortcutReader = function() {
var that = this;

this.of = function(shortcut) {
this.shortcut = shortcut;
var shortcutContentParsed = JSON.parse(this.shortcut.script);

if(shortcutContentParsed.type == "WINE") {
that._runner = new _WineShortcutReader(this.shortcut);
}
};

this.run = function(userArguments) {
that._runner.run(userArguments);
};

this.stop = function() {
that._runner.stop();
};

this.uninstall = function() {
that._runner.uninstall();
};
/**
* ShortcutReader prototype
* @constructor
*/
function ShortcutReader() {
}

/**
* sets shortcut
* @param {string} shortcut shortcut
* @returns {void}
*/
ShortcutReader.prototype.of = function (shortcut) {
this.shortcut = shortcut;
var shortcutContentParsed = JSON.parse(this.shortcut.script);

this.container = function() {
return that._runner.container();
};
};
if(shortcutContentParsed.type == "WINE") {
this._runner = new _WineShortcutReader(this.shortcut);
}
}

/**
* runs shortcut
* @param {array} userArguments arguments
* @returns {void}
*/
ShortcutReader.prototype.run = function (userArguments) {
this._runner.run(userArguments);
}

/**
* stops running shortcut
* @returns {void}
*/
ShortcutReader.prototype.stop = function () {
this._runner.stop();
}

/**
* uninstalls shortcut
* @returns {void}
*/
ShortcutReader.prototype.uninstall = function () {
this._runner.uninstall();
}

/**
* returns container of shortcut
* @returns {string} container
*/
ShortcutReader.prototype.container = function () {
return this._runner.container();
}
235 changes: 137 additions & 98 deletions Engines/Wine/Shortcuts/Wine/script.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,146 @@
include(["engines", "wine", "engine", "object"]);

/* exported WineShortcut */
var WineShortcut = function () {
var that = this;
that._shortcutManager = Bean("shortcutManager");
that._appsManager = Bean("repositoryManager");
that._fileSearcher = Bean("fileSearcher");
that._winePrefixesDirectory = Bean("propertyReader").getProperty("application.user.containers") + "/" + WINE_PREFIX_DIR + "/";

that._category = "Other";
that._description = "";

that.name = function (name) {
that._name = name;
return that;
};

that.type = function (type) {
that._type = type;
return that;
};

that.category = function (category) {
that._category = category;
return that;
};

that.description = function (description) {
that._description = description;
return that;
};

that.arguments = function(args) {
that._arguments = args;
return that;
};

that.search = function(search) {
that._search = search;
return that;
};

that.prefix = function(prefix) {
that._prefix = prefix;
return that;
};

/**
* sets the miniature for the shortcut
* @param {string[]|URI} miniature
* array which specifies the application of which the miniature shall be used
* or
* URI of the miniature
* @returns {WineShortcut}
*/
that.miniature = function(miniature) {
if(isArray(miniature)) {
// application of miniature given
var application = that._appsManager.getApplication(miniature);
if(application != null && application.getMainMiniature().isPresent()) {
that._miniature = application.getMainMiniature().get();
}
} else {
// miniature URI given
that._miniature = miniature;
/**
* WineShortcut prototype
* @constructor
*/
function WineShortcut() {
this._shortcutManager = Bean("shortcutManager");
this._appsManager = Bean("repositoryManager");
this._fileSearcher = Bean("fileSearcher");
this._winePrefixesDirectory = Bean("propertyReader").getProperty("application.user.containers") + "/" + WINE_PREFIX_DIR + "/";

this._category = "Other";
this._description = "";
}

/**
* sets shortcut name
* @param {string} name shortcut name
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.name = function (name) {
this._name = name;
return this;
}

/**
* sets shortcut type
* @param {string} type shortcut type
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.type = function (type) {
this._type = type;
return this;
}

/**
* sets shortcut category
* @param {string} category shortcut category
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.category = function (category) {
this._category = category;
return this;
}

/**
* sets shortcut description
* @param {string} description shortcut description
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.description = function (description) {
this._description = description;
return this;
}

/**
* sets shortcut arguments
* @param {array} args shortcut arguments
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.arguments = function (args) {
this._arguments = args;
return this;
}

/**
* sets executable which shall be used
* @param {string} search executable name
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.search = function (search) {
this._search = search;
return this;
}

/**
* sets shortcut prefix
* @param {string} prefix shortcut prefix
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.prefix = function (prefix) {
this._prefix = prefix;
return this;
}

/**
* sets the miniature for the shortcut
* @param {string[]|URI} miniature
* array which specifies the application of which the miniature shall be used
* or
* URI of the miniature
* @returns {WineShortcut} WineShortcut object
*/
WineShortcut.prototype.miniature = function (miniature) {
if(isArray(miniature)) {
// application of miniature given
var application = this._appsManager.getApplication(miniature);
if(application != null && application.getMainMiniature().isPresent()) {
this._miniature = application.getMainMiniature().get();
}
} else {
// miniature URI given
this._miniature = miniature;
}

return that;
};

that.create = function () {
var _shortcutPrefixDirectory = that._winePrefixesDirectory + "/" + that._prefix;
return this;
}

var executables = that._fileSearcher.search(_shortcutPrefixDirectory, that._search);
/**
* creates shortcut
* @returns {void}
*/
WineShortcut.prototype.create = function () {
var _shortcutPrefixDirectory = this._winePrefixesDirectory + "/" + this._prefix;

if (executables.length == 0) {
throw tr("Executable {0} not found!", that._search)
}
var executables = this._fileSearcher.search(_shortcutPrefixDirectory, this._search);

var info = new org.phoenicis.library.dto.ShortcutInfoDTO.Builder()
.withCategory(that._category)
.withName(that._name)
.withDescription(that._description)
.build();

var builder = new org.phoenicis.library.dto.ShortcutDTO.Builder()
.withId(that._name)
.withInfo(info)
.withScript(JSON.stringify({
type: "WINE",
wineDebug: "-all",
winePrefix: that._prefix,
arguments: that._arguments,
workingDirectory:executables[0].getParentFile().getAbsolutePath(),
executable: executables[0].getAbsolutePath()
}));

if(that._miniature) {
builder.withMiniature(that._miniature);
}
if (executables.length == 0) {
throw tr("Executable {0} not found!", this._search)
}

that._shortcutManager.createShortcut(
builder.build()
);
var info = new org.phoenicis.library.dto.ShortcutInfoDTO.Builder()
.withCategory(this._category)
.withName(this._name)
.withDescription(this._description)
.build();

var builder = new org.phoenicis.library.dto.ShortcutDTO.Builder()
.withId(this._name)
.withInfo(info)
.withScript(JSON.stringify({
type: "WINE",
wineDebug: "-all",
winePrefix: this._prefix,
arguments: this._arguments,
workingDirectory:executables[0].getParentFile().getAbsolutePath(),
executable: executables[0].getAbsolutePath()
}));

if(this._miniature) {
builder.withMiniature(this._miniature);
}
};

this._shortcutManager.createShortcut(builder.build());
}
53 changes: 32 additions & 21 deletions Utils/Functions/Apps/Resources/script.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
/* exported AppResource */
var AppResource = function() {
var that = this;
that._appsManager = Bean("repositoryManager");
/**
* AppResource prototype
* @constructor
*/
function AppResource() {
this._appsManager = Bean("repositoryManager");
}

this.application = function(application) {
that._application = application;
return that;
};
/**
* sets application
* @param {string} application application of the resource
* @returns {AppResource} AppResource object
*/
AppResource.prototype.application = function (application) {
this._application = application;
return this;
}

this.get = function(resourceName) {
var application = that._appsManager.getApplication(that._application);
var foundResource = null;
if(application != null && application.resources != null) {
application.resources.forEach(function(resource) {
if(resource.name == resourceName) {
foundResource = resource.content;
}
});
}

return foundResource;
/**
* returns resource
* @param {string} resourceName name of the resource
* @returns {Resource} found resource
*/
AppResource.prototype.get = function (resourceName) {
var application = this._appsManager.getApplication(this._application);
var foundResource = null;
if (application != null && application.resources != null) {
application.resources.forEach(function(resource) {
if(resource.name == resourceName) {
foundResource = resource.content;
}
});
}
};

return foundResource;
}
Loading