Subversion Repositories HomeAutomation

Rev

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

Rev 1740 Rev 1741
Line 100... Line 100...
100
 
100
 
101
Value Manager::Export_Log(const v8::Arguments& args)
101
Value Manager::Export_Log(const v8::Arguments& args)
102
{
102
{
103
    v8::Locker lock;
103
    v8::Locker lock;
104
    v8::Context::Scope context_scope(Manager::Instance()->GetContext());
104
    v8::Context::Scope context_scope(Manager::Instance()->GetContext());
-
 
105
    v8::HandleScope handle_scope;
105
   
106
     
106
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
107
    //LOG.Debug(std::string(__FUNCTION__) + " called!");
107
   
108
   
108
    if (args.Length() < 1)
109
    if (args.Length() < 1)
109
    {
110
    {
Line 113... Line 114...
113
   
114
   
114
    v8::String::AsciiValue str(args[0]);
115
    v8::String::AsciiValue str(args[0]);
115
       
116
       
116
    Manager::instance_->CallOutput(*str);
117
    Manager::instance_->CallOutput(*str);
117
   
118
   
118
    return v8::Undefined();
119
    return handle_scope.Close(v8::Undefined());
119
}
120
}
120
 
121
 
121
void Manager::Call(std::string plugin_name, unsigned int request_id, std::string name, ArgumentListPointer arguments)
122
void Manager::Call(std::string plugin_name, unsigned int request_id, std::string name, ArgumentListPointer arguments)
122
{
123
{
123
    this->io_service_.post(boost::bind(&Manager::CallHandler, this, plugin_name, request_id, name, arguments));
124
    this->io_service_.post(boost::bind(&Manager::CallHandler, this, plugin_name, request_id, name, arguments));
Line 138... Line 139...
138
    this->current_request_id_ = request_id;
139
    this->current_request_id_ = request_id;
139
   
140
   
140
    if (this->functions_.find(name) == this->functions_.end())
141
    if (this->functions_.find(name) == this->functions_.end())
141
    {
142
    {
142
        this->CallOutput("No such function found, " + name);
143
        this->CallOutput("No such function found, " + name);
143
       
144
       
144
        this->current_plugin_name_ = "";
145
        this->current_plugin_name_ = "";
145
        this->current_request_id_ = 0;
146
        this->current_request_id_ = 0;
146
        return false;
147
        return false;
147
    }
148
    }
148
 
149
 
149
    //LOG.Debug("Call: " + name);
150
    //LOG.Debug("Call: " + name);
Line 166... Line 167...
166
    this->current_request_id_ = 0;
167
    this->current_request_id_ = 0;
167
    return true;
168
    return true;
168
}
169
}
169
 
170
 
170
void Manager::StartHandler()
171
void Manager::StartHandler()
171
{
172
{
-
 
173
    v8::Locker lock;
-
 
174
    v8::HandleScope handle_scope;
172
    v8::Handle<v8::ObjectTemplate> raw_template = v8::ObjectTemplate::New();
175
    v8::Handle<v8::ObjectTemplate> raw_template = v8::ObjectTemplate::New();
173
   
176
   
174
    raw_template->Set(v8::String::New("Log"), v8::FunctionTemplate::New(Manager::Export_Log));
177
    raw_template->Set(v8::String::New("Log"), v8::FunctionTemplate::New(Manager::Export_Log));
175
   
178
   
176
    for (unsigned int c = 0; c < this->plugins_.size(); c++)
179
    for (unsigned int c = 0; c < this->plugins_.size(); c++)
Line 183... Line 186...
183
        }
186
        }
184
    }
187
    }
185
   
188
   
186
    this->context_ = v8::Context::New(NULL, raw_template);
189
    this->context_ = v8::Context::New(NULL, raw_template);
187
   
190
   
188
    v8::Locker lock;
191
   
189
    v8::Context::Scope context_scope(this->context_);
192
    v8::Context::Scope context_scope(this->context_);
190
   
193
   
191
    for (unsigned int c = 0; c < this->plugins_.size(); c++)
194
    for (unsigned int c = 0; c < this->plugins_.size(); c++)
192
    {
195
    {
193
        this->LoadScript("plugin/" + this->plugins_[c]->GetName() + ".js");
196
        this->LoadScript("plugin/" + this->plugins_[c]->GetName() + ".js");