コード例 #1
0
static void
on_bus_acquired (GDBusConnection *connection,
                 const gchar     *name,
                 gpointer         user_data)
{
  PortalImplementation *implementation;
  g_autoptr(GError) error = NULL;

  xdp_connection_track_name_owners (connection);
  init_document_proxy (connection);
  init_permission_store (connection);

  export_portal_implementation (connection, network_monitor_create (connection));
  export_portal_implementation (connection, proxy_resolver_create (connection));

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.FileChooser");
  if (implementation != NULL)
    export_portal_implementation (connection,
                                  file_chooser_create (connection, implementation->dbus_name));

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.AppChooser");
  if (implementation != NULL)
    export_portal_implementation (connection,
                                  open_uri_create (connection, implementation->dbus_name));

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.Print");
  if (implementation != NULL)
    export_portal_implementation (connection,
                                  print_create (connection, implementation->dbus_name));

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.Screenshot");
  if (implementation != NULL)
    export_portal_implementation (connection,
                                  screenshot_create (connection, implementation->dbus_name));

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.Notification");
  if (implementation != NULL)
    export_portal_implementation (connection,
                                  notification_create (connection, implementation->dbus_name));

  implementation = find_portal_implementation ("org.freedesktop.impl.portal.Inhibit");
  if (implementation != NULL)
    export_portal_implementation (connection,
                                  inhibit_create (connection, implementation->dbus_name));
}
コード例 #2
0
ファイル: dbus.c プロジェクト: Toqozz/yarn-c
static void
onNotify(GDBusConnection *connection,
         const gchar *sender,
         GVariant *parameters,
         GDBusMethodInvocation *invocation)
{
    gchar *app_name = NULL;
    guint replaces_id = 0;
    gchar *app_icon = NULL;
    gchar *summary = NULL;
    gchar *body = NULL;
    gint  expire_timeout = -1;

    {
        GVariantIter *iter = g_variant_iter_new(parameters);
        GVariant *content;
        int i = 0;
        while ((content = g_variant_iter_next_value(iter)))
        {
            switch(i) 
            {
                case 0:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        app_name = g_variant_dup_string(content, NULL);
                    break;
                case 1:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_UINT32))
                        replaces_id = g_variant_get_uint32(content);
                    break;
                case 2:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        app_icon = g_variant_dup_string(content, NULL);
                    break;
                case 3:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        summary = g_variant_dup_string(content, NULL);
                    break;
                case 4:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_STRING))
                        body = g_variant_dup_string(content, NULL);
                    break;
                case 5:
                    break;
                case 6:
                    break;
                case 7:
                    if (g_variant_is_of_type(content, G_VARIANT_TYPE_INT32))
                        expire_timeout = g_variant_get_int32(content);
                    break;
            }
        g_variant_unref(content);
        i++;
        }
    g_variant_iter_free(iter);
    }

    Notification *n = notification_create (app_name,
                                           replaces_id,
                                           app_icon,
                                           summary,
                                           body,
                                           expire_timeout);
    n->app_name = app_name;
    n->replaces_id = replaces_id;
    n->app_icon = app_icon;
    n->summary = summary;
    n->body = body;
    n->expire_timeout = expire_timeout;

    int id = 1;
    GVariant *reply = g_variant_new("(u)", id);
    g_dbus_method_invocation_return_value(invocation, reply);
    g_dbus_connection_flush(connection, NULL, NULL, NULL);

    g_print("About to print the summary from yarn.c\n");

    prepare(n);
}