static gboolean
plugin_launch_extension_prefs (PluginObject *obj,
                               NPString      uuid,
                               NPVariant    *result)
{
  gchar *uuid_str;

  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
  if (!uuid_is_valid (uuid_str))
    {
      g_free (uuid_str);
      return FALSE;
    }

  g_dbus_proxy_call (obj->proxy,
                     "LaunchExtensionPrefs",
                     g_variant_new ("(s)", uuid_str),
                     G_DBUS_CALL_FLAGS_NONE,
                     -1, /* timeout */
                     NULL, /* cancellable */
                     NULL, /* callback */
                     NULL /* user_data */);

  g_free (uuid_str);
  return TRUE;
}
static gboolean
plugin_install_extension (PluginObject *obj,
                          NPString      uuid,
                          NPString      version_tag)
{
  gchar *uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
  gchar *version_tag_str;

  if (!uuid_is_valid (uuid_str))
    {
      g_free (uuid_str);
      return FALSE;
    }

  version_tag_str = g_strndup (version_tag.UTF8Characters,
                               version_tag.UTF8Length);

  g_dbus_proxy_call (obj->proxy,
                     "InstallRemoteExtension",
                     g_variant_new ("(ss)",
                                    uuid_str,
                                    version_tag_str),
                     G_DBUS_CALL_FLAGS_NONE,
                     -1, /* timeout */
                     NULL, /* cancellable */
                     NULL, /* callback */
                     NULL /* user_data */);

  g_free (uuid_str);
  g_free (version_tag_str);

  return TRUE;
}
static gboolean
plugin_get_errors (PluginObject *obj,
                   NPString      uuid,
                   NPVariant    *result)
{
  GError *error = NULL;
  GVariant *res;
  gchar *uuid_str;

  uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
  if (!uuid_is_valid (uuid_str))
    {
      g_free (uuid_str);
      return FALSE;
    }

  res = g_dbus_proxy_call_sync (obj->proxy,
                                "GetExtensionErrors",
                                g_variant_new ("(s)", uuid_str),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1, /* timeout */
                                NULL, /* cancellable */
                                &error);

  g_free (uuid_str);

  if (!res)
    {
      g_warning ("Failed to retrieve errors: %s", error->message);
      g_error_free (error);
      return FALSE;
    }

  return jsonify_variant (res, result);
}
static gboolean
plugin_enable_extension (PluginObject *obj,
                         NPString      uuid,
                         gboolean      enabled)
{
  gchar *uuid_str = g_strndup (uuid.UTF8Characters, uuid.UTF8Length);
  if (!uuid_is_valid (uuid_str))
    {
      g_free (uuid_str);
      return FALSE;
    }

  g_dbus_proxy_call (obj->proxy,
                     (enabled ? "EnableExtension" : "DisableExtension"),
                     g_variant_new ("(s)", uuid_str),
                     G_DBUS_CALL_FLAGS_NONE,
                     -1, /* timeout */
                     NULL, /* cancellable */
                     NULL, /* callback */
                     NULL /* user_data */);

  g_free (uuid_str);

  return TRUE;
}
Ejemplo n.º 5
0
Archivo: uuid.c Proyecto: oldzhu/linux
static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
{
    static const u8 si[16] = {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34};
    unsigned int i;

    if (!uuid_is_valid(uuid))
        return -EINVAL;

    for (i = 0; i < 16; i++) {
        int hi = hex_to_bin(uuid[si[i]] + 0);
        int lo = hex_to_bin(uuid[si[i]] + 1);

        b[ei[i]] = (hi << 4) | lo;
    }

    return 0;
}