godot/platform/bb10/export/export.cpp

788 lines
22 KiB
C++
Raw Normal View History

/*************************************************************************/
/* export.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
2014-02-10 01:10:30 +00:00
#include "export.h"
#include "editor/editor_import_export.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
2014-02-10 01:10:30 +00:00
#include "globals.h"
#include "io/marshalls.h"
#include "io/xml_parser.h"
#include "io/zip_io.h"
2014-02-10 01:10:30 +00:00
#include "os/file_access.h"
#include "os/os.h"
#include "platform/bb10/logo.h"
#include "version.h"
2014-02-10 01:10:30 +00:00
#define MAX_DEVICES 5
class EditorExportPlatformBB10 : public EditorExportPlatform {
OBJ_TYPE(EditorExportPlatformBB10, EditorExportPlatform);
2014-02-10 01:10:30 +00:00
String custom_package;
int version_code;
String version_name;
String package;
String name;
String category;
String description;
String author_name;
String author_id;
String icon;
struct Device {
int index;
String name;
String description;
};
Vector<Device> devices;
bool devices_changed;
Mutex *device_lock;
Thread *device_thread;
Ref<ImageTexture> logo;
volatile bool quit_request;
static void _device_poll_thread(void *ud);
void _fix_descriptor(Vector<uint8_t> &p_manifest);
2014-02-10 01:10:30 +00:00
protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
2014-02-10 01:10:30 +00:00
public:
virtual String get_name() const { return "BlackBerry 10"; }
virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_ETC1; }
virtual Ref<Texture> get_logo() const { return logo; }
virtual bool poll_devices();
virtual int get_device_count() const;
virtual String get_device_name(int p_device) const;
virtual String get_device_info(int p_device) const;
virtual Error run(int p_device, int p_flags = 0);
2014-02-10 01:10:30 +00:00
virtual bool requires_password(bool p_debug) const { return !p_debug; }
2014-02-10 01:10:30 +00:00
virtual String get_binary_extension() const { return "bar"; }
virtual Error export_project(const String &p_path, bool p_debug, int p_flags = 0);
2014-02-10 01:10:30 +00:00
virtual bool can_export(String *r_error = NULL) const;
2014-02-10 01:10:30 +00:00
EditorExportPlatformBB10();
~EditorExportPlatformBB10();
};
bool EditorExportPlatformBB10::_set(const StringName &p_name, const Variant &p_value) {
String n = p_name;
if (n == "version/code")
version_code = p_value;
else if (n == "version/name")
version_name = p_value;
else if (n == "package/unique_name")
package = p_value;
else if (n == "package/category")
category = p_value;
else if (n == "package/name")
name = p_value;
else if (n == "package/description")
description = p_value;
else if (n == "package/icon")
icon = p_value;
else if (n == "package/custom_template")
custom_package = p_value;
else if (n == "release/author")
author_name = p_value;
else if (n == "release/author_id")
author_id = p_value;
2014-02-10 01:10:30 +00:00
else
return false;
return true;
}
bool EditorExportPlatformBB10::_get(const StringName &p_name, Variant &r_ret) const {
String n = p_name;
if (n == "version/code")
r_ret = version_code;
else if (n == "version/name")
r_ret = version_name;
else if (n == "package/unique_name")
r_ret = package;
else if (n == "package/category")
r_ret = category;
else if (n == "package/name")
r_ret = name;
else if (n == "package/description")
r_ret = description;
else if (n == "package/icon")
r_ret = icon;
else if (n == "package/custom_template")
r_ret = custom_package;
else if (n == "release/author")
r_ret = author_name;
else if (n == "release/author_id")
r_ret = author_id;
2014-02-10 01:10:30 +00:00
else
return false;
return true;
}
void EditorExportPlatformBB10::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,65535,1"));
p_list->push_back(PropertyInfo(Variant::STRING, "version/name"));
p_list->push_back(PropertyInfo(Variant::STRING, "package/unique_name"));
p_list->push_back(PropertyInfo(Variant::STRING, "package/category"));
p_list->push_back(PropertyInfo(Variant::STRING, "package/name"));
p_list->push_back(PropertyInfo(Variant::STRING, "package/description", PROPERTY_HINT_MULTILINE_TEXT));
p_list->push_back(PropertyInfo(Variant::STRING, "package/icon", PROPERTY_HINT_FILE, "png"));
p_list->push_back(PropertyInfo(Variant::STRING, "package/custom_template", PROPERTY_HINT_GLOBAL_FILE, "zip"));
p_list->push_back(PropertyInfo(Variant::STRING, "release/author"));
p_list->push_back(PropertyInfo(Variant::STRING, "release/author_id"));
2014-02-10 01:10:30 +00:00
//p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)"));
}
void EditorExportPlatformBB10::_fix_descriptor(Vector<uint8_t> &p_descriptor) {
2014-02-10 01:10:30 +00:00
String fpath = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp_bar-settings.xml");
2014-02-10 01:10:30 +00:00
{
FileAccessRef f = FileAccess::open(fpath, FileAccess::WRITE);
f->store_buffer(p_descriptor.ptr(), p_descriptor.size());
2014-02-10 01:10:30 +00:00
}
Ref<XMLParser> parser = memnew(XMLParser);
2014-02-10 01:10:30 +00:00
Error err = parser->open(fpath);
ERR_FAIL_COND(err != OK);
2014-02-10 01:10:30 +00:00
String txt;
err = parser->read();
Vector<String> depth;
while (err != ERR_FILE_EOF) {
2014-02-10 01:10:30 +00:00
ERR_FAIL_COND(err != OK);
2014-02-10 01:10:30 +00:00
switch (parser->get_node_type()) {
2014-02-10 01:10:30 +00:00
case XMLParser::NODE_NONE: {
print_line("???");
} break;
case XMLParser::NODE_ELEMENT: {
String e = "<";
e += parser->get_node_name();
for (int i = 0; i < parser->get_attribute_count(); i++) {
e += " ";
e += parser->get_attribute_name(i) + "=\"";
e += parser->get_attribute_value(i) + "\" ";
2014-02-10 01:10:30 +00:00
}
if (parser->is_empty()) {
e += "/";
2014-02-10 01:10:30 +00:00
} else {
depth.push_back(parser->get_node_name());
}
e += ">";
txt += e;
2014-02-10 01:10:30 +00:00
} break;
case XMLParser::NODE_ELEMENT_END: {
txt += "</" + parser->get_node_name() + ">";
if (depth.size() && depth[depth.size() - 1] == parser->get_node_name()) {
depth.resize(depth.size() - 1);
2014-02-10 01:10:30 +00:00
}
} break;
case XMLParser::NODE_TEXT: {
if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "id") {
2014-02-10 01:10:30 +00:00
txt += package;
} else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "name") {
2014-02-10 01:10:30 +00:00
String aname;
if (this->name != "") {
aname = this->name;
2014-02-10 01:10:30 +00:00
} else {
aname = Globals::get_singleton()->get("application/name");
}
if (aname == "") {
aname = _MKSTR(VERSION_NAME);
2014-02-10 01:10:30 +00:00
}
txt += aname;
} else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "versionNumber") {
txt += itos(version_code);
} else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "description") {
txt += description;
} else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "author") {
txt += author_name;
} else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "authorId") {
txt += author_id;
} else if (depth.size() == 2 && depth[0] == "qnx" && depth[1] == "category") {
txt += category;
2014-02-10 01:10:30 +00:00
} else {
txt += parser->get_node_data();
2014-02-10 01:10:30 +00:00
}
} break;
case XMLParser::NODE_COMMENT: {
txt += "<!--" + parser->get_node_name() + "-->";
2014-02-10 01:10:30 +00:00
} break;
case XMLParser::NODE_CDATA: {
//ignore
//print_line("cdata");
} break;
case XMLParser::NODE_UNKNOWN: {
//ignore
txt += "<" + parser->get_node_name() + ">";
2014-02-10 01:10:30 +00:00
} break;
}
err = parser->read();
}
CharString cs = txt.utf8();
p_descriptor.resize(cs.length());
for (int i = 0; i < cs.length(); i++)
p_descriptor[i] = cs[i];
2014-02-10 01:10:30 +00:00
}
Error EditorExportPlatformBB10::export_project(const String &p_path, bool p_debug, int p_flags) {
2014-02-10 01:10:30 +00:00
EditorProgress ep("export", "Exporting for BlackBerry 10", 104);
2014-02-10 01:10:30 +00:00
String src_template = custom_package;
2014-02-10 01:10:30 +00:00
if (src_template == "") {
String err;
src_template = find_export_template("bb10.zip", &err);
if (src_template == "") {
EditorNode::add_io_error(err);
return ERR_FILE_NOT_FOUND;
}
}
2014-02-10 01:10:30 +00:00
FileAccess *src_f = NULL;
2014-02-10 01:10:30 +00:00
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
ep.step("Creating FileSystem for BAR", 0);
2014-02-10 01:10:30 +00:00
unzFile pkg = unzOpen2(src_template.utf8().get_data(), &io);
if (!pkg) {
EditorNode::add_io_error("Could not find template zip to export:\n" + src_template);
2014-02-10 01:10:30 +00:00
return ERR_FILE_NOT_FOUND;
}
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
da->change_dir(EditorSettings::get_singleton()->get_settings_path());
if (da->change_dir("tmp") != OK) {
2014-02-10 01:10:30 +00:00
da->make_dir("tmp");
if (da->change_dir("tmp") != OK)
2014-02-10 01:10:30 +00:00
return ERR_CANT_CREATE;
}
if (da->change_dir("bb10_export") != OK) {
2014-02-10 01:10:30 +00:00
da->make_dir("bb10_export");
if (da->change_dir("bb10_export") != OK) {
2014-02-10 01:10:30 +00:00
return ERR_CANT_CREATE;
}
}
String bar_dir = da->get_current_dir();
if (bar_dir.ends_with("/")) {
bar_dir = bar_dir.substr(0, bar_dir.length() - 1);
2014-02-10 01:10:30 +00:00
}
//THIS IS SUPER, SUPER DANGEROUS!!!!
//CAREFUL WITH THIS CODE, MIGHT DELETE USERS HARD DRIVE OR HOME DIR
//EXTRA CHECKS ARE IN PLACE EVERYWERE TO MAKE SURE NOTHING BAD HAPPENS BUT STILL....
//BE SUPER CAREFUL WITH THIS PLEASE!!!
//BLACKBERRY THIS IS YOUR FAULT FOR NOT MAKING A BETTER WAY!!
2015-03-03 17:39:13 +00:00
bool berr = bar_dir.ends_with("bb10_export");
if (berr) {
if (da->list_dir_begin()) {
EditorNode::add_io_error("Can't ensure that dir is empty:\n" + bar_dir);
ERR_FAIL_COND_V(berr, FAILED);
2015-03-03 17:39:13 +00:00
};
String f = da->get_next();
while (f != "") {
if (f == "." || f == "..") {
f = da->get_next();
continue;
};
Error err = da->remove(bar_dir + "/" + f);
if (err != OK) {
EditorNode::add_io_error("Can't ensure that dir is empty:\n" + bar_dir);
ERR_FAIL_COND_V(err != OK, err);
2015-03-03 17:39:13 +00:00
};
f = da->get_next();
};
da->list_dir_end();
2014-02-10 01:10:30 +00:00
} else {
print_line("ARE YOU CRAZY??? THIS IS A SERIOUS BUG HERE!!!");
ERR_FAIL_V(ERR_OMFG_THIS_IS_VERY_VERY_BAD);
}
ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
int ret = unzGoToFirstFile(pkg);
while (ret == UNZ_OK) {
2014-02-10 01:10:30 +00:00
//get filename
unz_file_info info;
char fname[16384];
ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
2014-02-10 01:10:30 +00:00
String file = fname;
2014-02-10 01:10:30 +00:00
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
//read
unzOpenCurrentFile(pkg);
unzReadCurrentFile(pkg, data.ptr(), data.size());
2014-02-10 01:10:30 +00:00
unzCloseCurrentFile(pkg);
//write
if (file == "bar-descriptor.xml") {
2014-02-10 01:10:30 +00:00
_fix_descriptor(data);
}
if (file == "icon.png") {
bool found = false;
2014-02-10 01:10:30 +00:00
if (this->icon != "" && this->icon.ends_with(".png")) {
2014-02-10 01:10:30 +00:00
FileAccess *f = FileAccess::open(this->icon, FileAccess::READ);
2014-02-10 01:10:30 +00:00
if (f) {
data.resize(f->get_len());
f->get_buffer(data.ptr(), data.size());
2014-02-10 01:10:30 +00:00
memdelete(f);
found = true;
2014-02-10 01:10:30 +00:00
}
}
if (!found) {
String appicon = Globals::get_singleton()->get("application/icon");
if (appicon != "" && appicon.ends_with(".png")) {
FileAccess *f = FileAccess::open(appicon, FileAccess::READ);
2014-02-10 01:10:30 +00:00
if (f) {
data.resize(f->get_len());
f->get_buffer(data.ptr(), data.size());
2014-02-10 01:10:30 +00:00
memdelete(f);
}
}
}
}
if (file.find("/")) {
da->make_dir_recursive(file.get_base_dir());
}
FileAccessRef wf = FileAccess::open(bar_dir.plus_file(file), FileAccess::WRITE);
wf->store_buffer(data.ptr(), data.size());
2014-02-10 01:10:30 +00:00
ret = unzGoToNextFile(pkg);
}
ep.step("Adding Files..", 2);
2014-02-10 01:10:30 +00:00
FileAccess *dst = FileAccess::open(bar_dir + "/data.pck", FileAccess::WRITE);
2015-03-03 17:39:13 +00:00
if (!dst) {
EditorNode::add_io_error("Can't copy executable file to:\n " + p_path);
2015-03-03 17:39:13 +00:00
return ERR_FILE_CANT_WRITE;
2014-02-10 01:10:30 +00:00
}
2015-03-03 17:39:13 +00:00
save_pack(dst, false, 1024);
dst->close();
memdelete(dst);
2014-02-10 01:10:30 +00:00
ep.step("Creating BAR Package..", 104);
2014-02-10 01:10:30 +00:00
String bb_packager = EditorSettings::get_singleton()->get("blackberry/host_tools");
bb_packager = bb_packager.plus_file("blackberry-nativepackager");
if (OS::get_singleton()->get_name() == "Windows")
bb_packager += ".bat";
2014-02-10 01:10:30 +00:00
if (!FileAccess::exists(bb_packager)) {
EditorNode::add_io_error("Can't find packager:\n" + bb_packager);
2014-02-10 01:10:30 +00:00
return ERR_CANT_OPEN;
}
List<String> args;
args.push_back("-package");
args.push_back(p_path);
if (p_debug) {
String debug_token = EditorSettings::get_singleton()->get("blackberry/debug_token");
2014-02-10 01:10:30 +00:00
if (!FileAccess::exists(debug_token)) {
EditorNode::add_io_error("Debug token not found!");
} else {
args.push_back("-debugToken");
args.push_back(debug_token);
}
args.push_back("-devMode");
args.push_back("-configuration");
args.push_back("Device-Debug");
} else {
args.push_back("-configuration");
args.push_back("Device-Release");
}
args.push_back(bar_dir.plus_file("bar-descriptor.xml"));
int ec;
Error err = OS::get_singleton()->execute(bb_packager, args, true, NULL, NULL, &ec);
2014-02-10 01:10:30 +00:00
if (err != OK)
2014-02-10 01:10:30 +00:00
return err;
if (ec != 0)
2014-02-10 01:10:30 +00:00
return ERR_CANT_CREATE;
2016-03-08 23:00:52 +00:00
2014-02-10 01:10:30 +00:00
return OK;
}
bool EditorExportPlatformBB10::poll_devices() {
bool dc = devices_changed;
devices_changed = false;
2014-02-10 01:10:30 +00:00
return dc;
}
int EditorExportPlatformBB10::get_device_count() const {
device_lock->lock();
int dc = devices.size();
2014-02-10 01:10:30 +00:00
device_lock->unlock();
return dc;
}
String EditorExportPlatformBB10::get_device_name(int p_device) const {
ERR_FAIL_INDEX_V(p_device, devices.size(), "");
2014-02-10 01:10:30 +00:00
device_lock->lock();
String s = devices[p_device].name;
2014-02-10 01:10:30 +00:00
device_lock->unlock();
return s;
}
String EditorExportPlatformBB10::get_device_info(int p_device) const {
ERR_FAIL_INDEX_V(p_device, devices.size(), "");
2014-02-10 01:10:30 +00:00
device_lock->lock();
String s = devices[p_device].description;
2014-02-10 01:10:30 +00:00
device_lock->unlock();
return s;
}
void EditorExportPlatformBB10::_device_poll_thread(void *ud) {
EditorExportPlatformBB10 *ea = (EditorExportPlatformBB10 *)ud;
2014-02-10 01:10:30 +00:00
while (!ea->quit_request) {
2014-02-10 01:10:30 +00:00
String bb_deploy = EditorSettings::get_singleton()->get("blackberry/host_tools");
bb_deploy = bb_deploy.plus_file("blackberry-deploy");
bool windows = OS::get_singleton()->get_name() == "Windows";
2014-02-10 01:10:30 +00:00
if (windows)
bb_deploy += ".bat";
2014-02-10 01:10:30 +00:00
if (FileAccess::exists(bb_deploy)) {
2014-02-10 01:10:30 +00:00
Vector<Device> devices;
2014-02-10 01:10:30 +00:00
for (int i = 0; i < MAX_DEVICES; i++) {
2014-02-10 01:10:30 +00:00
String host = EditorSettings::get_singleton()->get("blackberry/device_" + itos(i + 1) + "/host");
if (host == String())
continue;
String pass = EditorSettings::get_singleton()->get("blackberry/device_" + itos(i + 1) + "/password");
if (pass == String())
continue;
2014-02-10 01:10:30 +00:00
List<String> args;
args.push_back("-listDeviceInfo");
args.push_back(host);
args.push_back("-password");
args.push_back(pass);
2014-02-10 01:10:30 +00:00
int ec;
String dp;
2014-02-10 01:10:30 +00:00
Error err = OS::get_singleton()->execute(bb_deploy, args, true, NULL, &dp, &ec);
2014-02-10 01:10:30 +00:00
if (err == OK && ec == 0) {
2014-02-10 01:10:30 +00:00
Device dev;
dev.index = i;
String descr;
Vector<String> ls = dp.split("\n");
2014-02-10 01:10:30 +00:00
for (int i = 0; i < ls.size(); i++) {
String l = ls[i].strip_edges();
if (l.begins_with("modelfullname::")) {
dev.name = l.get_slice("::", 1);
descr += "Model: " + dev.name + "\n";
}
if (l.begins_with("modelnumber::")) {
String s = l.get_slice("::", 1);
dev.name += " (" + s + ")";
descr += "Model Number: " + s + "\n";
}
if (l.begins_with("scmbundle::"))
descr += "OS Version: " + l.get_slice("::", 1) + "\n";
if (l.begins_with("[n]debug_token_expiration::"))
descr += "Debug Token Expires:: " + l.get_slice("::", 1) + "\n";
2014-02-10 01:10:30 +00:00
}
dev.description = descr;
devices.push_back(dev);
2014-02-10 01:10:30 +00:00
}
}
bool changed = false;
2014-02-10 01:10:30 +00:00
ea->device_lock->lock();
2014-02-10 01:10:30 +00:00
if (ea->devices.size() != devices.size()) {
changed = true;
} else {
2014-02-10 01:10:30 +00:00
for (int i = 0; i < ea->devices.size(); i++) {
2014-02-10 01:10:30 +00:00
if (ea->devices[i].index != devices[i].index) {
changed = true;
break;
}
2014-02-10 01:10:30 +00:00
}
}
if (changed) {
2014-02-10 01:10:30 +00:00
ea->devices = devices;
ea->devices_changed = true;
}
2014-02-10 01:10:30 +00:00
ea->device_lock->unlock();
}
2014-02-10 01:10:30 +00:00
uint64_t wait = 3000000;
uint64_t time = OS::get_singleton()->get_ticks_usec();
while (OS::get_singleton()->get_ticks_usec() - time < wait) {
OS::get_singleton()->delay_usec(1000);
if (ea->quit_request)
break;
}
2014-02-10 01:10:30 +00:00
}
}
Error EditorExportPlatformBB10::run(int p_device, int p_flags) {
2014-02-10 01:10:30 +00:00
ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER);
2014-02-10 01:10:30 +00:00
String bb_deploy = EditorSettings::get_singleton()->get("blackberry/host_tools");
bb_deploy = bb_deploy.plus_file("blackberry-deploy");
if (OS::get_singleton()->get_name() == "Windows")
bb_deploy += ".bat";
2014-02-10 01:10:30 +00:00
if (!FileAccess::exists(bb_deploy)) {
EditorNode::add_io_error("Blackberry Deploy not found:\n" + bb_deploy);
2014-02-10 01:10:30 +00:00
return ERR_FILE_NOT_FOUND;
}
device_lock->lock();
EditorProgress ep("run", "Running on " + devices[p_device].name, 3);
2014-02-10 01:10:30 +00:00
//export_temp
ep.step("Exporting APK", 0);
2014-02-10 01:10:30 +00:00
String export_to = EditorSettings::get_singleton()->get_settings_path().plus_file("/tmp/tmpexport.bar");
Error err = export_project(export_to, true, p_flags);
2014-02-10 01:10:30 +00:00
if (err) {
device_lock->unlock();
return err;
}
#if 0
ep.step("Uninstalling..",1);
print_line("Uninstalling previous version: "+devices[p_device].name);
List<String> args;
args.push_back("-s");
args.push_back(devices[p_device].id);
args.push_back("uninstall");
args.push_back(package);
int rv;
err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv);
if (err || rv!=0) {
EditorNode::add_io_error("Could not install to device.");
device_lock->unlock();
return ERR_CANT_CREATE;
}
print_line("Installing into device (please wait..): "+devices[p_device].name);
#endif
ep.step("Installing to Device (please wait..)..", 2);
2014-02-10 01:10:30 +00:00
List<String> args;
args.clear();
args.push_back("-installApp");
args.push_back("-launchApp");
args.push_back("-device");
String host = EditorSettings::get_singleton()->get("blackberry/device_" + itos(p_device + 1) + "/host");
String pass = EditorSettings::get_singleton()->get("blackberry/device_" + itos(p_device + 1) + "/password");
2014-02-10 01:10:30 +00:00
args.push_back(host);
args.push_back("-password");
args.push_back(pass);
args.push_back(export_to);
int rv;
err = OS::get_singleton()->execute(bb_deploy, args, true, NULL, NULL, &rv);
if (err || rv != 0) {
2014-02-10 01:10:30 +00:00
EditorNode::add_io_error("Could not install to device.");
device_lock->unlock();
return ERR_CANT_CREATE;
}
device_lock->unlock();
return OK;
}
EditorExportPlatformBB10::EditorExportPlatformBB10() {
version_code = 1;
version_name = "1.0";
package = "com.godot.noname";
category = "core.games";
name = "";
author_name = "Cert. Name";
author_id = "Cert. ID";
description = "Game made with Godot Engine";
2014-02-10 01:10:30 +00:00
device_lock = Mutex::create();
quit_request = false;
2014-02-10 01:10:30 +00:00
device_thread = Thread::create(_device_poll_thread, this);
devices_changed = true;
2014-02-10 01:10:30 +00:00
Image img(_bb10_logo);
logo = Ref<ImageTexture>(memnew(ImageTexture));
2014-02-10 01:10:30 +00:00
logo->create_from_image(img);
}
bool EditorExportPlatformBB10::can_export(String *r_error) const {
bool valid = true;
String bb_deploy = EditorSettings::get_singleton()->get("blackberry/host_tools");
2014-02-10 01:10:30 +00:00
String err;
if (!FileAccess::exists(bb_deploy.plus_file("blackberry-deploy"))) {
valid = false;
err += "Blackberry host tools not configured in editor settings.\n";
2014-02-10 01:10:30 +00:00
}
if (!exists_export_template("bb10.zip")) {
valid = false;
err += "No export template found.\nDownload and install export templates.\n";
2014-02-10 01:10:30 +00:00
}
String debug_token = EditorSettings::get_singleton()->get("blackberry/debug_token");
2014-02-10 01:10:30 +00:00
if (!FileAccess::exists(debug_token)) {
valid = false;
err += "No debug token set, will not be able to test on device.\n";
2014-02-10 01:10:30 +00:00
}
if (custom_package != "" && !FileAccess::exists(custom_package)) {
valid = false;
err += "Custom release package not found.\n";
2014-02-10 01:10:30 +00:00
}
if (r_error)
*r_error = err;
2014-02-10 01:10:30 +00:00
return valid;
}
EditorExportPlatformBB10::~EditorExportPlatformBB10() {
quit_request = true;
2014-02-10 01:10:30 +00:00
Thread::wait_to_finish(device_thread);
memdelete(device_lock);
memdelete(device_thread);
2014-02-10 01:10:30 +00:00
}
void register_bb10_exporter() {
EDITOR_DEF("blackberry/host_tools", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "blackberry/host_tools", PROPERTY_HINT_GLOBAL_DIR));
EDITOR_DEF("blackberry/debug_token", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "blackberry/debug_token", PROPERTY_HINT_GLOBAL_FILE, "bar"));
EDITOR_DEF("blackberry/device_1/host", "");
EDITOR_DEF("blackberry/device_1/password", "");
EDITOR_DEF("blackberry/device_2/host", "");
EDITOR_DEF("blackberry/device_2/password", "");
EDITOR_DEF("blackberry/device_3/host", "");
EDITOR_DEF("blackberry/device_3/password", "");
EDITOR_DEF("blackberry/device_4/host", "");
EDITOR_DEF("blackberry/device_4/password", "");
EDITOR_DEF("blackberry/device_5/host", "");
EDITOR_DEF("blackberry/device_5/password", "");
Ref<EditorExportPlatformBB10> exporter = Ref<EditorExportPlatformBB10>(memnew(EditorExportPlatformBB10));
2014-02-10 01:10:30 +00:00
EditorImportExport::get_singleton()->add_export_platform(exporter);
}