Rev 1740 | Rev 1887 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1740 | Rev 1741 | ||
|---|---|---|---|
| Line 68... | Line 68... | ||
| 68 | 68 | ||
| 69 | void Node::SlotOnNodeChangeHandler(control::Node::Id node_id, bool available) |
69 | void Node::SlotOnNodeChangeHandler(control::Node::Id node_id, bool available) |
| 70 | { |
70 | { |
| 71 | v8::Locker lock; |
71 | v8::Locker lock; |
| 72 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
72 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 73 | v8::HandleScope handle_scope; |
|
| 73 | 74 | ||
| 74 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
75 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 75 | 76 | ||
| 76 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
77 | ArgumentListPointer arguments = ArgumentListPointer(new ArgumentList); |
| 77 | arguments->push_back(v8::String::New(node_id.data())); |
78 | arguments->push_back(v8::String::New(node_id.data())); |
| Line 82... | Line 83... | ||
| 82 | 83 | ||
| 83 | Value Node::Export_ResetNode(const v8::Arguments& args) |
84 | Value Node::Export_ResetNode(const v8::Arguments& args) |
| 84 | { |
85 | { |
| 85 | v8::Locker lock; |
86 | v8::Locker lock; |
| 86 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
87 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 88 | v8::HandleScope handle_scope; |
|
| 87 | 89 | ||
| 88 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
90 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 89 | 91 | ||
| 90 | if (args.Length() < 1) |
92 | if (args.Length() < 1) |
| 91 | { |
93 | { |
| 92 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
94 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 93 | return v8 |
95 | return handle_scope.Close(v8::Boolean::New(false)); |
| 94 | } |
96 | } |
| 95 | 97 | ||
| 96 | v8::String::AsciiValue node_id(args[0]); |
98 | v8::String::AsciiValue node_id(args[0]); |
| 97 | 99 | ||
| 98 | return v8::Boolean::New(control |
100 | return handle_scope.Close(v8::Boolean::New(control::Manager::Instance()->ResetNode(*node_id))); |
| 99 | } |
101 | } |
| 100 | 102 | ||
| 101 | Value Node::Export_GetAvailableNodes(const v8::Arguments& args) |
103 | Value Node::Export_GetAvailableNodes(const v8::Arguments& args) |
| 102 | { |
104 | { |
| 103 | v8::Locker lock; |
105 | v8::Locker lock; |
| 104 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
106 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 107 | v8::HandleScope handle_scope; |
|
| 105 | 108 | ||
| 106 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
109 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 107 | 110 | ||
| 108 | common::StringList available_nodes = control::Manager::Instance()->GetAvailableNodes(); |
111 | common::StringList available_nodes = control::Manager::Instance()->GetAvailableNodes(); |
| 109 | 112 | ||
| Line 112... | Line 115... | ||
| 112 | for (unsigned int n = 0; n < available_nodes.size(); n++) |
115 | for (unsigned int n = 0; n < available_nodes.size(); n++) |
| 113 | { |
116 | { |
| 114 | result->Set(n, v8::String::New(available_nodes[n].data())); |
117 | result->Set(n, v8::String::New(available_nodes[n].data())); |
| 115 | } |
118 | } |
| 116 | 119 | ||
| 117 | return result; |
120 | return handle_scope.Close(result); |
| 118 | } |
121 | } |
| 119 | 122 | ||
| 120 | Value Node::Export_ProgramNode(const v8::Arguments& args) |
123 | Value Node::Export_ProgramNode(const v8::Arguments& args) |
| 121 | { |
124 | { |
| 122 | v8::Locker lock; |
125 | v8::Locker lock; |
| 123 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
126 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 127 | v8::HandleScope handle_scope; |
|
| 124 | 128 | ||
| 125 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
129 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 126 | 130 | ||
| 127 | if (args.Length() < 3) |
131 | if (args.Length() < 3) |
| 128 | { |
132 | { |
| 129 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
133 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 130 | return v8 |
134 | return handle_scope.Close(v8::Boolean::New(false)); |
| 131 | } |
135 | } |
| 132 | 136 | ||
| 133 | v8::String::AsciiValue node_id(args[0]); |
137 | v8::String::AsciiValue node_id(args[0]); |
| 134 | v8::String::AsciiValue filename(args[2]); |
138 | v8::String::AsciiValue filename(args[2]); |
| 135 | 139 | ||
| 136 | return v8: |
140 | return handle_scope.Close(v8::Boolean::New(control::Manager::Instance()->ProgramNode(*node_id, args[1]->BooleanValue(), std::string(*filename)))); |
| 137 | } |
141 | } |
| 138 | 142 | ||
| 139 | Value Node::Export_GetNodeInformation(const v8::Arguments& args) |
143 | Value Node::Export_GetNodeInformation(const v8::Arguments& args) |
| 140 | { |
144 | { |
| 141 | v8::Locker lock; |
145 | v8::Locker lock; |
| 142 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
146 | v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext()); |
| - | 147 | v8::HandleScope handle_scope; |
|
| 143 | 148 | ||
| 144 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
149 | //LOG.Debug(std::string(__FUNCTION__) + " called!"); |
| 145 | 150 | ||
| 146 | if (args.Length() < 1) |
151 | if (args.Length() < 1) |
| 147 | { |
152 | { |
| 148 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
153 | LOG.Error(std::string(__FUNCTION__) + ": To few arguments."); |
| 149 | return v8 |
154 | return handle_scope.Close(v8::Boolean::New(false)); |
| 150 | } |
155 | } |
| 151 | 156 | ||
| 152 | v8::String::AsciiValue node_id(args[0]); |
157 | v8::String::AsciiValue node_id(args[0]); |
| 153 | 158 | ||
| 154 | control::Node::Information information; |
159 | control::Node::Information information; |
| Line 158... | Line 163... | ||
| 158 | information = control::Manager::Instance()->GetNodeInformation(*node_id); |
163 | information = control::Manager::Instance()->GetNodeInformation(*node_id); |
| 159 | } |
164 | } |
| 160 | catch (std::runtime_error& e) |
165 | catch (std::runtime_error& e) |
| 161 | { |
166 | { |
| 162 | LOG.Error(e.what()); |
167 | LOG.Error(e.what()); |
| 163 | return v8: |
168 | return handle_scope.Close(v8::Undefined()); |
| 164 | } |
169 | } |
| 165 | 170 | ||
| 166 | v8::Local<v8::Array> result = v8::Array::New(6); |
171 | v8::Local<v8::Array> result = v8::Array::New(6); |
| 167 | 172 | ||
| 168 | result->Set(v8::String::New("Id"), args[0]); |
173 | result->Set(v8::String::New("Id"), args[0]); |
| Line 170... | Line 175... | ||
| 170 | result->Set(v8::String::New("BiosVersion"), v8::Uint32::New(information.bios_version_)); |
175 | result->Set(v8::String::New("BiosVersion"), v8::Uint32::New(information.bios_version_)); |
| 171 | result->Set(v8::String::New("DeviceType"), v8::String::New(information.device_type_.data())); |
176 | result->Set(v8::String::New("DeviceType"), v8::String::New(information.device_type_.data())); |
| 172 | result->Set(v8::String::New("HasApplication"),v8::Boolean::New(information.has_application_)); |
177 | result->Set(v8::String::New("HasApplication"),v8::Boolean::New(information.has_application_)); |
| 173 | result->Set(v8::String::New("LastActive"), v8::Uint32::New(information.last_active_)); |
178 | result->Set(v8::String::New("LastActive"), v8::Uint32::New(information.last_active_)); |
| 174 | 179 | ||
| 175 | return result; |
180 | return handle_scope.Close(result); |
| 176 | } |
181 | } |
| 177 | 182 | ||
| 178 | }; // namespace plugin |
183 | }; // namespace plugin |
| 179 | }; // namespace vm |
184 | }; // namespace vm |
| 180 | }; // namespace atom |
185 | }; // namespace atom |