Ejemplo n.º 1
0
static void sms_watch(struct ofono_atom *atom,
				enum ofono_atom_watch_condition cond,
				void *data)
{
	struct push_notification *pn = data;
	DBusConnection *conn = ofono_dbus_get_connection();

	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
		g_dbus_unregister_interface(conn,
					ofono_modem_get_path(pn->modem),
					PUSH_NOTIFICATION_INTERFACE);
		return;
	}

	DBG("registered");
	pn->sms = __ofono_atom_get_data(atom);

	if (!g_dbus_register_interface(conn, ofono_modem_get_path(pn->modem),
					PUSH_NOTIFICATION_INTERFACE,
					push_notification_methods, NULL, NULL,
					pn, push_notification_cleanup)) {
		ofono_error("Could not create %s interface",
				PUSH_NOTIFICATION_INTERFACE);

		return;
	}

	ofono_modem_add_interface(pn->modem, PUSH_NOTIFICATION_INTERFACE);
}
Ejemplo n.º 2
0
static void set_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ril_thermal_management *tm = user_data;
	struct ril_data *rd = ofono_modem_get_data(tm->modem);
	const char *path = ofono_modem_get_path(tm->modem);

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s RILD reply failure: %s",
			g_ril_request_id_to_string(rd->ril, message->req),
			ril_error_to_string(message->error));

		__ofono_dbus_pending_reply(&tm->pending,
					__ofono_error_failed(tm->pending));
		return;
	}

	/* Change the throttling state */
	tm->throttling = tm->throttling ? false : true;

	__ofono_dbus_pending_reply(&tm->pending,
				dbus_message_new_method_return(tm->pending));

	ofono_dbus_signal_property_changed(conn, path,
					THERMAL_MANAGEMENT_INTERFACE,
					"TransmitPowerThrottling",
					DBUS_TYPE_BOOLEAN,
					&tm->throttling);
}
Ejemplo n.º 3
0
static int ril_disable(struct ofono_modem *modem)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ril_data *rd = ofono_modem_get_data(modem);
	const char *path = ofono_modem_get_path(modem);
	struct parcel rilp;
	int cmd_id;
	char buf[4];

	DBG("%p", modem);

	if (g_dbus_unregister_interface(conn, path,
					THERMAL_MANAGEMENT_INTERFACE))
		ofono_modem_remove_interface(modem,
						THERMAL_MANAGEMENT_INTERFACE);

	/* RIL_OEM_HOOK_STRING_SET_MODEM_OFF = 0x000000CF */
	cmd_id = 0x000000CF;
	sprintf(buf, "%d", cmd_id);
	parcel_init(&rilp);
	parcel_w_int32(&rilp, 1);
	parcel_w_string(&rilp, buf);

	g_ril_append_print_buf(rd->ril, "{cmd_id=0x%02X}", cmd_id);

	g_ril_send(rd->ril, RIL_REQUEST_OEM_HOOK_STRINGS, &rilp,
					ril_send_power_off_cb, modem, NULL);

	return -EINPROGRESS;
}
Ejemplo n.º 4
0
static void modem_prop_changed_cb(const gchar *name, void *data)
{
	struct ofono_wan_data *od = data;
	const char *path = ofono_modem_get_path(od->modem);

	if (g_str_equal(name, "Interfaces")) {
		if (!od->cm && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_CONNECTION_MANAGER)) {
			od->cm = ofono_connection_manager_create(path);
			ofono_connection_manager_register_prop_changed_cb(od->cm, manager_property_changed_cb, od);
			ofono_connection_manager_register_contexts_changed_cb(od->cm, send_status_update_cb, od);
		}
		else if (od->cm && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_CONNECTION_MANAGER)) {
			ofono_connection_manager_free(od->cm);
			od->cm = NULL;
		}
		if (!od->netreg && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_NETWORK_REGISTRATION)) {
			od->netreg = ofono_network_registration_create(path);
			ofono_network_registration_register_prop_changed_handler(od->netreg, network_prop_changed_cb, od);
		}
		else if (od->netreg && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_NETWORK_REGISTRATION)) {
			ofono_network_registration_free(od->netreg);
			od->netreg = NULL;
			send_status_update_cb(od);
		}
	}
}
Ejemplo n.º 5
0
static DBusMessage *hfp_agent_release(DBusConnection *conn,
					DBusMessage *msg, void *data)
{
	struct ofono_modem *modem = data;
	struct hfp_data *hfp_data = ofono_modem_get_data(modem);
	const char *obj_path = ofono_modem_get_path(modem);

	g_dbus_unregister_interface(connection, obj_path, HFP_AGENT_INTERFACE);
	hfp_data->agent_registered = FALSE;

	g_hash_table_remove(modem_hash, hfp_data->handsfree_path);
	ofono_modem_remove(modem);

	return dbus_message_new_method_return(msg);
}
Ejemplo n.º 6
0
static void ril_remove(struct ofono_modem *modem)
{
	DBusConnection *conn = ofono_dbus_get_connection();
	struct ril_data *rd = ofono_modem_get_data(modem);
	const char *path = ofono_modem_get_path(modem);

	if (g_dbus_unregister_interface(conn, path,
					THERMAL_MANAGEMENT_INTERFACE))
		ofono_modem_remove_interface(modem,
						THERMAL_MANAGEMENT_INTERFACE);

	ofono_modem_set_data(modem, NULL);

	g_ril_unref(rd->ril);
	g_free(rd);
}
Ejemplo n.º 7
0
static void hfp_remove(struct ofono_modem *modem)
{
	struct hfp_data *data = ofono_modem_get_data(modem);
	const char *obj_path = ofono_modem_get_path(modem);

	if (data->call != NULL)
		dbus_pending_call_cancel(data->call);

	if (g_dbus_unregister_interface(connection, obj_path,
					HFP_AGENT_INTERFACE))
		hfp_unregister_ofono_handsfree(modem);

	g_free(data->handsfree_address);
	g_free(data->handsfree_path);
	g_free(data);

	ofono_modem_set_data(modem, NULL);
}
Ejemplo n.º 8
0
static int hfp_probe(struct ofono_modem *modem)
{
	const char *obj_path = ofono_modem_get_path(modem);
	struct hfp_data *data = ofono_modem_get_data(modem);

	if (data == NULL)
		return -EINVAL;

	g_dbus_register_interface(connection, obj_path, HFP_AGENT_INTERFACE,
			agent_methods, NULL, NULL, modem, NULL);

	data->agent_registered = TRUE;

	if (hfp_register_ofono_handsfree(modem) != 0)
		return -EINVAL;

	return 0;
}
Ejemplo n.º 9
0
static int hfp_unregister_ofono_handsfree(struct ofono_modem *modem)
{
	const char *obj_path = ofono_modem_get_path(modem);
	struct hfp_data *data = ofono_modem_get_data(modem);
	DBusMessage *msg;

	DBG("Unregistering oFono Agent from bluetooth daemon");

	msg = dbus_message_new_method_call(BLUEZ_SERVICE, data->handsfree_path,
				BLUEZ_GATEWAY_INTERFACE, "UnregisterAgent");
	if (msg == NULL)
		return -ENOMEM;

	dbus_message_append_args(msg, DBUS_TYPE_OBJECT_PATH, &obj_path,
				DBUS_TYPE_INVALID);

	g_dbus_send_message(connection, msg);
	return 0;
}
Ejemplo n.º 10
0
/*
 * Add or remove isimodems
 * when usbpn* phonet interfaces are added/removed
 */
static void usbpn_status_cb(GIsiModem *idx,
				GPhonetLinkState st,
				char const ifname[],
				void *data)
{
	struct ofono_modem *modem;
	int error;

	DBG("Phonet link %s (%u) is %s",
		ifname, g_isi_modem_index(idx),
		st == PN_LINK_REMOVED ? "removed" :
		st == PN_LINK_DOWN ? "down" : "up");

	/* Expect phonet interface name usbpn<idx> */
	if (strncmp(ifname, "usbpn", 5) ||
		ifname[5 + strspn(ifname + 5, "0123456789")])
		return;

	if (st == PN_LINK_REMOVED)
		return;

	if (g_pn_netlink_by_modem(idx)) {
		DBG("Modem for interface %s already exists", ifname);
		return;
	}

	error = g_pn_netlink_set_address(idx, PN_DEV_PC);
	if (error && error != -EEXIST) {
		DBG("g_pn_netlink_set_address: %s\n", strerror(-error));
		return;
	}

	modem = ofono_modem_create(NULL, "isimodem");
	if (!modem)
		return;

	ofono_modem_set_string(modem, "Interface", ifname);

	if (ofono_modem_register(modem) == 0)
		DBG("Done regging modem %s", ofono_modem_get_path(modem));
	else
		ofono_modem_remove(modem);
}
Ejemplo n.º 11
0
static void get_rf_power_status_cb(struct ril_msg *message, gpointer user_data)
{
	struct ofono_modem *modem = user_data;
	struct ril_data *rd = ofono_modem_get_data(modem);
	struct ril_thermal_management *tm;
	DBusConnection *conn = ofono_dbus_get_connection();
	struct parcel rilp;
	gint numstr;
	gchar *power_status;
	char *endptr;
	int enabled;
	const char *path = ofono_modem_get_path(modem);

	DBG("");

	if (message->error != RIL_E_SUCCESS) {
		ofono_error("%s RILD reply failure: %s",
			g_ril_request_id_to_string(rd->ril, message->req),
			ril_error_to_string(message->error));
		return;
	}

	g_ril_init_parcel(message, &rilp);

	numstr = parcel_r_int32(&rilp);
	if (numstr < 1) {
		ofono_error("RILD reply empty !");
		return;
	}

	power_status = parcel_r_string(&rilp);
	if (power_status == NULL || power_status == '\0')
		return;

	enabled = strtol(power_status, &endptr, 10);
	/*
	 * power_status == endptr => conversion error
	 * *endptr != '\0' => partial conversion
	 */
	if (power_status == endptr || *endptr != '\0')
		return;

	tm = g_try_new0(struct ril_thermal_management, 1);
	if (tm == NULL)
		return;

	tm->modem = modem;
	tm->throttling = (enabled > 0) ? true : false;


	if (!g_dbus_register_interface(conn, path, THERMAL_MANAGEMENT_INTERFACE,
					thermal_management_methods,
					thermal_management_signals,
					NULL, tm, thermal_management_cleanup)) {
		ofono_error("Could not register %s interface under %s",
					THERMAL_MANAGEMENT_INTERFACE, path);
		g_free(tm);
		return;
	}

	ofono_modem_add_interface(modem, THERMAL_MANAGEMENT_INTERFACE);
}
Ejemplo n.º 12
0
static void modem_prop_changed_cb(const gchar *name, void *data)
{
	struct ofono_data *od = data;
	bool powered = false, online = false;
	const char *path = ofono_modem_get_path(od->modem);

	if (g_str_equal(name, "Online")) {
		online = ofono_modem_get_online(od->modem);
		telephony_service_power_status_notify(od->service, online);
	}
	else if (g_str_equal(name, "Interfaces")) {
		if (!od->sim && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_SIM_MANAGER)) {
			od->sim = ofono_sim_manager_create(path);
			ofono_sim_manager_register_prop_changed_handler(od->sim, sim_prop_changed_cb, od);
		}
		else if (od->sim && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_SIM_MANAGER)) {
			ofono_sim_manager_free(od->sim);
			od->sim = NULL;
		}

		if (!od->netreg && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_NETWORK_REGISTRATION)) {
			od->netreg = ofono_network_registration_create(path);
			ofono_network_registration_register_prop_changed_handler(od->netreg, network_prop_changed_cb, od);
		}
		else if (od->netreg && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_NETWORK_REGISTRATION)) {
			ofono_network_registration_free(od->netreg);
			od->netreg = NULL;
			notify_no_network_registration(od->service);
		}

		if (!od->rs && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_RADIO_SETTINGS)) {
			od->rs = ofono_radio_settings_create(path);
		}
		else if (od->rs && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_RADIO_SETTINGS)) {
			ofono_radio_settings_free(od->rs);
			od->rs = NULL;
		}

		if (!od->vm && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_VOICE_CALL_MANAGER)) {
			od->vm = ofono_voicecall_manager_create(path);
		}
		else if (od->vm && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_VOICE_CALL_MANAGER)) {
			ofono_voicecall_manager_free(od->vm);
			od->vm = NULL;
		}

		if (!od->mm && ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_MESSAGE_MANAGER)) {
			od->mm = ofono_message_manager_create(path);
			ofono_message_manager_set_incoming_message_callback(od->mm, incoming_message_cb, od);
		}
		else if (od->mm && !ofono_modem_is_interface_supported(od->modem, OFONO_MODEM_INTERFACE_MESSAGE_MANAGER)) {
			ofono_message_manager_free(od->mm);
			od->mm = NULL;
		}
	}
	else if (g_str_equal(name, "Powered")) {
		powered = ofono_modem_get_powered(od->modem);
		/* We need to handle power status changes differently when in initialization phase */
		if (od->initializing && powered) {
			telephony_service_availability_changed_notify(od->service, true);
			od->initializing = false;
		}

		telephony_service_power_status_notify(od->service, powered);
	}
}