<h1>Project "FreeSWITCH user-contributed scripts, etc" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: 69415c934e4b3dc70b22816aa847706336c442f5 (commit)
      from: 8b7b83f0a42fc7cce5deaacd1c3a56f76c392175 (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Mathieu Parent
comments: 
MediaBrother: lot of changes
<span style="color: #A00000">- Separate Backend from Iterator</span>
<span style="color: #A00000">- Reduce size of reply by using hashes in session</span>
<span style="color: #A00000">- ...</span>

<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/browser/index.php b/sathieu/cisco-xml/browser/index.php</span>
<span style="color: #000080; font-weight: bold">index 1f0ae25..d142ff5 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/browser/index.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/browser/index.php</span>
<span style="color: #800080; font-weight: bold">@@ -33,10 +33,26 @@ ini_set(&#39;include_path&#39;, ini_get(&#39;include_path&#39;).PATH_SEPARATOR.&#39;../lib&#39;);</span>
 require(&#39;Cisco-XML/Cisco-XML.php&#39;);
 require_once(&#39;MediaBrotha/Core.php&#39;);
 
<span style="color: #00A000">+// Init</span>
 MediaBrotha_Core::init();
 MediaBrotha_Core::connectFrontend(&#39;CiscoXML&#39;, Array(&#39;push_url&#39; =&gt; &#39;http://cisco:cisco@192.168.0.220/CGI/Execute&#39;));
<span style="color: #00A000">+</span>
<span style="color: #00A000">+// Backends</span>
 MediaBrotha_Core::loadBackend(&#39;FileSystem&#39;, Array(&#39;base_path&#39; =&gt; &#39;/home/share/music/&#39;));
 MediaBrotha_Core::loadBackend(&#39;VLC&#39;, Array(&#39;http_intf&#39; =&gt; &#39;http://127.0.0.1:8080&#39;));
<span style="color: #00A000">+$ldap_connect_config = Array(</span>
<span style="color: #00A000">+        &#39;host&#39; =&gt; &#39;127.0.0.1&#39;,</span>
<span style="color: #00A000">+        //&#39;binddn&#39; =&gt; &#39;cn=nobody,cn=internal,dc=example,dc=org&#39;,</span>
<span style="color: #00A000">+        //&#39;bindpw&#39; =&gt; &#39;not24get&#39;,</span>
<span style="color: #00A000">+        &#39;basedn&#39; =&gt; &#39;dc=sathieu,dc=net&#39;,</span>
<span style="color: #00A000">+        &#39;filter&#39; =&gt; &#39;(objectClass=*)&#39;,</span>
<span style="color: #00A000">+        &#39;scope&#39; =&gt; &#39;one&#39;,</span>
<span style="color: #00A000">+);</span>
<span style="color: #00A000">+MediaBrotha_Core::loadBackend(&#39;LDAP&#39;, Array(&#39;ldap_connect_config&#39; =&gt; $ldap_connect_config));</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+// Roots</span>
<span style="color: #00A000">+MediaBrotha_Core::addRootMedia(&#39;file:///home/share/music/&#39;, Array(&#39;name&#39;=&gt; &#39;Fichiers&#39;));</span>
<span style="color: #00A000">+MediaBrotha_Core::addRootMedia(&#39;ldap:///&#39;, Array(&#39;name&#39;=&gt; &#39;Annuaire&#39;));</span>
 
 MediaBrotha_Core::go();
 
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php b/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php</span>
<span style="color: #000080; font-weight: bold">index 2253ca9..c711f9c 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php</span>
<span style="color: #800080; font-weight: bold">@@ -125,7 +125,10 @@ class CiscoXMLObject {</span>
                         );
 
                 $context  = stream_context_create($opts);
<span style="color: #A00000">-                return file_get_contents($url, false, $context);</span>
<span style="color: #00A000">+                $stream = fopen($url, &#39;r&#39;, false, $context);</span>
<span style="color: #00A000">+                if ($stream !== false) {</span>
<span style="color: #00A000">+                        return stream_get_contents($stream);</span>
<span style="color: #00A000">+                }</span>
         }
 
 }
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend.php</span>
<span style="color: #000080; font-weight: bold">index bb1fe8f..84a6a89 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend.php</span>
<span style="color: #800080; font-weight: bold">@@ -26,80 +26,56 @@ This file is part of MediaBrotha.</span>
 
 require_once(&#39;MediaBrotha/Media.php&#39;);
 
<span style="color: #A00000">-class MediaBrotha_Backend extends MediaBrotha_Media implements Iterator {</span>
<span style="color: #A00000">-        protected $_buffer = Array();</span>
<span style="color: #A00000">-        public function __construct(array $args = Array()) {</span>
<span style="color: #A00000">-                parent::__construct($args);</span>
<span style="color: #00A000">+class MediaBrotha_Backend {</span>
<span style="color: #00A000">+        protected $_params = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function __construct($params = NULL) {</span>
<span style="color: #00A000">+                $this-&gt;setParam($params);</span>
                 $this-&gt;register();
<span style="color: #A00000">-                $this-&gt;setMimeType(&#39;application/x-mediabrotha-backend-&#39;.strtolower($this-&gt;getName()));</span>
<span style="color: #A00000">-                MediaBrotha_Core::registerMimeType($this, &#39;application/x-mediabrotha-backend-&#39;.strtolower($this-&gt;getName()));</span>
<span style="color: #A00000">-                $this-&gt;setMetadata(&#39;name&#39;, $this-&gt;getName());</span>
<span style="color: #A00000">-                $this-&gt;setMetadata(&#39;uri&#39;, &#39;MediaBrotha_Backend://&#39;.$this-&gt;getName());</span>
         }
 
<span style="color: #A00000">-        public function register() {</span>
<span style="color: #A00000">-                MediaBrotha_Core::registerBackend($this);</span>
<span style="color: #00A000">+        /* params */</span>
<span style="color: #00A000">+        public function getParam($name = NULL) {</span>
<span style="color: #00A000">+                if ($name === NULL) {</span>
<span style="color: #00A000">+                        return $this-&gt;_params;</span>
<span style="color: #00A000">+                } elseif (isset($this-&gt;_params[$name])) {</span>
<span style="color: #00A000">+                        return $this-&gt;_params[$name];</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        return NULL;</span>
<span style="color: #00A000">+                }</span>
         }
<span style="color: #00A000">+        public function setParam($name, $value = NULL) {</span>
<span style="color: #00A000">+                if (is_array($name)) {</span>
<span style="color: #00A000">+                        $this-&gt;_params = $name;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        $this-&gt;_params[$name] = $value;</span>
 
<span style="color: #A00000">-        public function getName() {</span>
<span style="color: #A00000">-                return preg_replace(&#39;/^MediaBrotha_Backend_(.*)$/&#39;, &#39;$1&#39;, get_class($this));</span>
<span style="color: #00A000">+                }</span>
         }
 
<span style="color: #A00000">-        public function capabilities($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                return Array();</span>
<span style="color: #00A000">+        public function register() {</span>
<span style="color: #00A000">+                MediaBrotha_Core::registerBackend($this);</span>
         }
 
<span style="color: #A00000">-        public function isHidden() {</span>
<span style="color: #A00000">-                return parent::isHidden() || !in_array(&#39;browse&#39;, $this-&gt;capabilities());</span>
<span style="color: #00A000">+        public function getBackendName() {</span>
<span style="color: #00A000">+                return preg_replace(&#39;/^MediaBrotha_Backend_(.*)$/&#39;, &#39;$1&#39;, get_class($this));</span>
         }
 
<span style="color: #A00000">-        // Capability browse</span>
<span style="color: #A00000">-        protected function _mediaFromBufferItem($item) {</span>
<span style="color: #00A000">+        // Browsing</span>
<span style="color: #00A000">+        public function mediaFromBufferItem($item) {</span>
                 return $item;
         }
 
<span style="color: #A00000">-        public function fetch($uri) {</span>
<span style="color: #00A000">+        public function fetch(MediaBrotha_Media $media) {</span>
                 return false;
         }
 
<span style="color: #A00000">-        public function rewind() {</span>
<span style="color: #A00000">-                $this-&gt;_buffer-&gt;rewind();</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        public function current() {</span>
<span style="color: #A00000">-                return $this-&gt;_mediaFromBufferItem($this-&gt;_buffer-&gt;current());</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        public function key() {</span>
<span style="color: #A00000">-                return $this-&gt;_buffer-&gt;key();</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        public function next() {</span>
<span style="color: #A00000">-                return $this-&gt;_mediaFromBufferItem($this-&gt;_buffer-&gt;next());</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        public function valid() {</span>
<span style="color: #A00000">-                return $this-&gt;_buffer-&gt;valid();</span>
<span style="color: #00A000">+        // Actions</span>
<span style="color: #00A000">+        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                return Array();</span>
         }
 
<span style="color: #A00000">-        // Capability play</span>
<span style="color: #A00000">-        public function play(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return false;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function pause() {</span>
<span style="color: #A00000">-                return false;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function stop() {</span>
<span style="color: #A00000">-                return false;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        // Capability playlist</span>
<span style="color: #A00000">-        public function playlistEnqueue(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return false;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function playlistNext(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return false;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function playlistPrevious(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+        public function doMediaAction($action, MediaBrotha_Media $media) {</span>
                 return false;
         }
 }
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #000080; font-weight: bold">index 0dc8972..39928b4 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #800080; font-weight: bold">@@ -25,14 +25,10 @@ This file is part of MediaBrotha.</span>
  */
 
 class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {
<span style="color: #A00000">-        public function register() {</span>
<span style="color: #A00000">-                parent::register();</span>
<span style="color: #A00000">-                MediaBrotha_Core::registerMimeType($this, &#39;application/x-directory&#39;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        // Helper functions</span>
         public function isURISafe($uri) {
                 $real_path = realpath(parse_url($uri, PHP_URL_PATH));
<span style="color: #A00000">-                $real_base_path = realpath($this-&gt;getMetadata(&#39;base_path&#39;));</span>
<span style="color: #00A000">+                $real_base_path = realpath($this-&gt;getParam(&#39;base_path&#39;));</span>
                 do {
                         if ($real_path === $real_base_path) {
                                 return true;
<span style="color: #800080; font-weight: bold">@@ -41,19 +37,16 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
                 return false;
         }
 
<span style="color: #A00000">-        public function capabilities($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                return Array(</span>
<span style="color: #A00000">-                        &#39;browse&#39;,</span>
<span style="color: #A00000">-                );</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        // Capability browse</span>
<span style="color: #A00000">-        protected function _mediaFromBufferItem($file) {</span>
<span style="color: #00A000">+        // Browsing</span>
<span style="color: #00A000">+        public function mediaFromBufferItem($file) {</span>
                 if ($file) {
<span style="color: #A00000">-                        $media = new MediaBrotha_Media(Array(</span>
<span style="color: #A00000">-                                &#39;uri&#39; =&gt; &#39;file://&#39;.realpath($file-&gt;getPathname()),</span>
<span style="color: #A00000">-                                &#39;name&#39; =&gt; $file-&gt;getFilename(),</span>
<span style="color: #A00000">-                                &#39;hidden&#39; =&gt; !$file-&gt;isReadable() || preg_match(&#39;/^\.([^.]|$)/&#39;, $file-&gt;getFilename()),</span>
<span style="color: #A00000">-                        ));</span>
<span style="color: #00A000">+                        $media = new MediaBrotha_Media(</span>
<span style="color: #00A000">+                                &#39;file://&#39;.realpath($file-&gt;getPathname()),</span>
<span style="color: #00A000">+                                Array(</span>
<span style="color: #00A000">+                                        &#39;name&#39; =&gt; $file-&gt;getFilename(),</span>
<span style="color: #00A000">+                                        &#39;hidden&#39; =&gt; !$file-&gt;isReadable() || preg_match(&#39;/^\.([^.]|$)/&#39;, $file-&gt;getFilename()),</span>
<span style="color: #00A000">+                                )</span>
<span style="color: #00A000">+                        );</span>
                         if ($file-&gt;isDir()) {
                                 $media-&gt;setMimeType(&#39;application/x-directory&#39;);
                         } else {
<span style="color: #800080; font-weight: bold">@@ -65,12 +58,34 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
                 }
         }
 
<span style="color: #A00000">-        public function fetch($uri) {</span>
<span style="color: #00A000">+        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                $uri =$media-&gt;getURI();</span>
                 if ((parse_url($uri, PHP_URL_SCHEME) != &#39;file&#39;) || !$this-&gt;isURISafe($uri)) {
                         $uri = &#39;file://&#39;.$this-&gt;getMetadata(&#39;base_path&#39;);
                 }
<span style="color: #A00000">-                $this-&gt;_buffer = new DirectoryIterator(parse_url($uri, PHP_URL_PATH));</span>
<span style="color: #A00000">-                return true;</span>
<span style="color: #00A000">+                $path = parse_url($uri, PHP_URL_PATH);</span>
<span style="color: #00A000">+                if (is_dir($path)) {</span>
<span style="color: #00A000">+                        return new MediaBrotha_MediaIterator($this, $media, new DirectoryIterator($path));</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        $this-&gt;setURI(NULL);</span>
<span style="color: #00A000">+                        return false;</span>
<span style="color: #00A000">+                }</span>
         }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        // Actions</span>
<span style="color: #00A000">+        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                if ($mime_type === &#39;application/x-directory&#39;) {</span>
<span style="color: #00A000">+                        return Array(</span>
<span style="color: #00A000">+                                &#39;browse&#39;,</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                } elseif ($uri &amp;&amp; (substr($uri, 0, 7) === &#39;file://&#39;)) {</span>
<span style="color: #00A000">+                        return Array(</span>
<span style="color: #00A000">+                                &#39;browse&#39;,</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        return parent::getMediaActions($uri, $mime_type, $mime_encoding);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
 }
 
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #000080; font-weight: bold">index d275ff1..c882dd7 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #800080; font-weight: bold">@@ -29,27 +29,16 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
         private $_ldap;
         public function __construct(array $args = Array()) {
                 parent::__construct($args);
<span style="color: #A00000">-                $this-&gt;_ldap = Net_LDAP2::connect($this-&gt;getMetadata(&#39;ldap_connect_config&#39;));</span>
<span style="color: #00A000">+                $this-&gt;_ldap = Net_LDAP2::connect($this-&gt;getParam(&#39;ldap_connect_config&#39;));</span>
                 if (Net_LDAP2::isError($this-&gt;_ldap)) {
                         die(&#39;Could not fetch entry: &#39;.$this-&gt;_ldap-&gt;getMessage());
                 }
         }
<span style="color: #A00000">-        public function register() {</span>
<span style="color: #A00000">-                parent::register();</span>
<span style="color: #A00000">-                MediaBrotha_Core::registerMimeType($this, &#39;text/directory&#39;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        public function capabilities($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                return Array(</span>
<span style="color: #A00000">-                        &#39;browse&#39;,</span>
<span style="color: #A00000">-                );</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        // Helper functions</span>
         public function isURISafe($uri) {
                 return true;
         }
<span style="color: #A00000">-        </span>
<span style="color: #A00000">-        </span>
<span style="color: #00A000">+</span>
         public static function parseLDAPURI($uri, $component = NULL) {
                 $uri = preg_replace(&#39;@^ldap:///@&#39;, &#39;ldap://fake_host/&#39;, $uri);
                 $components = parse_url($uri, $component);
<span style="color: #800080; font-weight: bold">@@ -59,30 +48,50 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
                 return $components;
         }
 
<span style="color: #A00000">-        // Capability browse</span>
<span style="color: #A00000">-        public function fetch($uri) {</span>
<span style="color: #00A000">+        // Browsing</span>
<span style="color: #00A000">+        public function mediaFromBufferItem($entry) {</span>
<span style="color: #00A000">+                if ($entry) {</span>
<span style="color: #00A000">+                        $media = new MediaBrotha_Media(</span>
<span style="color: #00A000">+                                &#39;ldap:///&#39;.$entry-&gt;dn(),</span>
<span style="color: #00A000">+                                Array(</span>
<span style="color: #00A000">+                                        &#39;name&#39; =&gt; $entry-&gt;dn(), //$entry-&gt;getValue(&#39;sn&#39;, &#39;single&#39;),</span>
<span style="color: #00A000">+                                ),</span>
<span style="color: #00A000">+                                &#39;text/directory&#39;</span>
<span style="color: #00A000">+                                //$finfo-&gt;file($file-&gt;getPathname(), FILEINFO_MIME_ENCODING);</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                        return $media;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                $uri = $media-&gt;getURI();</span>
                 if (($this::parseLDAPURI($uri, PHP_URL_SCHEME) != &#39;ldap&#39;) || !$this-&gt;isURISafe($uri)) {
<span style="color: #A00000">-                        $ldap_connect_config = $this-&gt;getMetadata(&#39;ldap_connect_config&#39;);</span>
<span style="color: #00A000">+                        $ldap_connect_config = $this-&gt;getParam(&#39;ldap_connect_config&#39;);</span>
                         $uri = &#39;ldap:///&#39;.$ldap_connect_config[&#39;basedn&#39;];
                 }
                 $basedn = $this::parseLDAPURI($uri, PHP_URL_PATH);
                 if ($basedn &amp;&amp; ($basedn{0} = &#39;/&#39;)) {
<span style="color: #A00000">-                        $basedn = substr($basedn, 1);        </span>
<span style="color: #00A000">+                        $basedn = substr($basedn, 1);</span>
                 }
<span style="color: #A00000">-                $this-&gt;_buffer = $this-&gt;_ldap-&gt;search($basedn, NULL,</span>
<span style="color: #00A000">+                $ldap_search = $this-&gt;_ldap-&gt;search($basedn, NULL,</span>
                         Array());
<span style="color: #00A000">+                return new MediaBrotha_MediaIterator($this, $media, $ldap_search);</span>
                 return true;
         }
<span style="color: #A00000">-        protected function _mediaFromBufferItem($entry) {</span>
<span style="color: #A00000">-                if ($entry) {</span>
<span style="color: #A00000">-                        $media = new MediaBrotha_Media(Array(</span>
<span style="color: #A00000">-                                &#39;uri&#39; =&gt; &#39;ldap:///&#39;.$entry-&gt;dn(),</span>
<span style="color: #A00000">-                                &#39;name&#39; =&gt; $entry-&gt;dn(), //$entry-&gt;getValue(&#39;sn&#39;, &#39;single&#39;),</span>
<span style="color: #A00000">-                        ));</span>
<span style="color: #A00000">-                        $media-&gt;setMimeType(&#39;text/directory&#39;);</span>
<span style="color: #A00000">-                        //        $media-&gt;setMimeEncoding($finfo-&gt;file($file-&gt;getPathname(), FILEINFO_MIME_ENCODING));</span>
<span style="color: #A00000">-                        return $media;</span>
<span style="color: #00A000">+        // Actions</span>
<span style="color: #00A000">+        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                if ($mime_type === &#39;text/directory&#39;) {</span>
<span style="color: #00A000">+                        return Array(</span>
<span style="color: #00A000">+                                &#39;browse&#39;,</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                } elseif ($uri &amp;&amp; (substr($uri, 0, 7) === &#39;ldap://&#39;)) {</span>
<span style="color: #00A000">+                        return Array(</span>
<span style="color: #00A000">+                                &#39;browse&#39;,</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        return parent::getMediaActions($uri, $mime_type, $mime_encoding);</span>
                 }
         }
<span style="color: #00A000">+</span>
 }
 
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php</span>
<span style="color: #000080; font-weight: bold">index 5357cc3..addba42 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php</span>
<span style="color: #800080; font-weight: bold">@@ -25,22 +25,28 @@ This file is part of MediaBrotha.</span>
  */
 
 class MediaBrotha_Backend_Root extends MediaBrotha_Backend {
<span style="color: #A00000">-        public function capabilities($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                return Array(</span>
<span style="color: #A00000">-                        &#39;browse&#39;,</span>
<span style="color: #A00000">-                );</span>
<span style="color: #00A000">+        private $_media = NULL;</span>
<span style="color: #00A000">+        private $_media_iterator = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function __construct($params = NULL) {</span>
<span style="color: #00A000">+                parent::__construct($params);</span>
<span style="color: #00A000">+                $this-&gt;_media = new MediaBrotha_Media(&#39;MediaBrotha:///&#39;);</span>
<span style="color: #00A000">+                $this-&gt;_media_iterator = new MediaBrotha_MediaIterator($this, $this-&gt;_media);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function addRootMedia($media) {</span>
<span style="color: #00A000">+                $this-&gt;_media_iterator-&gt;bufferAdd($media);</span>
         }
<span style="color: #A00000">-        public function isHidden() {</span>
<span style="color: #A00000">-                return true;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        // Browsing</span>
<span style="color: #00A000">+        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                return $this-&gt;_media_iterator;</span>
         }
 
<span style="color: #A00000">-        // Capability browse</span>
<span style="color: #A00000">-        public function fetch($uri) {</span>
<span style="color: #A00000">-                $this-&gt;_buffer = new ArrayIterator();</span>
<span style="color: #A00000">-                foreach(MediaBrotha_Core::getBackends() as $id =&gt; $backend) {</span>
<span style="color: #A00000">-                        $this-&gt;_buffer[] = $backend;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                return true;</span>
<span style="color: #00A000">+        // Actions</span>
<span style="color: #00A000">+        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                return Array(</span>
<span style="color: #00A000">+                );</span>
         }
 
 }
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php</span>
<span style="color: #000080; font-weight: bold">index df10f93..2b4e7c6 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php</span>
<span style="color: #800080; font-weight: bold">@@ -25,20 +25,14 @@ This file is part of MediaBrotha.</span>
  */
 
 class MediaBrotha_Backend_VLC extends MediaBrotha_Backend {
<span style="color: #A00000">-        public function register() {</span>
<span style="color: #A00000">-                parent::register();</span>
<span style="color: #A00000">-                MediaBrotha_Core::registerMimeType($this, &#39;audio/mpeg&#39;);</span>
<span style="color: #A00000">-                MediaBrotha_Core::registerMimeType($this, &#39;video/x-msvideo&#39;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        static protected $_supported_mime_types = Array(</span>
<span style="color: #00A000">+                &#39;audio/mpeg&#39;,</span>
<span style="color: #00A000">+                &#39;video/x-msvideo&#39;,</span>
<span style="color: #00A000">+        );</span>
 
<span style="color: #A00000">-        public function capabilities($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                return Array(</span>
<span style="color: #A00000">-                        &#39;play&#39;,</span>
<span style="color: #A00000">-                        &#39;playlist&#39;,</span>
<span style="color: #A00000">-                );</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+        // Helper functions</span>
         private function send_command($command, array $args = Array()) {
<span style="color: #A00000">-                $url = $this-&gt;getMetadata(&#39;http_intf&#39;).</span>
<span style="color: #00A000">+                $url = $this-&gt;getParam(&#39;http_intf&#39;).</span>
                         &#39;/requests/status.xml&#39;.
                         &#39;?command=&#39;.$command;
                 foreach ($args as $k =&gt; $v) {
<span style="color: #800080; font-weight: bold">@@ -49,31 +43,53 @@ class MediaBrotha_Backend_VLC extends MediaBrotha_Backend {</span>
                 print $output.&#39;&lt;!--&#39;.$url.&quot;--&gt;\n&quot;;
         }
 
<span style="color: #A00000">-        // Capability browse</span>
<span style="color: #A00000">-        public function fetch($uri) {</span>
<span style="color: #A00000">-                $this-&gt;_buffer[] = new MediaBrotha_Media();</span>
<span style="color: #00A000">+        // Browsing</span>
<span style="color: #00A000">+        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                $this-&gt;_buffer[] = $media;</span>
                 return true;
         }
 
<span style="color: #A00000">-        // Capability play</span>
<span style="color: #A00000">-        public function play(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return $this-&gt;send_command(&#39;in_play&#39;, Array(&#39;input&#39; =&gt; $media-&gt;getURI()));</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function pause() {</span>
<span style="color: #A00000">-                return $this-&gt;send_command(&#39;pl_pause&#39;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function stop() {</span>
<span style="color: #A00000">-                return $this-&gt;send_command(&#39;pl_stop&#39;);</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        // Capability playlist</span>
<span style="color: #A00000">-        public function playlistEnqueue(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return $this-&gt;send_command(&#39;in_enqueue&#39;, Array(&#39;input&#39; =&gt; $media-&gt;getURI()));</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function playlistNext(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return $this-&gt;send_command(&#39;pl_next&#39;);</span>
<span style="color: #00A000">+        // Actions</span>
<span style="color: #00A000">+        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                if (in_array($mime_type, Array($this::$_supported_mime_types))) {</span>
<span style="color: #00A000">+                        return Array(</span>
<span style="color: #00A000">+                                &#39;play_media&#39;,</span>
<span style="color: #00A000">+                                &#39;pause_media&#39;,</span>
<span style="color: #00A000">+                                &#39;stop_media&#39;,</span>
<span style="color: #00A000">+                                &#39;enqueue_media&#39;,</span>
<span style="color: #00A000">+                                &#39;next_media&#39;,</span>
<span style="color: #00A000">+                                &#39;previous_media&#39;,</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                } elseif ($uri &amp;&amp; (substr($uri, 0, 7) === &#39;file://&#39;)) {</span>
<span style="color: #00A000">+                        return Array(</span>
<span style="color: #00A000">+                                &#39;play_media&#39;,</span>
<span style="color: #00A000">+                                &#39;pause_media&#39;,</span>
<span style="color: #00A000">+                                &#39;stop_media&#39;,</span>
<span style="color: #00A000">+                                &#39;enqueue_media&#39;,</span>
<span style="color: #00A000">+                                &#39;next_media&#39;,</span>
<span style="color: #00A000">+                                &#39;previous_media&#39;,</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        return parent::getMediaActions($uri, $mime_type, $mime_encoding);</span>
<span style="color: #00A000">+                }</span>
         }
<span style="color: #A00000">-        public function playlistPrevious(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return $this-&gt;send_command(&#39;pl_previous&#39;);</span>
<span style="color: #00A000">+        public function doMediaAction($action, MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                switch($action) {</span>
<span style="color: #00A000">+                        case &#39;play_media&#39;:</span>
<span style="color: #00A000">+                                return $this-&gt;send_command(&#39;in_play&#39;, Array(&#39;input&#39; =&gt; $media-&gt;getURI()));</span>
<span style="color: #00A000">+                        case &#39;pause_media&#39;:</span>
<span style="color: #00A000">+                                return $this-&gt;send_command(&#39;pl_pause&#39;);</span>
<span style="color: #00A000">+                        case &#39;stop_media&#39;:</span>
<span style="color: #00A000">+                                return $this-&gt;send_command(&#39;pl_stop&#39;);</span>
<span style="color: #00A000">+                        case &#39;enqueue_media&#39;:</span>
<span style="color: #00A000">+                                return $this-&gt;send_command(&#39;in_enqueue&#39;, Array(&#39;input&#39; =&gt; $media-&gt;getURI()));</span>
<span style="color: #00A000">+                        case &#39;next_media&#39;:</span>
<span style="color: #00A000">+                                return $this-&gt;send_command(&#39;pl_next&#39;);</span>
<span style="color: #00A000">+                        case &#39;previous_media&#39;:</span>
<span style="color: #00A000">+                                return $this-&gt;send_command(&#39;pl_previous&#39;);</span>
<span style="color: #00A000">+                        default:</span>
<span style="color: #00A000">+                                return parent::doMediaAction($action, $media);</span>
<span style="color: #00A000">+                }</span>
         }
 }
 
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Core.php b/sathieu/cisco-xml/lib/MediaBrotha/Core.php</span>
<span style="color: #000080; font-weight: bold">index b3eaa84..5ec90e8 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Core.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Core.php</span>
<span style="color: #800080; font-weight: bold">@@ -27,53 +27,80 @@ This file is part of MediaBrotha.</span>
 require_once(&#39;MediaBrotha/Backend.php&#39;);
 require_once(&#39;MediaBrotha/Frontend.php&#39;);
 require_once(&#39;MediaBrotha/Media.php&#39;);
<span style="color: #00A000">+require_once(&#39;MediaBrotha/MediaIterator.php&#39;);</span>
 
 class MediaBrotha_Core {
         private static $_frontend = NULL;
         private static $_backends = Array();
<span style="color: #A00000">-        private static $_mime_types = Array();</span>
         private static $_media = NULL;
         
         public static function init() {
<span style="color: #00A000">+                if (!session_start()) {</span>
<span style="color: #00A000">+                        die(&#39;Unable to start session&#39;);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (!isset($_SESSION[&#39;HASHES&#39;])) {</span>
<span style="color: #00A000">+                        $_SESSION[&#39;HASHES&#39;] = Array();</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (isset($_SERVER[&quot;QUERY_STRING&quot;])) {</span>
<span style="color: #00A000">+                        $tmp = explode(&#39;&amp;&#39;, $_SERVER[&quot;QUERY_STRING&quot;]);</span>
<span style="color: #00A000">+                        foreach ($tmp as $h) {</span>
<span style="color: #00A000">+                                if (preg_match(&#39;/^[a-z0-9]+$/&#39;, $h)) {</span>
<span style="color: #00A000">+                                        if ($s = MediaBrotha_Core::hash2string($h)) {</span>
<span style="color: #00A000">+                                                parse_str($s, $output);</span>
<span style="color: #00A000">+                                                $_GET = array_merge($_GET, $output);</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
                 MediaBrotha_Core::loadBackend(&#39;Root&#39;);
         }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public static function hash2string($h) {</span>
<span style="color: #00A000">+                if (isset($_SESSION[&#39;HASHES&#39;][$h])) {</span>
<span style="color: #00A000">+                        return $_SESSION[&#39;HASHES&#39;][$h];</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        //print &#39;NO string for hash &#39;.$h;</span>
<span style="color: #00A000">+                        return NULL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public static function string2hash($s) {</span>
<span style="color: #00A000">+                for($hash_length = 1 ; $hash_length &lt;=41 ; $hash_length++) {</span>
<span style="color: #00A000">+                        $h = substr(sha1($s), 0, $hash_length);</span>
<span style="color: #00A000">+                        if (!isset($_SESSION[&#39;HASHES&#39;][$h]) || ($_SESSION[&#39;HASHES&#39;][$h] === $s)) {</span>
<span style="color: #00A000">+                                break;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                $_SESSION[&#39;HASHES&#39;][$h] = $s;</span>
<span style="color: #00A000">+                return $h;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         public static function go() {
                 $current_backend = MediaBrotha_Core::getCurrentBackend();
<span style="color: #A00000">-                switch(MediaBrotha_Core::getAction()) {</span>
<span style="color: #A00000">-                        case &#39;play&#39;:</span>
<span style="color: #A00000">-                                $current_backend-&gt;play(MediaBrotha_Core::getCurrentMedia());</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;pause&#39;:</span>
<span style="color: #A00000">-                                $current_backend-&gt;pause(MediaBrotha_Core::getCurrentMedia());</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;stop&#39;:</span>
<span style="color: #A00000">-                                $current_backend-&gt;stop(MediaBrotha_Core::getCurrentMedia());</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;pl_enqueue&#39;:</span>
<span style="color: #A00000">-                                $current_backend-&gt;playlistEnqueue(MediaBrotha_Core::getCurrentMedia());</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;pl_next&#39;:</span>
<span style="color: #A00000">-                                $current_backend-&gt;playlistNext(MediaBrotha_Core::getCurrentMedia());</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;pl_previous&#39;:</span>
<span style="color: #A00000">-                                $current_backend-&gt;playlistPrevious(MediaBrotha_Core::getCurrentMedia());</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        case &#39;browse&#39;:</span>
<span style="color: #A00000">-                        default:</span>
<span style="color: #A00000">-                                $current_uri = MediaBrotha_Core::getCurrentURI();</span>
<span style="color: #A00000">-                                $current_backend-&gt;fetch((string) $current_uri);</span>
<span style="color: #A00000">-                                MediaBrotha_Core::$_frontend-&gt;begin($current_backend);</span>
<span style="color: #A00000">-                                foreach($current_backend as $item) {</span>
<span style="color: #00A000">+                $current_media = MediaBrotha_Core::getCurrentMedia();</span>
<span style="color: #00A000">+                if (MediaBrotha_Core::getAction() == &#39;browse&#39;) {</span>
<span style="color: #00A000">+                        if ($media_iterator = $current_backend-&gt;fetch($current_media)) {</span>
<span style="color: #00A000">+                                MediaBrotha_Core::$_frontend-&gt;begin($current_media);</span>
<span style="color: #00A000">+                                foreach ($media_iterator as $item) {</span>
                                         if ($item-&gt;isHidden()) {
                                                 continue;
                                         }
                                         MediaBrotha_Core::$_frontend-&gt;addItem($item);
                                 }
<span style="color: #A00000">-                                MediaBrotha_Core::$_frontend-&gt;finish($current_backend);</span>
<span style="color: #A00000">-                                MediaBrotha_Core::$_frontend-&gt;render();</span>
<span style="color: #00A000">+                                MediaBrotha_Core::$_frontend-&gt;finish($current_media);</span>
<span style="color: #00A000">+                                MediaBrotha_Core::$_frontend-&gt;render($current_media);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        $current_backend-&gt;doMediaAction(MediaBrotha_Core::getAction(), $current_media);</span>
                 }
         }
 
<span style="color: #00A000">+        public function addRootMedia($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                MediaBrotha_Core::$_backends[&#39;Root&#39;]-&gt;addRootMedia(</span>
<span style="color: #00A000">+                        new MediaBrotha_Media($URI, $metadata, $mime_type,$mime_encoding)</span>
<span style="color: #00A000">+                );</span>
<span style="color: #00A000">+        }</span>
         /*
          * Backends
          */
<span style="color: #800080; font-weight: bold">@@ -85,20 +112,29 @@ class MediaBrotha_Core {</span>
                 return new $class_name($args);
         }
         public static function registerBackend($backend) {
<span style="color: #A00000">-                MediaBrotha_Core::$_backends[] = $backend;</span>
<span style="color: #00A000">+                MediaBrotha_Core::$_backends[$backend-&gt;getBackendName()] = $backend;</span>
         }
<span style="color: #A00000">-        public static function registerMimeType($backend, $mime_type) {</span>
<span style="color: #A00000">-                MediaBrotha_Core::$_mime_types[$mime_type][] = $backend;</span>
<span style="color: #00A000">+        public static function getBackend($name) {</span>
<span style="color: #00A000">+                return MediaBrotha_Core::$_backends[$name];</span>
         }
         public static function getBackends() {
                 return MediaBrotha_Core::$_backends;
         }
         public static function getCurrentBackend() {
<span style="color: #A00000">-                if (!empty($_GET[&#39;mime_type&#39;]) &amp;&amp; !empty(MediaBrotha_Core::$_mime_types[$_GET[&#39;mime_type&#39;]])) {</span>
<span style="color: #A00000">-                        return MediaBrotha_Core::$_mime_types[$_GET[&#39;mime_type&#39;]][0];</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        return MediaBrotha_Core::$_backends[0];</span>
<span style="color: #00A000">+                if (!empty($_GET[&#39;backend&#39;]) &amp;&amp; !empty(MediaBrotha_Core::$_backends[$_GET[&#39;backend&#39;]])) {</span>
<span style="color: #00A000">+                        return MediaBrotha_Core::$_backends[$_GET[&#39;backend&#39;]];</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                foreach (MediaBrotha_Core::getBackends() as $backend) {</span>
<span style="color: #00A000">+                        foreach ($backend-&gt;getMediaActions(MediaBrotha_Core::getCurrentURI()) as $action) {</span>
<span style="color: #00A000">+                                if ($backend-&gt;getBackendName() == &#39;Root&#39;) {</span>
<span style="color: #00A000">+                                        continue;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                if ($action === MediaBrotha_Core::getAction()) {</span>
<span style="color: #00A000">+                                        return $backend;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        }</span>
                 }
<span style="color: #00A000">+                return MediaBrotha_Core::$_backends[&#39;Root&#39;];</span>
         }
         /*
          * Frontend
<span style="color: #800080; font-weight: bold">@@ -132,8 +168,7 @@ class MediaBrotha_Core {</span>
         }
         public static function getCurrentMedia() {
                 if (empty(MediaBrotha_Core::$_media)) {
<span style="color: #A00000">-                        MediaBrotha_Core::$_media = new MediaBrotha_Media();</span>
<span style="color: #A00000">-                        MediaBrotha_Core::$_media-&gt;setURI(MediaBrotha_Core::getCurrentURI());</span>
<span style="color: #00A000">+                        MediaBrotha_Core::$_media = new MediaBrotha_Media(MediaBrotha_Core::getCurrentURI());</span>
                 }
                 return MediaBrotha_Core::$_media;
         }
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #000080; font-weight: bold">index 84ce7b7..2cc6060 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #800080; font-weight: bold">@@ -26,9 +26,9 @@ This file is part of MediaBrotha.</span>
 
 class MediaBrotha_Frontend {
         protected $_infos = NULL;
<span style="color: #00A000">+</span>
         public function __construct(array $args = Array()) {
                 $this-&gt;_infos = $args;
         }
 }
 
<span style="color: #A00000">-</span>
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php</span>
<span style="color: #000080; font-weight: bold">index ce2f711..2baa6af 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php</span>
<span style="color: #800080; font-weight: bold">@@ -24,44 +24,48 @@ This file is part of MediaBrotha.</span>
  * @author Mathieu Parent
  */
 
<span style="color: #A00000">-class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend {</span>
<span style="color: #00A000">+require_once(&#39;HTTP.php&#39;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {</span>
         private $_xml = NULL;
         public function begin($item) {
                 $this-&gt;_xml = new CiscoIPPhoneMenu();
                 $this-&gt;_xml-&gt;setCiscoElement(&#39;Title&#39;, $item-&gt;getDisplayName());
<span style="color: #A00000">-                //$this-&gt;_xml-&gt;setCiscoElement(&#39;Prompt&#39;, &#39;kk&#39;);</span>
<span style="color: #00A000">+                $this-&gt;_xml-&gt;setCiscoElement(&#39;Prompt&#39;, substr($item-&gt;getURI(), -32));</span>
         }
         public function addItem($item) {
<span style="color: #A00000">-                $url = &#39;http://&#39;.$_SERVER[&#39;SERVER_NAME&#39;].$_SERVER[&#39;SCRIPT_NAME&#39;].&#39;?&#39;.</span>
<span style="color: #A00000">-                        &#39;mime_type=&#39;.urlencode($item-&gt;getMimeType()).&#39;&amp;&#39;.</span>
<span style="color: #A00000">-                        ($item-&gt;getMimeEncoding() ? (&#39;mime_encoding=&#39;.urlencode($item-&gt;getMimeEncoding()).&#39;&amp;&#39;) : &#39;&#39;).</span>
<span style="color: #A00000">-                        &#39;uri=&#39;.urlencode($item-&gt;getURI());</span>
<span style="color: #A00000">-                //$url = &#39;http://&#39;.$_SERVER[&#39;SERVER_NAME&#39;].$_SERVER[&#39;SCRIPT_NAME&#39;];</span>
<span style="color: #00A000">+                $url = $this-&gt;rootURL().&#39;?&#39;.</span>
<span style="color: #00A000">+                        MediaBrotha_Core::string2hash(</span>
<span style="color: #00A000">+                                &#39;mime_type=&#39;.urlencode($item-&gt;getMimeType()).&#39;&amp;&#39;.</span>
<span style="color: #00A000">+                                ($item-&gt;getMimeEncoding() ? (&#39;mime_encoding=&#39;.urlencode($item-&gt;getMimeEncoding()).&#39;&amp;&#39;) : &#39;&#39;).</span>
<span style="color: #00A000">+                                &#39;uri=&#39;.urlencode($item-&gt;getURI()));</span>
                 $this-&gt;_xml-&gt;setCiscoElement(&#39;MenuItem&#39;,
                         Array(&#39;Name&#39; =&gt; $item-&gt;getDisplayName(), &#39;URL&#39; =&gt; $url));
         }
<span style="color: #A00000">-        public function finish() {</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Select&#39;, &#39;URL&#39; =&gt; &#39;SoftKey:Select&#39;, &#39;Position&#39; =&gt; &#39;1&#39;));</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Play&#39;, &#39;URL&#39; =&gt; &#39;QueryStringParam:action=play&#39;, &#39;Position&#39; =&gt; &#39;2&#39;));</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Pause&#39;, &#39;URL&#39; =&gt; &#39;QueryStringParam:action=pause&#39;, &#39;Position&#39; =&gt; &#39;3&#39;));</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Stop&#39;, &#39;URL&#39; =&gt; &#39;QueryStringParam:action=stop&#39;, &#39;Position&#39; =&gt; &#39;4&#39;));</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Enqueue&#39;, &#39;URL&#39; =&gt; &#39;QueryStringParam:action=pl_enqueue&#39;, &#39;Position&#39; =&gt; &#39;5&#39;));</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Next&#39;, &#39;URL&#39; =&gt; &#39;QueryStringParam:action=pl_next&#39;, &#39;Position&#39; =&gt; &#39;6&#39;));</span>
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Previous&#39;, &#39;URL&#39; =&gt; &#39;QueryStringParam:action=pl_previous&#39;, &#39;Position&#39; =&gt; &#39;7&#39;));</span>
<span style="color: #00A000">+        public function finish($item) {</span>
<span style="color: #00A000">+                $pos = 1;</span>
                 $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,
<span style="color: #A00000">-                        Array(&#39;Name&#39; =&gt; &#39;Quit&#39;, &#39;URL&#39; =&gt; &#39;SoftKey:Exit&#39;, &#39;Position&#39; =&gt; &#39;8&#39;));</span>
<span style="color: #00A000">+                        Array(&#39;Name&#39; =&gt; &#39;Select&#39;,</span>
<span style="color: #00A000">+                        &#39;URL&#39; =&gt; &#39;SoftKey:Select&#39;,</span>
<span style="color: #00A000">+                        &#39;Position&#39; =&gt; $pos++));</span>
<span style="color: #00A000">+                foreach (MediaBrotha_Core::getBackends() as $backend) {</span>
<span style="color: #00A000">+                        foreach ($backend-&gt;getMediaActions(MediaBrotha_Core::getCurrentURI()) as $action) {</span>
<span style="color: #00A000">+                                $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,</span>
<span style="color: #00A000">+                                        Array(&#39;Name&#39; =&gt; $action,</span>
<span style="color: #00A000">+                                        &#39;URL&#39; =&gt; &#39;QueryStringParam:&#39;.MediaBrotha_Core::string2hash(&#39;action=&#39;.$action.&#39;&amp;backend=&#39;.$backend-&gt;getBackendName()),</span>
<span style="color: #00A000">+                                        &#39;Position&#39; =&gt; $pos++));</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
         }
         public function render() {
<span style="color: #A00000">-                CiscoXMLObject::HttpHeader();</span>
<span style="color: #A00000">-                print $this-&gt;_xml;</span>
<span style="color: #A00000">-                //$this-&gt;_xml-&gt;execute($this-&gt;_infos[&#39;push_url&#39;]);</span>
<span style="color: #00A000">+                if (true) {</span>
<span style="color: #00A000">+                        CiscoXMLObject::HttpHeader();</span>
<span style="color: #00A000">+                        print $this-&gt;_xml;</span>
<span style="color: #00A000">+                        //print &quot;\n&lt;!--&quot;.strlen($this-&gt;_xml).&#39;--&gt;&#39;;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        print strlen($this-&gt;_xml).&quot;\n&quot;;</span>
<span style="color: #00A000">+                        print $this-&gt;_xml-&gt;execute($this-&gt;_infos[&#39;push_url&#39;]);</span>
<span style="color: #00A000">+                }</span>
         }
 }
 
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php</span>
similarity index 77%
copy from sathieu/cisco-xml/lib/MediaBrotha/Frontend.php
copy to sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php
<span style="color: #000080; font-weight: bold">index 84ce7b7..de19bf7 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php</span>
<span style="color: #800080; font-weight: bold">@@ -24,11 +24,10 @@ This file is part of MediaBrotha.</span>
  * @author Mathieu Parent
  */
 
<span style="color: #A00000">-class MediaBrotha_Frontend {</span>
<span style="color: #A00000">-        protected $_infos = NULL;</span>
<span style="color: #A00000">-        public function __construct(array $args = Array()) {</span>
<span style="color: #A00000">-                $this-&gt;_infos = $args;</span>
<span style="color: #00A000">+class MediaBrotha_Frontend_HTTP extends MediaBrotha_Frontend {</span>
<span style="color: #00A000">+        public function rootURL() {</span>
<span style="color: #00A000">+                $url = &#39;http://&#39;.$_SERVER[&#39;SERVER_NAME&#39;].$_SERVER[&#39;SCRIPT_NAME&#39;];</span>
<span style="color: #00A000">+                $url = preg_replace(&#39;/index\.php$/&#39;, &#39;&#39;, $url);</span>
<span style="color: #00A000">+                return $url;</span>
         }
 }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-</span>
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Media.php b/sathieu/cisco-xml/lib/MediaBrotha/Media.php</span>
<span style="color: #000080; font-weight: bold">index cf3d66d..6efd1db 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Media.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Media.php</span>
<span style="color: #800080; font-weight: bold">@@ -26,25 +26,27 @@ This file is part of MediaBrotha.</span>
 
 class MediaBrotha_Media {
         private $_metadata = Array();
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        private $_URI = NULL;</span>
         private $_mimeType = NULL;
         private $_mimeEncoding = NULL;
<span style="color: #A00000">-        public function __construct(array $metadata = Array()) {</span>
<span style="color: #A00000">-                 $this-&gt;_metadata = $metadata;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function setMimeType($mime_type) {</span>
<span style="color: #A00000">-                $this-&gt;_mimeType = $mime_type;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-        public function getMimeType() {</span>
<span style="color: #A00000">-                // TODO</span>
<span style="color: #A00000">-                return $this-&gt;_mimeType;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function __construct($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                 $this-&gt;setURI($URI);</span>
<span style="color: #00A000">+                 $this-&gt;setMetadata($metadata);</span>
<span style="color: #00A000">+                 $this-&gt;setMimeType($mime_type);</span>
<span style="color: #00A000">+                 $this-&gt;setMimeEncoding($mime_encoding);</span>
         }
<span style="color: #A00000">-        public function setMimeEncoding($mime_encoding) {</span>
<span style="color: #A00000">-                $this-&gt;_mimeEncoding = $mime_encoding;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* URI */</span>
<span style="color: #00A000">+        public function getURI() {</span>
<span style="color: #00A000">+                return $this-&gt;_URI;</span>
         }
<span style="color: #A00000">-        public function getMimeEncoding() {</span>
<span style="color: #A00000">-                // TODO</span>
<span style="color: #A00000">-                return $this-&gt;_mimeEncoding;</span>
<span style="color: #00A000">+        public function setURI($URI) {</span>
<span style="color: #00A000">+                $this-&gt;_URI = $URI;</span>
         }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* metadata */</span>
         public function getMetadata($name = NULL) {
                 if ($name === NULL) {
                         return $this-&gt;_metadata;
<span style="color: #800080; font-weight: bold">@@ -54,7 +56,7 @@ class MediaBrotha_Media {</span>
                         return NULL;
                 }
         }
<span style="color: #A00000">-        public function setMetadata($name, $value) {</span>
<span style="color: #00A000">+        public function setMetadata($name, $value = NULL) {</span>
                 if (is_array($name)) {
                         $this-&gt;_metadata = $name;
                 } else {
<span style="color: #800080; font-weight: bold">@@ -62,21 +64,36 @@ class MediaBrotha_Media {</span>
 
                 }
         }
<span style="color: #A00000">-        /* Most used metadata */</span>
<span style="color: #A00000">-        public function getDisplayName($max_length = 0) {</span>
<span style="color: #A00000">-                return $this-&gt;getMetadata(&#39;name&#39;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* mimeType */</span>
<span style="color: #00A000">+        public function getMimeType() {</span>
<span style="color: #00A000">+                return $this-&gt;_mimeType;</span>
         }
<span style="color: #A00000">-        public function getURI() {</span>
<span style="color: #A00000">-                return $this-&gt;getMetadata(&#39;uri&#39;);</span>
<span style="color: #00A000">+        public function setMimeType($mime_type) {</span>
<span style="color: #00A000">+                $this-&gt;_mimeType = $mime_type;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* mimeEncoding */</span>
<span style="color: #00A000">+        public function getMimeEncoding() {</span>
<span style="color: #00A000">+                return $this-&gt;_mimeEncoding;</span>
         }
<span style="color: #A00000">-        public function setURI($value) {</span>
<span style="color: #A00000">-                return $this-&gt;setMetadata(&#39;uri&#39;, $value);</span>
<span style="color: #00A000">+        public function setMimeEncoding($mime_encoding) {</span>
<span style="color: #00A000">+                $this-&gt;_mimeEncoding = $mime_encoding;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* Most used metadata */</span>
<span style="color: #00A000">+        public function getDisplayName($max_length = 0) {</span>
<span style="color: #00A000">+                if ($name = $this-&gt;getMetadata(&#39;name&#39;)) {</span>
<span style="color: #00A000">+                        return $name;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        return &#39;?&#39;;</span>
<span style="color: #00A000">+                }</span>
         }
         public function getURIComponent($component) {
                 return parse_url($this-&gt;getURI($component));
         }
         public function isHidden() {
<span style="color: #A00000">-                return isset($this-&gt;_metadata[&#39;hidden&#39;]) &amp;&amp; $this-&gt;_metadata[&#39;hidden&#39;];</span>
<span style="color: #00A000">+                return (bool) $this-&gt;getMetadata(&#39;hidden&#39;);</span>
         }
 }
 
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php b/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..096759a</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,71 @@</span>
<span style="color: #00A000">+&lt;?php</span>
<span style="color: #00A000">+/*</span>
<span style="color: #00A000">+Copyright 2011 Mathieu Parent &lt;math.parent@gmail.com&gt; </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+This file is part of MediaBrotha.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        MediaBrotha is free software: you can</span>
<span style="color: #00A000">+        redistribute it and/or modify it under the terms of the GNU General</span>
<span style="color: #00A000">+        Public License as published by the Free Software Foundation, either</span>
<span style="color: #00A000">+        version 3 of the License, or (at your option) any later version.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        MediaBrotha is distributed in the hope that it</span>
<span style="color: #00A000">+        will be useful, but WITHOUT ANY WARRANTY; without even the implied</span>
<span style="color: #00A000">+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See</span>
<span style="color: #00A000">+        the GNU General Public License for more details.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        You should have received a copy of the GNU General Public License</span>
<span style="color: #00A000">+        along with MediaBrotha. If not, see</span>
<span style="color: #00A000">+        &lt;http://www.gnu.org/licenses/&gt;.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+*/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+/**</span>
<span style="color: #00A000">+ * @author Mathieu Parent</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+require_once(&#39;MediaBrotha/Media.php&#39;);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+class MediaBrotha_MediaIterator implements Iterator {</span>
<span style="color: #00A000">+        private $_backend = NULL;</span>
<span style="color: #00A000">+        private $_media = NULL;</span>
<span style="color: #00A000">+        private $_handle = NULL;</span>
<span style="color: #00A000">+        protected $_buffer = NULL;</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function __construct(MediaBrotha_Backend $backend, MediaBrotha_Media $media, $buffer = NULL) {</span>
<span style="color: #00A000">+                $this-&gt;_backend = $backend;</span>
<span style="color: #00A000">+                $this-&gt;_media = $media;</span>
<span style="color: #00A000">+                if ($buffer) {</span>
<span style="color: #00A000">+                        $this-&gt;_buffer = $buffer;</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        $this-&gt;_buffer = new ArrayIterator();</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* buffer */</span>
<span style="color: #00A000">+        public function bufferAdd($media) {</span>
<span style="color: #00A000">+                $this-&gt;_buffer[] = $media;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        /* iterator */</span>
<span style="color: #00A000">+        public function rewind() {</span>
<span style="color: #00A000">+                $this-&gt;_buffer-&gt;rewind();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function current() {</span>
<span style="color: #00A000">+                return $this-&gt;_backend-&gt;mediaFromBufferItem($this-&gt;_buffer-&gt;current());</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function key() {</span>
<span style="color: #00A000">+                return $this-&gt;_buffer-&gt;key();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function next() {</span>
<span style="color: #00A000">+                return $this-&gt;_backend-&gt;mediaFromBufferItem($this-&gt;_buffer-&gt;next());</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function valid() {</span>
<span style="color: #00A000">+                return $this-&gt;_buffer-&gt;valid();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
</pre></div>
========================================================================<pre>

Summary of changes:
 sathieu/cisco-xml/browser/index.php                |   16 +++
 sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php      |    5 +-
 sathieu/cisco-xml/lib/MediaBrotha/Backend.php      |   86 ++++++----------
 .../lib/MediaBrotha/Backend/FileSystem.php         |   57 +++++++----
 sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php |   65 +++++++-----
 sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php |   32 ++++---
 sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php  |   82 +++++++++------
 sathieu/cisco-xml/lib/MediaBrotha/Core.php         |  109 +++++++++++++-------
 sathieu/cisco-xml/lib/MediaBrotha/Frontend.php     |    2 +-
 .../lib/MediaBrotha/Frontend/CiscoXML.php          |   56 ++++++-----
 .../{Frontend.php => Frontend/HTTP.php}            |   11 +-
 sathieu/cisco-xml/lib/MediaBrotha/Media.php        |   63 +++++++----
 .../cisco-xml/lib/MediaBrotha/MediaIterator.php    |   71 +++++++++++++
 13 files changed, 411 insertions(+), 244 deletions(-)
 copy sathieu/cisco-xml/lib/MediaBrotha/{Frontend.php => Frontend/HTTP.php} (77%)
 create mode 100644 sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH user-contributed scripts, etc</p>