Subversion Repositories HomeAutomation

Rev

Rev 1625 | Rev 1647 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1625 Rev 1644
Line 29... Line 29...
29
namespace vm {
29
namespace vm {
30
namespace plugin {
30
namespace plugin {
31
 
31
 
32
logging::Logger System::LOG("vm::plugin::System");
32
logging::Logger System::LOG("vm::plugin::System");
33
   
33
   
34
System::System(boost::asio::io_service& io_service, bool legacy) : Plugin(io_service)
34
System::System(boost::asio::io_service& io_service) : Plugin(io_service)
35
{
35
{
36
    this->name_ = "system";
36
    this->name_ = "system";
37
   
-
 
38
    this->legacy_ = legacy;
-
 
39
                 
37
   
40
    this->ExportFunction("Log",        System::Export_Log);
38
    this->ExportFunction("Log",        System::Export_Log);
41
    this->ExportFunction("LoadScript", System::Export_LoadScript);
39
    this->ExportFunction("Require",    System::Export_Require);
42
    this->ExportFunction("Execute",    System::Export_Execute);
40
    this->ExportFunction("Execute",    System::Export_Execute);
43
}
41
}
44
 
42
 
45
System::~System()
43
System::~System()
46
{
44
{
47
 
45
 
48
}
46
}
49
 
47
 
50
void System::InitializeDone()
48
void System::InitializeDone()
51
{
49
{
52
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
50
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
53
   
51
   
54
    Plugin::InitializeDone();
52
    Plugin::InitializeDone();
55
   
53
   
56
    this->ImportFunction("Start");
-
 
57
   
-
 
58
    ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList);
54
    v8::Boolean::New(Manager::Instance()->LoadScript("user/autostart.js"));
59
   
-
 
60
    arguments->push_back(v8::Boolean::New(this->legacy_));
-
 
61
   
-
 
62
    this->Call(0, "Start", arguments);
-
 
63
}
55
}
64
 
56
 
65
Value System::Export_Log(const v8::Arguments& args)
57
Value System::Export_Log(const v8::Arguments& args)
66
{
58
{
67
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
59
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
68
   
60
   
69
    LOG.Debug(std::string(__FUNCTION__) + " called!");
61
    LOG.Debug(std::string(__FUNCTION__) + " called!");
70
   
62
   
71
    if (args.Length() < 1)
63
    if (args.Length() < 1)
72
    {
64
    {
73
        LOG.Error("To few arguments to log.");
65
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments to log.");
74
    }
66
    }
75
   
67
   
76
    v8::String::AsciiValue str(args[0]);
68
    v8::String::AsciiValue str(args[0]);
77
   
69
   
78
    LOG.Info(*str);
70
    LOG.Info(*str);
79
   
71
   
80
    return v8::Undefined();
72
    return v8::Undefined();
81
}
73
}
82
 
74
 
83
Value System::Export_LoadScript(const v8::Arguments& args)
75
Value System::Export_Require(const v8::Arguments& args)
84
{
76
{
85
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
77
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
86
   
78
   
87
    LOG.Debug(std::string(__FUNCTION__) + " called!");
79
    LOG.Debug(std::string(__FUNCTION__) + " called!");
88
   
80
   
89
    if (args.Length() < 1)
81
    if (args.Length() < 1)
90
    {
82
    {
91
        LOG.Error("To few arguments.");
83
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
92
    }
84
    }
93
   
85
   
94
    v8::String::AsciiValue str(args[0]);
86
    v8::String::AsciiValue str(args[0]);
95
   
87
   
96
    return v8::Boolean::New(Manager::Instance()->LoadScript(*str));
88
    return v8::Boolean::New(Manager::Instance()->LoadScript(*str));
Line 102... Line 94...
102
   
94
   
103
    LOG.Debug(std::string(__FUNCTION__) + " called!");
95
    LOG.Debug(std::string(__FUNCTION__) + " called!");
104
   
96
   
105
    if (args.Length() < 1)
97
    if (args.Length() < 1)
106
    {
98
    {
107
        LOG.Error("To few arguments.");
99
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
108
    }
100
    }
109
   
101
   
110
    v8::String::AsciiValue command(args[0]);
102
    v8::String::AsciiValue command(args[0]);
111
   
103
   
112
    std::string output_buffer;
104
    std::string output_buffer;