Geary.Folder: Add SpecialUse.CUSTOM and set_used_as_custom method
Support applications setting custom special uses for folders.
This commit is contained in:
parent
e9ce94b655
commit
e22d74db4b
5 changed files with 75 additions and 4 deletions
|
|
@ -108,7 +108,11 @@ public abstract class Geary.Folder : BaseObject, Logging.Source {
|
|||
IMPORTANT,
|
||||
|
||||
/** A view of email matching some kind of search criteria. */
|
||||
SEARCH;
|
||||
SEARCH,
|
||||
|
||||
/** A folder with an application-defined use. */
|
||||
CUSTOM;
|
||||
|
||||
|
||||
public bool is_outgoing() {
|
||||
return this == SENT || this == OUTBOX;
|
||||
|
|
@ -286,7 +290,15 @@ public abstract class Geary.Folder : BaseObject, Logging.Source {
|
|||
/** The folder path represented by this object. */
|
||||
public abstract Geary.FolderPath path { get; }
|
||||
|
||||
/** Determines the special use of this folder. */
|
||||
/**
|
||||
* Determines the special use of this folder.
|
||||
*
|
||||
* This will be set by the engine and updated as information about
|
||||
* a folders use is discovered and changed.
|
||||
*
|
||||
* @see use_changed
|
||||
* @see set_used_as_custom
|
||||
*/
|
||||
public abstract SpecialUse used_as { get; }
|
||||
|
||||
/** Monitor for notifying of progress when opening the folder. */
|
||||
|
|
@ -698,6 +710,29 @@ public abstract class Geary.Folder : BaseObject, Logging.Source {
|
|||
public abstract async Geary.Email fetch_email_async(Geary.EmailIdentifier email_id,
|
||||
Geary.Email.Field required_fields, ListFlags flags, Cancellable? cancellable = null) throws Error;
|
||||
|
||||
/**
|
||||
* Sets whether this folder has a custom special use.
|
||||
*
|
||||
* If `true`, this set a folder's {@link used_as} property so that
|
||||
* it returns {@link SpecialUse.CUSTOM}. If the folder's existing
|
||||
* special use is not currently set to {@link SpecialUse.NONE}
|
||||
* then {@link EngineError.UNSUPPORTED} is thrown.
|
||||
*
|
||||
* If `false` and the folder's use is currently {@link
|
||||
* SpecialUse.CUSTOM} then it is reset to be {@link
|
||||
* SpecialUse.NONE}, otherwise if the folder's use is something
|
||||
* other than {@link SpecialUse.NONE} then {@link
|
||||
* EngineError.UNSUPPORTED} is thrown.
|
||||
*
|
||||
* If some other engine process causes this folder's use to be
|
||||
* something other than {@link SpecialUse.NONE}, this will
|
||||
* override the custom use.
|
||||
*
|
||||
* @see used_as
|
||||
*/
|
||||
public abstract void set_used_as_custom(bool enabled)
|
||||
throws EngineError.UNSUPPORTED;
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public virtual Logging.State to_logging_state() {
|
||||
return new Logging.State(this, this.path.to_string());
|
||||
|
|
|
|||
|
|
@ -369,6 +369,11 @@ public class Geary.App.SearchFolder :
|
|||
}
|
||||
}
|
||||
|
||||
public override void set_used_as_custom(bool enabled)
|
||||
throws EngineError.UNSUPPORTED {
|
||||
throw new EngineError.UNSUPPORTED("Folder special use cannot be changed");
|
||||
}
|
||||
|
||||
private void require_id(EmailIdentifier id)
|
||||
throws EngineError.NOT_FOUND {
|
||||
if (!this.id_map.has_key(id)) {
|
||||
|
|
|
|||
|
|
@ -178,12 +178,33 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
|
|||
notify_email_flags_changed(flag_map);
|
||||
}
|
||||
|
||||
public override void set_used_as_custom(bool enabled)
|
||||
throws EngineError.UNSUPPORTED {
|
||||
if (enabled) {
|
||||
if (this._used_as != NONE) {
|
||||
throw new EngineError.UNSUPPORTED(
|
||||
"Folder already has special use"
|
||||
);
|
||||
}
|
||||
set_use(CUSTOM);
|
||||
} else {
|
||||
if (this._used_as != CUSTOM &&
|
||||
this._used_as != NONE) {
|
||||
throw new EngineError.UNSUPPORTED(
|
||||
"Folder already has special use"
|
||||
);
|
||||
}
|
||||
set_use(NONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void set_use(Folder.SpecialUse new_use) {
|
||||
var old_use = this._used_as;
|
||||
this._used_as = new_use;
|
||||
if (old_use != new_use)
|
||||
if (old_use != new_use) {
|
||||
notify_use_changed(old_use, new_use);
|
||||
update_harvester();
|
||||
update_harvester();
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
|
|
|||
|
|
@ -350,6 +350,11 @@ public class Geary.Outbox.Folder :
|
|||
return row_to_email(row);
|
||||
}
|
||||
|
||||
public override void set_used_as_custom(bool enabled)
|
||||
throws EngineError.UNSUPPORTED {
|
||||
throw new EngineError.UNSUPPORTED("Folder special use cannot be changed");
|
||||
}
|
||||
|
||||
internal async void
|
||||
add_to_containing_folders_async(Gee.Collection<Geary.EmailIdentifier> ids,
|
||||
Gee.MultiMap<Geary.EmailIdentifier,FolderPath> map,
|
||||
|
|
|
|||
|
|
@ -119,4 +119,9 @@ public class Geary.MockFolder : Folder, MockObject {
|
|||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
public override void set_used_as_custom(bool enabled)
|
||||
throws EngineError.UNSUPPORTED {
|
||||
throw new EngineError.UNSUPPORTED("Mock method");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue