online-accounts: Fix parameter parsing
The Online Accounts panel supports two commands: 'add' and 'show-account'. The 'add' command must receive an additional parameter, the 'provider' name, and an optional 'preseed' parameter. In the past, Settings would just push all the parameters to a GVariant and pass to the panels. Now, however, it skips the first one, making the parameter parsing code in Online Accounts panel wrong. This patch fix that by refactoring add_account() code, and fixing the GVariant parameter parsing.
This commit is contained in:
parent
55c6f0e1b7
commit
a9bf8b5b04
1 changed files with 29 additions and 18 deletions
|
@ -233,22 +233,14 @@ show_non_branded_providers (CcGoaPanel *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_provider_row_activated (CcGoaPanel *self,
|
add_account (CcGoaPanel *self,
|
||||||
GtkListBoxRow *activated_row)
|
GoaProvider *provider,
|
||||||
|
GVariant *preseed)
|
||||||
{
|
{
|
||||||
GoaProvider *provider;
|
|
||||||
GoaObject *object;
|
GoaObject *object;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
/* Show More row */
|
|
||||||
if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
|
|
||||||
{
|
|
||||||
show_non_branded_providers (self);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
|
|
||||||
|
|
||||||
gtk_container_foreach (GTK_CONTAINER (self->new_account_vbox),
|
gtk_container_foreach (GTK_CONTAINER (self->new_account_vbox),
|
||||||
(GtkCallback) gtk_widget_destroy,
|
(GtkCallback) gtk_widget_destroy,
|
||||||
|
@ -269,12 +261,33 @@ on_provider_row_activated (CcGoaPanel *self,
|
||||||
GTK_BOX (self->new_account_vbox),
|
GTK_BOX (self->new_account_vbox),
|
||||||
&error);
|
&error);
|
||||||
|
|
||||||
|
if (preseed)
|
||||||
|
goa_provider_set_preseed_data (provider, preseed);
|
||||||
|
|
||||||
if (object == NULL)
|
if (object == NULL)
|
||||||
gtk_widget_hide (self->edit_account_dialog);
|
gtk_widget_hide (self->edit_account_dialog);
|
||||||
else
|
else
|
||||||
show_page_account (self, object);
|
show_page_account (self, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_provider_row_activated (CcGoaPanel *self,
|
||||||
|
GtkListBoxRow *activated_row)
|
||||||
|
{
|
||||||
|
GoaProvider *provider;
|
||||||
|
|
||||||
|
/* Show More row */
|
||||||
|
if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
|
||||||
|
{
|
||||||
|
show_non_branded_providers (self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
|
||||||
|
|
||||||
|
add_account (self, provider, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
@ -307,20 +320,16 @@ command_add (CcGoaPanel *panel,
|
||||||
|
|
||||||
switch (g_variant_n_children (parameters))
|
switch (g_variant_n_children (parameters))
|
||||||
{
|
{
|
||||||
case 4:
|
|
||||||
g_variant_get_child (parameters, 3, "v", &preseed);
|
|
||||||
case 3:
|
case 3:
|
||||||
g_variant_get_child (parameters, 2, "v", &v);
|
g_variant_get_child (parameters, 2, "v", &preseed);
|
||||||
|
case 2:
|
||||||
|
g_variant_get_child (parameters, 1, "v", &v);
|
||||||
if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
|
if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
|
||||||
provider_name = g_variant_get_string (v, NULL);
|
provider_name = g_variant_get_string (v, NULL);
|
||||||
else
|
else
|
||||||
g_warning ("Wrong type for the second argument (provider name) GVariant, expected 's' but got '%s'",
|
g_warning ("Wrong type for the second argument (provider name) GVariant, expected 's' but got '%s'",
|
||||||
(gchar *)g_variant_get_type (v));
|
(gchar *)g_variant_get_type (v));
|
||||||
g_variant_unref (v);
|
g_variant_unref (v);
|
||||||
case 2:
|
|
||||||
/* Nothing to see here, move along */
|
|
||||||
case 1:
|
|
||||||
/* No flag to handle here */
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_warning ("Unexpected parameters found, ignore request");
|
g_warning ("Unexpected parameters found, ignore request");
|
||||||
|
@ -335,6 +344,8 @@ command_add (CcGoaPanel *panel,
|
||||||
g_warning ("Unable to get a provider for type '%s'", provider_name);
|
g_warning ("Unable to get a provider for type '%s'", provider_name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_account (panel, provider, preseed);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue