load remote and public paths from info.xml during upgrade instead of setting them every time

This commit is contained in:
Robin Appelman 2012-05-11 20:32:37 +02:00
parent d2bd78c41a
commit 736739bbbd
18 changed files with 100 additions and 95 deletions

View File

@ -23,5 +23,3 @@ OCP\App::addNavigationEntry( array(
'name' => $l->t('Calendar')));
OCP\App::registerPersonal('calendar', 'settings');
OC_Search::registerProvider('OC_Search_Provider_Calendar');
OCP\CONFIG::setAppValue('core', 'remote_caldav', '/apps/calendar/appinfo/remote.php');
OCP\CONFIG::setAppValue('core', 'public_calendar', '/apps/calendar/share.php');

View File

@ -7,4 +7,12 @@
<require>2</require>
<description>Calendar with CalDAV support</description>
<default_enable/>
<remote>
<calendar>appinfo/remote.php</calendar>
<caldav>appinfo/remote.php</caldav>
</remote>
<public>
<calendar>share.php</calendar>
<caldav>share.php</caldav>
</public>
</info>

View File

@ -1 +1 @@
0.3
0.4

View File

@ -25,4 +25,3 @@ OCP\App::addNavigationEntry( array(
OCP\App::registerPersonal('contacts','settings');
OCP\Util::addscript('contacts', 'loader');
OC_Search::registerProvider('OC_Search_Provider_Contacts');
OCP\CONFIG::setAppValue('core', 'remote_carddav', '/apps/contacts/appinfo/remote.php');

View File

@ -8,4 +8,8 @@
<description>Address book with CardDAV support.</description>
<standalone/>
<default_enable/>
<remote>
<contacts>appinfo/remote.php</contacts>
<carddav>appinfo/remote.php</carddav>
</remote>
</info>

View File

@ -1 +1 @@
0.1
0.2

View File

@ -7,4 +7,3 @@ OCP\App::registerAdmin('files','admin');
OCP\App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));
OC_Search::registerProvider('OC_Search_Provider_File');
OCP\CONFIG::setAppValue('core', 'remote_webdav', '/apps/files/appinfo/remote.php');

View File

@ -8,4 +8,8 @@
<require>2</require>
<standalone/>
<default_enable/>
<remote>
<files>appinfo/remote.php</files>
<webdav>appinfo/remote.php</webdav>
</remote>
</info>

View File

@ -1 +1 @@
1.0
1.1

View File

@ -0,0 +1,46 @@
<?php
/**
* Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class Test_CryptProxy extends UnitTestCase {
public function setUp(){
//set testing key
$_SESSION['enckey']=md5(time());
//clear all proxies and hooks so we can do clean testing
OC_FileProxy::clearProxies();
OC_Hook::clear('OC_Filesystem');
//enable only the encryption hook
OC_FileProxy::register(new OC_FileProxy_Encryption());
//set up temporary storage
OC_Filesystem::clearMounts();
OC_Filesystem::mount('OC_Filestorage_Temporary',array(),'/');
//set up the users home folder in the temp storage
$rootView=new OC_FilesystemView('');
$rootView->mkdir('/'.OC_User::getUser());
$rootView->mkdir('/'.OC_User::getUser().'/files');
}
public function testSimple(){
$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
$original=file_get_contents($file);
OC_Filesystem::file_put_contents('/file',$original);
OC_FileProxy::$enabled=false;
$stored=OC_Filesystem::file_get_contents('/file');
OC_FileProxy::$enabled=true;
$fromFile=OC_Filesystem::file_get_contents('/file');
$this->assertNotEqual($original,$stored);
$this->assertEqual($original,$fromFile);
}
}

View File

@ -56,5 +56,3 @@ class OC_GallerySearchProvider extends OC_Search_Provider{
OC_Search::registerProvider('OC_GallerySearchProvider');
require_once('apps/gallery/lib/hooks_handlers.php');
OCP\CONFIG::setAppValue('core', 'public_gallery', '/apps/gallery/sharing.php');
?>

View File

@ -8,4 +8,7 @@
<description>Dedicated pictures application</description>
<standalone/>
<default_enable/>
<public>
<gallery>sharing.php</gallery>
</public>
</info>

View File

@ -1 +1 @@
0.4.1
0.4.2

View File

@ -32,5 +32,3 @@ OCP\App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
OCP\App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
OC_Search::registerProvider('OC_MediaSearchProvider');
OCP\CONFIG::setAppValue('core', 'remote_ampache', '/apps/media/remote.php');
OCP\CONFIG::setAppValue('core', 'remote_tomahawk', '/apps/media/tomahawk.php');

View File

@ -8,4 +8,7 @@
<require>2</require>
<standalone/>
<default_enable/>
<remote>
<ampache>remote.php</ampache>
</remote>
</info>

View File

@ -1 +1 @@
0.3
0.4

View File

@ -1,78 +0,0 @@
<?php
/**
* ownCloud - media plugin
*
* @author Robin Appelman
* @copyright 2010 Robin Appelman icewind1991@gmail.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 Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
$_POST=$_GET; //debug
OCP\JSON::checkAppEnabled('media');
require_once(OC::$APPSROOT . '/apps/media/lib_collection.php');
$user=isset($_POST['user'])?$_POST['user']:'';
$pass=isset($_POST['pass'])?$_POST['pass']:'';
if(OCP\User::checkPassword($user,$pass)){
OC_Util::setupFS($user);
OC_MEDIA_COLLECTION::$uid=$user;
}else{
exit;
}
if(isset($_POST['play']) and $_POST['play']=='true'){
if(!isset($_POST['song'])){
exit;
}
$song=OC_MEDIA_COLLECTION::getSong($_POST['song']);
$ftype=OC_Filesystem::getMimeType( $song['song_path'] );
header('Content-Type:'.$ftype);
OCP\Response::disableCaching();
header('Content-Length: '.OC_Filesystem::filesize($song['song_path']));
OC_Filesystem::readfile($song['song_path']);
}
$artist=isset($_POST['artist'])?'%'.$_POST['artist'].'%':'';
$album=isset($_POST['album'])?'%'.$_POST['album'].'%':'';
$song=isset($_POST['song'])?$_POST['song']:'';
$artist=OC_MEDIA_COLLECTION::getArtistId($artist);
$album=OC_MEDIA_COLLECTION::getAlbumId($album,$artist);
$songs=OC_MEDIA_COLLECTION::getSongs($artist,$album,$song);
$baseUrl=$baseuri;
$results=array();
foreach($songs as $song) {
$results[] = (Object) array(
'artist' => OC_MEDIA_COLLECTION::getArtistName($song['song_artist']),
'album' => OC_MEDIA_COLLECTION::getAlbumName($song['song_album']),
'track' => $song['song_name'],
'source' => 'ownCloud',
'mimetype' => OC_Filesystem::getMimeType($song['song_path']),
'extension' => substr($song['song_path'],strrpos($song['song_path'],'.')),
'url' => $baseUrl.'?play=true&song='.$song['song_id'],
'bitrate' => round($song['song_id']/$song['song_length'],0),
'duration' => round($song['song_length'],0),
'size' => $song['song_size'],
'score' => (float)1.0
);
}
OCP\JSON::encodedPrint($results);

View File

@ -110,9 +110,9 @@ class OC_App{
if(!isset(self::$appTypes[$app])){
$appData=self::getAppInfo($app);
if(isset($appData['types'])){
self::$appTypes[$app]=$appData['types'];
self::$appTypes[$app]=implode(',',$appData['types']);
}else{
self::$appTypes[$app]=array();
self::$appTypes[$app]='';
}
OC_Appconfig::setValue($app,'types',implode(',',self::$appTypes[$app]));
@ -367,8 +367,18 @@ class OC_App{
}
$xml = new SimpleXMLElement($content);
$data['info']=array();
$data['remote']=array();
$data['public']=array();
foreach($xml->children() as $child){
if($child->getName()=='types'){
if($child->getName()=='remote'){
foreach($child->children() as $remote){
$data['remote'][$remote->getName()]=(string)$remote;
}
}elseif($child->getName()=='public'){
foreach($child->children() as $public){
$data['public'][$public->getName()]=(string)$public;
}
}elseif($child->getName()=='types'){
$data['types']=array();
foreach($child->children() as $type){
$data['types'][]=$type->getName();
@ -476,12 +486,16 @@ class OC_App{
public static function updateApps(){
// The rest comes here
$versions = self::getAppVersions();
//ensure files app is installed for upgrades
if(!isset($versions['files'])){
$versions['files']='0';
}
foreach( $versions as $app=>$installedVersion ){
$currentVersion=OC_App::getAppVersion($app);
if ($currentVersion) {
if (version_compare($currentVersion, $installedVersion, '>')) {
OC_App::updateApp($app);
OC_Appconfig::setValue($app,'installed_version',OC_App::getAppVersion($app));
OC_Appconfig::setValue($app,'installed_version',OC_App::getAppVersion($app));
}
}
}
@ -511,6 +525,15 @@ class OC_App{
if(file_exists(OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php')){
include OC::$APPSROOT.'/apps/'.$appid.'/appinfo/update.php';
}
//set remote/public handelers
$appData=self::getAppInfo($appid);
foreach($appData['remote'] as $name=>$path){
OCP\CONFIG::setAppValue('core', 'remote_'.$name, '/apps/'.$appid.'/'.$path);
}
foreach($appData['public'] as $name=>$path){
OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$appid.'/'.$path);
}
}
/**