diff --git a/data/sm.puri.Calls.appdata.xml b/data/sm.puri.Calls.appdata.xml
index 15b77a2..4aa1bd1 100644
--- a/data/sm.puri.Calls.appdata.xml
+++ b/data/sm.puri.Calls.appdata.xml
@@ -22,6 +22,10 @@
Audio
+
+ x-scheme-handler/tel
+
+
none
none
diff --git a/data/sm.puri.Calls.desktop b/data/sm.puri.Calls.desktop
index 225bd0e..96fced5 100644
--- a/data/sm.puri.Calls.desktop
+++ b/data/sm.puri.Calls.desktop
@@ -7,8 +7,9 @@ Keywords=Telephone;Call;Phone;Dial;Dialer;PTSN;
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=sm.puri.Calls
TryExec=calls
-Exec=calls
+Exec=calls %u
Type=Application
StartupNotify=true
Terminal=false
Categories=GNOME;GTK;Telephony;
+MimeType=x-scheme-handler/tel
diff --git a/debian/control b/debian/control
index 621bc7e..19521fc 100644
--- a/debian/control
+++ b/debian/control
@@ -11,6 +11,7 @@ Build-Depends:
libgsound-dev,
libpeas-dev,
libgom-1.0-dev,
+ libebook-contacts1.2-dev,
meson,
pkg-config,
# to run the tests
diff --git a/sm.puri.Calls.json b/sm.puri.Calls.json
index a5a5e14..d713c20 100644
--- a/sm.puri.Calls.json
+++ b/sm.puri.Calls.json
@@ -3,6 +3,9 @@
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"sdk" : "org.gnome.Sdk",
+ "sdk-extensions" : [
+ "org.freedesktop.Sdk.Extension.openjdk11"
+ ],
"command" : "calls",
"finish-args" : [
"--share=ipc",
@@ -21,7 +24,10 @@
/* Doesn't matter what the name is, just need to call system-talk-name? */
"--system-talk-name=sm.puri.Calls",
- "--talk-name=org.freedesktop.ModemManager1"
+ "--talk-name=org.freedesktop.ModemManager1",
+
+ /* For openjdk */
+ "--env=PATH=/app/jre/bin:/usr/bin"
],
"build-options" : {
"cflags" : "-O2 -g",
@@ -84,6 +90,138 @@
"/bin"
]
},
+ {
+ "name": "boost",
+ "buildsystem": "simple",
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2",
+ "sha256": "2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba"
+ }
+ ],
+ "build-commands": [
+ "./bootstrap.sh --prefix=${FLATPAK_DEST} --with-libraries=date_time,thread,system",
+ "./b2 -j ${FLATPAK_BUILDER_N_JOBS} install"
+ ],
+ "cleanup": ["*"]
+ },
+ {
+ "name": "GTest",
+ "buildsystem": "cmake-ninja",
+ "cleanup": ["*"],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "http://archive.ubuntu.com/ubuntu/pool/universe/g/googletest/googletest_1.8.0.orig.tar.gz",
+ "md5": "16877098823401d1bf2ed7891d7dce36"
+ }
+ ]
+ },
+ {
+ "name": "protobuf",
+ "cleanup": [
+ "protoc",
+ "/bin",
+ "/doc",
+ "/lib/plugins"
+ ],
+ "sources": [
+ {
+ "type": "archive",
+ "url": "https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz",
+ "sha256": "b3732e471a9bb7950f090fd0457ebd2536a9ba0891b7f3785919c654fe2a2529"
+ }
+ ]
+ },
+ {
+ "name": "openjdk",
+ "buildsystem": "simple",
+ "build-commands": [
+ "/usr/lib/sdk/openjdk11/install.sh"
+ ]
+ },
+ {
+ "name" : "libphonenumber",
+ "buildsystem" : "cmake-ninja",
+ "sources" : [
+ {
+ "type" : "archive",
+ "url" : "https://github.com/google/libphonenumber/archive/v8.10.16.tar.gz",
+ "sha256" : "0cd9baf788dc7a7cca94ecbd43d0a562c4acf21f234d66d756574be89edf14c5"
+ },
+ {
+ "type" : "shell",
+ "commands" : [
+ "sed -i -e 's/\${\${NAME}_BIN}-NOTFOUND/\${NAME}_BIN-NOTFOUND/' cpp/CMakeLists.txt"
+ ]
+ }
+ ],
+ "subdir" : "cpp",
+ "build-options" : {
+ "append-path" : "/app/jre/bin"
+ }
+ },
+ {
+ "name" : "libical",
+ "cleanup" : [
+ "/lib/cmake"
+ ],
+ "buildsystem" : "cmake-ninja",
+ "config-opts" : [
+ "-DCMAKE_INSTALL_LIBDIR:PATH=/app/lib",
+ "-DBUILD_SHARED_LIBS=On",
+ "-DICAL_BUILD_DOCS=False",
+ "-DWITH_CXX_BINDINGS=False"
+ ],
+ "sources" : [
+ {
+ "type" : "archive",
+ "url" : "https://github.com/libical/libical/releases/download/v3.0.5/libical-3.0.5.tar.gz",
+ "sha256" : "7ad550c8c49c9b9983658e3ab3e68b1eee2439ec17b169a6b1e6ecb5274e78e6"
+ }
+ ]
+ },
+ {
+ "name" : "evolution-data-server",
+ "cleanup": [ "/share/GConf" ],
+ "buildsystem" : "cmake-ninja",
+ "config-opts" : [
+ "-DENABLE_PHONENUMBER=ON",
+ "-DENABLE_DOT_LOCKING=OFF",
+ "-DENABLE_FILE_LOCKING=fcntl",
+ "-DENABLE_GOA=OFF",
+ "-DENABLE_GTK=ON",
+ "-DENABLE_GOOGLE=OFF",
+ "-DENABLE_VALA_BINDINGS=OFF",
+ "-DENABLE_WEATHER=OFF",
+ "-DWITH_OPENLDAP=OFF",
+ "-DWITH_LIBDB=OFF",
+ "-DENABLE_INTROSPECTION=OFF",
+ "-DENABLE_INSTALLED_TESTS=OFF",
+ "-DENABLE_GTK_DOC=OFF",
+ "-DENABLE_EXAMPLES=OFF",
+ "-DWITH_PHONENUMBER:PATH=/"
+ ],
+ "sources" : [
+ {
+ "type" : "git",
+ "url" : "https://gitlab.gnome.org/GNOME/evolution-data-server.git"
+ }
+ ]
+ },
+ {
+ "name": "gom",
+ "buildsystem": "meson",
+ "config-opts": [ "-Denable-introspection=false" ],
+ "sources": [
+ {
+ "type": "git",
+ "url": "https://gitlab.gnome.org/GNOME/gom.git",
+ "commit": "320df01c77c5cf6327040421454837277e4d6ee3"
+ }
+ ]
+ },
{
"name" : "calls",
"buildsystem" : "meson",
diff --git a/src/calls-application.c b/src/calls-application.c
index 8337a35..281e02e 100644
--- a/src/calls-application.c
+++ b/src/calls-application.c
@@ -40,6 +40,7 @@
#include
#include
+#include
/**
* SECTION: calls-application
@@ -58,6 +59,8 @@ struct _CallsApplication
CallsProvider *provider;
CallsRinger *ringer;
CallsRecordStore *record_store;
+ CallsMainWindow *main_window;
+ CallsCallWindow *call_window;
};
G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION)
@@ -215,56 +218,133 @@ load_provider_plugin (CallsApplication *self)
}
+static gboolean
+start_proper (CallsApplication *self)
+{
+ GtkApplication *gtk_app;
+
+ if (self->main_window)
+ {
+ return TRUE;
+ }
+
+ gtk_app = GTK_APPLICATION (self);
+
+ // Later we will make provider loading/unloaded a dynamic
+ // process but that will have far-reaching consequences and is
+ // of no use immediately so for now, we just load one provider
+ // at startup. We can't put this in the actual startup() method
+ // though, because we need to be able to set the provider name
+ // from the command line and we use actions to do that, which
+ // depend on the application already being started up.
+ load_provider_plugin (self);
+ if (!self->provider)
+ {
+ g_application_quit (G_APPLICATION (self));
+ return FALSE;
+ }
+
+ self->ringer = calls_ringer_new (self->provider);
+ g_assert (self->ringer != NULL);
+
+ self->record_store = calls_record_store_new (self->provider);
+ g_assert (self->record_store != NULL);
+
+ self->main_window = calls_main_window_new
+ (gtk_app,
+ self->provider,
+ G_LIST_MODEL (self->record_store));
+ g_assert (self->main_window != NULL);
+
+ self->call_window = calls_call_window_new
+ (gtk_app, self->provider);
+ g_assert (self->call_window != NULL);
+
+ return TRUE;
+}
+
+
static void
activate (GApplication *application)
{
- GtkApplication *gtk_app;
- GtkWindow *window;
+ CallsApplication *self = CALLS_APPLICATION (application);
+ gboolean ok;
- g_assert (GTK_IS_APPLICATION (application));
- gtk_app = GTK_APPLICATION (application);
+ g_debug ("Activated");
- window = gtk_application_get_active_window (gtk_app);
-
- if (window == NULL)
+ ok = start_proper (self);
+ if (!ok)
{
- CallsApplication *self = CALLS_APPLICATION (application);
-
- // Later we will make provider loading/unloaded a dynamic
- // process but that will have far-reaching consequences and is
- // of no use immediately so for now, we just load one provider
- // at startup. We can't put this in the actual startup() method
- // though, because we need to be able to set the provider name
- // from the command line and we use actions to do that, which
- // depend on the application already being started up.
- if (!self->provider)
- {
- load_provider_plugin (self);
- if (!self->provider)
- {
- g_application_quit (application);
- return;
- }
-
- self->ringer = calls_ringer_new (self->provider);
- g_assert (self->ringer != NULL);
-
- self->record_store = calls_record_store_new (self->provider);
- g_assert (self->record_store != NULL);
- }
-
- /*
- * We don't track the memory created. Ideally, we might have to.
- * But we assume that the application is closed by closing the
- * window. In that case, GTK+ frees the resources right.
- */
- window = GTK_WINDOW
- (calls_main_window_new (gtk_app, self->provider,
- G_LIST_MODEL (self->record_store)));
- calls_call_window_new (gtk_app, self->provider);
+ return;
}
- gtk_window_present (window);
+ gtk_window_present (GTK_WINDOW (self->main_window));
+}
+
+
+static void
+open_tel_uri (CallsApplication *self,
+ const gchar *uri)
+{
+ EPhoneNumber *number;
+ GError *error = NULL;
+ gchar *dial_str;
+
+ g_debug ("Opening tel URI `%s'", uri);
+
+ number = e_phone_number_from_string (uri, NULL, &error);
+ if (!number)
+ {
+ g_warning ("Ignoring unparsable tel URI `%s': %s",
+ uri, error->message);
+ g_error_free (error);
+ return;
+ }
+
+ dial_str = e_phone_number_to_string
+ (number, E_PHONE_NUMBER_FORMAT_E164);
+ e_phone_number_free (number);
+
+ calls_main_window_dial (self->main_window,
+ dial_str);
+ g_free (dial_str);
+}
+
+
+static void
+app_open (GApplication *application,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ CallsApplication *self = CALLS_APPLICATION (application);
+ gint i;
+
+ g_assert (n_files > 0);
+
+ g_debug ("Opened (%i files)", n_files);
+
+ start_proper (self);
+
+ for (i = 0; i < n_files; ++i)
+ {
+ gchar *uri;
+ if (g_file_has_uri_scheme (files[i], "tel"))
+ {
+ uri = g_file_get_uri (files[i]);
+
+ open_tel_uri (self, uri);
+ }
+ else
+ {
+ uri = g_file_get_parse_name (files[i]);
+ g_warning ("Don't know how to"
+ " open file `%s', ignoring",
+ uri);
+ }
+
+ g_free (uri);
+ }
}
@@ -289,6 +369,8 @@ dispose (GObject *object)
{
CallsApplication *self = (CallsApplication *)object;
+ g_clear_object (&self->call_window);
+ g_clear_object (&self->main_window);
g_clear_object (&self->record_store);
g_clear_object (&self->ringer);
g_clear_object (&self->provider);
@@ -321,6 +403,7 @@ calls_application_class_init (CallsApplicationClass *klass)
application_class->handle_local_options = handle_local_options;
application_class->startup = startup;
application_class->activate = activate;
+ application_class->open = app_open;
g_type_ensure (CALLS_TYPE_ENCRYPTION_INDICATOR);
g_type_ensure (CALLS_TYPE_HISTORY_BOX);
@@ -359,6 +442,6 @@ calls_application_new (void)
{
return g_object_new (CALLS_TYPE_APPLICATION,
"application-id", APP_ID,
- "flags", G_APPLICATION_FLAGS_NONE,
+ "flags", G_APPLICATION_HANDLES_OPEN,
NULL);
}
diff --git a/src/calls-main-window.c b/src/calls-main-window.c
index 6121bc5..b4ea26b 100644
--- a/src/calls-main-window.c
+++ b/src/calls-main-window.c
@@ -403,3 +403,11 @@ calls_main_window_new (GtkApplication *application,
"record-store", record_store,
NULL);
}
+
+
+void
+calls_main_window_dial (CallsMainWindow *self,
+ const gchar *target)
+{
+ calls_new_call_box_dial (self->new_call, target);
+}
diff --git a/src/calls-main-window.h b/src/calls-main-window.h
index d40c06e..727e262 100644
--- a/src/calls-main-window.h
+++ b/src/calls-main-window.h
@@ -38,6 +38,8 @@ G_DECLARE_FINAL_TYPE (CallsMainWindow, calls_main_window, CALLS, MAIN_WINDOW, Gt
CallsMainWindow *calls_main_window_new (GtkApplication *application,
CallsProvider *provider,
GListModel *record_store);
+void calls_main_window_dial (CallsMainWindow *self,
+ const gchar *target);
G_END_DECLS
diff --git a/src/calls-new-call-box.c b/src/calls-new-call-box.c
index b073bc6..15e4ca1 100644
--- a/src/calls-new-call-box.c
+++ b/src/calls-new-call-box.c
@@ -39,6 +39,8 @@ struct _CallsNewCallBox
GtkSearchEntry *number_entry;
GtkButton *dial;
GtkLabel *status;
+
+ GList *dial_queue;
};
G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX);
@@ -58,6 +60,29 @@ enum {
};
+static CallsOrigin *
+get_origin (CallsNewCallBox *self)
+{
+ GtkTreeIter iter;
+ gboolean ok;
+ CallsOrigin *origin;
+
+ ok = gtk_combo_box_get_active_iter (self->origin_box, &iter);
+ if (!ok)
+ {
+ return NULL;
+ }
+
+ gtk_tree_model_get (GTK_TREE_MODEL (self->origin_store),
+ &iter,
+ ORIGIN_STORE_COLUMN_ORIGIN, &origin,
+ -1);
+ g_assert (CALLS_IS_ORIGIN (origin));
+
+ return origin;
+}
+
+
static void
dial_pad_symbol_clicked_cb (CallsNewCallBox *self,
gchar symbol,
@@ -102,6 +127,48 @@ notify_status_cb (CallsNewCallBox *self,
}
+static void
+dial_queued_cb (gchar *target,
+ CallsOrigin *origin)
+{
+ g_debug ("Dialing queued target `%s'", target);
+ calls_origin_dial (origin, target);
+}
+
+
+static void
+clear_dial_queue (CallsNewCallBox *self)
+{
+ g_list_free_full (self->dial_queue, g_free);
+ self->dial_queue = NULL;
+}
+
+
+static void
+dial_queued (CallsNewCallBox *self)
+{
+ CallsOrigin *origin;
+
+ if (!self->dial_queue)
+ {
+ return;
+ }
+
+ g_debug ("Dialing %u queued targets",
+ g_list_length (self->dial_queue));
+
+ origin = get_origin (self);
+ g_assert (origin != NULL);
+
+ g_list_foreach (self->dial_queue,
+ (GFunc)dial_queued_cb,
+ origin);
+ g_object_unref (origin);
+
+ clear_dial_queue (self);
+}
+
+
void
update_origin_box (CallsNewCallBox *self)
{
@@ -125,19 +192,22 @@ update_origin_box (CallsNewCallBox *self)
{
gtk_combo_box_set_active (self->origin_box, 0);
gtk_widget_hide (GTK_WIDGET (self->origin_box));
- return;
}
-
- /* We know there are multiple origins. */
-
- if (gtk_combo_box_get_active (self->origin_box) < 0)
+ else
{
- gtk_combo_box_set_active (self->origin_box, 0);
+ /* We know there are multiple origins. */
+
+ if (gtk_combo_box_get_active (self->origin_box) < 0)
+ {
+ gtk_combo_box_set_active (self->origin_box, 0);
+ }
+
+ /* We know there are multiple origins and one is selected. */
+
+ gtk_widget_show (GTK_WIDGET (self->origin_box));
}
- /* We know there are multiple origins and one is selected. */
-
- gtk_widget_show (GTK_WIDGET (self->origin_box));
+ dial_queued (self);
}
@@ -244,6 +314,8 @@ dispose (GObject *object)
GObjectClass *parent_class = g_type_class_peek (GTK_TYPE_BOX);
CallsNewCallBox *self = CALLS_NEW_CALL_BOX (object);
+ clear_dial_queue (self);
+
if (self->origin_store)
{
remove_origins (self);
@@ -293,28 +365,26 @@ calls_new_call_box_new (CallsProvider *provider)
NULL);
}
+
void
calls_new_call_box_dial (CallsNewCallBox *self,
const gchar *target)
{
- GtkTreeIter iter;
- gboolean ok;
CallsOrigin *origin;
g_return_if_fail (CALLS_IS_NEW_CALL_BOX (self));
g_return_if_fail (target != NULL);
- ok = gtk_combo_box_get_active_iter (self->origin_box, &iter);
- if (!ok)
+ origin = get_origin (self);
+ if (!origin)
{
- g_debug ("Can't submit call with no origin");
+ // Queue for dialing when an origin appears
+ g_debug ("Can't submit call with no origin, queuing for later");
+ self->dial_queue = g_list_append (self->dial_queue,
+ g_strdup (target));
return;
}
- gtk_tree_model_get (GTK_TREE_MODEL (self->origin_store), &iter,
- ORIGIN_STORE_COLUMN_ORIGIN, &origin,
- -1);
- g_assert (CALLS_IS_ORIGIN (origin));
-
calls_origin_dial (origin, target);
+ g_object_unref (origin);
}
diff --git a/src/meson.build b/src/meson.build
index e06b8f0..9216028 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -31,6 +31,7 @@ calls_deps = [ dependency('gobject-2.0'),
dependency('gsound'),
dependency('libpeas-1.0'),
dependency('gom-1.0'),
+ dependency('libebook-contacts-1.2'),
]
calls_sources = files(['calls-message-source.c', 'calls-message-source.h',