storage

package
v0.0.0-...-57c9f0f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigPath

func GetConfigPath() string

GetConfigPath returns the path to the CalDAV config file Always uses ~/.config/chronos/caldav_config.json for consistency across platforms

func SaveCalDAVConfig

func SaveCalDAVConfig(config *CalDAVConfig) error

SaveCalDAVConfig saves CalDAV configuration to disk

Types

type CalDAVClient

type CalDAVClient struct {
	// contains filtered or unexported fields
}

CalDAVClient wraps the go-webdav CalDAV client with convenience methods

func NewCalDAVClient

func NewCalDAVClient(config *CalDAVConfig) (*CalDAVClient, error)

NewCalDAVClient creates and initializes a CalDAV client

func (*CalDAVClient) DeleteEvent

func (cc *CalDAVClient) DeleteEvent(calendarID string, eventUID string) error

DeleteEvent removes a single event from the CalDAV server

func (*CalDAVClient) FetchCalendar

func (cc *CalDAVClient) FetchCalendar(calendarID string) (*ical.Calendar, error)

FetchCalendar retrieves all events from a calendar

func (*CalDAVClient) GetCalendarIDs

func (cc *CalDAVClient) GetCalendarIDs() []string

GetCalendarIDs returns a list of all calendar IDs

func (*CalDAVClient) SaveEvent

func (cc *CalDAVClient) SaveEvent(calendarID string, event *ical.Event) (string, error)

SaveEvent uploads a single event to the CalDAV server

type CalDAVConfig

type CalDAVConfig struct {
	Enabled         bool   `json:"enabled"`
	ServerURL       string `json:"server_url"`
	Username        string `json:"username"`
	Password        string `json:"password"`
	CalendarHomeURL string `json:"calendar_home_url"` // Full URL to calendar home (will discover all calendars under this)
	SyncInterval    int    `json:"sync_interval"`     // Seconds between auto-sync (0 = manual only)
}

CalDAVConfig holds configuration for CalDAV server connection

func DefaultCalDAVConfig

func DefaultCalDAVConfig() *CalDAVConfig

DefaultCalDAVConfig returns a disabled default configuration

func LoadCalDAVConfig

func LoadCalDAVConfig() (*CalDAVConfig, error)

LoadCalDAVConfig loads CalDAV configuration from disk

func (*CalDAVConfig) Validate

func (c *CalDAVConfig) Validate() error

Validate checks if the CalDAV configuration is valid

type CalDAVStorage

type CalDAVStorage struct {
	// contains filtered or unexported fields
}

CalDAVStorage implements CalendarStorage using a remote CalDAV server All operations go directly to the server - no local caching

func NewCalDAVStorage

func NewCalDAVStorage(config *CalDAVConfig) (*CalDAVStorage, error)

NewCalDAVStorage creates a new CalDAV-based storage backend

func (*CalDAVStorage) DeleteEvent

func (cs *CalDAVStorage) DeleteEvent(calendarID string, eventUID string) error

DeleteEvent deletes a single event from the CalDAV server

func (*CalDAVStorage) ExportAllCalendars

func (cs *CalDAVStorage) ExportAllCalendars(calendars []*ical.Calendar, filePath string) error

ExportAllCalendars exports all calendars to a merged file

func (*CalDAVStorage) ExportCalendar

func (cs *CalDAVStorage) ExportCalendar(calendar *ical.Calendar, filePath string) error

ExportCalendar exports a calendar to a local file

func (*CalDAVStorage) GetStorageType

func (cs *CalDAVStorage) GetStorageType() string

GetStorageType returns "caldav" to identify this storage backend

func (*CalDAVStorage) ImportFromFile

func (cs *CalDAVStorage) ImportFromFile(filePath string) (*ical.Calendar, error)

ImportFromFile imports events from a local file

func (*CalDAVStorage) LoadCalendars

func (cs *CalDAVStorage) LoadCalendars() (map[string]*ical.Calendar, error)

LoadCalendars loads all calendars from the CalDAV server

func (*CalDAVStorage) SaveCalendars

func (cs *CalDAVStorage) SaveCalendars(calendarMap map[string]*ical.Calendar) error

SaveCalendars not supported for CalDAV

func (*CalDAVStorage) SaveEvent

func (cs *CalDAVStorage) SaveEvent(calendarID string, event *ical.Event) (string, error)

SaveEvent saves a single event to the CalDAV server

func (*CalDAVStorage) SupportsSync

func (cs *CalDAVStorage) SupportsSync() bool

SupportsSync returns true - CalDAV supports event-level operations

type CalendarStorage

type CalendarStorage interface {

	// LoadCalendars loads all calendars from persistent storage
	LoadCalendars() (map[string]*ical.Calendar, error)

	// SaveCalendars saves all calendars to persistent storage
	SaveCalendars(calendars map[string]*ical.Calendar) error

	// ExportCalendar exports a specific calendar to a file path
	ExportCalendar(calendar *ical.Calendar, filePath string) error

	// ExportAllCalendars exports all calendars to a single merged file
	ExportAllCalendars(calendars []*ical.Calendar, filePath string) error

	// ImportFromFile imports events from a .ics file and returns the calendar
	ImportFromFile(filePath string) (*ical.Calendar, error)

	// SaveEvent creates or updates a single event in a calendar
	// Returns the server's ETag (empty string for file storage)
	SaveEvent(calendarID string, event *ical.Event) (etag string, err error)

	// DeleteEvent removes a single event from a calendar by UID
	DeleteEvent(calendarID string, eventUID string) error

	// SupportsSync indicates if this storage backend supports incremental sync
	// File storage returns false, CalDAV storage returns true
	SupportsSync() bool

	// GetStorageType returns a string identifier for the storage type
	// e.g., "file", "caldav", "hybrid"
	GetStorageType() string
}

CalendarStorage defines the interface for calendar persistence operations

type FileStorage

type FileStorage struct{}

FileStorage implements CalendarStorage using local file system

func NewFileStorage

func NewFileStorage() *FileStorage

NewFileStorage creates a new file-based calendar storage

func (*FileStorage) DeleteEvent

func (fs *FileStorage) DeleteEvent(calendarID string, eventUID string) error

DeleteEvent removes a single event file

func (*FileStorage) ExportAllCalendars

func (fs *FileStorage) ExportAllCalendars(calendars []*ical.Calendar, filePath string) error

ExportAllCalendars exports all calendars to a single merged file implementing CalendarStorage interface

func (*FileStorage) ExportCalendar

func (fs *FileStorage) ExportCalendar(calendar *ical.Calendar, filePath string) error

ExportCalendar exports a specific calendar to a file implementing CalendarStorage interface

func (*FileStorage) GetStorageType

func (fs *FileStorage) GetStorageType() string

GetStorageType returns "file" to identify this storage backend

func (*FileStorage) ImportFromFile

func (fs *FileStorage) ImportFromFile(filePath string) (*ical.Calendar, error)

ImportFromFile imports events from a .ics file and returns the calendar implementing CalendarStorage interface

func (*FileStorage) LoadCalendars

func (fs *FileStorage) LoadCalendars() (map[string]*ical.Calendar, error)

LoadCalendars loads all calendars from persistent storage

func (*FileStorage) SaveCalendars

func (fs *FileStorage) SaveCalendars(calendarMap map[string]*ical.Calendar) error

SaveCalendars saves all calendars to disk as individual .ics files

func (*FileStorage) SaveEvent

func (fs *FileStorage) SaveEvent(calendarID string, event *ical.Event) (string, error)

SaveEvent saves a single event to a file

func (*FileStorage) SupportsSync

func (fs *FileStorage) SupportsSync() bool

SupportsSync returns true - file storage now supports event-level operations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL