Beispiel #1
0
/*!
  Returns the QCop channels for applications that offer
  \a service.

  \sa channel()
*/
QStringList QtopiaService::channels(const QString& service)
{
    QStringList r;
    QStringList rs = apps(service);
    for (QStringList::ConstIterator it = rs.begin(); it!=rs.end(); ++it)
        r.append( QString("QPE/Application/") + (*it).toLatin1() );
    return r;
}
Beispiel #2
0
/**
 * Destroy health applications
 */
static void destroy_health_applications()
{
	DBusGProxy *proxy;

	proxy = dbus_g_proxy_new_for_name(conn, "org.bluez",
					  "/org/bluez", "org.bluez.HealthManager");

	if (!proxy) {
		ERROR("BlueZ health manager service not found");
		return;
	}
	
	while (apps()->first) {
		GError *error = NULL;
		struct app_object *app = apps()->first->element;

		DEBUG("Destroying %s", app->path);

		if (!dbus_g_proxy_call(proxy, "DestroyApplication",
				       &error,
				       DBUS_TYPE_G_OBJECT_PATH, app->path,
				       G_TYPE_INVALID,
				       G_TYPE_INVALID)) {
			if (error) {
				ERROR("Can't call DestroyApplication: %s", error->message);
				g_error_free(error);
			} else {
				DEBUG("Can't call DestroyApplication, probably disconnected");
			}
		}

		llist_remove(apps(), app);
		g_free(app->path);
		g_free(app);
	}
	llist_destroy(apps(), NULL);
	_apps = NULL;
	g_object_unref(proxy);
}
Beispiel #3
0
    void Monitor::updateApplicationMap(const QString& path) {
        QDir apps(path); // "/usr/share/applications"
        QStringList filters;
        filters << "*.desktop";
        apps.setNameFilters(filters);

        const QStringList files = apps.entryList();
        QStringListIterator iterator(files);
        fAppNameMap.clear();
        while ( iterator.hasNext() ) {
            const QString& fileName = iterator.next();
            updateAppName(fileName);
        }
    }
Beispiel #4
0
CommsCommands::CommsCommands(LocalApplicationsStorage* applicationsStorage,
                             ApplicationRegistry* registry,
                             HeadServerConnection* headServerConnection,
                             DownloadableApplicationCache* downloadableApplicationCache,
                             PlayerSessionManager* playerSessions,
                             QObject *parent) :
    QObject(parent),
    _applicationRegistry(registry),
    _headServerConnection(headServerConnection),
    _downloadableApplicationCache(downloadableApplicationCache),
    _applicationsStorage(applicationsStorage),
    _playerSessions(playerSessions)
{
    QSharedPointer<LocalApplications> apps(new LocalApplications(_applicationsStorage));
    _iapps = (qSharedPointerCast<IApplications>(apps));
}
Beispiel #5
0
/**
 * Gets a HealthApplication path given a data type
 */
static const app_object *find_application_by_type(guint16 data_type)
{
	return (app_object *) llist_search_first(apps(), &data_type, cmp_data_type);
}
Beispiel #6
0
/**
 * Creates the HealthApplication's by calling BlueZ
 *
 * @param is_sink TRUE if data type is Sink role
 * @param data_type Specialization or data type 
 */
gboolean create_health_application(gboolean is_sink, guint16 data_type)
{
	/* Create HealthApplication */

	// Need to use non-GLib code here because GLib still does not have
	// the G_TYPE_UINT16 type.

	DBusMessage *msg, *reply;
	DBusError err;
	DBusMessageIter iter, array, entry, variant;
	guint16 value;
	const char *svalue;
	const char *key;
	char *app_path;
	app_object *app;

	msg = dbus_message_new_method_call("org.bluez", "/org/bluez",
					   "org.bluez.HealthManager", "CreateApplication");

	if (!msg) {
		DEBUG(" network:dbus Can't allocate new method call");
		return FALSE;
	}

	dbus_message_iter_init_append(msg, &iter);
	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &array);

	key = "DataType";
	value = data_type;
	dbus_message_iter_open_container(&array, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
	dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "q", &variant);
	dbus_message_iter_append_basic(&variant, DBUS_TYPE_UINT16, &value);
	dbus_message_iter_close_container(&entry, &variant);
	dbus_message_iter_close_container(&array, &entry);

	key = "Role";
	svalue = (is_sink ? "Sink" : "Source");
	dbus_message_iter_open_container(&array, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
	dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "s", &variant);
	dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &svalue);
	dbus_message_iter_close_container(&entry, &variant);
	dbus_message_iter_close_container(&array, &entry);

	key = "Description";
	svalue = "healthd";
	dbus_message_iter_open_container(&array, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
	dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
	dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, "s", &variant);
	dbus_message_iter_append_basic(&variant, DBUS_TYPE_STRING, &svalue);
	dbus_message_iter_close_container(&entry, &variant);
	dbus_message_iter_close_container(&array, &entry);

	dbus_message_iter_close_container(&iter, &array);

	dbus_error_init(&err);

	reply = dbus_connection_send_with_reply_and_block(
			dbus_g_connection_get_connection(conn),
			msg, -1, &err);

	dbus_message_unref(msg);

	if (!reply) {
		DEBUG(" network:dbus Can't create application");

		if (dbus_error_is_set(&err)) {
			ERROR("%s", err.message);
			dbus_error_free(&err);
		}

		return FALSE;
	}

	if (!dbus_message_get_args(reply, &err,
				   DBUS_TYPE_OBJECT_PATH, &app_path,
				   DBUS_TYPE_INVALID)) {
		DEBUG(" network:dbus Can't get reply arguments");

		if (dbus_error_is_set(&err)) {
			ERROR("%s", err.message);
			dbus_error_free(&err);
		}

		return FALSE;
	}

	app = g_new0(app_object, 1);
	app->path = g_strdup(app_path);
	app->data_type = data_type;
	app->is_sink = is_sink;

	llist_add(apps(), app);

	dbus_message_unref(reply);

	DEBUG("Created health application: %s", (char *) app->path);

	return TRUE;
}