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
17 changed files
with
457 additions
and
113 deletions.
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
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,67 @@ | ||
<?php | ||
/** | ||
* ownCloud - Calendar App | ||
* | ||
* @author Georg Ehrke | ||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or 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 AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
namespace OCA\Calendar\Controller; | ||
|
||
use OCA\Calendar\Http\StreamResponse; | ||
|
||
use OCP\AppFramework\Controller; | ||
use OCP\Http\Client\IClientService; | ||
use OCP\IRequest; | ||
|
||
class ProxyController extends Controller { | ||
|
||
/** | ||
* @var IClientService | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* @param string $appName | ||
* @param IRequest $request an instance of the request | ||
* @param IClientService $client | ||
*/ | ||
public function __construct($appName, IRequest $request, | ||
IClientService $client) { | ||
parent::__construct($appName, $request); | ||
$this->client = $client; | ||
} | ||
|
||
/** | ||
* @NoAdminRequired | ||
* | ||
* @param $url | ||
* @return StreamResponse | ||
*/ | ||
public function proxy($url) { | ||
$client = $this->client->newClient(); | ||
$clientResponse = $client->get($url, [ | ||
'stream' => true, | ||
]); | ||
|
||
$response = new StreamResponse($clientResponse->getBody()); | ||
$response->setHeaders([ | ||
'Content-Type' => 'text/calendar', | ||
]); | ||
|
||
return $response; | ||
} | ||
} |
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
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,51 @@ | ||
<?php | ||
/** | ||
* ownCloud - Calendar App | ||
* | ||
* @author Georg Ehrke | ||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com> | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License, version 3, | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
namespace OCA\Calendar\Http; | ||
|
||
use OCP\AppFramework\Http\ICallbackResponse; | ||
use OCP\AppFramework\Http\IOutput; | ||
use OCP\AppFramework\Http\Response; | ||
|
||
class StreamResponse extends Response implements ICallbackResponse { | ||
|
||
/** | ||
* @var resource | ||
*/ | ||
protected $stream; | ||
|
||
/** | ||
* @param resource $stream | ||
*/ | ||
public function __construct ($stream) { | ||
$this->stream = $stream; | ||
} | ||
|
||
|
||
/** | ||
* @param IOutput $output a small wrapper that handles output | ||
*/ | ||
public function callback (IOutput $output) { | ||
rewind($this->stream); | ||
fpassthru($this->stream); | ||
} | ||
|
||
} |
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,81 @@ | ||
/** | ||
* ownCloud - Calendar App | ||
* | ||
* @author Georg Ehrke | ||
* @copyright 2016 Georg Ehrke <oc.list@georgehrke.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or 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 AFFERO GENERAL PUBLIC LICENSE for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public | ||
* License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
app.factory('WebCal', function($http, Calendar, VEvent, TimezoneService, WebCalService) { | ||
'use strict'; | ||
|
||
function WebCal(url, props) { | ||
const context = {}; | ||
|
||
if (props.href.startsWith('webcal://')) { | ||
context.url = 'http://' + props.href.substr(9); | ||
} else if (props.href.startsWith('webcals://')) { | ||
context.url = 'https://' + props.href.substr(10); | ||
} else { | ||
context.url = props.href; | ||
} | ||
|
||
const iface = Calendar(url, props); | ||
iface._isAWebCalObject = true; | ||
|
||
iface.fcEventSource.events = function (start, end, timezone, callback) { | ||
var fcAPI = this; | ||
|
||
TimezoneService.get(timezone).then(function(tz) { | ||
iface.fcEventSource.isRendering = true; | ||
iface.emit(Calendar.hookFinishedRendering); | ||
|
||
WebCalService.get(context.url).then(function(response) { | ||
let vevents = []; | ||
|
||
response.vevents.forEach(function(ical) { | ||
try { | ||
const vevent = new VEvent(iface, ical, '', ''); | ||
const events = vevent.getFcEvent(start, end, tz); | ||
vevents = vevents.concat(events); | ||
} catch (err) { | ||
iface.addWarning(err.toString()); | ||
console.log(err); | ||
console.log(event); | ||
return; | ||
} | ||
}); | ||
|
||
callback(vevents); | ||
fcAPI.reportEvents(fcAPI.clientEvents()); | ||
|
||
iface.fcEventSource.isRendering = false; | ||
iface.emit(Calendar.hookFinishedRendering); | ||
}, function(error) { | ||
console.log(error); | ||
}); | ||
}); | ||
}; | ||
|
||
return iface; | ||
} | ||
|
||
WebCal.isWebCal = function(obj) { | ||
return (typeof obj === 'object' && obj !== null && obj._isAWebCalObject === false); | ||
}; | ||
|
||
return WebCal; | ||
}); |
Oops, something went wrong.