Skip to content
This repository has been archived by the owner on Jun 17, 2019. It is now read-only.

Commit

Permalink
added dictionary option type
Browse files Browse the repository at this point in the history
  • Loading branch information
jin_eld committed Feb 2, 2010
1 parent 30611b1 commit 41a52fe
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/config_manager.cc
Expand Up @@ -569,7 +569,11 @@ String ConfigManager::createDefaultConfig(String userhome)
Ref<Element> ext2mt(new Element(_("extension-mimetype")));
ext2mt->setAttribute(_("ignore-unknown"), _(DEFAULT_IGNORE_UNKNOWN_EXTENSIONS));
ext2mt->appendElementChild(map_from_to(_("mp3"), _("audio/mpeg")));
ext2mt->appendElementChild(map_from_to(_("ogg"), _("application/ogg")));
ext2mt->appendElementChild(map_from_to(_("ogx"), _("application/ogg")));
ext2mt->appendElementChild(map_from_to(_("ogv"), _("video/ogg")));
ext2mt->appendElementChild(map_from_to(_("oga"), _("audio/ogg")));
ext2mt->appendElementChild(map_from_to(_("ogg"), _("audio/ogg")));
ext2mt->appendElementChild(map_from_to(_("ogm"), _("video/ogg")));
ext2mt->appendElementChild(map_from_to(_("asf"), _("video/x-ms-asf")));
ext2mt->appendElementChild(map_from_to(_("asx"), _("video/x-ms-asf")));
ext2mt->appendElementChild(map_from_to(_("wma"), _("audio/x-ms-wma")));
Expand All @@ -581,6 +585,8 @@ String ConfigManager::createDefaultConfig(String userhome)
ext2mt->appendElementChild(map_from_to(_("m3u"), _("audio/x-mpegurl")));
ext2mt->appendElementChild(map_from_to(_("pls"), _("audio/x-scpls")));
ext2mt->appendElementChild(map_from_to(_("flv"), _("video/x-flv")));
ext2mt->appendElementChild(map_from_to(_("mkv"), _("video/x-matroska")));
ext2mt->appendElementChild(map_from_to(_("mka"), _("audio/x-matroska")));

Ref<Comment> ps3info(new Comment(_(" Uncomment the line below for PS3 divx support "), true));
Ref<Comment> ps3avi(new Comment(_(" <map from=\"avi\" to=\"video/divx\"/> "), true));
Expand Down Expand Up @@ -806,7 +812,14 @@ void ConfigManager::migrate()
Ref<ObjectArrayOption> (new ObjectArrayOption(optval));
#define SET_OBJARR_OPTION(opttype) \
options->set(RefCast(obj_array_opt, ConfigOption), opttype);
#endif
#endif//ONLINE_SERVICES

#define NEW_OBJDICT_OPTION(optval) obj_dict_opt = \
Ref<ObjectDictionaryOption> (new ObjectDictionaryOption(optval));
#define SET_OBJDICT_OPTION(opttype) \
options->set(RefCast(obj_dict_opt, ConfigOption), opttype);


void ConfigManager::validate(String serverhome)
{
String temp;
Expand Down Expand Up @@ -3066,6 +3079,11 @@ Ref<Array<StringBase> > ConfigManager::getStringArrayOption(config_option_t opti
return options->get(option)->getStringArrayOption();
}

Ref<ObjectDictionary<zmm::Object> > ConfigManager::getObjectDictionaryOption(config_option_t option)
{
return options->get(option)->getObjectDictionaryOption();
}

#ifdef ONLINE_SERVICES
Ref<Array<Object> > ConfigManager::getObjectArrayOption(config_option_t option)
{
Expand Down
2 changes: 2 additions & 0 deletions src/config_manager.h
Expand Up @@ -37,6 +37,7 @@
#include "mxml/mxml.h"
#include "singleton.h"
#include "dictionary.h"
#include "object_dictionary.h"
#include "xpath.h"
#include "autoscan.h"
#include "config_options.h"
Expand Down Expand Up @@ -229,6 +230,7 @@ class ConfigManager : public Singleton<ConfigManager>
/// \param option option to retrieve.
zmm::Ref<zmm::Array<zmm::StringBase> > getStringArrayOption(config_option_t option);

zmm::Ref<ObjectDictionary<zmm::Object> > getObjectDictionaryOption(config_option_t option);
#ifdef ONLINE_SERVICES
/// \brief returns a config option of type Array of Object
/// \param option option to retrieve.
Expand Down
24 changes: 23 additions & 1 deletion src/config_options.h
Expand Up @@ -36,6 +36,7 @@
#include "zmmf/zmmf.h"
#include "exceptions.h"
#include "autoscan.h"
#include "object_dictionary.h"

#ifdef EXTERNAL_TRANSCODING
#include "transcoding/transcoding.h"
Expand Down Expand Up @@ -94,6 +95,11 @@ class ConfigOption : public zmm::Object
throw _Exception(_("Wrong option type"));
}
#endif
virtual zmm::Ref<ObjectDictionary<zmm::Object> > getObjectDictionaryOption()
{
assert(0);
throw _Exception(_("Wrong option type"));
}
};

class Option : public ConfigOption
Expand Down Expand Up @@ -209,6 +215,22 @@ class ObjectArrayOption : public ConfigOption
zmm::Ref<zmm::Array<zmm::Object> > option;
};

#endif//ONLINE_SERVICES

class ObjectDictionaryOption : public ConfigOption
{
public:
ObjectDictionaryOption(zmm::Ref<ObjectDictionary<zmm::Object> > option)
{
this->option = option;
};

virtual zmm::Ref<ObjectDictionary<zmm::Object> > getObjectDictionaryOption()
{
return option;
};
protected:
zmm::Ref<ObjectDictionary<zmm::Object> > option;
};

#endif
#endif // __CONFIG_MANAGER_H__

0 comments on commit 41a52fe

Please sign in to comment.