static int _parse_route(RouteRef route) { char *actionorid,*next; char* url = route->_url; if (url[0]=='/') url++; route->_application = url; if ((route->_model = _tok(url)) == NULL) return 0; if ((actionorid = _tok(route->_model)) == NULL) return 1; next = _tok(actionorid); if (_isid(actionorid)) { route->_id = actionorid; route->_action = next; } else { route->_id = next; route->_action = actionorid; } _tok(next); return 1; }
static bool _GetRoute(char* url, RouteRef route) { char *actionorid,*next; memset(route, 0, sizeof(route[0])); if (url[0]=='/') url++; route->_application = url; if ((route->_model = _tok(url)) == NULL) return false; if ((actionorid = _tok(route->_model)) == NULL) return true; next = _tok(actionorid); if (_isid(actionorid)) { route->_id = actionorid; route->_action = next; } else { route->_id = next; route->_action = actionorid; } _tok(next); return true; }
static Eina_Bool _on_cmd_adapter_register_agent(__UNUSED__ char *cmd, char *args) { char *next_args, *path, *cap; E_Bluez_Element *element = _element_from_args(args, &next_args); if (!element) return ECORE_CALLBACK_RENEW; if (!next_args) { fputs("ERROR: missing parameters name, type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } path = next_args; cap = _tok(path); if (!cap) { fputs("ERROR: missing parameters name, type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } if (e_bluez_adapter_agent_register(element, path, cap, _method_success_check, "adapter_register_agent")) printf(":::Registering agent %s (%s)...\n", path, cap); else fprintf(stderr, "ERROR: can't register agent %s\n", path); return ECORE_CALLBACK_RENEW; }
static Eina_Bool _on_cmd_adapter_create_paired_device(__UNUSED__ char *cmd, char *args) { char *next_args, *path, *cap, *device; E_Bluez_Element *element = _element_from_args(args, &next_args); if (!element) return ECORE_CALLBACK_RENEW; if (!next_args) { fputs("ERROR: missing parameters name, type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } path = next_args; cap = _tok(path); if (!cap) { fputs("ERROR: missing parameters name, type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } device = _tok(cap); if (!device) { fputs("ERROR: missing parameters name, type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } if (e_bluez_adapter_create_paired_device(element, path, cap, device, _create_paired_device_cb, "adapter_create_paired_device")) { printf(":::Creating Paired Device %s (%s)...\n", path, cap); iface = e_dbus_interface_new("org.bluez.Agent"); if (!iface) { fputs("WARNING: Cannot add org.bluez.Agent interface",stderr); return EINA_FALSE; } _msgbus_data->obj = e_dbus_object_add(_msgbus_data->conn, path, NULL); e_dbus_object_interface_attach(_msgbus_data->obj, iface); e_dbus_interface_method_add(iface, "RequestPinCode", "o", "s", _request_pincode_cb); } else fprintf(stderr, "ERROR: can't create paired device %s\n", path); return ECORE_CALLBACK_RENEW; }
static E_Bluez_Element * _element_from_args(char *args, char **next_args) { E_Bluez_Element *element; if (!args) { fputs("ERROR: missing element path\n", stderr); *next_args = NULL; return NULL; } *next_args = _tok(args); element = e_bluez_element_get(args); if (!element) fprintf(stderr, "ERROR: no element called \"%s\".\n", args); return element; }
static Eina_Bool _on_cmd_property_set(__UNUSED__ char *cmd, char *args) { char *next_args, *name, *p; E_Bluez_Element *element = _element_from_args(args, &next_args); void *value; long vlong; unsigned short vu16; unsigned int vu32; int type; if (!element) return ECORE_CALLBACK_RENEW; if (!next_args) { fputs("ERROR: missing parameters name, type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } name = next_args; p = _tok(name); if (!p) { fputs("ERROR: missing parameters type and value.\n", stderr); return ECORE_CALLBACK_RENEW; } next_args = _tok(p); if (!next_args) { fputs("ERROR: missing parameter value.\n", stderr); return ECORE_CALLBACK_RENEW; } type = p[0]; switch (type) { case DBUS_TYPE_BOOLEAN: vlong = !!atol(next_args); value = &vlong; fprintf(stderr, "DBG: boolean is: %ld\n", vlong); break; case DBUS_TYPE_UINT16: vu16 = strtol(next_args, &p, 0); if (p == next_args) { fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args); return ECORE_CALLBACK_RENEW; } value = &vu16; fprintf(stderr, "DBG: u16 is: %hu\n", vu16); break; case DBUS_TYPE_UINT32: vu32 = strtol(next_args, &p, 0); if (p == next_args) { fprintf(stderr, "ERROR: invalid number \"%s\".\n", next_args); return ECORE_CALLBACK_RENEW; } value = &vu32; fprintf(stderr, "DBG: u16 is: %u\n", vu32); break; case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: p = next_args + strlen(next_args); if (p > next_args) p--; while (p > next_args && isspace(*p)) p--; if (p <= next_args) { fprintf(stderr, "ERROR: invalid string \"%s\".\n", next_args); } p[1] = '\0'; value = next_args; fprintf(stderr, "DBG: string is: \"%s\"\n", next_args); break; default: fprintf(stderr, "ERROR: don't know how to parse type '%c' (%d)\n", type, type); return ECORE_CALLBACK_RENEW; } fprintf(stderr, "set_property %s [%p] %s %c %p...\n", args, element, name, type, value); if (!e_bluez_element_property_set(element, name, type, value)) fputs("ERROR: error setting property.\n", stderr); return ECORE_CALLBACK_RENEW; }