Commit 78e8d7f0 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

Move the search provider to its own binary

https://bugzilla.gnome.org/show_bug.cgi?id=711409
parent 83affc44
......@@ -40,7 +40,7 @@ service_DATA = $(service_in_files:.service.in=.service)
# Rule to make the service file with bindir expanded
$(service_DATA): $(service_in_files) Makefile
@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
# Default bookmarks
# We don't put translations in the resulting rdf since the code can get
......
[Shell Search Provider]
DesktopId=epiphany.desktop
BusName=org.gnome.Epiphany
ObjectPath=/org/gnome/Epiphany
BusName=org.gnome.EpiphanySearchProvider
ObjectPath=/org/gnome/EpiphanySearchProvider
Version=2
[D-BUS Service]
Name=org.gnome.Epiphany
Exec=@bindir@/epiphany --headless-mode
Name=org.gnome.EpiphanySearchProvider
Exec=@libexecdir@/epiphany-search-provider
......@@ -44,7 +44,6 @@ INST_H_FILES = \
$(NULL)
libephymain_la_SOURCES = \
$(dbus_shell_search_provider_built_sources) \
ephy-action-helper.c \
ephy-completion-model.c \
ephy-completion-model.h \
......@@ -60,7 +59,6 @@ libephymain_la_SOURCES = \
ephy-navigation-history-action.c \
ephy-notebook.c \
ephy-page-menu-action.c \
ephy-search-provider.c \
ephy-session.c \
ephy-shell.c \
ephy-toolbar.c \
......@@ -165,6 +163,34 @@ epiphany_LDADD = \
$(CODE_COVERAGE_LDFLAGS) \
$(LIBINTL)
libexec_PROGRAMS = epiphany-search-provider
epiphany_search_provider_SOURCES = \
$(dbus_shell_search_provider_built_sources) \
ephy-search-provider.c \
ephy-search-provider-main.c
epiphany_search_provider_CPPFLAGS = \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/history \
-I$(top_srcdir)/src/bookmarks \
-DDATADIR=\""$(datadir)"\" \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
$(INCINTL) \
$(AM_CPPFLAGS)
epiphany_search_provider_CFLAGS = $(epiphany_CFLAGS)
epiphany_search_provider_LDADD = \
libephymain.la \
$(top_builddir)/src/bookmarks/libephybookmarks.la \
$(top_builddir)/lib/history/libephyhistory.la \
$(top_builddir)/lib/libephymisc.la \
$(DEPENDENCIES_LIBS) \
$(CODE_COVERAGE_LDFLAGS) \
$(LIBINTL)
TYPES_SOURCE = \
ephy-type-builtins.c \
ephy-type-builtins.h
......
/*
* Copyright (c) 2013 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with the Control Center; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "config.h"
#include "ephy-search-provider.h"
#include "ephy-file-helpers.h"
gint main (gint argc, gchar** argv)
{
EphySearchProvider *search_provider;
int status;
GError *error = NULL;
if (!ephy_file_helpers_init (NULL, 0, &error)) {
g_printerr ("%s\n", error->message);
g_error_free (error);
return 1;
}
search_provider = ephy_search_provider_new ();
status = g_application_run (G_APPLICATION (search_provider), argc, argv);
g_object_unref (search_provider);
ephy_file_helpers_shutdown ();
return status;
}
......@@ -21,39 +21,36 @@
#include "ephy-search-provider.h"
#include "ephy-bookmarks.h"
#include "ephy-completion-model.h"
#include "ephy-file-helpers.h"
#include "ephy-history-service.h"
#include "ephy-prefs.h"
#include "ephy-profile-utils.h"
#include "ephy-shell.h"
#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libsoup/soup.h>
struct _EphySearchProvider
{
GObject parent;
GApplication parent;
EphyShellSearchProvider2 *skeleton;
GCancellable *cancellable;
GSettings *settings;
EphyHistoryService *history_service;
EphyBookmarks *bookmarks;
EphyCompletionModel *model;
};
struct _EphySearchProviderClass
{
GObjectClass parent_class;
GApplicationClass parent_class;
};
G_DEFINE_TYPE (EphySearchProvider, ephy_search_provider, G_TYPE_OBJECT);
G_DEFINE_TYPE (EphySearchProvider, ephy_search_provider, G_TYPE_APPLICATION)
static void
on_model_updated (EphyHistoryService *service,
......@@ -139,7 +136,7 @@ complete_request (GObject *object,
g_dbus_method_invocation_take_error (user_data, error);
}
g_application_release (G_APPLICATION (ephy_shell_get_default ()));
g_application_release (G_APPLICATION (self));
}
static gboolean
......@@ -148,7 +145,7 @@ handle_get_initial_result_set (EphyShellSearchProvider2 *skeleton,
char **terms,
EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
g_application_hold (G_APPLICATION (self));
g_cancellable_reset (self->cancellable);
gather_results_async (self, terms, self->cancellable,
......@@ -164,7 +161,7 @@ handle_get_subsearch_result_set (EphyShellSearchProvider2 *skeleton,
char **terms,
EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
g_application_hold (G_APPLICATION (self));
g_cancellable_reset (self->cancellable);
gather_results_async (self, terms, self->cancellable,
......@@ -187,7 +184,7 @@ handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
char *name, *url;
gboolean is_bookmark;
g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
g_application_hold (G_APPLICATION (self));
g_cancellable_cancel (self->cancellable);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
......@@ -258,7 +255,7 @@ handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
invocation,
g_variant_builder_end (&builder));
g_application_release (G_APPLICATION (ephy_shell_get_default ()));
g_application_release (G_APPLICATION (self));
return TRUE;
}
......@@ -267,12 +264,12 @@ static void
launch_uri (const char *uri,
guint timestamp)
{
const char *uris[2];
char *str;
uris[0] = uri;
uris[1] = NULL;
ephy_shell_open_uris (ephy_shell_get_default (), uris, 0, timestamp);
/* TODO: Handle the timestamp */
str = g_strdup_printf ("epiphany %s", uri);
g_spawn_command_line_async (str, NULL);
g_free (str);
}
static void
......@@ -311,7 +308,7 @@ handle_activate_result (EphyShellSearchProvider2 *skeleton,
guint timestamp,
EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
g_application_hold (G_APPLICATION (self));
g_cancellable_cancel (self->cancellable);
if (strcmp (identifier, "special:search") == 0)
......@@ -320,7 +317,7 @@ handle_activate_result (EphyShellSearchProvider2 *skeleton,
launch_uri (identifier, timestamp);
ephy_shell_search_provider2_complete_activate_result (skeleton, invocation);
g_application_release (G_APPLICATION (ephy_shell_get_default ()));
g_application_release (G_APPLICATION (self));
return TRUE;
}
......@@ -332,13 +329,13 @@ handle_launch_search (EphyShellSearchProvider2 *skeleton,
guint timestamp,
EphySearchProvider *self)
{
g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
g_application_hold (G_APPLICATION (self));
g_cancellable_cancel (self->cancellable);
launch_search (self, terms, timestamp);
ephy_shell_search_provider2_complete_launch_search (skeleton, invocation);
g_application_release (G_APPLICATION (ephy_shell_get_default ()));
g_application_release (G_APPLICATION (self));
return TRUE;
}
......@@ -346,6 +343,10 @@ handle_launch_search (EphyShellSearchProvider2 *skeleton,
static void
ephy_search_provider_init (EphySearchProvider *self)
{
char *filename;
g_application_set_flags (G_APPLICATION (self), G_APPLICATION_IS_SERVICE);
self->skeleton = ephy_shell_search_provider2_skeleton_new ();
g_signal_connect (self->skeleton, "handle-get-initial-result-set",
......@@ -361,35 +362,54 @@ ephy_search_provider_init (EphySearchProvider *self)
self->settings = g_settings_new (EPHY_PREFS_SCHEMA);
self->model = ephy_completion_model_new (EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ())),
ephy_shell_get_bookmarks (ephy_shell_get_default ()));
filename = g_build_filename (ephy_dot_dir (), EPHY_HISTORY_FILE, NULL);
self->history_service = ephy_history_service_new (filename, TRUE);
self->bookmarks = ephy_bookmarks_new ();
self->model = ephy_completion_model_new (self->history_service, self->bookmarks);
g_free (filename);
self->cancellable = g_cancellable_new ();
}
gboolean
ephy_search_provider_dbus_register (EphySearchProvider *self,
GDBusConnection *connection,
const gchar *object_path,
GError **error)
static gboolean
ephy_search_provider_dbus_register (GApplication *application,
GDBusConnection *connection,
const gchar *object_path,
GError **error)
{
EphySearchProvider *self;
GDBusInterfaceSkeleton *skeleton;
if (!G_APPLICATION_CLASS (ephy_search_provider_parent_class)->dbus_register (application,
connection,
object_path,
error))
return FALSE;
self = EPHY_SEARCH_PROVIDER (application);
skeleton = G_DBUS_INTERFACE_SKELETON (self->skeleton);
return g_dbus_interface_skeleton_export (skeleton, connection, object_path, error);
}
void
ephy_search_provider_dbus_unregister (EphySearchProvider *self,
GDBusConnection *connection,
const gchar *object_path)
static void
ephy_search_provider_dbus_unregister (GApplication *application,
GDBusConnection *connection,
const gchar *object_path)
{
EphySearchProvider *self;
GDBusInterfaceSkeleton *skeleton;
self = EPHY_SEARCH_PROVIDER (application);
skeleton = G_DBUS_INTERFACE_SKELETON (self->skeleton);
if (g_dbus_interface_skeleton_has_connection (skeleton, connection))
g_dbus_interface_skeleton_unexport_from_connection (skeleton, connection);
g_dbus_interface_skeleton_unexport_from_connection (skeleton, connection);
g_clear_object (&self->skeleton);
G_APPLICATION_CLASS (ephy_search_provider_parent_class)->dbus_unregister (application,
connection,
object_path);
}
static void
......@@ -399,10 +419,11 @@ ephy_search_provider_dispose (GObject *object)
self = EPHY_SEARCH_PROVIDER (object);
g_clear_object (&self->skeleton);
g_clear_object (&self->settings);
g_clear_object (&self->cancellable);
g_clear_object (&self->model);
g_clear_object (&self->history_service);
g_clear_object (&self->bookmarks);
G_OBJECT_CLASS (ephy_search_provider_parent_class)->dispose (object);
}
......@@ -411,13 +432,19 @@ static void
ephy_search_provider_class_init (EphySearchProviderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
object_class->dispose = ephy_search_provider_dispose;
application_class->dbus_register = ephy_search_provider_dbus_register;
application_class->dbus_unregister = ephy_search_provider_dbus_unregister;
}
EphySearchProvider *
ephy_search_provider_new (void)
{
return g_object_new (EPHY_TYPE_SEARCH_PROVIDER, NULL);
return g_object_new (EPHY_TYPE_SEARCH_PROVIDER,
"application-id", "org.gnome.EpiphanySearchProvider",
NULL);
}
......@@ -42,14 +42,6 @@ GType ephy_search_provider_get_type (void) G_GNUC_CONST;
EphySearchProvider *ephy_search_provider_new (void);
gboolean ephy_search_provider_dbus_register (EphySearchProvider *provider,
GDBusConnection *connection,
const char *object_path,
GError **error);
void ephy_search_provider_dbus_unregister (EphySearchProvider *provider,
GDBusConnection *connection,
const char *object_path);
G_END_DECLS
#endif /* _EPHY_SEARCH_PROVIDER_H */
......@@ -35,7 +35,6 @@
#include "ephy-lockdown.h"
#include "ephy-prefs.h"
#include "ephy-private.h"
#include "ephy-search-provider.h"
#include "ephy-session.h"
#include "ephy-settings.h"
#include "ephy-type-builtins.h"
......@@ -54,7 +53,6 @@
#define EPHY_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SHELL, EphyShellPrivate))
struct _EphyShellPrivate {
EphySearchProvider *search_provider;
EphySession *session;
GList *windows;
GObject *lockdown;
......@@ -518,42 +516,6 @@ ephy_shell_constructed (GObject *object)
G_OBJECT_CLASS (ephy_shell_parent_class)->constructed (object);
}
static gboolean
ephy_shell_dbus_register (GApplication *application,
GDBusConnection *connection,
const gchar *object_path,
GError **error)
{
EphyShell *self;
if (!G_APPLICATION_CLASS (ephy_shell_parent_class)->dbus_register (application,
connection,
object_path,
error))
return FALSE;
self = EPHY_SHELL (application);
return ephy_search_provider_dbus_register (self->priv->search_provider, connection,
object_path, error);
}
static void
ephy_shell_dbus_unregister (GApplication *application,
GDBusConnection *connection,
const gchar *object_path)
{
EphyShell *self;
self = EPHY_SHELL (application);
if (self->priv->search_provider)
ephy_search_provider_dbus_unregister (self->priv->search_provider, connection, object_path);
G_APPLICATION_CLASS (ephy_shell_parent_class)->dbus_unregister (application,
connection,
object_path);
}
static void
ephy_shell_class_init (EphyShellClass *klass)
{
......@@ -568,8 +530,6 @@ ephy_shell_class_init (EphyShellClass *klass)
application_class->activate = ephy_shell_activate;
application_class->before_emit = ephy_shell_before_emit;
application_class->add_platform_data = ephy_shell_add_platform_data;
application_class->dbus_register = ephy_shell_dbus_register;
application_class->dbus_unregister = ephy_shell_dbus_unregister;
g_type_class_add_private (object_class, sizeof(EphyShellPrivate));
}
......@@ -644,10 +604,6 @@ ephy_shell_init (EphyShell *shell)
webkit_web_context_set_favicon_database_directory (web_context, favicon_db_path);
g_free (favicon_db_path);
shell->priv->search_provider = ephy_search_provider_new ();
g_application_set_inactivity_timeout (G_APPLICATION (shell), 60 * 1000);
}
static void
......@@ -657,7 +613,6 @@ ephy_shell_dispose (GObject *object)
LOG ("EphyShell disposing");
g_clear_object (&priv->search_provider);
g_clear_object (&priv->session);
g_clear_object (&priv->lockdown);
g_clear_pointer (&priv->bme, gtk_widget_destroy);
......@@ -1169,9 +1124,6 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
const char *url;
WebKitURIRequest *request = NULL;
if (!data->window && !data->flags)
return FALSE;
url = data->uris[data->current_uri];
if (url[0] == '\0') {
page_flags = EPHY_NEW_TAB_HOME_PAGE;
......
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