Example #1
0
static void
ask_password_cb (GMountOperation *op,
                 const char      *message,
                 const char      *default_user,
                 const char      *default_domain,
                 GAskPasswordFlags flags)
{
  char *s;
  g_print ("%s\n", message);

  if (flags & G_ASK_PASSWORD_NEED_USERNAME)
    {
      s = prompt_for ("User", default_user, TRUE);
      g_mount_operation_set_username (op, s);
      g_free (s);
    }

  if (flags & G_ASK_PASSWORD_NEED_DOMAIN)
    {
      s = prompt_for ("Domain", default_domain, TRUE);
      g_mount_operation_set_domain (op, s);
      g_free (s);
    }

  if (flags & G_ASK_PASSWORD_NEED_PASSWORD)
    {
      s = prompt_for ("Password", NULL, FALSE);
      g_mount_operation_set_password (op, s);
      g_free (s);
    }

  g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
}
Example #2
0
static VALUE
mountoperation_set_domain(VALUE self, VALUE value)
{
	g_mount_operation_set_domain(_SELF(self), RVAL2CSTR(value));

	return self;
}
Example #3
0
static void
pw_dialog_got_response (GtkDialog         *dialog,
                        gint               response_id,
                        GtkMountOperation *mount_op)
{
    GtkMountOperationPrivate *priv;
    GMountOperation *op;

    priv = mount_op->priv;
    op = G_MOUNT_OPERATION (mount_op);

    if (response_id == GTK_RESPONSE_OK)
    {
        const char *text;

        if (priv->ask_flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED)
            g_mount_operation_set_anonymous (op, priv->anonymous);

        if (priv->username_entry)
        {
            text = gtk_entry_get_text (GTK_ENTRY (priv->username_entry));
            g_mount_operation_set_username (op, text);
        }

        if (priv->domain_entry)
        {
            text = gtk_entry_get_text (GTK_ENTRY (priv->domain_entry));
            g_mount_operation_set_domain (op, text);
        }

        if (priv->password_entry)
        {
            text = gtk_entry_get_text (GTK_ENTRY (priv->password_entry));
            g_mount_operation_set_password (op, text);
        }

        if (priv->ask_flags & G_ASK_PASSWORD_SAVING_SUPPORTED)
            g_mount_operation_set_password_save (op, priv->password_save);

        g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
    }
    else
        g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);

    priv->dialog = NULL;
    g_object_notify (G_OBJECT (op), "is-showing");
    gtk_widget_destroy (GTK_WIDGET (dialog));
    g_object_unref (op);
}
Example #4
0
static void 
g_mount_operation_set_property (GObject      *object,
                                guint         prop_id,
                                const GValue *value,
                                GParamSpec   *pspec)
{
  GMountOperation *operation;

  operation = G_MOUNT_OPERATION (object);

  switch (prop_id)
    {
    case PROP_USERNAME:
      g_mount_operation_set_username (operation, 
                                      g_value_get_string (value));
      break;
   
    case PROP_PASSWORD:
      g_mount_operation_set_password (operation, 
                                      g_value_get_string (value));
      break;

    case PROP_ANONYMOUS:
      g_mount_operation_set_anonymous (operation, 
                                       g_value_get_boolean (value));
      break;

    case PROP_DOMAIN:
      g_mount_operation_set_domain (operation, 
                                    g_value_get_string (value));
      break;

    case PROP_PASSWORD_SAVE:
      g_mount_operation_set_password_save (operation, 
                                           g_value_get_enum (value));
      break;

    case PROP_CHOICE:
      g_mount_operation_set_choice (operation, 
                                    g_value_get_int (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Example #5
0
static void
ask_password_cb (GMountOperation *op,
                 const char      *message,
                 const char      *default_user,
                 const char      *default_domain,
                 GAskPasswordFlags flags)
{
  if ((flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED) && anonymous)
    {
      g_mount_operation_set_anonymous (op, TRUE);
    }
  else
    {
      char *s;
      g_print ("%s\n", message);

      if (flags & G_ASK_PASSWORD_NEED_USERNAME)
        {
          s = prompt_for ("User", default_user, TRUE);
          if (!s)
            goto error;
          g_mount_operation_set_username (op, s);
          g_free (s);
        }

      if (flags & G_ASK_PASSWORD_NEED_DOMAIN)
        {
          s = prompt_for ("Domain", default_domain, TRUE);
          if (!s)
            goto error;
          g_mount_operation_set_domain (op, s);
          g_free (s);
        }

      if (flags & G_ASK_PASSWORD_NEED_PASSWORD)
        {
          s = prompt_for ("Password", NULL, FALSE);
          if (!s)
            goto error;
          g_mount_operation_set_password (op, s);
          g_free (s);
        }
    }

  /* Only try anonymous access once. */
  if (anonymous &&
      GPOINTER_TO_INT (g_object_get_data (G_OBJECT (op), "state")) == MOUNT_OP_ASKED)
    {
      g_object_set_data (G_OBJECT (op), "state", GINT_TO_POINTER (MOUNT_OP_ABORTED));
      g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
    }
  else
    {
      g_object_set_data (G_OBJECT (op), "state", GINT_TO_POINTER (MOUNT_OP_ASKED));
      g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED);
    }

  return;

error:
  g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
}