-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,12 @@ | |
#hook = | ||
|
||
|
||
[share] | ||
|
||
# Share plugins | ||
#type = read, write, birthday | ||
|
||
|
||
[web] | ||
|
||
# Web interface backend | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This file is part of Radicale Server - Calendar Server | ||
# Copyright © 2018 Unrud<[email protected]> | ||
# | ||
# This library is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from importlib import import_module | ||
|
||
from radicale.log import logger | ||
|
||
INTERNAL_TYPES = ("read", "write", "birthday") | ||
|
||
|
||
def load(configuration): | ||
"""Load the share plugins chosen in configuration.""" | ||
share_types = tuple([ | ||
s.strip() for s in configuration.get("share", "type").split(",")]) | ||
classes = [] | ||
for share_type in share_types: | ||
if share_type in INTERNAL_TYPES: | ||
module = "radicale.share.%s" % share_type | ||
else: | ||
module = share_type | ||
try: | ||
classes.append(import_module(module).Share) | ||
except Exception as e: | ||
raise RuntimeError("Failed to load share module %r: %s" % | ||
(module, e)) from e | ||
logger.info("Share types are %r", share_types) | ||
return tuple([class_(configuration) for class_ in classes]) | ||
|
||
|
||
class BaseShare: | ||
|
||
name = "" | ||
uuid = "" | ||
group = "" | ||
|
||
tags = () | ||
item_writethrough = False | ||
|
||
def __init__(self, configuration): | ||
self.configuration = configuration | ||
|
||
def get(self, item): | ||
raise NotImplementedError | ||
|
||
def get_meta(self, props, base_props): | ||
raise NotImplementedError | ||
|
||
def set_meta(self, props, old_props, old_base_props): | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This file is part of Radicale Server - Calendar Server | ||
# Copyright © 2018 Unrud<[email protected]> | ||
# | ||
# This library is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from radicale.share import BaseShare | ||
|
||
|
||
class Share(BaseShare): | ||
|
||
name = "Birthday" | ||
uuid = "a5ee648a-2240-4400-af49-a2f064ec5678" | ||
group = "birthday" | ||
tags = ("VCALENDAR",) | ||
item_writethrough = False | ||
|
||
def get(self, item): | ||
return None | ||
|
||
def get_meta(self, props, base_props): | ||
return { | ||
"tag": "VCALENDAR", | ||
} | ||
|
||
def set_meta(self, props, old_props, old_base_props): | ||
return old_props, old_base_props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This file is part of Radicale Server - Calendar Server | ||
# Copyright © 2018 Unrud<[email protected]> | ||
# | ||
# This library is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from radicale.share import BaseShare | ||
|
||
|
||
class Share(BaseShare): | ||
|
||
name = "Read" | ||
uuid = "0d41f7f1-4d93-41e7-98ce-0f2069d6773a" | ||
group = "" | ||
|
||
tags = ("VADDRESSBOOK", "VCALENDAR") | ||
item_writethrough = False | ||
|
||
def get(self, item): | ||
return item | ||
|
||
def get_meta(self, props, base_props): | ||
return base_props | ||
|
||
def set_meta(self, props, old_props, old_base_props): | ||
return old_props, old_base_props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This file is part of Radicale Server - Calendar Server | ||
# Copyright © 2018 Unrud<[email protected]> | ||
# | ||
# This library is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
from radicale.share import BaseShare | ||
|
||
|
||
class Share(BaseShare): | ||
|
||
name = "Write" | ||
uuid = "d3027b80-9624-4d88-9aa0-382e9bcd92ad" | ||
group = "" | ||
|
||
tags = ("VADDRESSBOOK", "VCALENDAR") | ||
item_writethrough = True | ||
|
||
def get(self, item): | ||
return item | ||
|
||
def get_meta(self, props, base_props): | ||
return base_props | ||
|
||
def set_meta(self, props, old_props, old_base_props): | ||
return old_props, props |