Skip to content

Commit

Permalink
initial work on y2base replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 21, 2017
1 parent acbab85 commit 4b73441
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/binary/Yast.cc
Expand Up @@ -521,6 +521,10 @@ static VALUE ui_set_component(VALUE self, VALUE name)

static void init_ui()
{
// init_ui is needed only if run via rspec, if y2base is used ENV is initialized
if (getenv("YAST_IS_RUNNING") != NULL)
return;

const char *ui_name = "UI";

Y2Component *c = YUIComponent::uiComponent();
Expand All @@ -543,6 +547,27 @@ static void init_ui()
}
}

static VALUE ui_create(VALUE self, VALUE name, VALUE args)
{
Y2ComponentBroker::getNamespaceComponent("UI");

string name_s = StringValuePtr(name);
y2debug("creating UI %s", name_s.c_str());
Y2Component *server = Y2ComponentBroker::createServer(name_s.c_str());
int argc = RARRAY_LENINT(args);
char **argv = new char *[argc+1];
for (long i = 0; i < argc; ++i)
{
VALUE a = rb_ary_entry(args, i);
argv[i] = strdup(StringValuePtr(a));
}
argv[argc] = NULL;

server->setServerOptions(argc, argv);

return Qnil;
}

static VALUE ui_finalizer()
{
YUIComponent *c = YUIComponent::uiComponent();
Expand Down Expand Up @@ -586,9 +611,10 @@ extern "C"
rb_define_singleton_method( rb_mYast, "y2_logger", RUBY_METHOD_FUNC(yast_y2_logger), -1);

// UI initialization
rb_define_singleton_method( rb_mYast, "ui_create", RUBY_METHOD_FUNC(ui_create), 2);
rb_define_singleton_method( rb_mYast, "ui_component", RUBY_METHOD_FUNC(ui_get_component), 0);
rb_define_singleton_method( rb_mYast, "ui_component=", RUBY_METHOD_FUNC(ui_set_component), 1);
rb_define_singleton_method( rb_mYast, "ui_finalizer", RUBY_METHOD_FUNC(ui_finalizer), 0);
rb_define_singleton_method( rb_mYast, "ui_finalizer", RUBY_METHOD_FUNC(ui_finalizer), 0);

// Y2 references
rb_cYReference = rb_define_class_under(rb_mYast, "YReference", rb_cObject);
Expand Down
13 changes: 13 additions & 0 deletions src/y2base/y2base
@@ -0,0 +1,13 @@
#! /usr/bin/ruby

# TODO: signal handling
# TODO: option parsing
# TODO: umask
# TODO: pathsearch initialization

require "yast"

Yast.create_ui(ARGV[0],[])
Yast::WFM.CallFunction(ARGV[1])

0

0 comments on commit 4b73441

Please sign in to comment.