Provide custom app calendar

I am currently trying to write a small app which provides a custom calendar,
but after simply copying the code from the documentation I can not get it working.

Basically only used the app template, changed the Application.php:

public function register(IRegistrationContext $context): void {
		$context->registerCalendarProvider(\OCA\MyApp\Backend\CalendarProvider::class);
	}

And added a file lib/Backend/CalendarProvider.php

<?php
namespace OCA\MyApp\Backend;

use OCP\Calendar\ICalendarProvider;
use Psr\Log\LoggerInterface;

class CalendarProvider implements ICalendarProvider {
	protected LoggerInterface $logger;
	
	public function __construct(LoggerInterface $logger) {
		$this->logger = $logger;
        $this->logger->debug('Construct!');
	}

	public function getCalendars(string $principalUri, array $calendarUris = []): array {
		$this->logger->debug('getCalendars', ['uri' => $principalUri]);
		return [];
	}
}

But neither the __contruct nor the getCalendars is ever called.
(Also added some logic to provide custom calendars, but not relevant here)

I tried to find any working example, but the only app I could find providing custom calendars was the deck app, but that uses a completely different approach (using sabre DAV extensions directly).

So my question is, has someone sucessfully wrote an app providing custom calendars using the ICalendarProvider API? Or am I missing something?

What did you do in order to trigger the debug messages? Did you open the calendar app?

The documentation says that the calendars are lazy loaded. This could be the cause for the missing conductor call.

I tried to:

  • Disable / Enable the app
  • Open the calendar app
  • Used external CalDAV tool to query calendars

But non of these triggered the debug message.

I am sorry, I have to test this myself. Please give me a bit of time. I have not yet solved this problem myself.

I just tried to debug this a bit in my dev environment. I was not able to get it working as described in the documentation. I will ask the DAV group about this as I will probably need a calendar soon.

I asked in the Groupware dev team about the issue. Here aI want to cross-post theanswers to keep things together. I will just add screenshots here.

grafik



Here is the link clickable as well: Allow apps to provide Calendars in user's calendarHome by georgehrke · Pull Request #19196 · nextcloud/server · GitHub

Here again the clickable link: GitHub - georgehrke/davcalendardemo: Reference implementation of Nextcloud CalDAV Plugins


The main part of what I get so far is that the documentation is misleading. There are the calendars registered in PHP and those within CalDAV/Sabre. The official Calendar app will only show the CalDAV ones. The CalDAV remote.php backend will most probably not show the PHP-based calendars as well.

The question is not, what your intention is related to the calendars, @susnux. There is at least a workaround. I fear this a combination of a bug and a feature request in fact:

  1. The DAV/calendar backend seems not to work with the PHP-registered calendars (rendering the documentation misleading).
  2. Once a calendar is registered I had problems to see it with the documented PHP methods (see my own calender registered). I will most probably build a test case repository. From there I might be able to file a bug report/feature request.

Sorry, that I cannot give you a better report. At least there is a workaround possible to be used.

1 Like

Hi @susnux and @christianlupus

I just read up on the discussion and also had a look in the groupware channel.
@christianlupus I saw your work on the documentation there: Comparing master...fix/calendar-provider-for-apps · nextcloud/documentation · GitHub

Thanks for working on that!

Are you still trying to digg into this? I’m not so familar with groupware but if there’s anything i can help with let me know.

I wsa busy these days like hell due to my day-to-day obligations. I will try to fix some of the open issues on my personal agenda soon. One part is to have a look at the calendar thing. So, long story short, I have not done much since the PR.

2 Likes