static DBusMessage *gnss_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_gnss *gnss = data; const char *agent_path; if (gnss->pending) return __ofono_error_busy(msg); if (gnss->posr_agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); gnss->posr_agent = gnss_agent_new(agent_path, dbus_message_get_sender(msg)); if (gnss->posr_agent == NULL) return __ofono_error_failed(msg); gnss_agent_set_removed_notify(gnss->posr_agent, gnss_agent_notify, gnss); gnss->driver->set_position_reporting(gnss, TRUE, gnss_register_agent_cb, gnss); gnss->pending = dbus_message_ref(msg); return NULL; }
static DBusMessage *stk_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_stk *stk = data; const char *agent_path; if (stk->default_agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); stk->default_agent = stk_agent_new(agent_path, dbus_message_get_sender(msg), FALSE); if (!stk->default_agent) return __ofono_error_failed(msg); stk_agent_set_removed_notify(stk->default_agent, default_agent_notify, stk); if (!stk->session_agent) stk->current_agent = stk->default_agent; return dbus_message_new_method_return(msg); }
static DBusMessage *stk_select_item(DBusConnection *conn, DBusMessage *msg, void *data) { struct ofono_stk *stk = data; const char *agent_path; unsigned char selection, i; struct stk_envelope e; struct stk_menu *menu = stk->main_menu; if (stk->pending) return __ofono_error_busy(msg); if (stk->session_agent || !menu) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_BYTE, &selection, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); for (i = 0; i < selection && menu->items[i].text; i++); if (i != selection) return __ofono_error_invalid_format(msg); memset(&e, 0, sizeof(e)); e.type = STK_ENVELOPE_TYPE_MENU_SELECTION; e.src = STK_DEVICE_IDENTITY_TYPE_KEYPAD, e.menu_selection.item_id = menu->items[selection].item_id; e.menu_selection.help_request = FALSE; if (stk_send_envelope(stk, &e, menu_selection_envelope_cb, 0)) return __ofono_error_failed(msg); stk->pending = dbus_message_ref(msg); return NULL; }
static DBusMessage *push_notification_register_agent(DBusConnection *conn, DBusMessage *msg, void *data) { struct push_notification *pn = data; const char *agent_path; if (pn->agent) return __ofono_error_busy(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &agent_path, DBUS_TYPE_INVALID) == FALSE) return __ofono_error_invalid_args(msg); if (!__ofono_dbus_valid_object_path(agent_path)) return __ofono_error_invalid_format(msg); pn->agent = sms_agent_new(AGENT_INTERFACE, dbus_message_get_sender(msg), agent_path); if (pn->agent == NULL) return __ofono_error_failed(msg); sms_agent_set_removed_notify(pn->agent, agent_exited, pn); pn->push_watch[0] = __ofono_sms_datagram_watch_add(pn->sms, push_received, WAP_PUSH_DST_PORT, WAP_PUSH_SRC_PORT, pn, NULL); pn->push_watch[1] = __ofono_sms_datagram_watch_add(pn->sms, push_received, WAP_PUSH_DST_PORT, 0, pn, NULL); return dbus_message_new_method_return(msg); }
struct ofono_modem *ofono_modem_create(const char *name, const char *type) { struct ofono_modem *modem; char path[128]; DBG("name: %s, type: %s", name, type); if (strlen(type) > 16) return NULL; if (name && strlen(name) > 64) return NULL; if (name == NULL) snprintf(path, sizeof(path), "/%s_%d", type, next_modem_id); else snprintf(path, sizeof(path), "/%s", name); if (__ofono_dbus_valid_object_path(path) == FALSE) return NULL; modem = g_try_new0(struct ofono_modem, 1); if (modem == NULL) return modem; modem->path = g_strdup(path); modem->driver_type = g_strdup(type); modem->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, unregister_property); g_modem_list = g_slist_prepend(g_modem_list, modem); if (name == NULL) next_modem_id += 1; return modem; }