Subversion Repositories HomeAutomation

Rev

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

Rev 1644 Rev 1647
Line 33... Line 33...
33
   
33
   
34
System::System(boost::asio::io_service& io_service) : 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
   
37
   
38
    this->ExportFunction("Log",        System::Export_Log);
-
 
39
    this->ExportFunction("Require",    System::Export_Require);
38
    this->ExportFunction("Require",    System::Export_Require);
40
    this->ExportFunction("Execute",    System::Export_Execute);
39
    this->ExportFunction("Execute",    System::Export_Execute);
41
}
40
}
42
 
41
 
43
System::~System()
42
System::~System()
Line 52... Line 51...
52
    Plugin::InitializeDone();
51
    Plugin::InitializeDone();
53
   
52
   
54
    v8::Boolean::New(Manager::Instance()->LoadScript("user/autostart.js"));
53
    v8::Boolean::New(Manager::Instance()->LoadScript("user/autostart.js"));
55
}
54
}
56
 
55
 
57
Value System::Export_Log(const v8::Arguments& args)
56
void System::CallOutput(unsigned int request_id, std::string output)
58
{
57
{
59
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
60
   
-
 
61
    LOG.Debug(std::string(__FUNCTION__) + " called!");
-
 
62
   
-
 
63
    if (args.Length() < 1)
-
 
64
    {
-
 
65
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments to log.");
-
 
66
    }
-
 
67
   
-
 
68
    v8::String::AsciiValue str(args[0]);
-
 
69
   
-
 
70
    LOG.Info(*str);
58
    LOG.Info(output);
71
   
-
 
72
    return v8::Undefined();
-
 
73
}
59
}
74
 
60
 
75
Value System::Export_Require(const v8::Arguments& args)
61
Value System::Export_Require(const v8::Arguments& args)
76
{
62
{
77
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
63
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
Line 79... Line 65...
79
    LOG.Debug(std::string(__FUNCTION__) + " called!");
65
    LOG.Debug(std::string(__FUNCTION__) + " called!");
80
   
66
   
81
    if (args.Length() < 1)
67
    if (args.Length() < 1)
82
    {
68
    {
83
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
69
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
70
        return v8::Boolean::New(false);
84
    }
71
    }
85
   
72
   
86
    v8::String::AsciiValue str(args[0]);
73
    v8::String::AsciiValue str(args[0]);
87
   
74
   
88
    return v8::Boolean::New(Manager::Instance()->LoadScript(*str));
75
    return v8::Boolean::New(Manager::Instance()->LoadScript(*str));
Line 95... Line 82...
95
    LOG.Debug(std::string(__FUNCTION__) + " called!");
82
    LOG.Debug(std::string(__FUNCTION__) + " called!");
96
   
83
   
97
    if (args.Length() < 1)
84
    if (args.Length() < 1)
98
    {
85
    {
99
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
86
        LOG.Error(std::string(__FUNCTION__) + ": To few arguments.");
-
 
87
        return v8::Boolean::New(false);
100
    }
88
    }
101
   
89
   
102
    v8::String::AsciiValue command(args[0]);
90
    v8::String::AsciiValue command(args[0]);
103
   
91
   
104
    std::string output_buffer;
92
    std::string output_buffer;