Remove gearyd from project: Closes #7272

This commit is contained in:
Jim Nelson 2013-09-25 12:38:25 -07:00
parent af0a4c31df
commit 63f1d5569b
9 changed files with 1 additions and 555 deletions

View file

@ -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))

View file

@ -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)

View file

@ -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<Geary.Folder> 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);
}
}
}

View file

@ -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<ObjectPath, Object> path_to_object =
new Gee.HashMap<ObjectPath, Object>();
// 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<T>(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);
}
}

View file

@ -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<Geary.Email> 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;
}
}

View file

@ -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<Geary.App.Conversation> 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<Geary.Email> 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<Geary.Email> 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<Geary.EmailIdentifier, Geary.EmailFlags> flag_map) {
//TODO
}
}

View file

@ -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);
}
}
}

View file

@ -1,76 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<!-- The main API. Eventually we'll need an Engine interface and a Folder
interface, but for now we're only concerned with fetching conversations
from whatever account and inbox the D-Bus server is providing. -->
<interface name="org.yorba.Geary.Conversations">
<signal name="ScanStarted">
</signal>
<signal name="ScanError">
</signal>
<signal name="ScanCompleted">
</signal>
<signal name="ConversationsAdded">
<!-- Type: array of Conversation objects -->
<arg name="conversations" type="ao" direction="out"/>
</signal>
<signal name="ConversationRemoved">
<!-- Type: a Conversation object -->
<arg name="conversation" type="o" direction="out"/>
</signal>
<signal name="ConversationAppended">
<!-- Type: a Conversation object -->
<arg name="conversation" type="o" direction="out"/>
<!-- Type: array of email objects -->
<arg name="emails" type="ao" direction="out"/>
</signal>
<signal name="ConversationTrimmed">
<!-- Type: a Conversation object -->
<arg name="conversation" type="o" direction="out"/>
<!-- Type: an email object -->
<arg name="email" type="o" direction="out"/>
</signal>
<!-- Begins the scan, fetching the number of messages provided.
-->
<method name="FetchMessages">
<arg name="num_messages" type="i" direction="in"/>
</method>
</interface>
<!-- Represents a single conversation, used for managing groups of emails.
-->
<interface name="org.yorba.Geary.Conversation">
<method name="GetEmails">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<!-- Type: array of emails -->
<arg type="ao" direction="out"/>
</method>
</interface>
<!-- This represents a single email. The properties may be squished into
a D-Bus struct if they turns out to be expensive. Additionally, we may
want to add functions for marking an email read, adding/removing a flag,
and perhaps other feature for the demo -->
<interface name="org.yorba.Geary.Email">
<property name="To" type="s" access="read"/>
<property name="From" type="s" access="read"/>
<property name="Cc" type="s" access="read"/>
<property name="Subject" type="s" access="read"/>
<property name="Date" type="x" access="read"/>
<property name="Read" type="b" access="read"/>
<method name="GetBody">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" direction="out"/>
</method>
<method name="Remove">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
</method>
</interface>
</node>

View file

@ -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 <username> <password>\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;
}