2017-12-06 16:23:31 +11:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 Michael Gratton <mike@vee.net>
|
|
|
|
|
*
|
|
|
|
|
* This software is licensed under the GNU Lesser General Public License
|
|
|
|
|
* (version 2.1 or later). See the COPYING file in this distribution.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-08-10 16:13:57 +10:00
|
|
|
public class Mock.EmailIdentifer : Geary.EmailIdentifier {
|
2017-12-06 16:23:31 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
private int id;
|
|
|
|
|
|
|
|
|
|
|
2020-08-10 16:13:57 +10:00
|
|
|
public EmailIdentifer(int id) {
|
2017-12-06 16:23:31 +11:00
|
|
|
this.id = id;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 13:18:45 +11:00
|
|
|
public override uint hash() {
|
|
|
|
|
return GLib.int_hash(this.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool equal_to(Geary.EmailIdentifier other) {
|
|
|
|
|
return (
|
|
|
|
|
this.get_type() == other.get_type() &&
|
2020-08-10 16:13:57 +10:00
|
|
|
this.id == ((EmailIdentifer) other).id
|
2019-12-10 13:18:45 +11:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override string to_string() {
|
|
|
|
|
return "%s(%d)".printf(
|
|
|
|
|
this.get_type().name(),
|
|
|
|
|
this.id
|
|
|
|
|
);
|
2017-12-06 16:23:31 +11:00
|
|
|
}
|
|
|
|
|
|
2018-01-03 15:01:21 +11:00
|
|
|
public override GLib.Variant to_variant() {
|
|
|
|
|
return new GLib.Variant.int32(id);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 13:18:45 +11:00
|
|
|
public override int natural_sort_comparator(Geary.EmailIdentifier other) {
|
2020-08-10 16:13:57 +10:00
|
|
|
EmailIdentifer? other_mock = other as EmailIdentifer;
|
2019-12-10 13:18:45 +11:00
|
|
|
return (other_mock == null) ? 1 : this.id - other_mock.id;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-06 16:23:31 +11:00
|
|
|
}
|