From: Fábio M. <me...@pr...> - 2012-12-07 12:06:03
|
Hi all, I forgot to mention here, d-bus module is already working on elev8 and a simple connman gui was implemented by Ederson on easyui. Elev8 and easyUI are in proto repository. You will need elementary and EDBus installed to build the elev8. Since easyui is a javascript framework, once installed elev8, just go to the easyui directory and run easy-connman.js using elev8: 'elev8 easy-connman.js'. As expected you need connman running on your machine =P That's it. On Fri, Nov 30, 2012 at 10:02 PM, Carsten Haitzler <ra...@ra...>wrote: > On Fri, 30 Nov 2012 12:03:04 -0200 Gustavo Sverzut Barbieri > <bar...@pr...> said: > > you might actually finally make me happy :) god forbid that ever should > happen > > *grumble* *grumpy* *grrrr* > > :) > > > nice... now gimme econnman in JS with easyui :-) > > > > On Fri, Nov 30, 2012 at 11:30 AM, Enlightenment SVN > > <no-...@en...> wrote: > > > Log: > > > elev8: D-Bus: Implement client side support. > > > > > > Author: mello > > > Date: 2012-11-30 05:30:33 -0800 (Fri, 30 Nov 2012) > > > New Revision: 79896 > > > Trac: http://trac.enlightenment.org/e/changeset/79896 > > > > > > Added: > > > trunk/PROTO/elev8/data/javascript/dbus-client.js > > > trunk/PROTO/elev8/data/javascript/dbus-complex.js > > > trunk/PROTO/elev8/src/modules/dbus/Makefile.am Modified: > > > trunk/PROTO/elev8/configure.actrunk/PROTO/elev8/src/modules/Makefile.am > > > trunk/PROTO/elev8/src/modules/dbus/dbus-message.cc > > > trunk/PROTO/elev8/src/modules/dbus/dbus-message.h > > > trunk/PROTO/elev8/src/modules/dbus/dbus-module.h > > > trunk/PROTO/elev8/src/modules/dbus/dbus-object.cc > > > trunk/PROTO/elev8/src/modules/dbus/dbus-object.h > > > trunk/PROTO/elev8/src/modules/dbus/dbus-pending.cc > > > trunk/PROTO/elev8/src/modules/dbus/dbus-pending.h > > > trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.cc > > > trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.h > > > trunk/PROTO/elev8/src/modules/dbus/dbus.cc > > > > > > Modified: trunk/PROTO/elev8/configure.ac > > > =================================================================== > > > --- trunk/PROTO/elev8/configure.ac 2012-11-30 13:30:28 UTC (rev > 79895) > > > +++ trunk/PROTO/elev8/configure.ac 2012-11-30 13:30:33 UTC (rev > 79896) > > > @@ -113,7 +113,7 @@ > > > ecore-evas >= 1.0.999 > > > ]) > > > PKG_CHECK_MODULES([ECORECON], [ecore-con >= 1.0.999]) > > > - > > > +PKG_CHECK_MODULES([EDBUS], [edbus2]) > > > PKG_CHECK_MODULES([EIO], [eio]) > > > > > > dnl Check for libv8 and v8.h by linking a bit of code using v8 > > > @@ -154,6 +154,7 @@ > > > src/modules/http/Makefile > > > src/modules/elm/Makefile > > > src/modules/fs/Makefile > > > +src/modules/dbus/Makefile > > > data/Makefile > > > data/images/Makefile > > > data/desktop/Makefile > > > > > > Modified: trunk/PROTO/elev8/src/modules/Makefile.am > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/Makefile.am 2012-11-30 13:30:28 UTC > > > (rev 79895) +++ trunk/PROTO/elev8/src/modules/Makefile.am 2012-11-30 > > > 13:30:33 UTC (rev 79896) @@ -1,4 +1,4 @@ > > > AUTOMAKE_OPTIONS = 1.4 foreign > > > MAINTAINERCLEANFILES = Makefile.in > > > > > > -SUBDIRS = http elm fs > > > +SUBDIRS = http elm fs dbus > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-message.cc > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-message.cc 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-message.cc > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -3,7 +3,7 @@ > > > > > > namespace dbus { > > > > > > -static Persistent<FunctionTemplate> DMessage::base_template; > > > +Persistent<FunctionTemplate> DMessage::base_template; > > > > > > DMessage::~DMessage() > > > { > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-message.h > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-message.h 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-message.h > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -40,7 +40,7 @@ > > > static Handle<Value> NewSignal(const Arguments& args); > > > > > > EDBus_Message *msg; > > > - Persistent<FunctionTemplate> base_template; > > > + static Persistent<FunctionTemplate> base_template; > > > }; > > > > > > } > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-module.h > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-module.h 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-module.h > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -14,4 +14,10 @@ > > > #define THROW_EXCEPTION(msg) \ > > > return ThrowException(Exception::Error(String::New(msg))) > > > > > > +namespace dbus { > > > + > > > +extern int _log_domain; > > > + > > > +} > > > + > > > #endif > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-object.cc > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-object.cc 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-object.cc > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -1,4 +1,5 @@ > > > #include "dbus-connection.h" > > > +#include "dbus-message.h" > > > #include "dbus-object.h" > > > #include "dbus-proxy.h" > > > > > > @@ -69,15 +70,13 @@ > > > > > > Handle<Value> DObject::Send(const Arguments& args) > > > { > > > - if (!DMessage::IsMessage(args[0])) > > > - THROW_EXCEPTION("Expecting message"); > > > - if (!args[1]->IsFunction()) > > > - THROW_EXCEPTION("Expecting callback function"); > > > + if (!DMessage::IsMessage(args[0])) > > > + THROW_EXCEPTION("Expecting message"); > > > + if (!args[1]->IsFunction()) > > > + THROW_EXCEPTION("Expecting callback function"); > > > > > > - HandleScope scope; > > > - return scope.Close(External::Wrap(new WrappedProxyMessage(self, > > > - ObjectWrap::Unwrap<DMessage>(args[0]->ToObject()), > > > - args[1], args[2]))); > > > + HandleScope scope; > > > + return Undefined(); > > > } > > > > > > } > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-object.h > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-object.h 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-object.h > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -21,6 +21,7 @@ > > > > > > static Persistent<Function> constructor; > > > static Handle<Value> New(const Arguments& args); > > > + static Handle<Value> Send(const Arguments& args); > > > static Handle<Value> GetProxy(const Arguments& args); > > > > > > EDBus_Object *obj; > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-pending.cc > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-pending.cc 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-pending.cc > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -1,10 +1,11 @@ > > > #include "dbus-connection.h" > > > +#include "dbus-pending.h" > > > #include "dbus-object.h" > > > > > > namespace dbus { > > > > > > DPending::DPending(EDBus_Pending *pending_) > > > - : pending(pending_)) > > > + : pending(pending_) > > > { > > > } > > > > > > @@ -13,7 +14,7 @@ > > > edbus_pending_cancel(pending); > > > } > > > > > > -void DPending::Init(Handle<Object> target) > > > +void DPending::Init(Handle<Object>) > > > { > > > HandleScope scope; > > > > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-pending.h > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-pending.h 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-pending.h > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -1,5 +1,5 @@ > > > -#ifndef DBUS_CONNECTION_H > > > -#define DBUS_CONNECTION_H > > > +#ifndef DBUS_PENDING_H > > > +#define DBUS_PENDING_H > > > > > > #include "dbus-module.h" > > > > > > @@ -7,15 +7,16 @@ > > > > > > namespace dbus { > > > > > > -class DConnection : public ObjectWrap { > > > +class DPending : public ObjectWrap { > > > + EDBus_Pending *pending; > > > public: > > > static void Init(Handle<Object> target); > > > > > > EDBus_Connection *GetConnection() { return conn; } > > > > > > private: > > > - DConnection(EDBus_Connection_Type type); > > > - ~DConnection(); > > > + DPending(EDBus_Pending *pending_); > > > + ~DPending(); > > > > > > static Handle<Value> New(const Arguments& args); > > > static Handle<Value> GetObject(const Arguments& args); > > > @@ -25,4 +26,4 @@ > > > > > > } > > > > > > -#endif > > > \ No newline at end of file > > > +#endif > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.cc > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.cc 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.cc > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -1,4 +1,6 @@ > > > #include "dbus-connection.h" > > > +#include "dbus-message.h" > > > +#include "dbus-pending.h" > > > #include "dbus-object.h" > > > #include "dbus-proxy.h" > > > > > > @@ -6,14 +8,19 @@ > > > > > > Persistent<Function> DProxy::constructor; > > > > > > -DProxy::DProxy(DObject *obj, const char *iface) > > > - : proxy(edbus_proxy_get(obj->GetObject(), iface)) > > > +static Handle<Value> einaValueToValue(Eina_Value *value); > > > + > > > +DProxy::DProxy(DObject *_obj, const char *_iface) > > > + : proxy(edbus_proxy_get(_obj->GetObject(), _iface)) > > > { > > > + obj = _obj; > > > + iface = strdup(_iface); > > > } > > > > > > DProxy::~DProxy() > > > { > > > edbus_proxy_unref(proxy); > > > + free(iface); > > > } > > > > > > void DProxy::Init(Handle<Object>) > > > @@ -30,8 +37,6 @@ > > > FunctionTemplate::New(RemoveSignalHandler)->GetFunction()); > > > tpl->PrototypeTemplate()->Set(String::NewSymbol("call"), > > > FunctionTemplate::New(Call)->GetFunction()); > > > - tpl->PrototypeTemplate()->Set(String::NewSymbol("send"), > > > - FunctionTemplate::New(Send)->GetFunction()); > > > > > > constructor = Persistent<Function>::New(tpl->GetFunction()); > > > } > > > @@ -63,11 +68,47 @@ > > > return scope.Close(constructor->NewInstance(argc, argv)); > > > } > > > > > > -struct WrappedSignalHandler { > > > +struct WrappedMessage { > > > + static void Call(Handle<Function> callback, const EDBus_Message > *msg); > > > +}; > > > + > > > +void WrappedMessage::Call(Handle<Function> callback, const > EDBus_Message > > > *msg) +{ > > > + unsigned int argc = 0; > > > + Eina_Value *ev = NULL; > > > + Eina_Value_Struct st; > > > + const char *errname, *errmsg; > > > + > > > + if (edbus_message_error_get(msg, &errname, &errmsg)) > > > + { > > > + fprintf(stderr, "Error: %s %s\n", errname, errmsg); > > > + return; > > > + } > > > + > > > + if (strlen(edbus_message_signature_get(msg)) > 0) > > > + { > > > + ev = edbus_message_to_eina_value(msg); > > > + eina_value_pget(ev, &st); > > > + argc = st.desc->member_count; > > > + } > > > + > > > + Handle<Value> argv[argc]; > > > + > > > + for (unsigned int i = 0; i < argc; i++) > > > + { > > > + Eina_Value value; > > > + eina_value_struct_value_get(ev, st.desc->members[i].name, > &value); > > > + argv[i] = einaValueToValue(&value); > > > + } > > > + > > > + callback->Call(Context::GetCurrent()->Global(), argc, argv); > > > +} > > > + > > > +struct WrappedSignalHandler : WrappedMessage { > > > public: > > > WrappedSignalHandler(DProxy *proxy_, const char *signal_name_, > > > Handle<Value> cb_, Handle<Value> data_) > > > - : cb(cb_) > > > - , data(data_) > > > + : cb(Persistent<Value>::New(cb_)) > > > + , data(Persistent<Value>::New(data_)) > > > , sh(edbus_proxy_signal_handler_add(proxy_->GetProxy(), > > > signal_name_, > > > WrappedSignalHandler::Invoke, > > > @@ -76,25 +117,115 @@ > > > ~WrappedSignalHandler(); > > > > > > private: > > > - Handle<Value> cb; > > > - Handle<Value> data; > > > + Persistent<Value> cb; > > > + Persistent<Value> data; > > > EDBus_Signal_Handler *sh; > > > > > > static void Invoke(void *data, const EDBus_Message *msg); > > > }; > > > > > > -void WrappedSignalHandler::Invoke(void *data, const EDBus_Message *) > > > +static Handle<Value> einaValueToValue(Eina_Value *value) > > > { > > > - HandleScope scope; > > > - WrappedSignalHandler *self = static_cast<WrappedSignalHandler > *>(data); > > > - Handle<Function> callback(Function::Cast(*self->cb)); > > > + Handle<Value> val = Undefined(); > > > > > > - const unsigned argc = 2; > > > - /* FIXME: Convert msg to js */ > > > - Handle<Value> argv[argc] = { self->data, Undefined() }; > > > - callback->Call(Context::GetCurrent()->Global(), argc, argv); > > > + const Eina_Value_Type *type = eina_value_type_get(value); > > > + > > > + if (EINA_VALUE_TYPE_INT == type) > > > + { > > > + int i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_STRING == type) > > > + { > > > + const char *s; > > > + eina_value_get(value, &s); > > > + val = String::New(s); > > > + } > > > + else if (EINA_VALUE_TYPE_UCHAR == type) > > > + { > > > + unsigned char c; > > > + eina_value_get(value, &c); > > > + val = Number::New(c); > > > + } > > > + else if (EINA_VALUE_TYPE_SHORT == type) > > > + { > > > + short i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_USHORT == type) > > > + { > > > + unsigned short i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_UINT == type) > > > + { > > > + unsigned int i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_INT64 == type) > > > + { > > > + int64_t i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_UINT64 == type) > > > + { > > > + uint64_t i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_DOUBLE == type) > > > + { > > > + double i; > > > + eina_value_get(value, &i); > > > + val = Number::New(i); > > > + } > > > + else if (EINA_VALUE_TYPE_ARRAY == type) > > > + { > > > + unsigned int len = eina_value_array_count(value); > > > + val = Array::New(len); > > > + for (unsigned int i = 0; i < len; i++) > > > + { > > > + Eina_Value v; > > > + eina_value_array_value_get(value, i, &v); > > > + val->ToObject()->Set(i, einaValueToValue(&v)); > > > + } > > > + } > > > + else if (EINA_VALUE_TYPE_STRUCT == type) > > > + { > > > + Eina_Value_Struct st; > > > + eina_value_pget(value, &st); > > > + > > > + unsigned int len = st.desc->member_count; > > > + val = Array::New(len); > > > + > > > + for (unsigned int i = 0; i < len; i++) > > > + { > > > + Eina_Value v; > > > + eina_value_struct_value_get(value, > st.desc->members[i].name, > > > &v); > > > + val->ToObject()->Set(i, einaValueToValue(&v)); > > > + } > > > + } > > > + else > > > + { > > > + WRN("Unexpected Type."); > > > + } > > > + > > > + return val; > > > } > > > > > > +void WrappedSignalHandler::Invoke(void *data, const EDBus_Message > *msg) > > > +{ > > > + HandleScope scope; > > > + WrappedSignalHandler *self = static_cast<WrappedSignalHandler > *>(data); > > > + Handle<Function> callback(Function::Cast(*self->cb)); > > > + Call(callback, msg); > > > +} > > > + > > > WrappedSignalHandler::~WrappedSignalHandler() > > > { > > > edbus_signal_handler_unref(sh); > > > @@ -119,61 +250,166 @@ > > > delete static_cast<WrappedSignalHandler > *>(External::Unwrap(args[0])); > > > return Undefined(); > > > } > > > +struct WrappedCallMessage : WrappedMessage { > > > +public: > > > + WrappedCallMessage(Handle<Value> _callback) > > > + : cb(Persistent<Value>::New(_callback)) {} > > > + Persistent<Value> cb; > > > + static void Callback(void *data, const EDBus_Message *msg, > > > EDBus_Pending *pending); +}; > > > > > > -Handle<Value> DProxy::Call(const Arguments&) > > > +void WrappedCallMessage::Callback(void *data, const EDBus_Message > *msg, > > > EDBus_Pending *) { > > > - return Undefined(); > > > + HandleScope scope; > > > + WrappedCallMessage *self = static_cast<WrappedCallMessage *>(data); > > > + Handle<Function> callback(Function::Cast(*self->cb)); > > > + Call(callback, msg); > > > } > > > > > > -struct WrappedProxyMessage { > > > -public: > > > - WrappedProxyMessage(DProxy *proxy_, DMessage *msg_, Handle<Value> > cb_, > > > Handle<Value> data_) > > > - : cb(cb_) > > > - , data(data_) > > > - , pending(edbus_proxy_send(proxy_->GetProxy(), > > > - msg_->GetMessage(), > > > - WrappedProxyMessage::Invoke, > > > - this, > > > - -1)) {} > > > +static char getSigID(Handle<Value> val) > > > +{ > > > + char c = '?'; > > > + Local<Value> sig = > val->ToObject()->Get(String::NewSymbol("signature")); > > > > > > - ~WrappedProxyMessage(); > > > + if (!sig->IsUndefined()) > > > + { > > > + c = (*String::Utf8Value(sig))[0]; > > > + } > > > + else > > > + { > > > + if (val->IsBoolean()) > > > + c = 'b'; > > > + else if (val->IsNumber()) > > > + c = 'd'; > > > + else if (val->IsString()) > > > + c = 's'; > > > + else if (val->IsArray()) > > > + c = 'a'; > > > + else > > > + WRN("Unexpected type."); > > > + } > > > > > > -private: > > > - Handle<Value> cb; > > > - Handle<Value> data; > > > - EDBus_Pending *pending; > > > + return c; > > > +} > > > > > > - static void Invoke(void *data, const EDBus_Message *msg, > EDBus_Pending > > > *pending); -}; > > > +static Local<String> getSignature(Local<String> signature, > Handle<Value> > > > val) +{ > > > + if (val->IsUndefined()) > > > + return signature; > > > > > > -WrappedProxyMessage::~WrappedProxyMessage() > > > + const char sig[2] = { getSigID(val), '\0' }; > > > + > > > + if ('r' == sig[0]) > > > + { > > > + Local<Object> obj = val->ToObject(); > > > + Local<Array> props = obj->GetOwnPropertyNames(); > > > + unsigned int len = props->Length(); > > > + > > > + signature = String::Concat(signature, String::New("(")); > > > + for (unsigned int i = 0; i < len; i++) > > > + signature = getSignature(signature, > obj->Get(props->Get(i))); > > > + signature = String::Concat(signature, String::New(")")); > > > + } > > > + else > > > + { > > > + signature = String::Concat(signature, String::New(sig)); > > > + > > > + if (val->IsArray()) > > > + { > > > + Local<Value> v = val->ToObject()->Get(0); > > > + signature = getSignature(signature, v); > > > + } > > > + } > > > + > > > + return signature; > > > +} > > > + > > > +static Local<String> getSignature(Handle<Value> val) > > > { > > > - edbus_pending_unref(pending); > > > + return getSignature(String::New(""), val); > > > } > > > > > > -void WrappedProxyMessage::Invoke(void *data, const EDBus_Message *msg, > > > EDBus_Pending *) +static void append(EDBus_Message_Iter *iter, > > > Handle<Value> val) { > > > - HandleScope scope; > > > - WrappedProxyMessage *self = static_cast<WrappedProxyMessage > *>(data); > > > - Handle<Function> callback(Function::Cast(*self->cb)); > > > + if (val->IsUndefined()) > > > + return; > > > > > > - const unsigned argc = 2; > > > - /* FIXME: Convert msg to js */ > > > - Handle<Value> argv[argc] = { self->data, Undefined() }; > > > - callback->Call(Context::GetCurrent()->Global(), argc, argv); > > > + const char sig = getSigID(val); > > > + > > > + switch (sig) > > > + { > > > + default: > > > + edbus_message_iter_basic_append(iter, sig, *String::Utf8Value > > > (val)); > > > + break; > > > + case 'b': > > > + edbus_message_iter_basic_append(iter, sig, > val->BooleanValue()); > > > + break; > > > + case 'n': > > > + case 'i': > > > + case 'x': > > > + edbus_message_iter_basic_append(iter, sig, > val->Int32Value()); > > > + break; > > > + case 'y': > > > + case 'q': > > > + case 'u': > > > + case 't': > > > + edbus_message_iter_basic_append(iter, sig, > val->ToUint32()->Value > > > ()); > > > + break; > > > + case 'd': > > > + edbus_message_iter_basic_append(iter, sig, > val->NumberValue()); > > > + break; > > > + case 'v': > > > + case 'a': > > > + { > > > + Local<Object> obj = val->ToObject(); > > > + Local<Array> props = obj->GetOwnPropertyNames(); > > > + EDBus_Message_Iter *sub_iter = > > > edbus_message_iter_container_new > > > + (iter, sig, > &(*String::Utf8Value(getSignature(val)))[1]); > > > + > > > + for (unsigned int i = 0, len = props->Length(); i < len; > i++) > > > + append(sub_iter, obj->Get(props->Get(i))); > > > + > > > + edbus_message_iter_container_close(iter, sub_iter); > > > + break; > > > + } > > > + case 'r': > > > + { > > > + EDBus_Message_Iter *sub_iter; > > > + Local<Object> obj = val->ToObject(); > > > + Local<Array> props = obj->GetOwnPropertyNames(); > > > + > > > + edbus_message_iter_arguments_set > > > + (iter, *String::Utf8Value(getSignature(val)), > &sub_iter); > > > + > > > + for (unsigned int i = 0, len = props->Length(); i < > len; i++) > > > + append(sub_iter, obj->Get(props->Get(i))); > > > + > > > + edbus_message_iter_container_close(iter, sub_iter); > > > + break; > > > + } > > > + } > > > } > > > > > > -Handle<Value> DProxy::Send(const Arguments& args) > > > +Handle<Value> DProxy::Call(const Arguments& args) > > > { > > > - if (!DMessage::IsMessage(args[0])) > > > - THROW_EXCEPTION("Expecting message"); > > > - if (!args[1]->IsFunction()) > > > - THROW_EXCEPTION("Expecting callback function"); > > > + DProxy *self = ObjectWrap::Unwrap<DProxy>(args.This()); > > > > > > - HandleScope scope; > > > - return scope.Close(External::Wrap(new WrappedProxyMessage(self, > > > - ObjectWrap::Unwrap<DMessage>(args[0]->ToObject()), > > > - args[1], args[2]))); > > > + EDBus_Message *msg; > > > + EDBus_Message_Iter *iter; > > > + > > > + msg = edbus_proxy_method_call_new(self->proxy, > *String::Utf8Value(args > > > [0])); > > > + iter = edbus_message_iter_get(msg); > > > + > > > + unsigned int len = args.Length() - 1; > > > + > > > + for (unsigned int i = 1; i < len; i++) > > > + append(iter, args[i]); > > > + > > > + edbus_proxy_send(self->proxy, msg, WrappedCallMessage::Callback, > > > + new WrappedCallMessage(args[len]), -1); > > > + edbus_message_unref(msg); > > > + > > > + return Undefined(); > > > } > > > > > > } > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.h > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.h 2012-11-30 > 13:30:28 > > > UTC (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus-proxy.h > > > 2012-11-30 13:30:33 UTC (rev 79896) @@ -16,7 +16,7 @@ > > > EDBus_Proxy *GetProxy() { return proxy; } > > > > > > private: > > > - DProxy(DObject *obj, const char *iface); > > > + DProxy(DObject *_obj, const char *_iface); > > > ~DProxy(); > > > > > > static Persistent<Function> constructor; > > > @@ -25,9 +25,10 @@ > > > static Handle<Value> AddSignalHandler(const Arguments &args); > > > static Handle<Value> RemoveSignalHandler(const Arguments &args); > > > static Handle<Value> Call(const Arguments &args); > > > - static Handle<Value> Send(const Arguments &args); > > > > > > EDBus_Proxy *proxy; > > > + DObject *obj; > > > + char *iface; > > > }; > > > > > > } > > > > > > Modified: trunk/PROTO/elev8/src/modules/dbus/dbus.cc > > > =================================================================== > > > --- trunk/PROTO/elev8/src/modules/dbus/dbus.cc 2012-11-30 13:30:28 UTC > > > (rev 79895) +++ trunk/PROTO/elev8/src/modules/dbus/dbus.cc 2012-11-30 > > > 13:30:33 UTC (rev 79896) @@ -18,6 +18,83 @@ > > > > > > } > > > > > > +static Handle<Value> sigIt(Handle<Value> val, const char *sig) > > > +{ > > > + val->ToObject()->Set(String::NewSymbol("signature"), > String::New(sig), > > > DontEnum); > > > + return val; > > > +} > > > + > > > +static Handle<Value> DBoolean(const Arguments& args) > > > +{ > > > + return args[0]->ToBoolean(); > > > +} > > > + > > > +static Handle<Value> DByte(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->ToUint32()->Value()), "y"); > > > +} > > > + > > > +static Handle<Value> DInt16(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->Int32Value()), "n"); > > > +} > > > + > > > +static Handle<Value> DInt32(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->Int32Value()), "i"); > > > +} > > > + > > > +static Handle<Value> DInt64(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->Int32Value()), "x"); > > > +} > > > + > > > +static Handle<Value> DUint16(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->ToUint32()->Value()), "q"); > > > +} > > > + > > > +static Handle<Value> DUint32(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->ToUint32()->Value()), "u"); > > > +} > > > + > > > +static Handle<Value> DUint64(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->ToUint32()->Value()), "t"); > > > +} > > > + > > > +static Handle<Value> DDouble(const Arguments& args) > > > +{ > > > + return sigIt(NumberObject::New(args[0]->NumberValue()), "d"); > > > +} > > > + > > > +static Handle<Value> DString(const Arguments& args) > > > +{ > > > + return sigIt(StringObject::New(args[0]->ToString()), "s"); > > > +} > > > + > > > +static Handle<Value> DArray(const Arguments& args) > > > +{ > > > + unsigned int len = args.Length(); > > > + Handle<Array> array = Array::New(len); > > > + for (unsigned int i = 0; i < len; i++) > > > + array->Set(i, args[i]); > > > + return array; > > > +} > > > + > > > +static Handle<Value> DStruct(const Arguments& args) > > > +{ > > > + return sigIt(DArray(args), "r"); > > > +} > > > + > > > +static Handle<Value> DVariant(const Arguments& args) > > > +{ > > > + return sigIt(DArray(args), "v"); > > > +} > > > + > > > +extern "C" void RegisterModule(Handle<Object> target); > > > + > > > extern "C" > > > void RegisterModule(Handle<Object> target) > > > { > > > @@ -32,6 +109,21 @@ > > > ecore_init(); > > > edbus_init(); > > > > > > + target->Set(String::NewSymbol("Boolean"), FunctionTemplate::New > > > (DBoolean)->GetFunction()); > > > + target->Set(String::NewSymbol("Byte"), FunctionTemplate::New > > > (DByte)->GetFunction()); > > > + target->Set(String::NewSymbol("Int16"), FunctionTemplate::New > > > (DInt16)->GetFunction()); > > > + target->Set(String::NewSymbol("Int32"), FunctionTemplate::New > > > (DInt32)->GetFunction()); > > > + target->Set(String::NewSymbol("Int64"), FunctionTemplate::New > > > (DInt64)->GetFunction()); > > > + target->Set(String::NewSymbol("UInt16"), FunctionTemplate::New > > > (DUint16)->GetFunction()); > > > + target->Set(String::NewSymbol("UInt32"), FunctionTemplate::New > > > (DUint32)->GetFunction()); > > > + target->Set(String::NewSymbol("UInt64"), FunctionTemplate::New > > > (DUint64)->GetFunction()); > > > + target->Set(String::NewSymbol("Double"), FunctionTemplate::New > > > (DDouble)->GetFunction()); > > > + target->Set(String::NewSymbol("String"), FunctionTemplate::New > > > (DString)->GetFunction()); + > > > + target->Set(String::NewSymbol("Array"), FunctionTemplate::New > > > (DArray)->GetFunction()); > > > + target->Set(String::NewSymbol("Struct"), FunctionTemplate::New > > > (DStruct)->GetFunction()); > > > + target->Set(String::NewSymbol("Variant"), FunctionTemplate::New > > > (DVariant)->GetFunction()); + > > > dbus::DConnection::Init(target); > > > dbus::DObject::Init(target); > > > dbus::DProxy::Init(target); > > > > > > > > > > ------------------------------------------------------------------------------ > > > Keep yourself connected to Go Parallel: > > > TUNE You got it built. Now make it sing. Tune shows you how. > > > http://goparallel.sourceforge.net > > > _______________________________________________ > > > enlightenment-svn mailing list > > > enl...@li... > > > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > > > > > > > > -- > > Gustavo Sverzut Barbieri > > http://profusion.mobi embedded systems > > -------------------------------------- > > MSN: bar...@gm... > > Skype: gsbarbieri > > Mobile: +55 (19) 9225-2202 > > > > > ------------------------------------------------------------------------------ > > Keep yourself connected to Go Parallel: > > TUNE You got it built. Now make it sing. Tune shows you how. > > http://goparallel.sourceforge.net > > _______________________________________________ > > enlightenment-devel mailing list > > enl...@li... > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > > > > -- > ------------- Codito, ergo sum - "I code, therefore I am" -------------- > The Rasterman (Carsten Haitzler) ra...@ra... > > > > ------------------------------------------------------------------------------ > Keep yourself connected to Go Parallel: > INSIGHTS What's next for parallel hardware, programming and related areas? > Interviews and blogs by thought leaders keep you ahead of the curve. > http://goparallel.sourceforge.net > _______________________________________________ > enlightenment-devel mailing list > enl...@li... > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > |