Author: dmeyer
Date: Sat Feb  3 20:14:40 2007
New Revision: 9148

Added:
   trunk/ui/src/media.py
Modified:
   trunk/ui/src/audio/__init__.py
   trunk/ui/src/audio/audioitem.py
   trunk/ui/src/audio/interface.py
   trunk/ui/src/directory.py
   trunk/ui/src/fxditem.py
   trunk/ui/src/image/__init__.py
   trunk/ui/src/image/fxdhandler.py
   trunk/ui/src/image/interface.py
   trunk/ui/src/image/plugins/apod.py
   trunk/ui/src/menu/mediaitem.py
   trunk/ui/src/playlist.py
   trunk/ui/src/plugin.py
   trunk/ui/src/plugins/mbus.py
   trunk/ui/src/plugins/mediamenu.py
   trunk/ui/src/plugins/unpack.py
   trunk/ui/src/video/__init__.py
   trunk/ui/src/video/interface.py
   trunk/ui/src/video/videoitem.py

Log:
move mimetypePlugin as MediaPlugin to media.py

Modified: trunk/ui/src/audio/__init__.py
==============================================================================
--- trunk/ui/src/audio/__init__.py      (original)
+++ trunk/ui/src/audio/__init__.py      Sat Feb  3 20:14:40 2007
@@ -6,8 +6,8 @@
 #
 # This file imports everything needed to use this audio module.  There
 # is only one class provided for audio files, the PluginInterface from
-# interface.py. It is a MimetypePlugin that can be accessed from
-# plugin.mimetype(). It will also register an fxd handler for the
+# interface.py. It is a MediaPlugin that can be accessed from
+# media.get_plugins(). It will also register an fxd handler for the
 # <playlist> tag.
 #
 # Audio plugins are also allowed to use AudioItem to create a new AudioItem

Modified: trunk/ui/src/audio/audioitem.py
==============================================================================
--- trunk/ui/src/audio/audioitem.py     (original)
+++ trunk/ui/src/audio/audioitem.py     Sat Feb  3 20:14:40 2007
@@ -96,7 +96,6 @@
         MediaItem.set_url(self, url)
         if self.url.startswith('cdda://'):
             self.network_play = False
-            self.mimetype = 'cdda'
 
 
     def __getitem__(self, key):

Modified: trunk/ui/src/audio/interface.py
==============================================================================
--- trunk/ui/src/audio/interface.py     (original)
+++ trunk/ui/src/audio/interface.py     Sat Feb  3 20:14:40 2007
@@ -35,7 +35,8 @@
 
 # only export 'PluginInterface' to the outside. This will be used
 # with plugin.activate('audio') and everything else should be handled
-# by using plugin.mimetype()
+# by using media.get_plugins()
+
 __all__ = [ 'PluginInterface' ]
 
 # Python imports
@@ -44,10 +45,8 @@
 import stat
 
 # Freevo imports
-from freevo.ui import config
-from freevo.ui import util
-from freevo.ui import plugin
-from freevo.ui import fxditem
+from freevo.ui import config, util, plugin, fxditem
+from freevo.ui.media import MediaPlugin
 
 # AudioItem
 from audioitem import AudioItem
@@ -56,7 +55,7 @@
 # fxdhandler for <audio> tags
 from fxdhandler import fxdhandler
 
-class PluginInterface(plugin.MimetypePlugin):
+class PluginInterface(MediaPlugin):
     """
     Plugin to handle all kinds of audio items
     """

Modified: trunk/ui/src/directory.py
==============================================================================
--- trunk/ui/src/directory.py   (original)
+++ trunk/ui/src/directory.py   Sat Feb  3 20:14:40 2007
@@ -48,8 +48,8 @@
 import util
 
 import menu
-import plugin
 import fxditem
+import media
 
 from menu import Item, Files, Action, ActionItem
 from playlist import Playlist
@@ -179,8 +179,8 @@
         if self.display_type == 'tv':
             type = 'video'
 
-        # Check mimetype plugins if they want to add something
-        for p in plugin.mimetype(type):
+        # Check media plugins if they want to add something
+        for p in media.get_plugins(type):
             p.dirinfo(self)
 
 
@@ -208,7 +208,7 @@
                 log.info('create metainfo for %s', self.dir)
                 listing = 
kaa.beacon.query(parent=self.info).get(filter='extmap')
                 num_items = [ self.info.get('mtime'), 0 ]
-                for p in plugin.mimetype(display_type):
+                for p in media.get_plugins(display_type):
                     num_items[1] += p.count(self, listing)
                 num_items.append(len(listing.get('beacon:dir')))
                 if self.info.scanned():
@@ -280,7 +280,7 @@
         if event == DIRECTORY_CHANGE_DISPLAY_TYPE:
             possible = [ ]
 
-            for p in plugin.get('mimetype'):
+            for p in media.get_plugins():
                 for t in p.display_type:
                     if not t in possible:
                         possible.append(t)
@@ -413,7 +413,7 @@
         # build items
         #
         # build play_items, pl_items and dir_items
-        for p in plugin.mimetype(display_type):
+        for p in media.get_plugins(display_type):
             for i in p.get(self, listing):
                 if i.type == 'playlist':
                     pl_items.append(i)

Modified: trunk/ui/src/fxditem.py
==============================================================================
--- trunk/ui/src/fxditem.py     (original)
+++ trunk/ui/src/fxditem.py     Sat Feb  3 20:14:40 2007
@@ -55,6 +55,7 @@
 import util
 import plugin
 
+from media import MediaPlugin, get_plugins
 from menu import Item, Action, Menu
 
 # get logging object
@@ -70,7 +71,7 @@
     _callbacks.append((types, node, callback))
 
     
-class Mimetype(plugin.MimetypePlugin):
+class PluginInterface(MediaPlugin):
     """
     Class to handle fxd files in directories
     """
@@ -171,6 +172,6 @@
 
 
 
-# register the plugin as mimetype for fxd files
-mimetype = Mimetype()
-plugin.activate(mimetype, level=0)
+# load the MediaPlugin
+interface = PluginInterface()
+plugin.activate(interface, level=0)

Modified: trunk/ui/src/image/__init__.py
==============================================================================
--- trunk/ui/src/image/__init__.py      (original)
+++ trunk/ui/src/image/__init__.py      Sat Feb  3 20:14:40 2007
@@ -6,8 +6,8 @@
 #
 # This file imports everything needed to use this image module.  There
 # is only one class provided for images, the PluginInterface from
-# interface.py. It is a MimetypePlugin that can be accessed from
-# plugin.mimetype(). It will also register an fxd handler for the
+# interface.py. It is a MediaPlugin that can be accessed from
+# media.get_plugins(). It will also register an fxd handler for the
 # <slideshow> tag.
 #
 # Image plugins are also allowed to use ImageItem to create a new

Modified: trunk/ui/src/image/fxdhandler.py
==============================================================================
--- trunk/ui/src/image/fxdhandler.py    (original)
+++ trunk/ui/src/image/fxdhandler.py    Sat Feb  3 20:14:40 2007
@@ -60,6 +60,7 @@
 # Freevo imports
 from freevo.ui import config
 from freevo.ui import plugin
+from freevo.ui import media
 
 from freevo.ui.util import match_files
 from freevo.ui.playlist import Playlist
@@ -125,7 +126,7 @@
 
     files  = []
     suffix = []
-    for p in plugin.mimetype('audio'):
+    for p in media.get_plugins('audio'):
         suffix += p.suffix()
 
     for child in children:

Modified: trunk/ui/src/image/interface.py
==============================================================================
--- trunk/ui/src/image/interface.py     (original)
+++ trunk/ui/src/image/interface.py     Sat Feb  3 20:14:40 2007
@@ -35,13 +35,13 @@
 
 # only export 'PluginInterface' to the outside. This will be used
 # with plugin.activate('image') and everything else should be handled
-# by using plugin.mimetype()
+# by using media.get_plugins()
+
 __all__ = [ 'PluginInterface' ]
 
 # freevo imports
-from freevo.ui import config
-from freevo.ui import plugin
-from freevo.ui import fxditem
+from freevo.ui import config, plugin, fxditem
+from freevo.ui.media import MediaPlugin
 
 # ImageItem
 from imageitem import ImageItem
@@ -49,7 +49,7 @@
 # fxdhandler for <slideshow> tags
 from fxdhandler import fxdhandler
 
-class PluginInterface(plugin.MimetypePlugin):
+class PluginInterface(MediaPlugin):
     """
     Plugin to handle all kinds of image items
     """

Modified: trunk/ui/src/image/plugins/apod.py
==============================================================================
--- trunk/ui/src/image/plugins/apod.py  (original)
+++ trunk/ui/src/image/plugins/apod.py  Sat Feb  3 20:14:40 2007
@@ -41,6 +41,7 @@
 # freevo imports
 from freevo.ui import plugin
 from freevo.ui import menu
+from freevo.ui import media
 
 from freevo.ui.menu import Item, Action, ActionItem, Menu
 from freevo.ui.image import ImageItem
@@ -91,7 +92,7 @@
 
         # get items
         items = []
-        for p in plugin.mimetype('image'):
+        for p in media.get_plugins('image'):
             items += p.get(self, listing)
 
         if items:

Added: trunk/ui/src/media.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/media.py       Sat Feb  3 20:14:40 2007
@@ -0,0 +1,99 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# media.py - Media Handling
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# Media type handling
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2007 Dirk Meyer, et al.
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+import plugin
+
+class MediaPlugin(plugin.Plugin):
+    """
+    Plugin class for medias handled in a directory/playlist.
+    self.display_type is a list of display types where this media
+    should be displayed, [] for always.
+    """
+    display_type = []
+
+    def __init__(self, name=''):
+        plugin.Plugin.__init__(self, name)
+        self._plugin_type = 'media'
+
+
+    def suffix(self):
+        """
+        return the list of suffixes this class handles
+        """
+        return []
+
+
+    def get(self, parent, files):
+        """
+        return a list of items based on the files
+        """
+        return []
+
+
+    def count(self, parent, listing):
+        """
+        return how many items will be build on files
+        """
+        c = 0
+        for t in self.suffix():
+            c += len(listing.get(t))
+        return c
+
+
+    def dirinfo(self, diritem):
+        """
+        set informations for a diritem based on the content, etc.
+        """
+        pass
+
+
+    def database(self):
+        """
+        returns a database object
+        """
+        return None
+
+
+
+def get_plugins(display_type=None):
+    """
+    Return all MediaPlugins for the given display_type. If display_type
+    is None, return all MediaPlugins.
+    """
+    if not display_type:
+        return plugin.get('media')
+    ret = []
+    for p in plugin.get('media'):
+        if not p.display_type or display_type in p.display_type:
+            ret.append(p)
+    return ret

Modified: trunk/ui/src/menu/mediaitem.py
==============================================================================
--- trunk/ui/src/menu/mediaitem.py      (original)
+++ trunk/ui/src/menu/mediaitem.py      Sat Feb  3 20:14:40 2007
@@ -80,7 +80,6 @@
             self.filename     = ''      # filename if it's a file:// url
             self.mode         = ''      # the type (file, http, dvd...)
             self.files        = None    # Files
-            self.mimetype     = ''      # extention or mode
             self.name         = u''
             return
 
@@ -98,9 +97,6 @@
             self.filename     = self.url[7:]
             self.files.append(self.filename)
 
-            # set the suffix of the file as mimetype
-            self.mimetype = self.filename[self.filename.rfind('.')+1:].lower()
-
             # FIXME: this is slow. Maybe handle this in the gui code
             # and choose to print self.info.get('name')
             if self.parent and \
@@ -114,7 +110,6 @@
             # types like dvd are handled inside the derivated class
             self.network_play = True
             self.filename     = ''
-            self.mimetype     = self.type
             if not self.name:
                 self.name = self.info.get('title')
             if not self.name:

Modified: trunk/ui/src/playlist.py
==============================================================================
--- trunk/ui/src/playlist.py    (original)
+++ trunk/ui/src/playlist.py    Sat Feb  3 20:14:40 2007
@@ -46,6 +46,7 @@
 import util
 import plugin
 import fxditem
+from media import MediaPlugin, get_plugins
 
 from event import *
 from menu import Action, Item, MediaItem, Menu
@@ -175,7 +176,7 @@
         # Note: playlist is a list of Items, strings (filenames) or a
         # beacon queries now.
 
-        plugins = plugin.mimetype(self.display_type)
+        plugins = get_plugins(self.display_type)
         for item in playlist:
 
             if isinstance(item, Item):
@@ -449,12 +450,12 @@
 
 
 
-class Mimetype(plugin.MimetypePlugin):
+class PluginInterface(MediaPlugin):
     """
     Plugin class for playlist items
     """
     def __init__(self):
-        plugin.MimetypePlugin.__init__(self)
+        MediaPlugin.__init__(self)
 
         # add fxd parser callback
         fxditem.add_parser([], 'playlist', self.fxdhandler)
@@ -525,6 +526,6 @@
         return pl
 
 
-# load the MimetypePlugin
-mimetype = Mimetype()
-plugin.activate(mimetype)
+# load the MediaPlugin
+interface = PluginInterface()
+plugin.activate(interface)

Modified: trunk/ui/src/plugin.py
==============================================================================
--- trunk/ui/src/plugin.py      (original)
+++ trunk/ui/src/plugin.py      Sat Feb  3 20:14:40 2007
@@ -80,57 +80,6 @@
 
 
 
-class MimetypePlugin(Plugin):
-    """
-    Plugin class for mimetypes handled in a directory/playlist.
-    self.display_type is a list of display types where this mimetype
-    should be displayed, [] for always.
-    """
-    display_type = []
-
-    def __init__(self, name=''):
-        Plugin.__init__(self, name)
-        self._plugin_type = 'mimetype'
-
-
-    def suffix(self):
-        """
-        return the list of suffixes this class handles
-        """
-        return []
-
-
-    def get(self, parent, files):
-        """
-        return a list of items based on the files
-        """
-        return []
-
-
-    def count(self, parent, listing):
-        """
-        return how many items will be build on files
-        """
-        c = 0
-        for t in self.suffix():
-            c += len(listing.get(t))
-        return c
-
-
-    def dirinfo(self, diritem):
-        """
-        set informations for a diritem based on the content, etc.
-        """
-        pass
-
-
-    def database(self):
-        """
-        returns a database object
-        """
-        return None
-
-
 class PluginLoader(object):
     """
     Class for handling the different plugins.
@@ -376,16 +325,3 @@
 get = _loader.get
 getbyname = _loader.getbyname
 register = _loader.register
-
-def mimetype(display_type=None):
-    """
-    return all MimetypePlugins for the given display_type. If display_type
-    is None, return all MimetypePlugins.
-    """
-    if not display_type:
-        return get('mimetype')
-    ret = []
-    for p in get('mimetype'):
-        if not p.display_type or display_type in p.display_type:
-            ret.append(p)
-    return ret

Modified: trunk/ui/src/plugins/mbus.py
==============================================================================
--- trunk/ui/src/plugins/mbus.py        (original)
+++ trunk/ui/src/plugins/mbus.py        Sat Feb  3 20:14:40 2007
@@ -10,6 +10,7 @@
 from freevo.ui import plugin, application
 from freevo.ui.event import *
 from freevo.ui.directory import DirItem
+from freevo.ui.media import get_plugins
 
 import logging
 log = logging.getLogger('mbus')
@@ -61,7 +62,7 @@
         kaa.beacon.query(filename=unicode_to_str(file)).get(filter='extmap')
 
         # normal file
-        for p in plugin.mimetype(type):
+        for p in get_plugins(type):
             i = p.get(None, listing)
             if i and hasattr(i[0], 'play'):
                 i[0].play()

Modified: trunk/ui/src/plugins/mediamenu.py
==============================================================================
--- trunk/ui/src/plugins/mediamenu.py   (original)
+++ trunk/ui/src/plugins/mediamenu.py   Sat Feb  3 20:14:40 2007
@@ -48,6 +48,8 @@
 from freevo.ui.directory import DirItem
 from freevo.ui.mainmenu import MainMenuItem
 from freevo.ui.menu import Menu, Item
+from freevo.ui.media import get_plugins
+
 # from games import machine
 
 # get logging object
@@ -158,7 +160,7 @@
 
                 query = kaa.beacon.query(filename=filename)
                 listing = query.get(filter='extmap')
-                for p in plugin.mimetype(self.display_type):
+                for p in get_plugins(self.display_type):
                     p_items = p.get(self, listing)
                     if title:
                         for i in p_items:
@@ -173,7 +175,7 @@
             if media.mountpoint == '/':
                 continue
             listing = kaa.beacon.wrap(media.root, filter='extmap')
-            for p in plugin.mimetype(self.display_type):
+            for p in get_plugins(self.display_type):
                 items.extend(p.get(self, listing))
             for d in listing.get('beacon:dir'):
                 items.append(DirItem(d, self, name=media.label,

Modified: trunk/ui/src/plugins/unpack.py
==============================================================================
--- trunk/ui/src/plugins/unpack.py      (original)
+++ trunk/ui/src/plugins/unpack.py      Sat Feb  3 20:14:40 2007
@@ -1,6 +1,6 @@
 # -*- coding: iso-8859-1 -*-
 # -----------------------------------------------------------------------------
-# unpack.py - mimetype plugin for archives
+# unpack.py - media plugin for archives
 # -----------------------------------------------------------------------------
 # $Id$
 #
@@ -41,8 +41,8 @@
 import kaa.notifier
 
 # freevo imports
-from freevo.ui import plugin
 from freevo.ui import util
+from freevo.ui.media import MediaPlugin
 
 from freevo.ui.menu import Item, Action
 from freevo.ui.application import TextWindow
@@ -93,9 +93,9 @@
         self.pop.destroy()
 
         
-class PluginInterface(plugin.MimetypePlugin):
+class PluginInterface(MediaPlugin):
     """
-    A mimetype plugin for zip and rar archives.
+    A media plugin for zip and rar archives.
     """
     def suffix(self):
         """

Modified: trunk/ui/src/video/__init__.py
==============================================================================
--- trunk/ui/src/video/__init__.py      (original)
+++ trunk/ui/src/video/__init__.py      Sat Feb  3 20:14:40 2007
@@ -6,8 +6,8 @@
 #
 # This file imports everything needed to use this video module.
 # There is  only one class provided for video files, the PluginInterface
-# from interface.py. It is a MimetypePlugin that can be accessed
-# from plugin.mimetype(). It will also register an fxd handler for the
+# from interface.py. It is a MediaPlugin that can be accessed
+# from media.get_plugins(). It will also register an fxd handler for the
 # <movie> and <disc-set> tags.
 #
 # Video plugins are also allowed to use VideoItem to create a new VideoItem

Modified: trunk/ui/src/video/interface.py
==============================================================================
--- trunk/ui/src/video/interface.py     (original)
+++ trunk/ui/src/video/interface.py     Sat Feb  3 20:14:40 2007
@@ -41,10 +41,8 @@
 import string
 
 # freevo imports
-from freevo.ui import config
-from freevo.ui import util
-from freevo.ui import plugin
-from freevo.ui import fxditem
+from freevo.ui import config, util, plugin, fxditem
+from freevo.ui.media import MediaPlugin
 from freevo.ui.menu import Files
 
 # video imports
@@ -52,7 +50,7 @@
 import database
 import fxdhandler
 
-class PluginInterface(plugin.MimetypePlugin):
+class PluginInterface(MediaPlugin):
     """
     Plugin to handle all kinds of video items
     """
@@ -66,7 +64,7 @@
         fxditem.add_parser(['video'], 'movie', fxdhandler.parse_movie)
         # fxditem.add_parser(['video'], 'disc-set', fxdhandler.parse_disc_set)
 
-        # update the database based on the current mimetypes
+        # update the database
         database.update()
         
         # activate the mediamenu for video

Modified: trunk/ui/src/video/videoitem.py
==============================================================================
--- trunk/ui/src/video/videoitem.py     (original)
+++ trunk/ui/src/video/videoitem.py     Sat Feb  3 20:14:40 2007
@@ -143,7 +143,6 @@
         MediaItem.set_url(self, url)
         if self.url.startswith('dvd://') or self.url.startswith('vcd://'):
             self.network_play = False
-            self.mimetype = self.url[:self.url.find('://')].lower()
             if self.info.filename:
                 # dvd on harddisc, add '/' for xine
                 self.url = self.url + '/'
@@ -159,7 +158,6 @@
 
         elif self.url.endswith('.iso') and self.info['mime'] == 'video/dvd':
             # dvd iso
-            self.mimetype = 'dvd'
             self.mode     = 'dvd'
             self.url      = 'dvd' + self.url[4:] + '/'
             

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to