From 736739bbbda2e9930b7bdcf79f43a28fad4d1d5d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 11 May 2012 20:32:37 +0200 Subject: [PATCH] load remote and public paths from info.xml during upgrade instead of setting them every time --- apps/calendar/appinfo/app.php | 2 - apps/calendar/appinfo/info.xml | 8 +++ apps/calendar/appinfo/version | 2 +- apps/contacts/appinfo/app.php | 1 - apps/contacts/appinfo/info.xml | 4 ++ apps/contacts/appinfo/version | 2 +- apps/files/appinfo/app.php | 1 - apps/files/appinfo/info.xml | 4 ++ apps/files/appinfo/version | 2 +- apps/files_encryption/tests/proxy.php | 46 ++++++++++++++++ apps/gallery/appinfo/app.php | 2 - apps/gallery/appinfo/info.xml | 3 ++ apps/gallery/appinfo/version | 2 +- apps/media/appinfo/app.php | 2 - apps/media/appinfo/info.xml | 3 ++ apps/media/appinfo/version | 2 +- apps/media/tomahawk.php | 78 --------------------------- lib/app.php | 31 +++++++++-- 18 files changed, 100 insertions(+), 95 deletions(-) create mode 100644 apps/files_encryption/tests/proxy.php delete mode 100755 apps/media/tomahawk.php diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 0c91bf8f135..b02fc602c6b 100755 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -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'); \ No newline at end of file diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml index 101840aa1fa..f45f306e7d0 100644 --- a/apps/calendar/appinfo/info.xml +++ b/apps/calendar/appinfo/info.xml @@ -7,4 +7,12 @@ 2 Calendar with CalDAV support + + appinfo/remote.php + appinfo/remote.php + + + share.php + share.php + diff --git a/apps/calendar/appinfo/version b/apps/calendar/appinfo/version index 1d71ef97443..e6adf3fc7bb 100644 --- a/apps/calendar/appinfo/version +++ b/apps/calendar/appinfo/version @@ -1 +1 @@ -0.3 \ No newline at end of file +0.4 \ No newline at end of file diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php index 7e196733064..e5e1d572f2d 100755 --- a/apps/contacts/appinfo/app.php +++ b/apps/contacts/appinfo/app.php @@ -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'); \ No newline at end of file diff --git a/apps/contacts/appinfo/info.xml b/apps/contacts/appinfo/info.xml index 4d2fe383723..86692d65b4f 100644 --- a/apps/contacts/appinfo/info.xml +++ b/apps/contacts/appinfo/info.xml @@ -8,4 +8,8 @@ Address book with CardDAV support. + + appinfo/remote.php + appinfo/remote.php + diff --git a/apps/contacts/appinfo/version b/apps/contacts/appinfo/version index ceab6e11ece..2f4536184bc 100644 --- a/apps/contacts/appinfo/version +++ b/apps/contacts/appinfo/version @@ -1 +1 @@ -0.1 \ No newline at end of file +0.2 \ No newline at end of file diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php index e7358242ddb..5c0d3c8db83 100755 --- a/apps/files/appinfo/app.php +++ b/apps/files/appinfo/app.php @@ -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'); \ No newline at end of file diff --git a/apps/files/appinfo/info.xml b/apps/files/appinfo/info.xml index 03076dee98c..76a06a0cb4b 100644 --- a/apps/files/appinfo/info.xml +++ b/apps/files/appinfo/info.xml @@ -8,4 +8,8 @@ 2 + + appinfo/remote.php + appinfo/remote.php + diff --git a/apps/files/appinfo/version b/apps/files/appinfo/version index 9f8e9b69a33..b123147e2a1 100644 --- a/apps/files/appinfo/version +++ b/apps/files/appinfo/version @@ -1 +1 @@ -1.0 \ No newline at end of file +1.1 \ No newline at end of file diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php new file mode 100644 index 00000000000..0450de82acb --- /dev/null +++ b/apps/files_encryption/tests/proxy.php @@ -0,0 +1,46 @@ + + * 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); + } +} diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 333b1581ce1..878da48698a 100755 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -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'); -?> diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml index 5b5ee0f731b..43a22bae077 100644 --- a/apps/gallery/appinfo/info.xml +++ b/apps/gallery/appinfo/info.xml @@ -8,4 +8,7 @@ Dedicated pictures application + + sharing.php + diff --git a/apps/gallery/appinfo/version b/apps/gallery/appinfo/version index 267577d47e4..2b7c5ae0184 100644 --- a/apps/gallery/appinfo/version +++ b/apps/gallery/appinfo/version @@ -1 +1 @@ -0.4.1 +0.4.2 diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php index 332b73546ec..26cb2045549 100755 --- a/apps/media/appinfo/app.php +++ b/apps/media/appinfo/app.php @@ -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'); diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml index ea5b77c9c8f..b0f205f8b1d 100644 --- a/apps/media/appinfo/info.xml +++ b/apps/media/appinfo/info.xml @@ -8,4 +8,7 @@ 2 + + remote.php + diff --git a/apps/media/appinfo/version b/apps/media/appinfo/version index 1d71ef97443..e6adf3fc7bb 100644 --- a/apps/media/appinfo/version +++ b/apps/media/appinfo/version @@ -1 +1 @@ -0.3 \ No newline at end of file +0.4 \ No newline at end of file diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php deleted file mode 100755 index c74d168c42d..00000000000 --- a/apps/media/tomahawk.php +++ /dev/null @@ -1,78 +0,0 @@ -. -* -*/ - -$_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); diff --git a/lib/app.php b/lib/app.php index f274194b25c..bc4f9c87e96 100644 --- a/lib/app.php +++ b/lib/app.php @@ -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); + } } /** -- 2.39.5