Closes #5745 libgee 0.8

This commit is contained in:
Eric Gregory 2013-04-24 12:22:32 -07:00
parent 6e68d67f34
commit ddbd4c7213
65 changed files with 744 additions and 426 deletions

6
bindings/vapi/unity.deps Normal file
View file

@ -0,0 +1,6 @@
glib-2.0
gobject-2.0
gio-2.0
gio-unix-2.0
dee-1.0
Dbusmenu-0.4

438
bindings/vapi/unity.vapi Normal file
View file

@ -0,0 +1,438 @@
/* unity.vapi generated by valac 0.18.0, do not modify. */
namespace Unity {
namespace IO {
[CCode (cheader_filename = "unity.h")]
public static string[] get_system_data_dirs ();
[CCode (cheader_filename = "unity.h")]
public static async GLib.FileInputStream? open_from_data_dirs (string filename) throws GLib.Error;
[CCode (cheader_filename = "unity.h")]
public static async GLib.FileInputStream? open_from_dirs (string filename, string[] dirs) throws GLib.Error;
[CCode (cheader_filename = "unity.h")]
public static async void read_stream_async (GLib.InputStream input, int io_priority = GLib.Priority.LOW, GLib.Cancellable? cancellable = null, out uint8[] data, out size_t size) throws GLib.IOError;
}
[CCode (cheader_filename = "unity.h")]
public class ActivationResponse : GLib.InitiallyUnowned {
public ActivationResponse (Unity.HandledType handled, string goto_uri = "");
public ActivationResponse.with_preview (Unity.Preview preview);
public string goto_uri { get; set construct; }
public Unity.HandledType handled { get; construct; }
}
[CCode (cheader_filename = "unity.h")]
public class AnnotatedIcon : GLib.Object {
public AnnotatedIcon (GLib.Icon base_icon);
public string to_string ();
public Unity.CategoryType category { get; set; }
public GLib.Icon icon { get; set; }
public string ribbon { get; set; }
public Unity.IconSizeHint size_hint { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class AppInfoManager : GLib.Object {
public void clear ();
public unowned string[]? get_categories (string id);
public static Unity.AppInfoManager get_default ();
[Deprecated (replacement = "AppInfoManager.get_default")]
public static Unity.AppInfoManager get_instance ();
public unowned string[]? get_keywords (string id);
public string? get_path (string id);
public GLib.AppInfo? lookup (string id);
public async GLib.AppInfo? lookup_async (string id) throws GLib.Error;
public signal void changed (string id, GLib.AppInfo? new_appinfo);
}
[CCode (cheader_filename = "unity.h")]
public class ApplicationPreview : Unity.Preview {
public ApplicationPreview (string title, string subtitle, string description, GLib.Icon? icon, GLib.Icon? screenshot);
public void set_rating (float rating, uint num_ratings);
public GLib.Icon app_icon { get; set; }
public string copyright { get; set; }
public string last_update { get; set; }
public string license { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class AsyncPreview : Unity.Preview {
public AsyncPreview ();
[CCode (name = "unity_async_preview_preview_ready")]
public void emit_preview_ready (Unity.Preview? preview);
public AsyncPreview.with_cancellable (GLib.Cancellable cancellable);
public GLib.Cancellable cancellable { get; set construct; }
public signal void preview_ready (Unity.Preview? preview);
}
[CCode (cheader_filename = "unity.h")]
public class Category : GLib.Object {
public Category (string name, GLib.Icon icon_hint, Unity.CategoryRenderer renderer = CategoryRenderer.VERTICAL_TILE);
public Unity.CategoryRenderer default_renderer { get; construct; }
public GLib.Icon? icon_hint { get; construct; }
public string name { get; construct; }
}
[CCode (cheader_filename = "unity.h")]
public class CheckOptionFilter : Unity.OptionsFilter {
public CheckOptionFilter (string id, string display_name, GLib.Icon? icon_hint = null, bool collapsed = false);
}
[CCode (cheader_filename = "unity.h")]
public class CheckOptionFilterCompact : Unity.OptionsFilter {
public CheckOptionFilterCompact (string id, string display_name, GLib.Icon? icon_hint = null, bool collapsed = false);
}
[CCode (cheader_filename = "unity.h")]
public abstract class Filter : GLib.Object {
public Filter ();
public bool collapsed { get; construct; }
public string display_name { get; internal set construct; }
public bool filtering { get; internal set construct; }
public GLib.Icon? icon_hint { get; construct; }
public string id { get; construct; }
public Unity.FilterRenderer renderer { get; construct; }
public bool visible { get; set construct; }
public signal void changed ();
}
[CCode (cheader_filename = "unity.h")]
public class FilterOption : GLib.Object {
public FilterOption (string id, string display_name, GLib.Icon? icon_hint = null, bool active = false);
public bool active { get; internal set construct; }
public string display_name { get; construct; }
public GLib.Icon icon_hint { get; construct; }
public string id { get; construct; }
}
[CCode (cheader_filename = "unity.h")]
public class GenericPreview : Unity.Preview {
public GenericPreview (string title, string description, GLib.Icon? image);
}
[CCode (cheader_filename = "unity.h")]
public class InfoHint : GLib.InitiallyUnowned {
public InfoHint (string id, string display_name, GLib.Icon? icon_hint, string data);
public InfoHint.with_variant (string id, string display_name, GLib.Icon? icon_hint, GLib.Variant data);
public GLib.Variant data { get; construct; }
public string display_name { get; construct; }
public GLib.Icon? icon_hint { get; construct; }
public string id { get; construct; }
}
[CCode (cheader_filename = "unity.h")]
public class Inspector : GLib.Object {
public static unowned Unity.Inspector get_default ();
public string? unity_bus_name { get; }
public bool unity_running { get; }
}
[CCode (cheader_filename = "unity.h")]
public class LauncherEntry : Dee.Serializable, GLib.Object {
public static Unity.LauncherEntry get_for_app_uri (string app_uri);
public static Unity.LauncherEntry get_for_desktop_file (string desktop_file);
public static Unity.LauncherEntry get_for_desktop_id (string desktop_id);
public string app_uri { get; set construct; }
public int64 count { get; set; }
public bool count_visible { get; set; }
public double progress { get; set; }
public bool progress_visible { get; set; }
public Dbusmenu.Menuitem? quicklist { get; set; }
public bool urgent { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class LauncherFavorites : GLib.Object {
public GLib.AppInfo[] enumerate_app_infos ();
public string[] enumerate_ids ();
public static unowned Unity.LauncherFavorites get_default ();
public bool has_app_id (string app_id);
public bool has_app_info (GLib.AppInfo appinfo);
public GLib.AppInfo? lookup (string app_id);
public signal void changed ();
}
[CCode (cheader_filename = "unity.h")]
public class Lens : GLib.Object {
public Lens (string dbus_path_, string id_);
public void add_local_scope (Unity.Scope scope);
public void export () throws GLib.IOError;
public bool active { get; private set; }
public GLib.List<Unity.Category> categories { get; set; }
public string dbus_path { get; construct; }
public bool exported { get; private set; }
public GLib.List<Unity.Filter> filters { get; set; }
public Unity.MergeStrategy global_merge_strategy { get; set; }
public string home_lens_default_name { get; set; }
public string id { get; construct; }
public Unity.MergeStrategy merge_strategy { get; set; }
public string search_hint { get; set; }
public bool search_in_global { get; set; }
public bool searching { get; private set; }
public string sources_display_name { get; set construct; }
public bool visible { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class LensSearch : GLib.InitiallyUnowned {
public LensSearch (string search_string, GLib.HashTable<string,GLib.Variant> hints, Dee.SerializableModel results_model);
[CCode (cname = "unity_lens_search_finished")]
public void emit_finished ();
public bool equals (Unity.LensSearch? other);
public void set_reply_hint (string key, GLib.Variant variant);
public GLib.HashTable<string,GLib.Variant> hints { get; construct; }
public Dee.SerializableModel results_model { get; construct; }
public string search_string { get; construct; }
[Signal (action = true)]
public signal void finished ();
}
[CCode (cheader_filename = "unity.h")]
public class MoviePreview : Unity.Preview {
public MoviePreview (string title, string subtitle, string description, GLib.Icon? image);
public void set_rating (float rating, uint num_ratings);
public string year { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class MultiRangeFilter : Unity.OptionsFilter {
public MultiRangeFilter (string id, string display_name, GLib.Icon? icon_hint = null, bool collapsed = false);
public Unity.FilterOption? get_first_active ();
public Unity.FilterOption? get_last_active ();
}
[CCode (cheader_filename = "unity.h")]
public class MusicPlayer : GLib.Object {
public MusicPlayer (string desktop);
public bool add_playlist (Unity.Playlist p);
public void edit_playlist_name (string id, string name);
public void export ();
public Unity.Playlist[] get_playlists ();
public bool remove_playlist (Unity.Playlist p);
public void unexport ();
public GLib.AppInfo app_info { get; construct; }
public bool can_go_next { get; set; }
public bool can_go_previous { get; set; }
public bool can_pause { get; set; }
public bool can_play { get; set; }
public Unity.Playlist current_playlist { get; set; }
public Unity.TrackMetadata current_track { get; set; }
public string desktop_file_name { get; construct; }
public bool is_blacklisted { get; set; }
public Unity.PlaybackState playback_state { get; set; }
public Dbusmenu.Menuitem? player_menu { get; set; }
public string title { get; set; }
public Dbusmenu.Menuitem? track_menu { get; set; }
public signal void activate_playlist (GLib.ObjectPath playlist_id);
public signal void next ();
public signal void play_pause ();
public signal void previous ();
public signal void raise ();
}
[CCode (cheader_filename = "unity.h")]
public class MusicPreview : Unity.Preview {
public enum TrackState {
STOPPED,
PLAYING,
PAUSED
}
public MusicPreview (string title, string subtitle, GLib.Icon? image);
public void add_track (Unity.TrackMetadata track);
public float current_progress { get; set; }
public Unity.MusicPreview.TrackState current_track_state { get; set; }
public string current_track_uri { get; set; }
public signal void pause (string uri);
public signal void play (string uri);
}
[CCode (cheader_filename = "unity.h")]
public class OptionsFilter : Unity.Filter {
public enum SortType {
MANUAL,
DISPLAY_NAME,
ID
}
public GLib.List<Unity.FilterOption> options;
public OptionsFilter ();
public Unity.FilterOption add_option (string id, string display_name, GLib.Icon? icon_hint = null);
public Unity.FilterOption? get_option (string id);
public bool remove_option (string id);
public Unity.OptionsFilter.SortType sort_type { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class Playlist : GLib.Object {
public Playlist (string id);
public GLib.DateTime creation_date { get; set; }
public GLib.Icon icon { get; set; }
public string id { get; construct; }
public GLib.DateTime last_play_date { get; set; }
public GLib.DateTime modification_date { get; set; }
public string name { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class PreferencesManager : GLib.Object {
public enum RemoteContent {
ALL,
NONE
}
public static Unity.PreferencesManager get_default ();
public Unity.PreferencesManager.RemoteContent remote_content_search { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public abstract class Preview : GLib.Object, Dee.Serializable {
public Preview ();
public void add_action (Unity.PreviewAction action);
public void add_info (Unity.InfoHint info_hint);
public string description_markup { get; set; }
public GLib.Icon? image { get; set; }
public string image_source_uri { get; set; }
public string subtitle { get; set; }
public string title { get; set; }
public signal void closed ();
}
[CCode (cheader_filename = "unity.h")]
public class PreviewAction : GLib.Object, Dee.Serializable {
public PreviewAction (string id, string display_name, GLib.Icon? icon_hint);
public PreviewAction.with_layout_hint (string id, string display_name, GLib.Icon? icon_hint, Unity.LayoutHint layout);
public string display_name { get; construct; }
public string extra_text { get; set; }
public GLib.HashTable<string,GLib.Variant>? hints { get; }
public GLib.Icon? icon_hint { get; construct; }
public string id { get; construct; }
public Unity.LayoutHint layout_hint { get; construct; }
public signal Unity.ActivationResponse activated (string uri);
}
[CCode (cheader_filename = "unity.h")]
public class RadioOptionFilter : Unity.OptionsFilter {
public RadioOptionFilter (string id, string display_name, GLib.Icon? icon_hint = null, bool collapsed = false);
public Unity.FilterOption? get_active_option ();
}
[CCode (cheader_filename = "unity.h")]
public class RatingsFilter : Unity.Filter {
public RatingsFilter (string id, string display_name, GLib.Icon? icon_hint = null, bool collapsed = false);
public float rating { get; internal set construct; }
}
[CCode (cheader_filename = "unity.h")]
public class Scope : GLib.Object {
public Scope (string dbus_path_);
public void export () throws GLib.IOError;
public Unity.Filter? get_filter (string id);
public void invalidate_search (Unity.SearchType search_type);
public void queue_search_changed (Unity.SearchType search_type);
public bool active { get; set; }
public string dbus_path { get; construct; }
public bool exported { get; private set; }
public GLib.List<Unity.Filter> filters { get; }
public Dee.SerializableModel global_results_model { get; }
public bool provides_personal_content { get; set; }
public Dee.SerializableModel results_model { get; }
public bool search_in_global { get; set; }
public Unity.OptionsFilter sources { get; internal set; }
public signal Unity.ActivationResponse? activate_uri (string uri);
public signal void active_sources_changed (string[] active_ids);
public signal void filters_changed ();
[Signal (detailed = true)]
public signal string generate_search_key (Unity.LensSearch search);
public signal Unity.Preview? preview_uri (string uri);
public signal void search_changed (Unity.LensSearch search, Unity.SearchType search_type, GLib.Cancellable cancellable);
}
[CCode (cheader_filename = "unity.h")]
public class SocialPreview : Unity.Preview {
public class Comment : GLib.InitiallyUnowned {
public Comment (string id, string name, string text, string time);
public string id { get; construct; }
public string name { get; construct; }
public string text { get; construct; }
public string time { get; construct; }
}
public SocialPreview (string sender, string subtitle, string content, GLib.Icon? avatar);
public void add_comment (Unity.SocialPreview.Comment comment);
public GLib.Icon avatar { get; set; }
public string content { get; set; }
public string sender { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public class TrackMetadata : GLib.Object {
public TrackMetadata ();
public TrackMetadata.full (string uri, int track_no, string title, string artist, string album, uint length);
public string album { get; set; }
public GLib.Icon art_icon { get; set; }
public GLib.File art_location { get; set; }
public string artist { get; set; }
public uint length { get; set; }
public string title { get; set; }
public int track_no { get; set; }
public string uri { get; set; }
}
[CCode (cheader_filename = "unity.h")]
public interface MergeStrategy : GLib.Object {
public abstract unowned Dee.ModelIter? merge_result (Dee.Model target, GLib.Variant[] row);
}
[CCode (cheader_filename = "unity.h")]
public struct ActivePlaylistContainer {
public bool valid;
public Unity.PlaylistDetails details;
}
[CCode (cheader_filename = "unity.h")]
public struct PlaylistDetails {
public GLib.ObjectPath id;
public string name;
public string icon_name;
}
[CCode (cheader_filename = "unity.h")]
public enum CategoryRenderer {
VERTICAL_TILE,
HORIZONTAL_TILE,
LIST_TILE,
FLOW
}
[CCode (cheader_filename = "unity.h")]
public enum CategoryType {
NONE,
APPLICATION,
BOOK,
MUSIC,
MOVIE,
GAMES,
ELECTRONICS,
COMPUTERS,
OFFICE,
HOME,
GARDEN,
PETS,
TOYS,
CHILDREN,
BABY,
CLOTHES,
SHOES,
WATCHES,
SPORTS,
OUTDOORS,
GROCERY,
HEALTH,
BEAUTY,
DIY,
TOOLS,
CAR,
N_CATEGORIES
}
[CCode (cheader_filename = "unity.h")]
public enum FilterRenderer {
CHECK_OPTIONS,
RADIO_OPTIONS,
MULTIRANGE,
RATINGS,
CHECK_OPTIONS_COMPACT
}
[CCode (cheader_filename = "unity.h")]
public enum HandledType {
NOT_HANDLED,
SHOW_DASH,
HIDE_DASH,
GOTO_DASH_URI,
SHOW_PREVIEW
}
[CCode (cheader_filename = "unity.h")]
public enum IconSizeHint {
DEFAULT,
SMALL,
LARGE
}
[CCode (cheader_filename = "unity.h")]
public enum LayoutHint {
NONE,
LEFT,
RIGHT,
TOP,
BOTTOM
}
[CCode (cheader_filename = "unity.h")]
public enum PlaybackState {
PLAYING,
PAUSED
}
[CCode (cheader_filename = "unity.h")]
public enum SearchType {
DEFAULT,
GLOBAL,
N_TYPES
}
}

4
debian/control vendored
View file

@ -3,7 +3,7 @@ Section: gnome
Priority: optional Priority: optional
Maintainer: Jim Nelson <jim@yorba.org> Maintainer: Jim Nelson <jim@yorba.org>
Build-Depends: debhelper (>= 8), Build-Depends: debhelper (>= 8),
libgee-dev (>= 0.6.0), libgee-0.8-dev (>= 0.8.0),
libglib2.0-dev (>= 2.30.0), libglib2.0-dev (>= 2.30.0),
libgtk-3-dev (>= 3.2.0), libgtk-3-dev (>= 3.2.0),
libunique-3.0-dev (>= 3.0.0), libunique-3.0-dev (>= 3.0.0),
@ -26,7 +26,7 @@ Homepage: http://www.yorba.org
Package: geary Package: geary
Architecture: any Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, Depends: ${shlibs:Depends}, ${misc:Depends},
libgee2 (>= 0.6.0), libgee-0.8-2 (>= 0.8.0),
libglib2.0-0 (>= 2.30.0), libglib2.0-0 (>= 2.30.0),
libgtk-3-0 (>= 3.2.0), libgtk-3-0 (>= 3.2.0),
libunique-3.0-0 (>= 3.0.0), libunique-3.0-0 (>= 3.0.0),

View file

@ -347,7 +347,7 @@ pkg_check_modules(DEPS REQUIRED
glib-2.0>=${TARGET_GLIB}.0 glib-2.0>=${TARGET_GLIB}.0
gio-2.0>=2.28.0 gio-2.0>=2.28.0
gtk+-3.0>=3.4.0 gtk+-3.0>=3.4.0
gee-1.0>=0.6.0 gee-0.8>=0.8.0
unique-3.0>=3.0.0 unique-3.0>=3.0.0
libnotify>=0.7.5 libnotify>=0.7.5
libcanberra>=0.28 libcanberra>=0.28
@ -359,7 +359,7 @@ pkg_check_modules(DEPS REQUIRED
) )
set(ENGINE_PACKAGES set(ENGINE_PACKAGES
glib-2.0 gee-1.0 gio-2.0 gmime-2.6 unique-3.0 posix sqlite3 glib-2.0 gee-0.8 gio-2.0 gmime-2.6 unique-3.0 posix sqlite3
) )
set(CLIENT_PACKAGES set(CLIENT_PACKAGES
@ -371,7 +371,7 @@ set(CONSOLE_PACKAGES
) )
set(DBUSSERVICE_PACKAGES set(DBUSSERVICE_PACKAGES
gee-1.0 glib-2.0 gee-0.8 glib-2.0
) )
set(GSETTINGS_DIR ${CMAKE_SOURCE_DIR}/desktop) set(GSETTINGS_DIR ${CMAKE_SOURCE_DIR}/desktop)

View file

@ -53,7 +53,7 @@ public class AccountDialogAccountListPane : AccountDialogPane {
} }
// Sort accounts and add them to the UI. // Sort accounts and add them to the UI.
account_list.sort((CompareFunc) Geary.AccountInformation.compare_ascending); account_list.sort(Geary.AccountInformation.compare_ascending);
foreach (Geary.AccountInformation account in account_list) foreach (Geary.AccountInformation account in account_list)
on_account_added(account); on_account_added(account);

View file

@ -153,8 +153,8 @@ public class AccountDialog : Gtk.Dialog {
Geary.AccountInformation? real_info = Geary.AccountInformation? real_info =
GearyApplication.instance.get_real_account_information(info); GearyApplication.instance.get_real_account_information(info);
if (real_info != null) { if (real_info != null) {
validate_connection = !real_info.imap_credentials.equals(info.imap_credentials) || validate_connection = !real_info.imap_credentials.equal_to(info.imap_credentials) ||
(info.smtp_credentials != null && !real_info.smtp_credentials.equals(info.smtp_credentials)); (info.smtp_credentials != null && !real_info.smtp_credentials.equal_to(info.smtp_credentials));
} }
} }

View file

@ -127,7 +127,8 @@ public class ComposerWindow : Gtk.Window {
public ComposeType compose_type { get; private set; default = ComposeType.NEW_MESSAGE; } public ComposeType compose_type { get; private set; default = ComposeType.NEW_MESSAGE; }
private string? body_html = null; private string? body_html = null;
private Gee.Set<File> attachment_files = new Gee.HashSet<File>(File.hash, (EqualFunc) File.equal); private Gee.Set<File> attachment_files = new Gee.HashSet<File>(Geary.Files.nullable_hash,
Geary.Files.nullable_equal);
private Gtk.Builder builder; private Gtk.Builder builder;
private Gtk.Label from_label; private Gtk.Label from_label;

View file

@ -20,8 +20,7 @@ public class FolderList.AccountBranch : Sidebar.Branch {
new ThemedIcon("folder-open"), new ThemedIcon("folder")); new ThemedIcon("folder-open"), new ThemedIcon("folder"));
user_folder_group = new SpecialGrouping(2, "", user_folder_group = new SpecialGrouping(2, "",
IconFactory.instance.get_custom_icon("tags", IconFactory.ICON_SIDEBAR)); IconFactory.instance.get_custom_icon("tags", IconFactory.ICON_SIDEBAR));
folder_entries = new Gee.HashMap<Geary.FolderPath, FolderEntry>( folder_entries = new Gee.HashMap<Geary.FolderPath, FolderEntry>();
Geary.Hashable.hash_func, Geary.Equalable.equal_func);
account.information.notify["nickname"].connect(on_nicknamed_changed); account.information.notify["nickname"].connect(on_nicknamed_changed);

View file

@ -677,7 +677,7 @@ public class GearyController {
return; return;
} }
all_accounts.sort((CompareFunc) Geary.AccountInformation.compare_ascending); all_accounts.sort(Geary.AccountInformation.compare_ascending);
account_to_select = Geary.Engine.instance.get_account_instance(all_accounts.get(0)); account_to_select = Geary.Engine.instance.get_account_instance(all_accounts.get(0));
} catch (Error e) { } catch (Error e) {
debug("Error selecting first inbox: %s", e.message); debug("Error selecting first inbox: %s", e.message);

View file

@ -106,7 +106,7 @@ public class ConversationListStore : Gtk.ListStore {
if (conversation_lowest == null) if (conversation_lowest == null)
continue; continue;
if (lowest_id == null || conversation_lowest.compare(lowest_id) < 0) if (lowest_id == null || conversation_lowest.compare_to(lowest_id) < 0)
lowest_id = conversation_lowest; lowest_id = conversation_lowest;
} while (iter_next(ref iter)); } while (iter_next(ref iter));
@ -227,13 +227,11 @@ public class ConversationListStore : Gtk.ListStore {
// sort the conversations so the previews are fetched from the newest to the oldest, matching // sort the conversations so the previews are fetched from the newest to the oldest, matching
// the user experience // the user experience
Gee.TreeSet<Geary.Conversation> sorted_conversations = new Geary.Collection.FixedTreeSet<Geary.Conversation>( Gee.TreeSet<Geary.Conversation> sorted_conversations = new Geary.Collection.FixedTreeSet<Geary.Conversation>(
(CompareFunc) compare_conversation_descending); compare_conversation_descending);
sorted_conversations.add_all(conversation_monitor.get_conversations()); sorted_conversations.add_all(conversation_monitor.get_conversations());
folder_emails = new Gee.HashSet<Geary.EmailIdentifier>( folder_emails = new Gee.HashSet<Geary.EmailIdentifier>();
Geary.Hashable.hash_func, Geary.Equalable.equal_func); account_emails = new Gee.HashSet<Geary.EmailIdentifier>();
account_emails = new Gee.HashSet<Geary.EmailIdentifier>(
Geary.Hashable.hash_func, Geary.Equalable.equal_func);
foreach (Geary.Conversation conversation in sorted_conversations) { foreach (Geary.Conversation conversation in sorted_conversations) {
Geary.Email? need_preview = conversation.get_latest_email(); Geary.Email? need_preview = conversation.get_latest_email();
if (need_preview == null) if (need_preview == null)
@ -243,7 +241,7 @@ public class ConversationListStore : Gtk.ListStore {
// if all preview fields present and it's the same email, don't need to refresh // if all preview fields present and it's the same email, don't need to refresh
if (current_preview != null if (current_preview != null
&& need_preview.id.equals(current_preview.id) && need_preview.id.equal_to(current_preview.id)
&& current_preview.fields.is_all_set(ConversationListStore.WITH_PREVIEW_FIELDS)) { && current_preview.fields.is_all_set(ConversationListStore.WITH_PREVIEW_FIELDS)) {
continue; continue;
} }
@ -301,7 +299,7 @@ public class ConversationListStore : Gtk.ListStore {
FormattedConversationData? existing_message_data = get_message_data_at_iter(iter); FormattedConversationData? existing_message_data = get_message_data_at_iter(iter);
if (existing_message_data == null || !existing_message_data.preview.id.equals(last_email.id)) { if (existing_message_data == null || !existing_message_data.preview.id.equal_to(last_email.id)) {
set_row(iter, conversation, last_email); set_row(iter, conversation, last_email);
} else if (existing_message_data != null && } else if (existing_message_data != null &&
existing_message_data.num_emails != conversation.get_count()) { existing_message_data.num_emails != conversation.get_count()) {

View file

@ -19,8 +19,7 @@ public class NewMessagesMonitor : Geary.BaseObject {
public Cancellable? cancellable = null; public Cancellable? cancellable = null;
public int count = 0; public int count = 0;
public Gee.HashSet<Geary.EmailIdentifier> new_ids public Gee.HashSet<Geary.EmailIdentifier> new_ids
= new Gee.HashSet<Geary.EmailIdentifier>( = new Gee.HashSet<Geary.EmailIdentifier>();
Geary.Hashable.hash_func, Geary.Equalable.equal_func);
public MonitorInformation(Geary.Folder folder, Cancellable? cancellable) { public MonitorInformation(Geary.Folder folder, Cancellable? cancellable) {
this.folder = folder; this.folder = folder;
@ -180,7 +179,7 @@ public class NewMessagesMonitor : Geary.BaseObject {
MonitorInformation info = folder_information.get(folder); MonitorInformation info = folder_information.get(folder);
foreach (Geary.EmailIdentifier email_id in email_ids) { foreach (Geary.EmailIdentifier email_id in email_ids) {
if (last_new_message != null && last_new_message.id.equals(email_id)) { if (last_new_message != null && last_new_message.id.equal_to(email_id)) {
last_new_message_folder = null; last_new_message_folder = null;
last_new_message = null; last_new_message = null;
} }

View file

@ -48,16 +48,13 @@ public class Sidebar.Branch : Object {
this.comparator = comparator; this.comparator = comparator;
} }
private static int comparator_wrapper(void *a, void *b) { private static int comparator_wrapper(Node anode, Node bnode) {
if (a == b) if (anode == bnode)
return 0; return 0;
Node *anode = (Node *) a; assert(anode.parent == bnode.parent);
Node *bnode = (Node *) b;
assert(anode->parent == bnode->parent); return anode.parent.comparator(anode.entry, bnode.entry);
return anode->parent.comparator(anode->entry, bnode->entry);
} }
public bool has_children() { public bool has_children() {

View file

@ -24,7 +24,7 @@ public class FolderMenu : GtkUtil.ToggleToolbarDropdown {
public void add_folder(Geary.Folder folder) { public void add_folder(Geary.Folder folder) {
folder_list.add(folder); folder_list.add(folder);
folder_list.sort((CompareFunc) folder_sort); folder_list.sort(folder_sort);
int index = folder_list.index_of(folder); int index = folder_list.index_of(folder);
menu.insert(build_menu_item(folder), index); menu.insert(build_menu_item(folder), index);
@ -65,7 +65,7 @@ public class FolderMenu : GtkUtil.ToggleToolbarDropdown {
} }
private static int folder_sort(Geary.Folder a, Geary.Folder b) { private static int folder_sort(Geary.Folder a, Geary.Folder b) {
return a.get_path().compare(b.get_path()); return a.get_path().compare_to(b.get_path());
} }
} }

View file

@ -42,7 +42,7 @@ public class ConversationViewer : Gtk.Box {
// List of emails in this view. // List of emails in this view.
public Gee.TreeSet<Geary.Email> messages { get; private set; default = public Gee.TreeSet<Geary.Email> messages { get; private set; default =
new Geary.Collection.FixedTreeSet<Geary.Email>((CompareFunc<Geary.Email>) Geary.Email.compare_date_ascending); } new Geary.Collection.FixedTreeSet<Geary.Email>(Geary.Email.compare_date_ascending); }
// The HTML viewer to view the emails. // The HTML viewer to view the emails.
public ConversationWebView web_view { get; private set; } public ConversationWebView web_view { get; private set; }
@ -52,8 +52,7 @@ public class ConversationViewer : Gtk.Box {
// Maps emails to their corresponding elements. // Maps emails to their corresponding elements.
private Gee.HashMap<Geary.EmailIdentifier, WebKit.DOM.HTMLElement> email_to_element = new private Gee.HashMap<Geary.EmailIdentifier, WebKit.DOM.HTMLElement> email_to_element = new
Gee.HashMap<Geary.EmailIdentifier, WebKit.DOM.HTMLElement>(Geary.Hashable.hash_func, Gee.HashMap<Geary.EmailIdentifier, WebKit.DOM.HTMLElement>();
Geary.Equalable.equal_func);
private string? hover_url = null; private string? hover_url = null;
private Gtk.Menu? context_menu = null; private Gtk.Menu? context_menu = null;
@ -472,7 +471,7 @@ public class ConversationViewer : Gtk.Box {
// Update the flags in our message set. // Update the flags in our message set.
foreach (Geary.Email message in messages) { foreach (Geary.Email message in messages) {
if (message.id.equals(email.id)) { if (message.id.equal_to(email.id)) {
message.set_flags(flags); message.set_flags(flags);
break; break;
} }

View file

@ -19,7 +19,7 @@ public class FormattedConversationData : Geary.BaseObject {
private const int FONT_SIZE_PREVIEW = 8; private const int FONT_SIZE_PREVIEW = 8;
private const int FONT_SIZE_MESSAGE_COUNT = 8; private const int FONT_SIZE_MESSAGE_COUNT = 8;
private class ParticipantDisplay : Geary.BaseObject, Geary.Equalable { private class ParticipantDisplay : Geary.BaseObject, Gee.Hashable<ParticipantDisplay> {
public string key; public string key;
public Geary.RFC822.MailboxAddress address; public Geary.RFC822.MailboxAddress address;
public bool is_unread; public bool is_unread;
@ -65,16 +65,16 @@ public class FormattedConversationData : Geary.BaseObject {
is_unread ? "<b>" : "", Geary.HTML.escape_markup(participant), is_unread ? "</b>" : ""); is_unread ? "<b>" : "", Geary.HTML.escape_markup(participant), is_unread ? "</b>" : "");
} }
public bool equals(Geary.Equalable o) { public bool equal_to(ParticipantDisplay other) {
ParticipantDisplay? other = o as ParticipantDisplay;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
return key == other.key; return key == other.key;
} }
public uint hash() {
return key.hash();
}
} }
private static int cell_height = -1; private static int cell_height = -1;
@ -185,7 +185,7 @@ public class FormattedConversationData : Geary.BaseObject {
// Build chronological list of AuthorDisplay records, setting to unread if any message by // Build chronological list of AuthorDisplay records, setting to unread if any message by
// that author is unread // that author is unread
Gee.ArrayList<ParticipantDisplay> list = new Gee.ArrayList<ParticipantDisplay>(Geary.Equalable.equal_func); Gee.ArrayList<ParticipantDisplay> list = new Gee.ArrayList<ParticipantDisplay>();
foreach (Geary.Email message in conversation.get_emails(Geary.Conversation.Ordering.DATE_ASCENDING)) { foreach (Geary.Email message in conversation.get_emails(Geary.Conversation.Ordering.DATE_ASCENDING)) {
// only display if something to display // only display if something to display
Geary.RFC822.MailboxAddresses? addresses = use_to ? message.to : message.from; Geary.RFC822.MailboxAddresses? addresses = use_to ? message.to : message.from;

View file

@ -7,11 +7,11 @@
namespace Geary.DBus { namespace Geary.DBus {
public uint db_email_hash(Geary.Email key) { public uint db_email_hash(Geary.Email key) {
return key.id.to_hash(); return key.id.hash();
} }
public bool db_email_equal(Geary.Email a, Geary.Email b) { public bool db_email_equal(Geary.Email a, Geary.Email b) {
return a.id.equals(b.id); return a.id.equal_to(b.id);
} }
} }

View file

@ -29,7 +29,7 @@ public class Geary.ComposedEmail : BaseObject {
public string? body_html { get; set; default = null; } public string? body_html { get; set; default = null; }
public string? mailer { get; set; default = null; } public string? mailer { get; set; default = null; }
public Gee.Set<File> attachment_files { get; private set; public Gee.Set<File> attachment_files { get; private set;
default = new Gee.HashSet<File>(File.hash, (EqualFunc) File.equal); } default = new Gee.HashSet<File>(Geary.Files.nullable_hash, Geary.Files.nullable_equal); }
public ComposedEmail(DateTime date, RFC822.MailboxAddresses from, public ComposedEmail(DateTime date, RFC822.MailboxAddresses from,
RFC822.MailboxAddresses? to = null, RFC822.MailboxAddresses? cc = null, RFC822.MailboxAddresses? to = null, RFC822.MailboxAddresses? cc = null,

View file

@ -19,18 +19,16 @@ public class Geary.ConversationMonitor : BaseObject {
private int convnum; private int convnum;
private weak Geary.ConversationMonitor? owner; private weak Geary.ConversationMonitor? owner;
private Gee.HashMap<EmailIdentifier, Email> emails = new Gee.HashMap<EmailIdentifier, Email>( private Gee.HashMap<EmailIdentifier, Email> emails = new Gee.HashMap<EmailIdentifier, Email>();
Hashable.hash_func, Equalable.equal_func); private Gee.HashMultiSet<RFC822.MessageID> message_ids = new Gee.HashMultiSet<RFC822.MessageID>();
private Gee.HashMultiSet<RFC822.MessageID> message_ids = new Gee.HashMultiSet<RFC822.MessageID>(
Hashable.hash_func, Equalable.equal_func);
private Geary.EmailIdentifier? lowest_id; private Geary.EmailIdentifier? lowest_id;
// this isn't ideal but the cost of adding an email to multiple sorted sets once versus // this isn't ideal but the cost of adding an email to multiple sorted sets once versus
// the number of times they're accessed makes it worth it // the number of times they're accessed makes it worth it
private Gee.SortedSet<Email> date_ascending = new Collection.FixedTreeSet<Email>( private Gee.SortedSet<Email> date_ascending = new Collection.FixedTreeSet<Email>(
(CompareFunc) compare_date_ascending); Geary.Email.compare_date_ascending);
private Gee.SortedSet<Email> date_descending = new Collection.FixedTreeSet<Email>( private Gee.SortedSet<Email> date_descending = new Collection.FixedTreeSet<Email>(
(CompareFunc) compare_date_descending); Geary.Email.compare_date_descending);
public ImplConversation(Geary.ConversationMonitor owner) { public ImplConversation(Geary.ConversationMonitor owner) {
convnum = next_convnum++; convnum = next_convnum++;
@ -114,8 +112,7 @@ public class Geary.ConversationMonitor : BaseObject {
date_ascending.remove(email); date_ascending.remove(email);
date_descending.remove(email); date_descending.remove(email);
Gee.Set<RFC822.MessageID> removed_message_ids = new Gee.HashSet<RFC822.MessageID>( Gee.Set<RFC822.MessageID> removed_message_ids = new Gee.HashSet<RFC822.MessageID>();
Hashable.hash_func, Equalable.equal_func);
Gee.Set<RFC822.MessageID>? ancestors = email.get_ancestors(); Gee.Set<RFC822.MessageID>? ancestors = email.get_ancestors();
if (ancestors != null) { if (ancestors != null) {
@ -135,30 +132,10 @@ public class Geary.ConversationMonitor : BaseObject {
} }
private void check_lowest_id(EmailIdentifier id) { private void check_lowest_id(EmailIdentifier id) {
if (id.get_folder_path() != null && (lowest_id == null || id.compare(lowest_id) < 0)) if (id.get_folder_path() != null && (lowest_id == null || id.compare_to(lowest_id) < 0))
lowest_id = id; lowest_id = id;
} }
private static int compare_date_ascending(Email a, Email b) {
int diff = a.date.value.compare(b.date.value);
// stabilize the sort if the same date
return (diff != 0) ? diff : compare_id_ascending(a, b);
}
private static int compare_date_descending(Email a, Email b) {
return compare_date_ascending(b, a);
}
private static int compare_id_ascending(Email a, Email b) {
// Arbitrarily, "account" email ids come after "folder" email ids.
if (a.id.get_folder_path() == null && b.id.get_folder_path() != null)
return 1;
if (a.id.get_folder_path() != null && b.id.get_folder_path() == null)
return -1;
return a.id.compare(b.id);
}
public string to_string() { public string to_string() {
return "[#%d] (%d emails)".printf(convnum, emails.size); return "[#%d] (%d emails)".printf(convnum, emails.size);
} }
@ -198,9 +175,9 @@ public class Geary.ConversationMonitor : BaseObject {
private bool readonly; private bool readonly;
private Gee.Set<ImplConversation> conversations = new Gee.HashSet<ImplConversation>(); private Gee.Set<ImplConversation> conversations = new Gee.HashSet<ImplConversation>();
private Gee.HashMap<Geary.EmailIdentifier, ImplConversation> geary_id_map = new Gee.HashMap< private Gee.HashMap<Geary.EmailIdentifier, ImplConversation> geary_id_map = new Gee.HashMap<
Geary.EmailIdentifier, ImplConversation>(Hashable.hash_func, Equalable.equal_func); Geary.EmailIdentifier, ImplConversation>();
private Gee.HashMap<Geary.RFC822.MessageID, ImplConversation> message_id_map = new Gee.HashMap< private Gee.HashMap<Geary.RFC822.MessageID, ImplConversation> message_id_map = new Gee.HashMap<
Geary.RFC822.MessageID, ImplConversation>(Hashable.hash_func, Equalable.equal_func); Geary.RFC822.MessageID, ImplConversation>();
private Cancellable? cancellable_monitor = null; private Cancellable? cancellable_monitor = null;
private bool retry_connection = false; private bool retry_connection = false;
private int64 last_retry_time = 0; private int64 last_retry_time = 0;
@ -562,8 +539,7 @@ public class Geary.ConversationMonitor : BaseObject {
folder.to_string(), emails.size); folder.to_string(), emails.size);
// MessageIDs we're adding to each conversation. // MessageIDs we're adding to each conversation.
Gee.HashSet<RFC822.MessageID> new_message_ids = new Gee.HashSet<RFC822.MessageID>( Gee.HashSet<RFC822.MessageID> new_message_ids = new Gee.HashSet<RFC822.MessageID>();
Hashable.hash_func, Equalable.equal_func);
Gee.HashSet<Conversation> new_conversations = new Gee.HashSet<Conversation>(); Gee.HashSet<Conversation> new_conversations = new Gee.HashSet<Conversation>();
Gee.MultiMap<Conversation, Geary.Email> appended_conversations = new Gee.HashMultiMap< Gee.MultiMap<Conversation, Geary.Email> appended_conversations = new Gee.HashMultiMap<
@ -649,7 +625,7 @@ public class Geary.ConversationMonitor : BaseObject {
}; };
Gee.ArrayList<Geary.FolderPath?> blacklist Gee.ArrayList<Geary.FolderPath?> blacklist
= new Gee.ArrayList<Geary.FolderPath?>(Equalable.nullable_equal_func); = new Gee.ArrayList<Geary.FolderPath?>();
foreach (Geary.SpecialFolderType type in blacklisted_folder_types) { foreach (Geary.SpecialFolderType type in blacklisted_folder_types) {
try { try {
Geary.Folder? blacklist_folder = folder.account.get_special_folder(type); Geary.Folder? blacklist_folder = folder.account.get_special_folder(type);
@ -699,7 +675,7 @@ public class Geary.ConversationMonitor : BaseObject {
// collect their results into a single collection of addt'l emails // collect their results into a single collection of addt'l emails
Gee.HashMap<Geary.EmailIdentifier, Geary.Email> needed_messages = new Gee.HashMap< Gee.HashMap<Geary.EmailIdentifier, Geary.Email> needed_messages = new Gee.HashMap<
Geary.EmailIdentifier, Geary.Email>(Hashable.hash_func, Equalable.equal_func); Geary.EmailIdentifier, Geary.Email>();
foreach (int id in batch.get_ids()) { foreach (int id in batch.get_ids()) {
LocalSearchOperation op = (LocalSearchOperation) batch.get_operation(id); LocalSearchOperation op = (LocalSearchOperation) batch.get_operation(id);
if (op.emails != null) { if (op.emails != null) {
@ -806,7 +782,7 @@ public class Geary.ConversationMonitor : BaseObject {
Geary.EmailIdentifier? earliest_id = null; Geary.EmailIdentifier? earliest_id = null;
foreach (Geary.Conversation conversation in conversations) { foreach (Geary.Conversation conversation in conversations) {
Geary.EmailIdentifier? id = conversation.get_lowest_email_id(); Geary.EmailIdentifier? id = conversation.get_lowest_email_id();
if (id != null && (earliest_id == null || id.compare(earliest_id) < 0)) if (id != null && (earliest_id == null || id.compare_to(earliest_id) < 0))
earliest_id = id; earliest_id = id;
} }

View file

@ -18,7 +18,7 @@
* in the background and asking the user to reauthenticate each time is deemed inconvenient. * in the background and asking the user to reauthenticate each time is deemed inconvenient.
*/ */
public class Geary.Credentials : BaseObject, Geary.Equalable { public class Geary.Credentials : BaseObject, Gee.Hashable<Geary.Credentials> {
public string? user { get; set; } public string? user { get; set; }
public string? pass { get; set; } public string? pass { get; set; }
@ -43,15 +43,15 @@ public class Geary.Credentials : BaseObject, Geary.Equalable {
return user; return user;
} }
public bool equals(Equalable other) { public bool equal_to(Geary.Credentials c) {
Geary.Credentials? c = other as Geary.Credentials;
if (c == null)
return false;
if (this == c) if (this == c)
return true; return true;
return user == c.user && pass == c.pass; return user == c.user && pass == c.pass;
} }
public uint hash() {
return to_string().hash();
}
} }

View file

@ -4,25 +4,21 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
public class Geary.EmailFlag : BaseObject, Geary.Equalable, Geary.Hashable { public class Geary.EmailFlag : BaseObject, Gee.Hashable<Geary.EmailFlag> {
private string name; private string name;
public EmailFlag(string name) { public EmailFlag(string name) {
this.name = name; this.name = name;
} }
public bool equals(Equalable o) { public bool equal_to(Geary.EmailFlag other) {
EmailFlag? other = o as EmailFlag;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
return name.down() == other.name.down(); return name.down() == other.name.down();
} }
public uint to_hash() { public uint hash() {
return name.down().hash(); return name.down().hash();
} }

View file

@ -4,7 +4,7 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
public class Geary.EmailFlags : BaseObject, Geary.Equalable { public class Geary.EmailFlags : BaseObject, Gee.Hashable<Geary.EmailFlags> {
private static EmailFlag? _unread = null; private static EmailFlag? _unread = null;
public static EmailFlag UNREAD { get { public static EmailFlag UNREAD { get {
if (_unread == null) if (_unread == null)
@ -21,7 +21,7 @@ public class Geary.EmailFlags : BaseObject, Geary.Equalable {
return _flagged; return _flagged;
} } } }
private Gee.Set<EmailFlag> list = new Gee.HashSet<EmailFlag>(Hashable.hash_func, Equalable.equal_func); private Gee.Set<EmailFlag> list = new Gee.HashSet<EmailFlag>();
public virtual signal void added(Gee.Collection<EmailFlag> flags) { public virtual signal void added(Gee.Collection<EmailFlag> flags) {
} }
@ -96,11 +96,7 @@ public class Geary.EmailFlags : BaseObject, Geary.Equalable {
return contains(FLAGGED); return contains(FLAGGED);
} }
public bool equals(Equalable o) { public bool equal_to(Geary.EmailFlags other) {
Geary.EmailFlags? other = o as Geary.EmailFlags;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
@ -115,6 +111,10 @@ public class Geary.EmailFlags : BaseObject, Geary.Equalable {
return true; return true;
} }
public uint hash() {
return Geary.String.stri_hash(to_string());
}
public string to_string() { public string to_string() {
string ret = "["; string ret = "[";
foreach (EmailFlag flag in list) { foreach (EmailFlag flag in list) {

View file

@ -23,7 +23,8 @@
* passed to equals() and compare(). This may be added in the future. * passed to equals() and compare(). This may be added in the future.
*/ */
public abstract class Geary.EmailIdentifier : BaseObject, Geary.Equalable, Geary.Comparable, Geary.Hashable { public abstract class Geary.EmailIdentifier : BaseObject, Gee.Comparable<Geary.EmailIdentifier>,
Gee.Hashable<Geary.EmailIdentifier> {
public int64 ordering { get; protected set; } public int64 ordering { get; protected set; }
protected EmailIdentifier(int64 ordering) { protected EmailIdentifier(int64 ordering) {
@ -36,19 +37,15 @@ public abstract class Geary.EmailIdentifier : BaseObject, Geary.Equalable, Geary
return null; return null;
} }
public virtual uint to_hash() { public virtual uint hash() {
return Geary.Hashable.int64_hash(ordering); return Geary.Collection.int64_hash(ordering);
} }
// Virtual default implementation not provided because base class *must* verify that the // Virtual default implementation not provided because base class *must* verify that the
// Equalable is of its own type. // Equalable is of its own type.
public abstract bool equals(Geary.Equalable other); public abstract bool equal_to(Geary.EmailIdentifier e);
public virtual int compare(Geary.Comparable o) { public virtual int compare_to(Geary.EmailIdentifier other) {
Geary.EmailIdentifier? other = o as Geary.EmailIdentifier;
if (other == null)
return -1;
if (this == other) if (this == other)
return 0; return 0;

View file

@ -287,8 +287,7 @@ public class Geary.Email : BaseObject {
* this method to return a complete list. * this method to return a complete list.
*/ */
public Gee.Set<RFC822.MessageID>? get_ancestors() { public Gee.Set<RFC822.MessageID>? get_ancestors() {
Gee.Set<RFC822.MessageID> ancestors = new Gee.HashSet<RFC822.MessageID>( Gee.Set<RFC822.MessageID> ancestors = new Gee.HashSet<RFC822.MessageID>();
Hashable.hash_func, Equalable.equal_func);
// the email's Message-ID counts as its lineage // the email's Message-ID counts as its lineage
if (message_id != null) if (message_id != null)
@ -348,50 +347,47 @@ public class Geary.Email : BaseObject {
* CompareFunc to sort Email by date. If the date field is not available on both Emails, their * CompareFunc to sort Email by date. If the date field is not available on both Emails, their
* identifiers are compared. * identifiers are compared.
*/ */
public static int compare_date_ascending(void* a, void *b) { public static int compare_date_ascending(Geary.Email aemail, Geary.Email bemail) {
Geary.Email *aemail = (Geary.Email *) a;
Geary.Email *bemail = (Geary.Email *) b;
int diff = 0; int diff = 0;
if (aemail->date != null && bemail->date != null) if (aemail.date != null && bemail.date != null)
diff = aemail->date.value.compare(bemail->date.value); diff = aemail.date.value.compare(bemail.date.value);
// stabilize sort by using the mail's ordering, which is always unique in a folder // stabilize sort by using the mail's ordering, which is always unique in a folder
return (diff != 0) ? diff : aemail->id.compare(bemail->id); return (diff != 0) ? diff : aemail.id.compare_to(bemail.id);
} }
/** /**
* CompareFunc to sort Email by date. If the date field is not available on both Emails, their * CompareFunc to sort Email by date. If the date field is not available on both Emails, their
* identifiers are compared. * identifiers are compared.
*/ */
public static int compare_date_descending(void* a, void *b) { public static int compare_date_descending(Geary.Email aemail, Geary.Email bemail) {
return compare_date_ascending(b, a); return compare_date_ascending(bemail, aemail);
} }
/** /**
* CompareFunc to sort Email by EmailIdentifier. * CompareFunc to sort Email by EmailIdentifier.
*/ */
public static int compare_id_ascending(void* a, void *b) { public static int compare_id_ascending(Geary.Email aemail, Geary.Email bemail) {
return ((Email *) a)->id.compare(((Email *) b)->id); return aemail.id.compare_to(bemail.id);
} }
/** /**
* CompareFunc to sort Email by EmailIdentifier. * CompareFunc to sort Email by EmailIdentifier.
*/ */
public static int compare_id_descending(void* a, void *b) { public static int compare_id_descending(Geary.Email aemail, Geary.Email bemail) {
return compare_id_ascending(b, a); return compare_id_ascending(bemail, aemail);
} }
/** /**
* CompareFunc to sort Email by EmailProperties.total_bytes. If not available, emails are * CompareFunc to sort Email by EmailProperties.total_bytes. If not available, emails are
* compared by EmailIdentifier. * compared by EmailIdentifier.
*/ */
public static int compare_size_ascending(void *a, void *b) { public static int compare_size_ascending(Geary.Email aemail, Geary.Email bemail) {
Geary.EmailProperties? aprop = (Geary.EmailProperties) ((Geary.Email *) a)->properties; Geary.EmailProperties? aprop = (Geary.EmailProperties) aemail.properties;
Geary.EmailProperties? bprop = (Geary.EmailProperties) ((Geary.Email *) b)->properties; Geary.EmailProperties? bprop = (Geary.EmailProperties) bemail.properties;
if (aprop == null || bprop == null) if (aprop == null || bprop == null)
return compare_id_ascending(a, b); return compare_id_ascending(aemail, bemail);
long asize = aprop.total_bytes; long asize = aprop.total_bytes;
long bsize = bprop.total_bytes; long bsize = bprop.total_bytes;
@ -401,39 +397,36 @@ public class Geary.Email : BaseObject {
else if (asize > bsize) else if (asize > bsize)
return 1; return 1;
else else
return compare_id_ascending(a, b); return compare_id_ascending(aemail, bemail);
} }
/** /**
* CompareFunc to sort Email by EmailProperties.total_bytes. If not available, emails are * CompareFunc to sort Email by EmailProperties.total_bytes. If not available, emails are
* compared by EmailIdentifier. * compared by EmailIdentifier.
*/ */
public static int compare_size_descending(void *a, void *b) { public static int compare_size_descending(Geary.Email aemail, Geary.Email bemail) {
return compare_size_ascending(b, a); return compare_size_ascending(bemail, aemail);
} }
/** /**
* CompareFunc to sort Email by EmailProperties.date_received. If not available, emails are * CompareFunc to sort Email by EmailProperties.date_received. If not available, emails are
* compared by EmailIdentifier. * compared by EmailIdentifier.
*/ */
public static int compare_date_received_ascending(void *a, void *b) { public static int compare_date_received_ascending(Geary.Email aemail, Geary.Email bemail) {
Geary.Email aemail = (Geary.Email) a;
Geary.Email bemail = (Geary.Email) b;
if (aemail.properties == null || bemail.properties == null) if (aemail.properties == null || bemail.properties == null)
return compare_id_ascending(a, b); return compare_id_ascending(aemail, bemail);
int cmp = aemail.properties.date_received.compare(bemail.properties.date_received); int cmp = aemail.properties.date_received.compare(bemail.properties.date_received);
return (cmp != 0) ? cmp : compare_id_ascending(a, b); return (cmp != 0) ? cmp : compare_id_ascending(aemail, bemail);
} }
/** /**
* CompareFunc to sort Email by EmailProperties.date_received. If not available, emails are * CompareFunc to sort Email by EmailProperties.date_received. If not available, emails are
* compared by EmailIdentifier. * compared by EmailIdentifier.
*/ */
public static int compare_date_received_descending(void *a, void *b) { public static int compare_date_received_descending(Geary.Email aemail, Geary.Email bemail) {
return compare_date_received_ascending(b, a); return compare_date_received_ascending(bemail, aemail);
} }
} }

View file

@ -4,13 +4,14 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
public class Geary.FolderPath : BaseObject, Hashable, Equalable, Comparable { public class Geary.FolderPath : BaseObject, Gee.Hashable<Geary.FolderPath>,
Gee.Comparable<Geary.FolderPath> {
public string basename { get; private set; } public string basename { get; private set; }
private Gee.List<Geary.FolderPath>? path = null; private Gee.List<Geary.FolderPath>? path = null;
private string? fullpath = null; private string? fullpath = null;
private string? fullpath_separator = null; private string? fullpath_separator = null;
private uint hash = uint.MAX; private uint stored_hash = uint.MAX;
protected FolderPath(string basename) { protected FolderPath(string basename) {
assert(this is FolderRoot); assert(this is FolderRoot);
@ -123,11 +124,7 @@ public class Geary.FolderPath : BaseObject, Hashable, Equalable, Comparable {
* are less-than longer paths, assuming the path elements are equal up to the shorter path's * are less-than longer paths, assuming the path elements are equal up to the shorter path's
* length. * length.
*/ */
public int compare(Comparable o) { public int compare_to(Geary.FolderPath other) {
FolderPath? other = o as FolderPath;
if (other == null)
return -1;
if (this == other) if (this == other)
return 0; return 0;
@ -149,9 +146,9 @@ public class Geary.FolderPath : BaseObject, Hashable, Equalable, Comparable {
return this_list.size - other_list.size; return this_list.size - other_list.size;
} }
public uint to_hash() { public uint hash() {
if (hash != uint.MAX) if (stored_hash != uint.MAX)
return hash; return stored_hash;
bool cs = get_root().case_sensitive; bool cs = get_root().case_sensitive;
@ -162,23 +159,16 @@ public class Geary.FolderPath : BaseObject, Hashable, Equalable, Comparable {
for (int ctr = 1; ctr < path_length; ctr++) for (int ctr = 1; ctr < path_length; ctr++)
calc ^= get_folder_at(ctr).get_basename_hash(cs); calc ^= get_folder_at(ctr).get_basename_hash(cs);
hash = calc; stored_hash = calc;
return hash; return stored_hash;
} }
private bool is_basename_equal(string cmp, bool cs) { private bool is_basename_equal(string cmp, bool cs) {
return cs ? (basename == cmp) : (basename.down() == cmp.down()); return cs ? (basename == cmp) : (basename.down() == cmp.down());
} }
public bool equals(Equalable o) { public bool equal_to(Geary.FolderPath other) {
FolderPath? other = o as FolderPath;
if (o == null)
return false;
if (o == this)
return true;
int path_length = get_path_length(); int path_length = get_path_length();
if (other.get_path_length() != path_length) if (other.get_path_length() != path_length)
return false; return false;

View file

@ -28,8 +28,7 @@ public interface Geary.FolderSupportsArchive : Geary.Folder {
*/ */
public virtual async void archive_single_email_async(Geary.EmailIdentifier email_id, public virtual async void archive_single_email_async(Geary.EmailIdentifier email_id,
Cancellable? cancellable = null) throws Error { Cancellable? cancellable = null) throws Error {
Gee.ArrayList<Geary.EmailIdentifier> ids = new Gee.ArrayList<Geary.EmailIdentifier>( Gee.ArrayList<Geary.EmailIdentifier> ids = new Gee.ArrayList<Geary.EmailIdentifier>();
Equalable.equal_func);
ids.add(email_id); ids.add(email_id);
yield archive_email_async(ids, cancellable); yield archive_email_async(ids, cancellable);

View file

@ -26,8 +26,7 @@ public interface Geary.FolderSupportsMark : Geary.Folder {
public virtual async void mark_single_email_async(Geary.EmailIdentifier to_mark, public virtual async void mark_single_email_async(Geary.EmailIdentifier to_mark,
Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove, Geary.EmailFlags? flags_to_add, Geary.EmailFlags? flags_to_remove,
Cancellable? cancellable = null) throws Error { Cancellable? cancellable = null) throws Error {
Gee.ArrayList<Geary.EmailIdentifier> list = new Gee.ArrayList<Geary.EmailIdentifier>( Gee.ArrayList<Geary.EmailIdentifier> list = new Gee.ArrayList<Geary.EmailIdentifier>();
Equalable.equal_func);
list.add(to_mark); list.add(to_mark);
yield mark_email_async(list, flags_to_add, flags_to_remove, cancellable); yield mark_email_async(list, flags_to_add, flags_to_remove, cancellable);

View file

@ -29,8 +29,7 @@ public interface Geary.FolderSupportsRemove : Geary.Folder {
*/ */
public virtual async void remove_single_email_async(Geary.EmailIdentifier email_id, public virtual async void remove_single_email_async(Geary.EmailIdentifier email_id,
Cancellable? cancellable = null) throws Error { Cancellable? cancellable = null) throws Error {
Gee.ArrayList<Geary.EmailIdentifier> ids = new Gee.ArrayList<Geary.EmailIdentifier>( Gee.ArrayList<Geary.EmailIdentifier> ids = new Gee.ArrayList<Geary.EmailIdentifier>();
Equalable.equal_func);
ids.add(email_id); ids.add(email_id);
yield remove_email_async(ids, cancellable); yield remove_email_async(ids, cancellable);

View file

@ -18,10 +18,11 @@ public abstract class Geary.Common.MessageData : BaseObject {
public abstract string to_string(); public abstract string to_string();
} }
public abstract class Geary.Common.StringMessageData : Geary.Common.MessageData, Hashable, Equalable { public abstract class Geary.Common.StringMessageData : Geary.Common.MessageData,
Gee.Hashable<Geary.Common.StringMessageData> {
public string value { get; private set; } public string value { get; private set; }
private uint hash = uint.MAX; private uint stored_hash = uint.MAX;
public StringMessageData(string value) { public StringMessageData(string value) {
this.value = value; this.value = value;
@ -30,22 +31,18 @@ public abstract class Geary.Common.StringMessageData : Geary.Common.MessageData,
/** /**
* Default definition of equals is case-sensitive comparison. * Default definition of equals is case-sensitive comparison.
*/ */
public virtual bool equals(Equalable e) { public virtual bool equal_to(StringMessageData other) {
StringMessageData? other = e as StringMessageData;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
if (to_hash() != other.to_hash()) if (hash() != other.hash())
return false; return false;
return (value == other.value); return (value == other.value);
} }
public virtual uint to_hash() { public virtual uint hash() {
return (hash != uint.MAX) ? hash : (hash = str_hash(value)); return (stored_hash != uint.MAX) ? stored_hash : (stored_hash = str_hash(value));
} }
public override string to_string() { public override string to_string() {
@ -53,28 +50,24 @@ public abstract class Geary.Common.StringMessageData : Geary.Common.MessageData,
} }
} }
public abstract class Geary.Common.IntMessageData : Geary.Common.MessageData, Hashable, Equalable { public abstract class Geary.Common.IntMessageData : Geary.Common.MessageData, Gee.Hashable<Geary.Common.IntMessageData> {
public int value { get; private set; } public int value { get; private set; }
private uint hash = uint.MAX; private uint stored_hash = uint.MAX;
public IntMessageData(int value) { public IntMessageData(int value) {
this.value = value; this.value = value;
} }
public virtual bool equals(Equalable e) { public virtual bool equal_to(Geary.Common.IntMessageData other) {
IntMessageData? other = e as IntMessageData;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
return (value == other.value); return (value == other.value);
} }
public virtual uint to_hash() { public virtual uint hash() {
return (hash != uint.MAX) ? hash : (hash = int_hash(value)); return (stored_hash != uint.MAX) ? stored_hash : (stored_hash = int_hash(value));
} }
public override string to_string() { public override string to_string() {
@ -82,28 +75,25 @@ public abstract class Geary.Common.IntMessageData : Geary.Common.MessageData, Ha
} }
} }
public abstract class Geary.Common.LongMessageData : Geary.Common.MessageData, Hashable, Equalable { public abstract class Geary.Common.LongMessageData : Geary.Common.MessageData,
Gee.Hashable<Geary.Common.LongMessageData> {
public long value { get; private set; } public long value { get; private set; }
private uint hash = uint.MAX; private uint stored_hash = uint.MAX;
public LongMessageData(long value) { public LongMessageData(long value) {
this.value = value; this.value = value;
} }
public virtual bool equals(Equalable e) { public virtual bool equal_to(Geary.Common.LongMessageData other) {
LongMessageData? other = e as LongMessageData;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
return (value == other.value); return (value == other.value);
} }
public virtual uint to_hash() { public virtual uint hash() {
return (hash != uint.MAX) ? hash : (hash = int64_hash((int64) value)); return (stored_hash != uint.MAX) ? stored_hash : (stored_hash = int64_hash((int64) value));
} }
public override string to_string() { public override string to_string() {
@ -111,28 +101,25 @@ public abstract class Geary.Common.LongMessageData : Geary.Common.MessageData, H
} }
} }
public abstract class Geary.Common.Int64MessageData : Geary.Common.MessageData, Hashable, Equalable { public abstract class Geary.Common.Int64MessageData : Geary.Common.MessageData,
Gee.Hashable<Geary.Common.Int64MessageData> {
public int64 value { get; private set; } public int64 value { get; private set; }
private uint hash = uint.MAX; private uint stored_hash = uint.MAX;
public Int64MessageData(int64 value) { public Int64MessageData(int64 value) {
this.value = value; this.value = value;
} }
public virtual bool equals(Equalable e) { public virtual bool equal_to(Geary.Common.Int64MessageData other) {
Int64MessageData? other = e as Int64MessageData;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
return (value == other.value); return (value == other.value);
} }
public virtual uint to_hash() { public virtual uint hash() {
return (hash != uint.MAX) ? hash : (hash = int64_hash(value)); return (stored_hash != uint.MAX) ? stored_hash : (stored_hash = int64_hash(value));
} }
public override string to_string() { public override string to_string() {

View file

@ -22,7 +22,7 @@ private class Geary.ImapDB.Account : BaseObject {
private AccountInformation account_information; private AccountInformation account_information;
private ImapDB.Database? db = null; private ImapDB.Database? db = null;
private Gee.HashMap<Geary.FolderPath, FolderReference> folder_refs = private Gee.HashMap<Geary.FolderPath, FolderReference> folder_refs =
new Gee.HashMap<Geary.FolderPath, FolderReference>(Hashable.hash_func, Equalable.equal_func); new Gee.HashMap<Geary.FolderPath, FolderReference>();
public ContactStore contact_store { get; private set; } public ContactStore contact_store { get; private set; }
public Account(Geary.AccountInformation account_information) { public Account(Geary.AccountInformation account_information) {
@ -233,9 +233,9 @@ private class Geary.ImapDB.Account : BaseObject {
// TODO: A better solution here would be to only pull the FolderProperties if the Folder // TODO: A better solution here would be to only pull the FolderProperties if the Folder
// object itself doesn't already exist // object itself doesn't already exist
Gee.HashMap<Geary.FolderPath, int64?> id_map = new Gee.HashMap< Gee.HashMap<Geary.FolderPath, int64?> id_map = new Gee.HashMap<
Geary.FolderPath, int64?>(Hashable.hash_func, Equalable.equal_func); Geary.FolderPath, int64?>();
Gee.HashMap<Geary.FolderPath, Geary.Imap.FolderProperties> prop_map = new Gee.HashMap< Gee.HashMap<Geary.FolderPath, Geary.Imap.FolderProperties> prop_map = new Gee.HashMap<
Geary.FolderPath, Geary.Imap.FolderProperties>(Hashable.hash_func, Equalable.equal_func); Geary.FolderPath, Geary.Imap.FolderProperties>();
yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => { yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
int64 parent_id = Db.INVALID_ROWID; int64 parent_id = Db.INVALID_ROWID;
if (parent != null) { if (parent != null) {

View file

@ -9,7 +9,7 @@ private class Geary.ImapDB.EmailIdentifier : Geary.EmailIdentifier {
base (message_id); base (message_id);
} }
public override bool equals(Geary.Equalable o) { public override bool equal_to(Geary.EmailIdentifier o) {
Geary.ImapDB.EmailIdentifier? other = o as Geary.ImapDB.EmailIdentifier; Geary.ImapDB.EmailIdentifier? other = o as Geary.ImapDB.EmailIdentifier;
if (other == null) if (other == null)
return false; return false;

View file

@ -62,8 +62,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
private string account_owner_email; private string account_owner_email;
private int64 folder_id; private int64 folder_id;
private Geary.Imap.FolderProperties properties; private Geary.Imap.FolderProperties properties;
private Gee.HashSet<Geary.EmailIdentifier> marked_removed = new Gee.HashSet<Geary.EmailIdentifier>( private Gee.HashSet<Geary.EmailIdentifier> marked_removed = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func);
internal Folder(ImapDB.Database db, Geary.FolderPath path, ContactStore contact_store, internal Folder(ImapDB.Database db, Geary.FolderPath path, ContactStore contact_store,
string account_owner_email, int64 folder_id, Geary.Imap.FolderProperties properties) { string account_owner_email, int64 folder_id, Geary.Imap.FolderProperties properties) {
@ -660,7 +659,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
return null; return null;
Gee.HashMap<Geary.EmailIdentifier, Geary.Email.Field> map = new Gee.HashMap< Gee.HashMap<Geary.EmailIdentifier, Geary.Email.Field> map = new Gee.HashMap<
Geary.EmailIdentifier, Geary.Email.Field>(Hashable.hash_func, Equalable.equal_func); Geary.EmailIdentifier, Geary.Email.Field>();
// Break up the work // Break up the work
Gee.List<Geary.EmailIdentifier> list = new Gee.ArrayList<Geary.EmailIdentifier>(); Gee.List<Geary.EmailIdentifier> list = new Gee.ArrayList<Geary.EmailIdentifier>();
@ -1054,7 +1053,7 @@ private class Geary.ImapDB.Folder : BaseObject, Geary.ReferenceSemantics {
Db.Statement fetch_stmt = cx.prepare("SELECT flags FROM MessageTable WHERE id=?"); Db.Statement fetch_stmt = cx.prepare("SELECT flags FROM MessageTable WHERE id=?");
Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> map = new Gee.HashMap< Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> map = new Gee.HashMap<
Geary.EmailIdentifier, Geary.EmailFlags>(Hashable.hash_func, Equalable.equal_func); Geary.EmailIdentifier, Geary.EmailFlags>();
foreach (Geary.EmailIdentifier id in ids) { foreach (Geary.EmailIdentifier id in ids) {
int64 message_id = do_find_message(cx, id, ListFlags.NONE, cancellable); int64 message_id = do_find_message(cx, id, ListFlags.NONE, cancellable);

View file

@ -9,7 +9,7 @@ private class Geary.SmtpOutboxEmailIdentifier : Geary.EmailIdentifier {
base (ordering); base (ordering);
} }
public override bool equals(Geary.Equalable o) { public override bool equal_to(Geary.EmailIdentifier o) {
SmtpOutboxEmailIdentifier? other = o as SmtpOutboxEmailIdentifier; SmtpOutboxEmailIdentifier? other = o as SmtpOutboxEmailIdentifier;
if (other == null) if (other == null)
return false; return false;

View file

@ -413,7 +413,7 @@ private class Geary.SmtpOutboxFolder : Geary.AbstractFolder, Geary.FolderSupport
check_open(); check_open();
Gee.Map<Geary.EmailIdentifier, Geary.Email.Field> map = new Gee.HashMap< Gee.Map<Geary.EmailIdentifier, Geary.Email.Field> map = new Gee.HashMap<
Geary.EmailIdentifier, Geary.Email.Field>(Hashable.hash_func, Equalable.equal_func); Geary.EmailIdentifier, Geary.Email.Field>();
yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => { yield db.exec_transaction_async(Db.TransactionType.RO, (cx) => {
Db.Statement stmt = cx.prepare( Db.Statement stmt = cx.prepare(
"SELECT id FROM SmtpOutboxTable WHERE ordering=?"); "SELECT id FROM SmtpOutboxTable WHERE ordering=?");

View file

@ -41,8 +41,7 @@ private class Geary.ImapEngine.GmailAccount : Geary.ImapEngine.GenericAccount {
base (name, account_information, remote, local); base (name, account_information, remote, local);
if (path_type_map == null) { if (path_type_map == null) {
path_type_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>( path_type_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>();
Hashable.hash_func, Equalable.equal_func);
path_type_map.set(new Geary.FolderRoot(Imap.Account.INBOX_NAME, Imap.Account.ASSUMED_SEPARATOR, path_type_map.set(new Geary.FolderRoot(Imap.Account.INBOX_NAME, Imap.Account.ASSUMED_SEPARATOR,
Imap.Folder.CASE_SENSITIVE), SpecialFolderType.INBOX); Imap.Folder.CASE_SENSITIVE), SpecialFolderType.INBOX);

View file

@ -120,7 +120,7 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
return cmp; return cmp;
// sort by path to stabilize the sort // sort by path to stabilize the sort
return a.get_path().compare(b.get_path()); return a.get_path().compare_to(b.get_path());
} }
// Lower the score, the higher the importance. // Lower the score, the higher the importance.

View file

@ -109,7 +109,7 @@ private class Geary.ImapEngine.EmailFlagWatcher : BaseObject {
// Get all email identifiers in the local folder; also, update the low and count arguments // Get all email identifiers in the local folder; also, update the low and count arguments
Gee.HashMap<Geary.EmailIdentifier, Geary.EmailFlags> local_map = new Gee.HashMap< Gee.HashMap<Geary.EmailIdentifier, Geary.EmailFlags> local_map = new Gee.HashMap<
Geary.EmailIdentifier, Geary.EmailFlags>(Geary.Hashable.hash_func, Geary.Equalable.equal_func); Geary.EmailIdentifier, Geary.EmailFlags>();
foreach (Geary.Email e in list_local) { foreach (Geary.Email e in list_local) {
if (low == -1) if (low == -1)
low = e.position; low = e.position;
@ -131,13 +131,12 @@ private class Geary.ImapEngine.EmailFlagWatcher : BaseObject {
// Build map of emails that have changed. // Build map of emails that have changed.
Gee.HashMap<Geary.EmailIdentifier, Geary.EmailFlags> changed_map = Gee.HashMap<Geary.EmailIdentifier, Geary.EmailFlags> changed_map =
new Gee.HashMap<Geary.EmailIdentifier, Geary.EmailFlags>(Geary.Hashable.hash_func, new Gee.HashMap<Geary.EmailIdentifier, Geary.EmailFlags>();
Geary.Equalable.equal_func);
foreach (Geary.Email e in list_remote) { foreach (Geary.Email e in list_remote) {
if (!local_map.has_key(e.id)) if (!local_map.has_key(e.id))
continue; continue;
if (!local_map.get(e.id).equals(e.email_flags)) if (!local_map.get(e.id).equal_to(e.email_flags))
changed_map.set(e.id, e.email_flags); changed_map.set(e.id, e.email_flags);
} }

View file

@ -20,8 +20,7 @@ public class Geary.ImapEngine.EmailPrefetcher : Object {
private unowned Geary.Folder folder; private unowned Geary.Folder folder;
private int start_delay_sec; private int start_delay_sec;
private NonblockingMutex mutex = new NonblockingMutex(); private NonblockingMutex mutex = new NonblockingMutex();
private Gee.HashSet<Geary.EmailIdentifier> prefetch_ids = new Gee.HashSet<Geary.EmailIdentifier>( private Gee.HashSet<Geary.EmailIdentifier> prefetch_ids = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func);
private uint schedule_id = 0; private uint schedule_id = 0;
private Cancellable cancellable = new Cancellable(); private Cancellable cancellable = new Cancellable();
@ -119,8 +118,7 @@ public class Geary.ImapEngine.EmailPrefetcher : Object {
low = Numeric.int_floor(low - PREFETCH_CHUNKS, 1); low = Numeric.int_floor(low - PREFETCH_CHUNKS, 1);
Gee.HashSet<Geary.EmailIdentifier> ids = new Gee.HashSet<Geary.EmailIdentifier>( Gee.HashSet<Geary.EmailIdentifier> ids = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func);
foreach (Geary.Email email in list) foreach (Geary.Email email in list)
ids.add(email.id); ids.add(email.id);
@ -176,7 +174,7 @@ public class Geary.ImapEngine.EmailPrefetcher : Object {
private async void do_prefetch_batch() throws Error { private async void do_prefetch_batch() throws Error {
// snarf up all requested EmailIdentifiers for this round // snarf up all requested EmailIdentifiers for this round
Gee.HashSet<Geary.EmailIdentifier> ids = prefetch_ids; Gee.HashSet<Geary.EmailIdentifier> ids = prefetch_ids;
prefetch_ids = new Gee.HashSet<Geary.EmailIdentifier>(Hashable.hash_func, Equalable.equal_func); prefetch_ids = new Gee.HashSet<Geary.EmailIdentifier>();
if (ids.size == 0) if (ids.size == 0)
return; return;

View file

@ -14,11 +14,10 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
private ImapDB.Account local; private ImapDB.Account local;
private bool open = false; private bool open = false;
private Gee.HashMap<FolderPath, Imap.FolderProperties> properties_map = new Gee.HashMap< private Gee.HashMap<FolderPath, Imap.FolderProperties> properties_map = new Gee.HashMap<
FolderPath, Imap.FolderProperties>(Hashable.hash_func, Equalable.equal_func); FolderPath, Imap.FolderProperties>();
private Gee.HashMap<FolderPath, GenericFolder> existing_folders = new Gee.HashMap< private Gee.HashMap<FolderPath, GenericFolder> existing_folders = new Gee.HashMap<
FolderPath, GenericFolder>(Hashable.hash_func, Equalable.equal_func); FolderPath, GenericFolder>();
private Gee.HashMap<FolderPath, Folder> local_only = new Gee.HashMap<FolderPath, Folder>( private Gee.HashMap<FolderPath, Folder> local_only = new Gee.HashMap<FolderPath, Folder>();
Hashable.hash_func, Equalable.equal_func);
private uint refresh_folder_timeout_id = 0; private uint refresh_folder_timeout_id = 0;
private bool in_refresh_enumerate = false; private bool in_refresh_enumerate = false;
private Cancellable refresh_cancellable = new Cancellable(); private Cancellable refresh_cancellable = new Cancellable();
@ -179,7 +178,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
foreach(FolderPath path in existing_folders.keys) { foreach(FolderPath path in existing_folders.keys) {
FolderPath? path_parent = path.get_parent(); FolderPath? path_parent = path.get_parent();
if ((parent == null && path_parent == null) || if ((parent == null && path_parent == null) ||
(parent != null && path_parent != null && path_parent.equals(parent))) { (parent != null && path_parent != null && path_parent.equal_to(parent))) {
matches.add(existing_folders.get(path)); matches.add(existing_folders.get(path));
} }
} }
@ -317,8 +316,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
} }
// update all remote folders properties in the local store and active in the system // update all remote folders properties in the local store and active in the system
Gee.HashSet<Geary.FolderPath> altered_paths = new Gee.HashSet<Geary.FolderPath>( Gee.HashSet<Geary.FolderPath> altered_paths = new Gee.HashSet<Geary.FolderPath>();
Hashable.hash_func, Equalable.equal_func);
foreach (Imap.Folder remote_folder in remote_folders) { foreach (Imap.Folder remote_folder in remote_folders) {
// only worry about alterations if the remote is openable // only worry about alterations if the remote is openable
if (remote_folder.get_properties().is_openable.is_possible()) { if (remote_folder.get_properties().is_openable.is_possible()) {
@ -347,14 +345,12 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.AbstractAccount {
} }
// Get local paths of all engine (local) folders // Get local paths of all engine (local) folders
Gee.Set<Geary.FolderPath> local_paths = new Gee.HashSet<Geary.FolderPath>( Gee.Set<Geary.FolderPath> local_paths = new Gee.HashSet<Geary.FolderPath>();
Geary.Hashable.hash_func, Geary.Equalable.equal_func);
foreach (Geary.Folder local_folder in engine_folders) foreach (Geary.Folder local_folder in engine_folders)
local_paths.add(local_folder.get_path()); local_paths.add(local_folder.get_path());
// Get remote paths of all remote folders // Get remote paths of all remote folders
Gee.Set<Geary.FolderPath> remote_paths = new Gee.HashSet<Geary.FolderPath>( Gee.Set<Geary.FolderPath> remote_paths = new Gee.HashSet<Geary.FolderPath>();
Geary.Hashable.hash_func, Geary.Equalable.equal_func);
foreach (Geary.Imap.Folder remote_folder in remote_folders) { foreach (Geary.Imap.Folder remote_folder in remote_folders) {
remote_paths.add(remote_folder.get_path()); remote_paths.add(remote_folder.get_path());

View file

@ -151,7 +151,7 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
Gee.Collection<Geary.EmailIdentifier> all_locally_appended_ids = new Gee.ArrayList<Geary.EmailIdentifier>(); Gee.Collection<Geary.EmailIdentifier> all_locally_appended_ids = new Gee.ArrayList<Geary.EmailIdentifier>();
Gee.Collection<Geary.EmailIdentifier> all_removed_ids = new Gee.ArrayList<Geary.EmailIdentifier>(); Gee.Collection<Geary.EmailIdentifier> all_removed_ids = new Gee.ArrayList<Geary.EmailIdentifier>();
Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> all_flags_changed = new Gee.HashMap<Geary.EmailIdentifier, Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> all_flags_changed = new Gee.HashMap<Geary.EmailIdentifier,
Geary.EmailFlags>(Hashable.hash_func, Equalable.equal_func); Geary.EmailFlags>();
Geary.Imap.EmailIdentifier current_start_id = new Geary.Imap.EmailIdentifier(earliest_uid, local_folder.get_path()); Geary.Imap.EmailIdentifier current_start_id = new Geary.Imap.EmailIdentifier(earliest_uid, local_folder.get_path());
for (;;) { for (;;) {
@ -218,7 +218,7 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
Geary.Imap.EmailFlags? local_email_flags = (Geary.Imap.EmailFlags) local_email.email_flags; Geary.Imap.EmailFlags? local_email_flags = (Geary.Imap.EmailFlags) local_email.email_flags;
Geary.Imap.EmailFlags remote_email_flags = (Geary.Imap.EmailFlags) remote_email.email_flags; Geary.Imap.EmailFlags remote_email_flags = (Geary.Imap.EmailFlags) remote_email.email_flags;
if ((local_email_flags == null) || !local_email_flags.equals(remote_email_flags)) { if ((local_email_flags == null) || !local_email_flags.equal_to(remote_email_flags)) {
// check before writebehind // check before writebehind
if (replay_queue.query_local_writebehind_operation(ReplayOperation.WritebehindOperation.UPDATE_FLAGS, if (replay_queue.query_local_writebehind_operation(ReplayOperation.WritebehindOperation.UPDATE_FLAGS,
remote_email.id, (Imap.EmailFlags) remote_email.email_flags)) { remote_email.id, (Imap.EmailFlags) remote_email.email_flags)) {
@ -364,8 +364,8 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
// if gone past both local and remote extremes, time to exit // if gone past both local and remote extremes, time to exit
// TODO: If UIDNEXT isn't available on server, will need to fetch the highest UID // TODO: If UIDNEXT isn't available on server, will need to fetch the highest UID
if (current_start_id.uid.compare(latest_uid) >= 0 if (current_start_id.uid.compare_to(latest_uid) >= 0
&& current_start_id.uid.compare(remote_properties.uid_next) >= 0) && current_start_id.uid.compare_to(remote_properties.uid_next) >= 0)
break; break;
} }
@ -618,10 +618,8 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
debug("do_replay_appended_messages %s: remote_count=%d new_remote_count=%d", to_string(), debug("do_replay_appended_messages %s: remote_count=%d new_remote_count=%d", to_string(),
remote_count, new_remote_count); remote_count, new_remote_count);
Gee.HashSet<Geary.EmailIdentifier> created = new Gee.HashSet<Geary.EmailIdentifier>( Gee.HashSet<Geary.EmailIdentifier> created = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func); Gee.HashSet<Geary.EmailIdentifier> appended = new Gee.HashSet<Geary.EmailIdentifier>();
Gee.HashSet<Geary.EmailIdentifier> appended = new Gee.HashSet<Geary.EmailIdentifier>(
Hashable.hash_func, Equalable.equal_func);
try { try {
// If remote doesn't fully open, then don't fire signal, as we'll be unable to // If remote doesn't fully open, then don't fire signal, as we'll be unable to
@ -1066,8 +1064,7 @@ private class Geary.ImapEngine.GenericFolder : Geary.AbstractFolder, Geary.Folde
int mutex_token = yield normalize_email_positions_mutex.claim_async(cancellable); int mutex_token = yield normalize_email_positions_mutex.claim_async(cancellable);
Gee.HashSet<Geary.EmailIdentifier> created_ids = new Gee.HashSet<Geary.EmailIdentifier>( Gee.HashSet<Geary.EmailIdentifier> created_ids = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func);
Error? error = null; Error? error = null;
try { try {
local_count = yield local_folder.get_email_count_async(ImapDB.Folder.ListFlags.NONE, local_count = yield local_folder.get_email_count_async(ImapDB.Folder.ListFlags.NONE,

View file

@ -6,8 +6,7 @@
private class Geary.ImapEngine.CopyEmail : Geary.ImapEngine.SendReplayOperation { private class Geary.ImapEngine.CopyEmail : Geary.ImapEngine.SendReplayOperation {
private GenericFolder engine; private GenericFolder engine;
private Gee.List<Geary.EmailIdentifier> to_copy = new Gee.ArrayList<Geary.EmailIdentifier>( private Gee.List<Geary.EmailIdentifier> to_copy = new Gee.ArrayList<Geary.EmailIdentifier>();
Equalable.equal_func);
private Geary.FolderPath destination; private Geary.FolderPath destination;
private Cancellable? cancellable; private Cancellable? cancellable;

View file

@ -6,8 +6,7 @@
private class Geary.ImapEngine.ExpungeEmail : Geary.ImapEngine.SendReplayOperation { private class Geary.ImapEngine.ExpungeEmail : Geary.ImapEngine.SendReplayOperation {
private GenericFolder engine; private GenericFolder engine;
private Gee.List<Geary.EmailIdentifier> to_remove = new Gee.ArrayList<EmailIdentifier>( private Gee.List<Geary.EmailIdentifier> to_remove = new Gee.ArrayList<EmailIdentifier>();
Equalable.equal_func);
private Cancellable? cancellable; private Cancellable? cancellable;
private int original_count = 0; private int original_count = 0;

View file

@ -84,7 +84,7 @@ private class Geary.ImapEngine.FetchEmail : Geary.ImapEngine.SendReplayOperation
public override bool query_local_writebehind_operation(ReplayOperation.WritebehindOperation op, public override bool query_local_writebehind_operation(ReplayOperation.WritebehindOperation op,
EmailIdentifier id, Imap.EmailFlags? flags) { EmailIdentifier id, Imap.EmailFlags? flags) {
if (!this.id.equals(id)) if (!this.id.equal_to(id))
return true; return true;
switch (op) { switch (op) {

View file

@ -73,8 +73,7 @@ private class Geary.ImapEngine.ListEmailBySparseID : Geary.ImapEngine.SendReplay
} }
private GenericFolder owner; private GenericFolder owner;
private Gee.HashSet<Geary.EmailIdentifier> ids = new Gee.HashSet<Geary.EmailIdentifier>( private Gee.HashSet<Geary.EmailIdentifier> ids = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func);
private Geary.Email.Field required_fields; private Geary.Email.Field required_fields;
private Folder.ListFlags flags; private Folder.ListFlags flags;
private bool local_only; private bool local_only;
@ -83,7 +82,7 @@ private class Geary.ImapEngine.ListEmailBySparseID : Geary.ImapEngine.SendReplay
private unowned EmailCallback cb; private unowned EmailCallback cb;
private Cancellable? cancellable; private Cancellable? cancellable;
private Gee.HashMultiMap<Geary.Email.Field, Geary.EmailIdentifier> unfulfilled = new Gee.HashMultiMap< private Gee.HashMultiMap<Geary.Email.Field, Geary.EmailIdentifier> unfulfilled = new Gee.HashMultiMap<
Geary.Email.Field, Geary.EmailIdentifier>(null, null, Hashable.hash_func, Equalable.equal_func); Geary.Email.Field, Geary.EmailIdentifier>();
public ListEmailBySparseID(GenericFolder owner, Gee.Collection<Geary.EmailIdentifier> ids, public ListEmailBySparseID(GenericFolder owner, Gee.Collection<Geary.EmailIdentifier> ids,
Geary.Email.Field required_fields, Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator, Geary.Email.Field required_fields, Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator,
@ -173,7 +172,7 @@ private class Geary.ImapEngine.ListEmailBySparseID : Geary.ImapEngine.SendReplay
if (accumulator != null) { if (accumulator != null) {
Gee.HashSet<Geary.Email> wb_removed = new Gee.HashSet<Geary.Email>(); Gee.HashSet<Geary.Email> wb_removed = new Gee.HashSet<Geary.Email>();
foreach (Geary.Email email in accumulator) { foreach (Geary.Email email in accumulator) {
if (email.id.equals(id)) if (email.id.equal_to(id))
wb_removed.add(email); wb_removed.add(email);
} }

View file

@ -55,7 +55,7 @@ private class Geary.ImapEngine.ListEmail : Geary.ImapEngine.SendReplayOperation
private Gee.List<Geary.Email>? local_list = null; private Gee.List<Geary.Email>? local_list = null;
private int local_list_size = 0; private int local_list_size = 0;
private Gee.HashMultiMap<Geary.Email.Field, Geary.EmailIdentifier> unfulfilled = new Gee.HashMultiMap< private Gee.HashMultiMap<Geary.Email.Field, Geary.EmailIdentifier> unfulfilled = new Gee.HashMultiMap<
Geary.Email.Field, Geary.EmailIdentifier>(null, null, Hashable.hash_func, Equalable.equal_func); Geary.Email.Field, Geary.EmailIdentifier>();
public ListEmail(GenericFolder engine, int low, int count, Geary.Email.Field required_fields, public ListEmail(GenericFolder engine, int low, int count, Geary.Email.Field required_fields,
Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator, EmailCallback? cb, Cancellable? cancellable) { Folder.ListFlags flags, Gee.List<Geary.Email>? accumulator, EmailCallback? cb, Cancellable? cancellable) {
@ -215,7 +215,7 @@ private class Geary.ImapEngine.ListEmail : Geary.ImapEngine.SendReplayOperation
if (accumulator != null) { if (accumulator != null) {
Gee.HashSet<Geary.Email> wb_removed = new Gee.HashSet<Geary.Email>(); Gee.HashSet<Geary.Email> wb_removed = new Gee.HashSet<Geary.Email>();
foreach (Geary.Email email in accumulator) { foreach (Geary.Email email in accumulator) {
if (email.id.equals(id)) if (email.id.equal_to(id))
wb_removed.add(email); wb_removed.add(email);
} }
@ -372,8 +372,7 @@ private class Geary.ImapEngine.ListEmail : Geary.ImapEngine.SendReplayOperation
assert(create_op.merged != null); assert(create_op.merged != null);
// report locally added (non-duplicate, not unknown) emails & collect emails post-merge // report locally added (non-duplicate, not unknown) emails & collect emails post-merge
Gee.HashSet<Geary.EmailIdentifier> created_ids = new Gee.HashSet<Geary.EmailIdentifier>( Gee.HashSet<Geary.EmailIdentifier> created_ids = new Gee.HashSet<Geary.EmailIdentifier>();
Hashable.hash_func, Equalable.equal_func);
foreach (Geary.Email email in create_op.created.keys) { foreach (Geary.Email email in create_op.created.keys) {
// true means created // true means created
if (create_op.created.get(email)) if (create_op.created.get(email))

View file

@ -6,8 +6,7 @@
private class Geary.ImapEngine.MarkEmail : Geary.ImapEngine.SendReplayOperation { private class Geary.ImapEngine.MarkEmail : Geary.ImapEngine.SendReplayOperation {
private GenericFolder engine; private GenericFolder engine;
private Gee.List<Geary.EmailIdentifier> to_mark = new Gee.ArrayList<Geary.EmailIdentifier>( private Gee.List<Geary.EmailIdentifier> to_mark = new Gee.ArrayList<Geary.EmailIdentifier>();
Equalable.equal_func);
private Geary.EmailFlags? flags_to_add; private Geary.EmailFlags? flags_to_add;
private Geary.EmailFlags? flags_to_remove; private Geary.EmailFlags? flags_to_remove;
private Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags>? original_flags = null; private Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags>? original_flags = null;

View file

@ -6,8 +6,7 @@
private class Geary.ImapEngine.MoveEmail : Geary.ImapEngine.SendReplayOperation { private class Geary.ImapEngine.MoveEmail : Geary.ImapEngine.SendReplayOperation {
private GenericFolder engine; private GenericFolder engine;
private Gee.List<Geary.EmailIdentifier> to_move = new Gee.ArrayList<Geary.EmailIdentifier>( private Gee.List<Geary.EmailIdentifier> to_move = new Gee.ArrayList<Geary.EmailIdentifier>();
Equalable.equal_func);
private Geary.FolderPath destination; private Geary.FolderPath destination;
private Cancellable? cancellable; private Cancellable? cancellable;
private int original_count = 0; private int original_count = 0;

View file

@ -38,8 +38,7 @@ private class Geary.ImapEngine.YahooAccount : Geary.ImapEngine.GenericAccount {
base (name, account_information, remote, local); base (name, account_information, remote, local);
if (special_map == null) { if (special_map == null) {
special_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>( special_map = new Gee.HashMap<Geary.FolderPath, Geary.SpecialFolderType>();
Hashable.hash_func, Equalable.equal_func);
special_map.set(new Geary.FolderRoot(Imap.Account.INBOX_NAME, Imap.Account.ASSUMED_SEPARATOR, false), special_map.set(new Geary.FolderRoot(Imap.Account.INBOX_NAME, Imap.Account.ASSUMED_SEPARATOR, false),
Geary.SpecialFolderType.INBOX); Geary.SpecialFolderType.INBOX);

View file

@ -19,10 +19,10 @@ public class Geary.Imap.EmailFlags : Geary.EmailFlags {
protected override void notify_added(Gee.Collection<EmailFlag> added) { protected override void notify_added(Gee.Collection<EmailFlag> added) {
foreach (EmailFlag flag in added) { foreach (EmailFlag flag in added) {
if (flag.equals(UNREAD)) if (flag.equal_to(UNREAD))
message_flags.remove(MessageFlag.SEEN); message_flags.remove(MessageFlag.SEEN);
if (flag.equals(FLAGGED)) if (flag.equal_to(FLAGGED))
message_flags.add(MessageFlag.FLAGGED); message_flags.add(MessageFlag.FLAGGED);
} }
@ -31,10 +31,10 @@ public class Geary.Imap.EmailFlags : Geary.EmailFlags {
protected override void notify_removed(Gee.Collection<EmailFlag> removed) { protected override void notify_removed(Gee.Collection<EmailFlag> removed) {
foreach (EmailFlag flag in removed) { foreach (EmailFlag flag in removed) {
if (flag.equals(UNREAD)) if (flag.equal_to(UNREAD))
message_flags.add(MessageFlag.SEEN); message_flags.add(MessageFlag.SEEN);
if (flag.equals(FLAGGED)) if (flag.equal_to(FLAGGED))
message_flags.remove(MessageFlag.FLAGGED); message_flags.remove(MessageFlag.FLAGGED);
} }

View file

@ -19,11 +19,11 @@ private class Geary.Imap.EmailIdentifier : Geary.EmailIdentifier {
return folder_path; return folder_path;
} }
public override uint to_hash() { public override uint hash() {
return uid.to_hash(); return uid.hash();
} }
public override bool equals(Equalable o) { public override bool equal_to(Geary.EmailIdentifier o) {
Geary.Imap.EmailIdentifier? other = o as Geary.Imap.EmailIdentifier; Geary.Imap.EmailIdentifier? other = o as Geary.Imap.EmailIdentifier;
if (other == null) if (other == null)
return false; return false;
@ -31,7 +31,7 @@ private class Geary.Imap.EmailIdentifier : Geary.EmailIdentifier {
if (this == other) if (this == other)
return true; return true;
return uid.equals(other.uid) && folder_path.equals(other.folder_path); return uid.equal_to(other.uid) && folder_path.equal_to(other.folder_path);
} }
public override string to_string() { public override string to_string() {

View file

@ -4,7 +4,7 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
public class Geary.Imap.EmailProperties : Geary.EmailProperties, Equalable { public class Geary.Imap.EmailProperties : Geary.EmailProperties, Gee.Hashable<Geary.Imap.EmailProperties> {
public InternalDate? internaldate { get; private set; } public InternalDate? internaldate { get; private set; }
public RFC822.Size? rfc822_size { get; private set; } public RFC822.Size? rfc822_size { get; private set; }
@ -15,11 +15,7 @@ public class Geary.Imap.EmailProperties : Geary.EmailProperties, Equalable {
this.rfc822_size = rfc822_size; this.rfc822_size = rfc822_size;
} }
public bool equals(Equalable e) { public bool equal_to(Geary.Imap.EmailProperties other) {
Imap.EmailProperties? other = e as Imap.EmailProperties;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
@ -34,6 +30,10 @@ public class Geary.Imap.EmailProperties : Geary.EmailProperties, Equalable {
return true; return true;
} }
public uint hash() {
return to_string().hash();
}
public override string to_string() { public override string to_string() {
return "internaldate:%s/size:%s".printf((internaldate != null) ? internaldate.to_string() : "(none)", return "internaldate:%s/size:%s".printf((internaldate != null) ? internaldate.to_string() : "(none)",
(rfc822_size != null) ? rfc822_size.to_string() : "(none)"); (rfc822_size != null) ? rfc822_size.to_string() : "(none)");

View file

@ -60,7 +60,7 @@ public class Geary.Imap.FolderProperties : Geary.FolderProperties {
*/ */
public Trillian have_contents_changed(Geary.Imap.FolderProperties other) { public Trillian have_contents_changed(Geary.Imap.FolderProperties other) {
// UIDNEXT changes indicate messages have been added, but not if they've been removed // UIDNEXT changes indicate messages have been added, but not if they've been removed
if (uid_next != null && other.uid_next != null && !uid_next.equals(other.uid_next)) if (uid_next != null && other.uid_next != null && !uid_next.equal_to(other.uid_next))
return Trillian.TRUE; return Trillian.TRUE;
// Gmail includes Chat messages in STATUS results but not in SELECT/EXAMINE // Gmail includes Chat messages in STATUS results but not in SELECT/EXAMINE

View file

@ -4,7 +4,7 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
public abstract class Geary.Imap.Flag : BaseObject, Equalable, Hashable { public abstract class Geary.Imap.Flag : BaseObject, Gee.Hashable<Geary.Imap.Flag> {
public string value { get; private set; } public string value { get; private set; }
public Flag(string value) { public Flag(string value) {
@ -19,15 +19,11 @@ public abstract class Geary.Imap.Flag : BaseObject, Equalable, Hashable {
return this.value.down() == value.down(); return this.value.down() == value.down();
} }
public bool equals(Equalable b) { public bool equal_to(Geary.Imap.Flag flag) {
Flag? flag = b as Flag;
if (flag == null)
return false;
return (flag == this) ? true : flag.equals_string(value); return (flag == this) ? true : flag.equals_string(value);
} }
public uint to_hash() { public uint hash() {
return str_hash(value.down()); return str_hash(value.down());
} }

View file

@ -19,7 +19,7 @@
public interface Geary.Imap.MessageData : Geary.Common.MessageData { public interface Geary.Imap.MessageData : Geary.Common.MessageData {
} }
public class Geary.Imap.UID : Geary.Common.Int64MessageData, Geary.Imap.MessageData, Comparable { public class Geary.Imap.UID : Geary.Common.Int64MessageData, Geary.Imap.MessageData, Gee.Comparable<Geary.Imap.UID> {
// Using statics because int32.MAX is static, not const (??) // Using statics because int32.MAX is static, not const (??)
public static int64 MIN = 1; public static int64 MIN = 1;
public static int64 MAX = int32.MAX; public static int64 MAX = int32.MAX;
@ -63,11 +63,7 @@ public class Geary.Imap.UID : Geary.Common.Int64MessageData, Geary.Imap.MessageD
return new UID(Numeric.int64_floor(value - 1, MIN)); return new UID(Numeric.int64_floor(value - 1, MIN));
} }
public virtual int compare(Comparable o) { public virtual int compare_to(Geary.Imap.UID other) {
UID? other = o as UID;
if (other == null)
return -1;
if (value < other.value) if (value < other.value)
return -1; return -1;
else if (value > other.value) else if (value > other.value)
@ -94,13 +90,14 @@ public class Geary.Imap.MessageNumber : Geary.Common.IntMessageData, Geary.Imap.
} }
} }
public abstract class Geary.Imap.Flags : Geary.Common.MessageData, Geary.Imap.MessageData, Equalable { public abstract class Geary.Imap.Flags : Geary.Common.MessageData, Geary.Imap.MessageData,
Gee.Hashable<Geary.Imap.Flags> {
public int size { get { return list.size; } } public int size { get { return list.size; } }
protected Gee.Set<Flag> list; protected Gee.Set<Flag> list;
public Flags(Gee.Collection<Flag> flags) { public Flags(Gee.Collection<Flag> flags) {
list = new Gee.HashSet<Flag>(Hashable.hash_func, Equalable.equal_func); list = new Gee.HashSet<Flag>();
list.add_all(flags); list.add_all(flags);
} }
@ -120,11 +117,7 @@ public abstract class Geary.Imap.Flags : Geary.Common.MessageData, Geary.Imap.Me
return to_string(); return to_string();
} }
public bool equals(Equalable e) { public bool equal_to(Geary.Imap.Flags other) {
Imap.Flags? other = e as Imap.Flags;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
@ -150,6 +143,10 @@ public abstract class Geary.Imap.Flags : Geary.Common.MessageData, Geary.Imap.Me
return builder.str; return builder.str;
} }
public uint hash() {
return to_string().hash();
}
} }
public class Geary.Imap.MessageFlags : Geary.Imap.Flags { public class Geary.Imap.MessageFlags : Geary.Imap.Flags {

View file

@ -4,7 +4,7 @@
* (version 2.1 or later). See the COPYING file in this distribution. * (version 2.1 or later). See the COPYING file in this distribution.
*/ */
public class Geary.Imap.Tag : StringParameter, Hashable, Equalable { public class Geary.Imap.Tag : StringParameter, Gee.Hashable<Geary.Imap.Tag> {
public const string UNTAGGED_VALUE = "*"; public const string UNTAGGED_VALUE = "*";
public const string CONTINUATION_VALUE = "+"; public const string CONTINUATION_VALUE = "+";
public const string UNASSIGNED_VALUE = "----"; public const string UNASSIGNED_VALUE = "----";
@ -54,15 +54,11 @@ public class Geary.Imap.Tag : StringParameter, Hashable, Equalable {
return (value != UNASSIGNED_VALUE) && (value != CONTINUATION_VALUE); return (value != UNASSIGNED_VALUE) && (value != CONTINUATION_VALUE);
} }
public uint to_hash() { public uint hash() {
return str_hash(value); return str_hash(value);
} }
public bool equals(Equalable e) { public bool equal_to(Geary.Imap.Tag tag) {
Tag? tag = e as Tag;
if (tag == null)
return false;
if (this == tag) if (this == tag)
return true; return true;

View file

@ -89,8 +89,7 @@ public class Geary.Imap.ClientConnection : BaseObject {
private char tag_prefix = 'a'; private char tag_prefix = 'a';
private uint flush_timeout_id = 0; private uint flush_timeout_id = 0;
private bool idle_when_quiet = false; private bool idle_when_quiet = false;
private Gee.HashSet<Tag> posted_idle_tags = new Gee.HashSet<Tag>(Hashable.hash_func, private Gee.HashSet<Tag> posted_idle_tags = new Gee.HashSet<Tag>();
Equalable.equal_func);
private uint timeout_id = 0; private uint timeout_id = 0;
private uint timeout_cmd_count = 0; private uint timeout_cmd_count = 0;

View file

@ -181,10 +181,8 @@ public class Geary.Imap.ClientSession : BaseObject {
private ClientConnection? cx = null; private ClientConnection? cx = null;
private string? current_mailbox = null; private string? current_mailbox = null;
private bool current_mailbox_readonly = false; private bool current_mailbox_readonly = false;
private Gee.HashMap<Tag, CommandCallback> tag_cb = new Gee.HashMap<Tag, CommandCallback>( private Gee.HashMap<Tag, CommandCallback> tag_cb = new Gee.HashMap<Tag, CommandCallback>();
Hashable.hash_func, Equalable.equal_func); private Gee.HashMap<Tag, CommandResponse> tag_response = new Gee.HashMap<Tag, CommandResponse>();
private Gee.HashMap<Tag, CommandResponse> tag_response = new Gee.HashMap<Tag, CommandResponse>(
Hashable.hash_func, Equalable.equal_func);
private Capabilities capabilities = new Capabilities(0); private Capabilities capabilities = new Capabilities(0);
private int next_capabilities_revision = 1; private int next_capabilities_revision = 1;
private CommandResponse current_cmd_response = new CommandResponse(); private CommandResponse current_cmd_response = new CommandResponse();
@ -1311,7 +1309,7 @@ public class Geary.Imap.ClientSession : BaseObject {
assert(removed); assert(removed);
assert(cmd_response.is_sealed()); assert(cmd_response.is_sealed());
assert(cmd_response.status_response.tag.equals(cmd.tag)); assert(cmd_response.status_response.tag.equal_to(cmd.tag));
if (!imap_server_pipeline && claim_stub != NonblockingMutex.INVALID_TOKEN) { if (!imap_server_pipeline && claim_stub != NonblockingMutex.INVALID_TOKEN) {
try { try {

View file

@ -17,7 +17,7 @@ public class Geary.NonblockingMailbox<G> : BaseObject {
if (comparator == null) if (comparator == null)
queue = new Gee.LinkedList<G>(); queue = new Gee.LinkedList<G>();
else else
queue = new Gee.PriorityQueue<G>(comparator); queue = new Gee.PriorityQueue<G>();
} }
public bool send(G msg) { public bool send(G msg) {

View file

@ -97,7 +97,8 @@ public class Geary.RFC822.MessageIDList : Geary.Common.MessageData, Geary.RFC822
} }
} }
public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.Common.MessageData, Equalable, Hashable { public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.Common.MessageData,
Gee.Hashable<Geary.RFC822.Date> {
public string original { get; private set; } public string original { get; private set; }
public DateTime value { get; private set; } public DateTime value { get; private set; }
public time_t as_time_t { get; private set; } public time_t as_time_t { get; private set; }
@ -111,18 +112,14 @@ public class Geary.RFC822.Date : Geary.RFC822.MessageData, Geary.Common.MessageD
original = iso8601; original = iso8601;
} }
public virtual bool equals(Equalable e) { public virtual bool equal_to(Geary.RFC822.Date other) {
RFC822.Date? other = e as RFC822.Date;
if (other == null)
return false;
if (this == other) if (this == other)
return true; return true;
return value.equal(other.value); return value.equal(other.value);
} }
public virtual uint to_hash() { public virtual uint hash() {
return value.hash(); return value.hash();
} }

View file

@ -92,7 +92,7 @@ public string reply_references(Geary.Email source) {
// 2. If there's an In-Reply-To Message-ID and it's not the last Message-ID on the // 2. If there's an In-Reply-To Message-ID and it's not the last Message-ID on the
// References list, append it // References list, append it
if (source.in_reply_to != null && list.size > 0 && !list.last().equals(source.in_reply_to)) if (source.in_reply_to != null && list.size > 0 && !list.last().equal_to(source.in_reply_to))
list.add(source.in_reply_to); list.add(source.in_reply_to);
// 3. Append the source's Message-ID, if available. // 3. Append the source's Message-ID, if available.

View file

@ -31,11 +31,45 @@ public bool are_sets_equal<G>(Gee.Set<G> a, Gee.Set<G> b) {
return true; return true;
} }
/**
* To be used by a Hashable's to_hash() method.
*/
public static uint int64_hash(int64 value) {
return hash_memory(&value, sizeof(int64));
}
/**
* To be used as a raw HashFunc where an int64 is being stored directly.
*/
public static uint bare_int64_hash(void *ptr) {
return hash_memory(ptr, sizeof(int64));
}
/**
* A HashFunc for DateTime.
*/
public static uint date_time_hash(void *a) {
return ((DateTime) a).hash();
}
/**
* A rotating-XOR hash that can be used to hash memory buffers of any size. Use only if
* equality is determined by memory contents.
*/
public static uint hash_memory(void *ptr, size_t bytes) {
uint8 *u8 = (uint8 *) ptr;
uint hash = 0;
for (int ctr = 0; ctr < bytes; ctr++)
hash = (hash << 4) ^ (hash >> 28) ^ (*u8++);
return hash;
}
// This *must* be used in place of Gee,TreeSet until the fix for this bug is widely distributed: // This *must* be used in place of Gee,TreeSet until the fix for this bug is widely distributed:
// https://bugzilla.gnome.org/show_bug.cgi?id=695045 // https://bugzilla.gnome.org/show_bug.cgi?id=695045
public class FixedTreeSet<G> : Gee.TreeSet<G> { public class FixedTreeSet<G> : Gee.TreeSet<G> {
public FixedTreeSet(CompareFunc? compare_func = null) { public FixedTreeSet(owned GLib.CompareDataFunc<G>? compare_func = null) {
base (compare_func); base ( (owned) compare_func);
} }
~FixedTreeSet() { ~FixedTreeSet() {

View file

@ -54,5 +54,27 @@ public async void recursive_delete_async(File folder, Cancellable? cancellable =
} }
} }
public uint hash(File file) {
return file.hash();
}
public bool equal(File a, File b) {
return a.equal(b);
}
public uint nullable_hash(File? file) {
return (file != null) ? file.hash() : 0;
}
public bool nullable_equal(File? a, File? b) {
if (a == null && b == null)
return true;
if (a == null || b == null)
return false;
return a.equal(b);
}
} }

View file

@ -8,8 +8,11 @@ public class Geary.GenericCapabilities : BaseObject {
public string name_separator { get; private set; } public string name_separator { get; private set; }
public string? value_separator { get; private set; } public string? value_separator { get; private set; }
// All params must be nullable to support both libgee 0.8.0 and 0.8.6 (for Quantal and Rarring, respectively.)
// This behavior was changed in the following libgee commit:
// https://git.gnome.org/browse/libgee/commit/?id=5a35303cb04154d0e929a7d8895d4a4812ba7a1c
private Gee.HashMultiMap<string, string?> map = new Gee.HashMultiMap<string, string?>( private Gee.HashMultiMap<string, string?> map = new Gee.HashMultiMap<string, string?>(
String.stri_hash, String.stri_equal, String.nullable_stri_hash, String.nullable_stri_equal); String.nullable_stri_hash, String.nullable_stri_equal, String.nullable_stri_hash, String.nullable_stri_equal);
/** /**
* Creates an empty set of capabilities. * Creates an empty set of capabilities.

View file

@ -41,82 +41,3 @@ public interface Geary.Comparable {
} }
} }
public interface Geary.Equalable {
public abstract bool equals(Equalable other);
/**
* An EqualFunc for any object that implements Equalable.
*/
public static bool equal_func(void *a, void *b) {
return ((Equalable *) a)->equals((Equalable *) b);
}
/**
* EqualFunc for nullable objects that implement Equalable.
*/
public static bool nullable_equal_func(void *a, void *b) {
if (a == null || b == null)
return (a == null && b == null);
return equal_func(a, b);
}
/**
* The EqualsFunc counterpart to Hashable.bare_int64_hash().
*/
public static bool bare_int64_equals(void *a, void *b) {
return *((int64 *) a) == *((int64 *) b);
}
/**
* An EqualFunc for DateTime.
*/
public static bool date_time_equal(void *a, void *b) {
return ((DateTime) a).equal((DateTime) b);
}
}
public interface Geary.Hashable {
public abstract uint to_hash();
/**
* A HashFunc for any object that implements Hashable.
*/
public static uint hash_func(void *ptr) {
return ((Hashable *) ptr)->to_hash();
}
/**
* To be used by a Hashable's to_hash() method.
*/
public static uint int64_hash(int64 value) {
return hash_memory(&value, sizeof(int64));
}
/**
* To be used as a raw HashFunc where an int64 is being stored directly.
*/
public static uint bare_int64_hash(void *ptr) {
return hash_memory(ptr, sizeof(int64));
}
/**
* A HashFunc for DateTime.
*/
public static uint date_time_hash(void *a) {
return ((DateTime) a).hash();
}
/**
* A rotating-XOR hash that can be used to hash memory buffers of any size. Use only if
* equality is determined by memory contents.
*/
public static uint hash_memory(void *ptr, size_t bytes) {
uint8 *u8 = (uint8 *) ptr;
uint hash = 0;
for (int ctr = 0; ctr < bytes; ctr++)
hash = (hash << 4) ^ (hash >> 28) ^ (*u8++);
return hash;
}
}

View file

@ -8,7 +8,10 @@
* Singleton is a simple way of creating a one-item read-only collection. * Singleton is a simple way of creating a one-item read-only collection.
*/ */
private class Geary.Singleton<G> : Gee.AbstractCollection<G> { private class Geary.Singleton<G> : Gee.AbstractCollection<G> {
private class IteratorImpl<G> : BaseObject, Gee.Iterator<G> { private class IteratorImpl<G> : BaseObject, Gee.Traversable<G>, Gee.Iterator<G> {
public bool read_only { get { return true; } }
public bool valid { get { return !done; } }
private G item; private G item;
private bool done = false; private bool done = false;
@ -16,12 +19,6 @@ private class Geary.Singleton<G> : Gee.AbstractCollection<G> {
this.item = item; this.item = item;
} }
public bool first() {
done = false;
return true;
}
public new G? get() { public new G? get() {
return item; return item;
} }
@ -41,23 +38,27 @@ private class Geary.Singleton<G> : Gee.AbstractCollection<G> {
public void remove() { public void remove() {
message("Geary.Singleton is read-only"); message("Geary.Singleton is read-only");
} }
public new bool @foreach(Gee.ForallFunc<G> f) {
return f(item);
}
} }
public override bool read_only { get { return true; } }
public G item { get; private set; } public G item { get; private set; }
public override int size { get { return 1; } } public override int size { get { return 1; } }
private EqualFunc equal_func; private Gee.EqualDataFunc equal_func;
public Singleton(G item, EqualFunc? equal_func = null) { public Singleton(G item, owned Gee.EqualDataFunc? equal_func = null) {
this.item = item; this.item = item;
if (equal_func != null) if (equal_func != null)
this.equal_func = equal_func; this.equal_func = (owned) equal_func;
else if (typeof(G).is_a(typeof(Geary.Equalable))) else {
this.equal_func = Geary.Equalable.equal_func;
else
this.equal_func = Gee.Functions.get_equal_func_for(typeof(G)); this.equal_func = Gee.Functions.get_equal_func_for(typeof(G));
}
} }
public override bool add(G element) { public override bool add(G element) {

View file

@ -48,23 +48,23 @@ public inline bool ascii_equali(string a, string b) {
return ascii_cmpi(a, b) == 0; return ascii_cmpi(a, b) == 0;
} }
public uint stri_hash(void *str) { public uint stri_hash(string str) {
return str_hash(((string *) str)->down()); return str_hash(str.down());
} }
public uint nullable_stri_hash(void *str) { public uint nullable_stri_hash(string? str) {
return (str != null) ? stri_hash(str) : 0; return (str != null) ? stri_hash(str) : 0;
} }
public bool stri_equal(void *a, void *b) { public bool stri_equal(string a, string b) {
return str_equal(((string *) a)->down(), ((string *) b)->down()); return str_equal(a.down(), b.down());
} }
public bool equals_ci(string a, string b) { public bool equals_ci(string a, string b) {
return a.down() == b.down(); return a.down() == b.down();
} }
public bool nullable_stri_equal(void *a, void *b) { public bool nullable_stri_equal(string? a, string? b) {
if (a == null) if (a == null)
return (b == null); return (b == null);