From 63f1d5569b24cb93c13a97d96ce43b4e2a01d067 Mon Sep 17 00:00:00 2001 From: Jim Nelson Date: Wed, 25 Sep 2013 12:38:25 -0700 Subject: [PATCH] Remove gearyd from project: Closes #7272 --- Makefile.in | 2 +- src/CMakeLists.txt | 25 ----- src/dbusservice/controller.vala | 100 -------------------- src/dbusservice/database.vala | 110 ---------------------- src/dbusservice/dbus-conversation.vala | 33 ------- src/dbusservice/dbus-conversations.vala | 117 ------------------------ src/dbusservice/dbus-email.vala | 70 -------------- src/dbusservice/geary.xml | 76 --------------- src/dbusservice/main.vala | 23 ----- 9 files changed, 1 insertion(+), 555 deletions(-) delete mode 100644 src/dbusservice/controller.vala delete mode 100644 src/dbusservice/database.vala delete mode 100644 src/dbusservice/dbus-conversation.vala delete mode 100644 src/dbusservice/dbus-conversations.vala delete mode 100644 src/dbusservice/dbus-email.vala delete mode 100644 src/dbusservice/geary.xml delete mode 100644 src/dbusservice/main.vala diff --git a/Makefile.in b/Makefile.in index 814cbfc5..a966404b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3,7 +3,7 @@ # Copyright 2012-2013 Yorba Foundation BUILD_DIR := build -BINARIES := geary gearyd geary-console geary-mailer +BINARIES := geary geary-console geary-mailer BUILD_BINARIES := $(addprefix $(BUILD_DIR)/,$(BINARIES)) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7bca298d..ef47283f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -619,30 +619,6 @@ add_custom_command( ${CMAKE_COMMAND} -E copy geary-mailer ${CMAKE_BINARY_DIR}/ ) -# DBus Service -################################################# -vala_precompile(DBUS_VALA_C gearyd - ${DBUSSERVICE_SRC} -PACKAGES - ${DBUSSERVICE_PACKAGES} - ${ENGINE_PACKAGES} -CUSTOM_VAPIS - "${CMAKE_BINARY_DIR}/src/geary-static.vapi" -OPTIONS - ${VALAC_OPTIONS} - --vapidir=${CMAKE_BINARY_DIR}/src -) - -add_executable(gearyd ${DBUS_VALA_C}) -target_link_libraries(gearyd ${DEPS_LIBRARIES} gthread-2.0 geary-static) -add_custom_command( - TARGET - gearyd - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy gearyd ${CMAKE_BINARY_DIR}/ -) - # Valadoc ################################################# foreach(pkg ${ENGINE_PACKAGES}) @@ -667,7 +643,6 @@ set_property( geary geary-console geary-mailer - gearyd ) add_subdirectory(sqlite3-unicodesn) diff --git a/src/dbusservice/controller.vala b/src/dbusservice/controller.vala deleted file mode 100644 index 3bc2934a..00000000 --- a/src/dbusservice/controller.vala +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -public class Geary.DBus.Controller { - public static const string CONVERSATION_PATH_PREFIX = "/org/yorba/geary/conversation/"; - public static const string EMAIL_PATH_PREFIX = "/org/yorba/geary/email/"; - - public static Geary.DBus.Controller instance { get; private set; } - - public DBusConnection connection { get; private set; } - - private string[] args; - private Geary.Account account; - private Geary.DBus.Conversations conversations; - - public static void init(string[] args) { - instance = new Geary.DBus.Controller(args); - Database.init(); - } - - protected Controller(string[] args) { - this.args = args; - } - - public async void start() { - try { - yield Geary.Engine.instance.open_async(get_user_data_directory(), get_resource_directory(), null); - - connection = yield Bus.get(GLib.BusType.SESSION); - - // Open the account. - // TODO: Don't assume username is email, allow separate imap/smtp credentials. - Geary.AccountInformation account_information = Geary.Engine.instance.get_accounts().get(args[1]); - if (account_information == null) - account_information = Geary.Engine.instance.create_orphan_account(args[1]); - account_information.imap_credentials = new Geary.Credentials(args[1], args[2]); - account_information.smtp_credentials = new Geary.Credentials(args[1], args[2]); - - // convert AccountInformation into an Account - try { - account = Geary.Engine.instance.get_account_instance(account_information); - } catch (Error err) { - error("Problem loading account from account information: %s", err.message); - } - - account.report_problem.connect(on_report_problem); - - // Open the Inbox folder. - Geary.Folder? folder = null; - Gee.Collection folders = account.list_matching_folders(null); - foreach(Geary.Folder folder_to_check in folders) { - if(folder_to_check.special_folder_type == Geary.SpecialFolderType.INBOX) { - folder = folder_to_check; - break; - } - } - - if (folder == null) { - warning("No inbox folder found"); - return; - } - yield folder.open_async(Geary.Folder.OpenFlags.NONE, null); - - conversations = new Geary.DBus.Conversations(folder); - - // Register interfaces. - Bus.own_name(BusType.SESSION, Geary.DBus.Conversations.INTERFACE_NAME, BusNameOwnerFlags.NONE, - on_conversations_aquired); - Bus.own_name(BusType.SESSION, Geary.DBus.Conversation.INTERFACE_NAME, BusNameOwnerFlags.NONE); - Bus.own_name(BusType.SESSION, Geary.DBus.Email.INTERFACE_NAME, BusNameOwnerFlags.NONE); - } catch (Error e) { - debug("Startup error: %s", e.message); - return; - } - } - - public File get_user_data_directory() { - return File.new_for_path(Environment.get_user_data_dir()).get_child("geary"); - } - - public File get_resource_directory() { - return File.new_for_path(Environment.get_current_dir()); - } - - private void on_report_problem(Geary.Account.Problem problem, Error? err) { - debug("Reported problem: %s Error: %s", problem.to_string(), err != null ? err.message : "(N/A)"); - } - - private void on_conversations_aquired(DBusConnection c) { - try { - connection.register_object("/org/yorba/geary/conversations", conversations); - } catch (IOError e) { - debug("Error: %s", e.message); - } - } -} - diff --git a/src/dbusservice/database.vala b/src/dbusservice/database.vala deleted file mode 100644 index 91a45a36..00000000 --- a/src/dbusservice/database.vala +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -namespace Geary.DBus { - -public uint db_email_hash(Geary.Email key) { - return key.id.hash(); -} - -public bool db_email_equal(Geary.Email a, Geary.Email b) { - return a.id.equal_to(b.id); -} - -} - -public class Geary.DBus.Database : Object { - - public static Database instance { get; private set; } - - private const string DBUS_PATH_PROP = "dbus-path"; - private const string DBUS_REG_PROP = "dbus-registration"; - - private Gee.HashMap path_to_object = - new Gee.HashMap(); - - // This is for tracking conversations. - // TODO: find a better way to give conversations unique IDs. - private int counter = 0; - - private Database() { - } - - // Must call this to init the database. - public static void init() { - instance = new Geary.DBus.Database(); - } - - // Finds the conversation and returns the path. If the conversation does not have - // a path, it will be assigned one. - public ObjectPath get_conversation_path(Geary.App.Conversation c, Geary.Folder folder) { - ObjectPath? path = c.get_data(DBUS_PATH_PROP); - - if (path == null) { - // Assign new path based on counter. - path = new ObjectPath(Controller.CONVERSATION_PATH_PREFIX + - (counter++).to_string()); - - register_object(c, new Geary.DBus.Conversation(c, folder), path); - } - - return path; - } - - // Gets a path for an email object. If one does not exist, it will be created. - public ObjectPath get_email_path(Geary.Email e, Geary.Folder folder) { - ObjectPath? path = e.get_data(DBUS_PATH_PROP); - if (path == null) { - // Generate a path and save it. - path = new ObjectPath(Controller.EMAIL_PATH_PREFIX + e.id.to_string()); - register_object(e, new Geary.DBus.Email(folder, e), path); - } - - return path; - } - - // Registers an object with DBus and saves the path. - // Uses generics to bypass Vala's dbus codegen warning. - private void register_object(Object object, T dbus_object, ObjectPath path) { - try { - uint reg_id = Controller.instance.connection.register_object(path, dbus_object); - object.set_data(DBUS_PATH_PROP, path); - object.set_data(DBUS_REG_PROP, reg_id.to_string()); - path_to_object.set(path, object); - } catch (Error e) { - warning("Could not register path: %s", path); - debug("Error: %s", e.message); - } - } - - public void remove_by_path(ObjectPath path) { - debug("Removing path: %s", path); - Object? o = path_to_object.get(path); - if (o == null) { - warning("Unable to remove object: %s", path); - return; - } - - remove(o); - } - - // Removes an object - private void remove(Object object) { - debug("removing object"); - assert(object != null); - ObjectPath? path = object.get_data(DBUS_PATH_PROP); - string? reg_id_s = object.get_data(DBUS_REG_PROP); - if (path == null || reg_id_s == null) { - warning("Unable to remove object"); - return; - } - - uint reg_id = (uint) long.parse(reg_id_s); - path_to_object.unset(path); - Controller.instance.connection.unregister_object(reg_id); - } -} - diff --git a/src/dbusservice/dbus-conversation.vala b/src/dbusservice/dbus-conversation.vala deleted file mode 100644 index d210887b..00000000 --- a/src/dbusservice/dbus-conversation.vala +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -[DBus (name = "org.yorba.Geary.Conversation", timeout = 120000)] -public class Geary.DBus.Conversation : Object { - - public static const string INTERFACE_NAME = "org.yorba.Geary.Conversation"; - - private Geary.App.Conversation conversation; - private Geary.Folder folder; - - public Conversation(Geary.App.Conversation c, Geary.Folder f) { - conversation = c; - folder = f; - } - - public async ObjectPath[] get_emails() throws IOError { - Gee.List pool = conversation.get_emails(Geary.App.Conversation.Ordering.DATE_ASCENDING); - if (pool.size == 0) - return new ObjectPath[0]; - - ObjectPath[] paths = new ObjectPath[0]; - - foreach (Geary.Email e in pool) { - paths += new ObjectPath(Database.instance.get_email_path(e, folder)); - } - - return paths; - } -} diff --git a/src/dbusservice/dbus-conversations.vala b/src/dbusservice/dbus-conversations.vala deleted file mode 100644 index 0edf7eb9..00000000 --- a/src/dbusservice/dbus-conversations.vala +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -[DBus (name = "org.yorba.Geary.Conversations", timeout = 120000)] -public class Geary.DBus.Conversations : Object { - public static const string INTERFACE_NAME = "org.yorba.Geary.Conversations"; - - public signal void scan_started(); - - public signal void scan_error(); - - public signal void scan_completed(); - - public signal void conversations_added(ObjectPath[] conversations); - - public signal void conversation_removed(ObjectPath conversation); - - public signal void conversation_appended(ObjectPath conversation, ObjectPath[] emails); - - public signal void conversation_trimmed(ObjectPath conversation, ObjectPath email); - - private Geary.Folder folder; - private Geary.App.ConversationMonitor conversations; - - public Conversations(Geary.Folder folder) { - this.folder = folder; - conversations = new Geary.App.ConversationMonitor(folder, Geary.Folder.OpenFlags.NONE, - Geary.Email.Field.ENVELOPE | Geary.Email.Field.FLAGS, 20); // Download 20 conversations - - start_monitoring_async.begin(); - } - - private async void start_monitoring_async() { - try { - yield conversations.start_monitoring_async(); - } catch (Error err) { - debug("Unable to start monitoring %s for conversations: %s", folder.to_string(), - err.message); - - return; - } - - conversations.scan_started.connect(on_scan_started); - conversations.scan_error.connect(on_scan_error); - conversations.scan_completed.connect(on_scan_completed); - conversations.conversations_added.connect(on_conversations_added); - conversations.conversation_appended.connect(on_conversation_appended); - conversations.conversation_trimmed.connect(on_conversation_trimmed); - conversations.conversation_removed.connect(on_conversation_removed); - - folder.email_flags_changed.connect(on_email_flags_changed); - } - - private void on_scan_started() { - scan_started(); - } - - private void on_scan_error(Error err) { - scan_error(); - } - - private void on_scan_completed() { - scan_completed(); - } - - private void on_conversations_added(Gee.Collection conversations) { - debug("Conversation added: %d conversations", conversations.size); - ObjectPath[] paths = new ObjectPath[0]; - - foreach (Geary.App.Conversation c in conversations) { - paths += new ObjectPath(Database.instance.get_conversation_path(c, folder)); - } - - conversations_added(paths); - } - - private void on_conversation_removed(Geary.App.Conversation conversation) { - debug("conversation removed"); - // Fire signal, then delete. - ObjectPath path = Database.instance.get_conversation_path(conversation, folder); - - conversation_removed(path); - Database.instance.remove_by_path(path); - } - - private void on_conversation_appended(Geary.App.Conversation conversation, - Gee.Collection email_list) { - debug("conversation appended"); - - ObjectPath[] email_paths = new ObjectPath[0]; - foreach (Geary.Email e in email_list) - email_paths += Database.instance.get_email_path(e, folder); - - conversation_appended(Database.instance.get_conversation_path(conversation, folder), - email_paths); - } - - private void on_conversation_trimmed(Geary.App.Conversation conversation, - Gee.Collection emails) { - debug("conversation trimmed"); - foreach (Geary.Email email in emails) { - // Fire signal, then delete. - ObjectPath email_path = Database.instance.get_email_path(email, folder); - conversation_trimmed(Database.instance.get_conversation_path(conversation, folder), - email_path); - Database.instance.remove_by_path(email_path); - } - } - - private void on_email_flags_changed(Gee.Map flag_map) { - //TODO - } -} - diff --git a/src/dbusservice/dbus-email.vala b/src/dbusservice/dbus-email.vala deleted file mode 100644 index b4ffd58e..00000000 --- a/src/dbusservice/dbus-email.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -[DBus (name = "org.yorba.Geary.Email", timeout = 120000)] -public class Geary.DBus.Email : Object { - public static const string INTERFACE_NAME = "org.yorba.Geary.Email"; - - public string to { get; private set; } - public string from { get; private set; } - public string cc { get; private set; } - public string subject { get; private set; } - public int64 date { get; private set; } - public bool read { get; private set; } - - private Geary.Folder folder; - private Geary.Email email; - - public Email(Geary.Folder f, Geary.Email e) { - folder = f; - email = e; - - to = email.to != null ? email.to.to_string() : ""; - from = email.from != null ? email.from.to_string() : ""; - cc = email.cc != null ? email.cc.to_string() : ""; - subject = email.subject != null ? email.subject.to_string() : ""; - date = email.date != null ? email.date.as_time_t : 0; - read = email.email_flags != null ? email.email_flags.contains(EmailFlags.UNREAD) - : true; - } - - public async string get_body() throws IOError { - string body_text = ""; - Geary.Email full_email; - - try { - full_email = yield folder.fetch_email_async(email.id, Geary.Email.Field.ALL, - Geary.Folder.ListFlags.NONE); - } catch (Error err) { - warning("Could not load email: %s", err.message); - return ""; - } - - try { - body_text = full_email.get_message().get_body(true); - } catch (Error err) { - debug("Could not get message text. %s", err.message); - } - - return body_text; - } - - public async void remove() throws IOError { - Geary.FolderSupport.Remove? supports_remove = folder as Geary.FolderSupport.Remove; - if (supports_remove == null) - return; - - try { - yield supports_remove.remove_single_email_async(email.id); - } catch (Error e) { - if (e is IOError) - throw (IOError) e; - else - warning("Unexpected error removing email: %s", e.message); - } - } -} - diff --git a/src/dbusservice/geary.xml b/src/dbusservice/geary.xml deleted file mode 100644 index a9c284c1..00000000 --- a/src/dbusservice/geary.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/dbusservice/main.vala b/src/dbusservice/main.vala deleted file mode 100644 index ea76f0e0..00000000 --- a/src/dbusservice/main.vala +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2011-2013 Yorba Foundation - * - * This software is licensed under the GNU Lesser General Public License - * (version 2.1 or later). See the COPYING file in this distribution. - */ - -int main(string[] args) { - if (args.length != 3) { - stderr.printf("Geary D-Bus daemon\n"); - stderr.printf("Usage: gearyd \n"); - - return 1; - } - - debug("Starting Gearyd..."); - Geary.DBus.Controller.init(args); - Geary.DBus.Controller.instance.start.begin(); - - debug("Entering main loop"); - new MainLoop().run(); - - return 0; -}