Commit 7f9d9933 authored by Mohammed Sadiq's avatar Mohammed Sadiq

application: Fix handling commandline arguments

handle_local_options() are supposed to be handled only in local instance,
and not in remote instance.
parent eda460ac
Pipeline #64801 failed with stages
in 18 minutes and 4 seconds
......@@ -67,58 +67,9 @@ struct _CallsApplication
G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION);
static gboolean start_proper (CallsApplication *self);
static gint
handle_local_options (GApplication *application,
GVariantDict *options)
{
gboolean ok;
g_autoptr (GError) error = NULL;
const gchar *arg;
g_debug ("Registering application");
ok = g_application_register (application, NULL, &error);
if (!ok)
{
g_error ("Error registering application: %s",
error->message);
}
ok = g_variant_dict_lookup (options, "provider", "&s", &arg);
if (ok)
{
g_action_group_activate_action (G_ACTION_GROUP (application),
"set-provider-name",
g_variant_new_string (arg));
}
else
{
g_action_group_activate_action (G_ACTION_GROUP (application),
"set-provider-name",
g_variant_new_string (DEFAULT_PROVIDER_PLUGIN));
}
ok = g_variant_dict_contains (options, "daemon");
if (ok)
{
g_action_group_activate_action (G_ACTION_GROUP (application),
"set-daemon",
NULL);
}
ok = g_variant_dict_lookup (options, "dial", "&s", &arg);
if (ok)
{
g_action_group_activate_action (G_ACTION_GROUP (application),
"dial",
g_variant_new_string (arg));
}
return -1; // Continue processing signal
}
char **uri_list = NULL;
static gboolean start_proper (CallsApplication *self);
static void
set_provider_name_action (GSimpleAction *action,
......@@ -328,6 +279,47 @@ startup (GApplication *application)
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
static int
calls_application_command_line (GApplication *application,
GApplicationCommandLine *command_line)
{
GVariantDict *options;
const char *arg;
options = g_application_command_line_get_options_dict (command_line);
if (!g_variant_dict_lookup (options, "provider", "&s", &arg))
arg = DEFAULT_PROVIDER_PLUGIN;
g_action_group_activate_action (G_ACTION_GROUP (application),
"set-provider-name",
g_variant_new_string (arg));
if (g_variant_dict_contains (options, "daemon"))
g_action_group_activate_action (G_ACTION_GROUP (application),
"set-daemon",
NULL);
if (g_variant_dict_lookup (options, "dial", "&s", &arg))
g_action_group_activate_action (G_ACTION_GROUP (application),
"dial",
g_variant_new_string (arg));
if (uri_list) {
g_autoptr(GPtrArray) files = NULL;
files = g_ptr_array_new_full (0, g_object_unref);
for (char **uri = uri_list; *uri; uri++)
g_ptr_array_add (files, g_file_new_for_commandline_arg (*uri));
g_application_open (application, (GFile **)files->pdata, files->len, "");
g_strfreev (uri_list);
}
g_application_activate (application);
return 0;
}
static void
notify_window_visible_cb (GtkWidget *window,
......@@ -511,8 +503,8 @@ calls_application_class_init (CallsApplicationClass *klass)
object_class->finalize = finalize;
application_class->handle_local_options = handle_local_options;
application_class->startup = startup;
application_class->command_line = calls_application_command_line;
application_class->activate = activate;
application_class->open = app_open;
......@@ -544,6 +536,12 @@ calls_application_init (CallsApplication *self)
_("Dial a number"),
_("NUMBER")
},
{
G_OPTION_REMAINING, 0, G_OPTION_FLAG_NONE,
G_OPTION_ARG_FILENAME_ARRAY, &uri_list,
_("tel:// URI"),
_("[URL…]")
},
{
NULL
}
......@@ -558,7 +556,7 @@ calls_application_new (void)
{
return g_object_new (CALLS_TYPE_APPLICATION,
"application-id", APP_ID,
"flags", G_APPLICATION_HANDLES_OPEN,
"flags", G_APPLICATION_HANDLES_OPEN | G_APPLICATION_HANDLES_COMMAND_LINE,
"register-session", TRUE,
NULL);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment