static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg, void *data) { dbus_uint32_t status; DBG("status %d", sim_card_conn_status); if (sim_card_conn_status != SIM_CONNECTED) return g_dbus_create_error(msg, "org.bluez.Error.Failed", "Can't change msg size when not connected."); if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &status, DBUS_TYPE_INVALID)) return invalid_args(msg); if (status) { if (sim_card_conn_status == SIM_MISSING) { sim_card_conn_status = SIM_CONNECTED; sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_INSERTED); } } else { sim_card_conn_status = SIM_MISSING; sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED); } DBG("Card status changed to %d", status); return dbus_message_new_method_return(msg); }
void sap_connect_req(void *sap_device, uint16_t maxmsgsize) { DBG("status: %d", sim_card_conn_status); if (sim_card_conn_status != SIM_DISCONNECTED) { sap_connect_rsp(sap_device, SAP_STATUS_CONNECTION_FAILED); return; } if (max_msg_size_supported > maxmsgsize) { sap_connect_rsp(sap_device, SAP_STATUS_MAX_MSG_SIZE_TOO_SMALL); return; } if (max_msg_size_supported < maxmsgsize) { sap_connect_rsp(sap_device, SAP_STATUS_MAX_MSG_SIZE_NOT_SUPPORTED); return; } if (ongoing_call_status) { sap_connect_rsp(sap_device, SAP_STATUS_OK_ONGOING_CALL); return; } sim_card_conn_status = SIM_CONNECTED; sap_data = sap_device; sap_connect_rsp(sap_device, SAP_STATUS_OK); sap_status_ind(sap_device, SAP_STATUS_CHANGE_CARD_RESET); }
static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg, void *data) { sim_card_conn_status = SIM_DISCONNECTED; sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE); return dbus_message_new_method_return(msg); }
static DBusMessage *card_status(DBusConnection *conn, DBusMessage *msg, void *data) { dbus_uint32_t status; DBG("status %d", sim_card_conn_status); if (sim_card_conn_status != SIM_CONNECTED) return btd_error_failed(msg, "Can't change msg size when not connected."); if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &status, DBUS_TYPE_INVALID)) return btd_error_invalid_args(msg); switch (status) { case 0: /* card removed */ sim_card_conn_status = SIM_MISSING; sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_REMOVED); break; case 1: /* card inserted */ if (sim_card_conn_status == SIM_MISSING) { sim_card_conn_status = SIM_CONNECTED; sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_INSERTED); } break; case 2: /* card not longer available*/ sim_card_conn_status = SIM_POWERED_OFF; sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_NOT_ACCESSIBLE); break; default: return btd_error_failed(msg, "Unknown card status. Use 0, 1 or 2."); } DBG("Card status changed to %d", status); return dbus_message_new_method_return(msg); }
static DBusMessage *ongoing_call(DBusConnection *conn, DBusMessage *msg, void *data) { dbus_bool_t ongoing; if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_BOOLEAN, &ongoing, DBUS_TYPE_INVALID)) return btd_error_invalid_args(msg); if (ongoing_call_status && !ongoing) { /* An ongoing call has finished. Continue connection.*/ sap_status_ind(sap_data, SAP_STATUS_CHANGE_CARD_RESET); ongoing_call_status = FALSE; } else if (!ongoing_call_status && ongoing) { /* An ongoing call has started.*/ ongoing_call_status = TRUE; } DBG("OngoingCall status set to %d", ongoing_call_status); return dbus_message_new_method_return(msg); }
static void recv_status(uint32_t status) { sap_status_ind(u8500.sap_data, get_sap_status_change(status)); }