How to rename task list using libecal-2.0?

Hi Everybody!

I’m working on the elementary Tasks app using libecal-2.0. There, I’d like to renname a task list - but the change does not get stored in the Nextcloud backend (seems only to have an effect locally). What I’m missing here? See this PR on GitHub for the currently used approach:

1 Like

anyone/anything to take this one step further?

Turned out there is no high level API for renaming a task list in a WebDAV backend. Although it is possible to do so using lower level API’s. Ended up with a working example which looks like the following:

var registry = Tasks.Application.model.get_registry.end (res);
var collection_source = registry.find_extension (source, E.SOURCE_EXTENSION_COLLECTION);

if (collection_source != null && source.has_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND)) {
    debug (@"WebDAV Rename '$(source.get_uid())'");

    var collection_source_webdav_session = new E.WebDAVSession (collection_source);
    var source_webdav_extension = (E.SourceWebdav) source.get_extension (E.SOURCE_EXTENSION_WEBDAV_BACKEND);

    var credentials_provider = new E.SourceCredentialsProvider (registry);
    E.NamedParameters credentials;
    credentials_provider.lookup_sync (collection_source, null, out credentials);
    collection_source_webdav_session.credentials = credentials;

    var changes = new GLib.SList<E.WebDAVPropertyChange> ();
    changes.append (new E.WebDAVPropertyChange.set (
        E.WEBDAV_NS_DAV,
        "displayname",
        editable_title.text
    ));

    E.webdav_session_update_properties_sync (
        collection_source_webdav_session,
        source_webdav_extension.soup_uri.to_string (false),
        changes,
        null
    );

    registry.refresh_backend_sync (collection_source.uid, null);
}

References:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.