Rev 1642 | Rev 1647 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1642 | Rev 1644 | ||
|---|---|---|---|
| Line 33... | Line 33... | ||
| 33 | 33 | ||
| 34 | Module::Module(boost::asio::io_service& io_service) : Plugin(io_service) |
34 | Module::Module(boost::asio::io_service& io_service) : Plugin(io_service) |
| 35 | { |
35 | { |
| 36 | this->name_ = "module"; |
36 | this->name_ = "module"; |
| 37 | 37 | ||
| 38 | this->ExportFunction(" |
38 | this->ExportFunction("ModuleExport_SendMessage", Module::Export_SendModuleMessage); |
| 39 | this->ExportFunction(" |
39 | this->ExportFunction("ModuleExport_GetAvailableModules", Module::Export_GetAvailableModules); |
| 40 | this->ExportFunction(" |
40 | this->ExportFunction("ModuleExport_ProgramNode", Module::Export_ProgramNode); |
| 41 | } |
41 | } |
| 42 | 42 | ||
| 43 | Module::~Module() |
43 | Module::~Module() |
| 44 | { |
44 | { |
| 45 | this->tracker_.reset(); |
45 | this->tracker_.reset(); |
| Line 140... | Line 140... | ||
| 140 | variables[std::string(*name)] = std::string(*value); |
140 | variables[std::string(*name)] = std::string(*value); |
| 141 | } |
141 | } |
| 142 | 142 | ||
| 143 | control::Manager::Instance()->SendMessage(std::string(*full_id), std::string(*command), variables); |
143 | control::Manager::Instance()->SendMessage(std::string(*full_id), std::string(*command), variables); |
| 144 | 144 | ||
| 145 | return v8:: |
145 | return v8::Boolean::New(true); |
| 146 | } |
146 | } |
| 147 | 147 | ||
| 148 | Value Module:: |
148 | Value Module::Export_GetAvailableModules(const v8::Arguments& args) |
| 149 | { |
149 | { |
| 150 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
150 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 151 | 151 | ||
| 152 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
152 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 153 | 153 | ||
| 154 | if (args.Length() < 1) |
154 | if (args.Length() < 1) |
| 155 | { |
155 | { |
| 156 | LOG.Error("To few arguments."); |
156 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 157 | } |
- | |
| 158 | - | ||
| 159 | v8::String::AsciiValue full_id(args[0]); |
- | |
| 160 | - | ||
| 161 | return v8::Boolean::New(control::Manager::Instance()->IsModuleAvailable(std::string(*full_id))); |
- | |
| 162 | } |
157 | } |
| 163 | 158 | ||
| - | 159 | common::StringList available_modules = control::Manager::Instance()->GetAvailableModules(); |
|
| - | 160 | ||
| - | 161 | v8::Local<v8::Array> result = v8::Array::New(available_modules.size()); |
|
| - | 162 | ||
| - | 163 | for (unsigned int n = 0; n < available_modules.size(); n++) |
|
| - | 164 | { |
|
| - | 165 | result->Set(n, v8::String::New(available_modules[n].data())); |
|
| - | 166 | } |
|
| - | 167 | ||
| - | 168 | return result; |
|
| - | 169 | } |
|
| 164 | 170 | ||
| 165 | Value Module::Export_ProgramNode(const v8::Arguments& args) |
171 | Value Module::Export_ProgramNode(const v8::Arguments& args) |
| 166 | { |
172 | { |
| 167 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
173 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| 168 | 174 | ||
| 169 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
175 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 170 | 176 | ||
| 171 | if (args.Length() < 3) |
177 | if (args.Length() < 3) |
| 172 | { |
178 | { |
| 173 | LOG.Error("To few arguments."); |
179 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 174 | } |
180 | } |
| 175 | 181 | ||
| 176 | v8::String::AsciiValue filename(args[2]); |
182 | v8::String::AsciiValue filename(args[2]); |
| 177 | 183 | ||
| 178 | return v8::Boolean::New(control::Manager::Instance()->ProgramNode(args[0]->Uint32Value(), args[1]->BooleanValue(), std::string(*filename))); |
184 | return v8::Boolean::New(control::Manager::Instance()->ProgramNode(args[0]->Uint32Value(), args[1]->BooleanValue(), std::string(*filename))); |