summaryrefslogtreecommitdiff
path: root/muggle.c
diff options
context:
space:
mode:
Diffstat (limited to 'muggle.c')
-rw-r--r--muggle.c342
1 files changed, 172 insertions, 170 deletions
diff --git a/muggle.c b/muggle.c
index 8346337..f08a1d2 100644
--- a/muggle.c
+++ b/muggle.c
@@ -1,10 +1,10 @@
-/*!
+/*!
* \file muggle.c
* \brief Implements a plugin for browsing media libraries within VDR
*
* \version $Revision: 1.10 $
* \date $Date$
- * \author Ralf Klueber, Lars von Wedel, Andreas Kellner
+ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner, Wolfgang Rohdewald
* \author Responsible author: $Author$
*
* $Id$
@@ -15,222 +15,224 @@
#include "vdr_menu.h"
#include "vdr_setup.h"
#include "mg_tools.h"
-#include "mg_playlist.h"
-#include "mg_content_interface.h"
-#include "mg_media.h"
+#include "mg_db.h"
#include "i18n.h"
#include <getopt.h>
#include <config.h>
-static const char *VERSION = "0.0.8";
-static const char *DESCRIPTION = "Media juggle plugin for VDR";
-static const char *MAINMENUENTRY = "Muggle";
+static const char *VERSION = "0.1.0";
+static const char *DESCRIPTION = "Media juggle plugin for VDR";
+static const char *MAINMENUENTRY = "Muggle";
-static unsigned s_resume_idx = 0;
-
-const char* mgMuggle::Version(void)
-{
- return VERSION;
+const char *
+mgMuggle::Version (void)
+{
+ return VERSION;
}
-const char* mgMuggle::Description(void)
-{
- return DESCRIPTION;
-}
-const char* mgMuggle::MainMenuEntry(void)
-{
- return MAINMENUENTRY;
-}
-
-mgMuggle::mgMuggle(void)
+const char *
+mgMuggle::Description (void)
{
- // defaults for database arguments
- the_setup.DbHost = strdup ("localhost");
- the_setup.DbSocket = NULL;
- the_setup.DbPort = 0;
- the_setup.DbName = strdup ("GiantDisc");
- the_setup.DbUser = strdup ("");
- the_setup.DbPass = strdup ("");
- the_setup.GdCompatibility = false;
- the_setup.ToplevelDir = strdup ("/mnt/music/");
+ return DESCRIPTION;
}
-mgMuggle::~mgMuggle()
-{
- // Clean up after yourself!
- // save current playlist as "current" and it will be retrieved at the next startup
- if( m_playlist )
- {
- m_playlist->storeAs( "current" );
- }
-}
-const char *mgMuggle::CommandLineHelp(void)
+const char *
+mgMuggle::MainMenuEntry (void)
{
- // Return a string that describes all known command line options.
- return
- " -h HHHH, --host=HHHH specify database host (default is localhost)\n"
- " -s SSSS --socket=PATH specify database socket (default is TCP connection)\n"
- " -n NNNN, --name=NNNN specify database name (overridden by -g)\n"
- " -p PPPP, --port=PPPP specify port of database server (default is )\n"
- " -u UUUU, --user=UUUU specify database user (default is )\n"
- " -w WWWW, --password=WWWW specify database password (default is empty)\n"
- " -t TTTT, --toplevel=TTTT specify toplevel directory for music (default is /mnt/music)\n"
- " -g, --giantdisc enable full Giantdisc compatibility mode\n";
+ return MAINMENUENTRY;
}
-bool mgMuggle::ProcessArgs(int argc, char *argv[])
-{
- mgDebug( 1, "mgMuggle::ProcessArgs" );
-
- // Implement command line argument processing here if applicable.
- static struct option long_options[] =
- {
- { "host", required_argument, NULL, 'h' },
- { "socket", required_argument, NULL, 's' },
- { "name", required_argument, NULL, 'n' },
- { "port", required_argument, NULL, 'p' },
- { "user", required_argument, NULL, 'u' },
- { "password", required_argument, NULL, 'w' },
- { "toplevel", required_argument, NULL, 't' },
- { "giantdisc", no_argument, NULL, 'g' },
- { NULL }
- };
-
- int c, option_index = 0;
- while( ( c = getopt_long( argc, argv, "gh:s:n:p:t:u:w:", long_options, &option_index ) ) != -1 )
- {
- switch (c)
- {
- case 'h':
- {
- the_setup.DbHost = strcpyrealloc (the_setup.DbHost, optarg);
- } break;
- case 's':
- {
- the_setup.DbSocket = strcpyrealloc (the_setup.DbSocket, optarg);
- } break;
- case 'n':
- {
- the_setup.DbName = strcpyrealloc (the_setup.DbName, optarg);
- } break;
- case 'p':
- {
- the_setup.DbPort = atoi( optarg );
- } break;
- case 'u':
- {
- the_setup.DbUser = strcpyrealloc (the_setup.DbUser, optarg);
- } break;
- case 'w':
- {
- the_setup.DbPass = strcpyrealloc (the_setup.DbPass, optarg);
- } break;
- case 't':
- {
- if (optarg[strlen(optarg) - 1] != '/')
- {
- std::string res = std::string(optarg) + "/";
- the_setup.ToplevelDir = strdup( res.c_str() );
- }
- else
- {
- the_setup.ToplevelDir = strcpyrealloc (the_setup.ToplevelDir, optarg);
- }
- } break;
- case 'g':
- {
- the_setup.DbName = strcpyrealloc (the_setup.DbName, "GiantDisc");
- the_setup.GdCompatibility = true;
- } break;
- default: return false;
- }
- }
- return true;
+mgMuggle::mgMuggle (void)
+{
+ main = NULL;
+// defaults for database arguments
+ the_setup.DbHost = strdup ("localhost");
+ the_setup.DbSocket = NULL;
+ the_setup.DbPort = 0;
+ the_setup.DbName = strdup ("GiantDisc");
+ the_setup.DbUser = strdup ("");
+ the_setup.DbPass = strdup ("");
+ the_setup.GdCompatibility = false;
+ the_setup.ToplevelDir = strdup ("/mnt/music/");
}
-bool mgMuggle::Initialize(void)
+
+mgMuggle::~mgMuggle ()
{
- // Initialize any background activities the plugin shall perform.
- return true;
+// Clean up after yourself!
+ if (main) main->SaveState();
}
-bool mgMuggle::Start(void)
+
+const char *
+mgMuggle::CommandLineHelp (void)
{
- // Start any background activities the plugin shall perform.
- mgSetDebugLevel( 99 );
- RegisterI18n( Phrases );
+// Return a string that describes all known command line options.
+ return
+ " -h HHHH, --host=HHHH specify database host (default is localhost)\n"
+ " -s SSSS --socket=PATH specify database socket (default is TCP connection)\n"
+ " -n NNNN, --name=NNNN specify database name (overridden by -g)\n"
+ " -p PPPP, --port=PPPP specify port of database server (default is )\n"
+ " -u UUUU, --user=UUUU specify database user (default is )\n"
+ " -w WWWW, --password=WWWW specify database password (default is empty)\n"
+ " -t TTTT, --toplevel=TTTT specify toplevel directory for music (default is /mnt/music)\n"
+ " -g, --giantdisc enable full Giantdisc compatibility mode\n";
+}
- // Database initialization
- m_media = new mgMedia( mgMedia::GD_MP3 );
- m_root = m_media->getSelectionRoot();
- m_playlist = m_media->createTemporaryPlaylist();
- m_media->initFilterSet();
- // Read commands for playlists in etc. /video/muggle/playlist_commands.conf
- m_playlist_commands = new cCommands();
+bool mgMuggle::ProcessArgs (int argc, char *argv[])
+{
+ mgDebug (1, "mgMuggle::ProcessArgs");
- char *cmd_file = (char *) AddDirectory( cPlugin::ConfigDirectory("muggle"), "playlist_commands.conf" );
- mgDebug( 1, "mgMuggle::Start: Looking for file %s", cmd_file );
- bool have_cmd_file = m_playlist_commands->Load( (const char*) cmd_file );
+// Implement command line argument processing here if applicable.
+ static struct option
+ long_options[] =
+ {
+ {"host", required_argument, NULL, 'h'},
+ {"socket", required_argument, NULL, 's'},
+ {"name", required_argument, NULL, 'n'},
+ {"port", required_argument, NULL, 'p'},
+ {"user", required_argument, NULL, 'u'},
+ {"password", required_argument, NULL, 'w'},
+ {"toplevel", required_argument, NULL, 't'},
+ {"giantdisc", no_argument, NULL, 'g'},
+ {NULL}
+ };
- if( !have_cmd_file )
+ int
+ c,
+ option_index = 0;
+ while ((c =
+ getopt_long (argc, argv, "gh:s:n:p:t:u:w:", long_options,
+ &option_index)) != -1)
{
- delete m_playlist_commands;
- m_playlist_commands = NULL;
+ switch (c)
+ {
+ case 'h':
+ {
+ the_setup.DbHost = strcpyrealloc (the_setup.DbHost, optarg);
+ }
+ break;
+ case 's':
+ {
+ the_setup.DbSocket = strcpyrealloc (the_setup.DbSocket, optarg);
+ }
+ break;
+ case 'n':
+ {
+ the_setup.DbName = strcpyrealloc (the_setup.DbName, optarg);
+ }
+ break;
+ case 'p':
+ {
+ the_setup.DbPort = atoi (optarg);
+ }
+ break;
+ case 'u':
+ {
+ the_setup.DbUser = strcpyrealloc (the_setup.DbUser, optarg);
+ }
+ break;
+ case 'w':
+ {
+ the_setup.DbPass = strcpyrealloc (the_setup.DbPass, optarg);
+ }
+ break;
+ case 't':
+ {
+ if (optarg[strlen (optarg) - 1] != '/')
+ {
+ std::string res = std::string (optarg) + "/";
+ the_setup.ToplevelDir = strdup (res.c_str ());
+ }
+ else
+ {
+ the_setup.ToplevelDir =
+ strcpyrealloc (the_setup.ToplevelDir, optarg);
+ }
+ }
+ break;
+ case 'g':
+ {
+ the_setup.DbName = strcpyrealloc (the_setup.DbName, "GiantDisc");
+ the_setup.GdCompatibility = true;
+ }
+ break;
+ default:
+ return false;
+ }
}
- return true;
+ return true;
}
-void mgMuggle::Housekeeping(void)
+
+bool mgMuggle::Initialize (void)
{
- // Perform any cleanup or other regular tasks.
+// Initialize any background activities the plugin shall perform.
+ return true;
}
-cOsdObject *mgMuggle::MainMenuAction(void)
-{
- // Perform the action when selected from the main VDR menu.
- cOsdObject* osd = new mgMainMenu( m_media, m_root, m_playlist,
- m_playlist_commands );
- return osd;
+bool mgMuggle::Start (void)
+{
+// Start any background activities the plugin shall perform.
+ mgSetDebugLevel (99);
+ RegisterI18n (Phrases);
+ return true;
}
-cMenuSetupPage *mgMuggle::SetupMenu(void)
+
+void
+mgMuggle::Housekeeping (void)
{
- return new mgMenuSetup();
+// Perform any cleanup or other regular tasks.
}
-bool mgMuggle::SetupParse(const char *Name, const char *Value)
+
+cOsdObject *
+mgMuggle::MainMenuAction (void)
{
- mgDebug( 1, "mgMuggle::SetupParse" );
-
- if (!strcasecmp(Name, "InitLoopMode")) the_setup.InitLoopMode = atoi(Value);
- else if (!strcasecmp(Name, "InitShuffleMode")) the_setup.InitShuffleMode = atoi(Value);
- else if (!strcasecmp(Name, "AudioMode")) the_setup.AudioMode = atoi(Value);
- else if (!strcasecmp(Name, "DisplayMode")) the_setup.DisplayMode = atoi(Value);
- else if (!strcasecmp(Name, "BackgrMode")) the_setup.BackgrMode = atoi(Value);
- else if (!strcasecmp(Name, "TargetLevel")) the_setup.TargetLevel = atoi(Value);
- else if (!strcasecmp(Name, "LimiterLevel")) the_setup.LimiterLevel = atoi(Value);
- else if (!strcasecmp(Name, "Only48kHz")) the_setup.Only48kHz = atoi(Value);
- else return false;
-
- return true;
+// Perform the action when selected from the main VDR menu.
+ main = new mgMainMenu ();
+ return main;
}
-void mgMuggle::setResumeIndex( unsigned index )
+cMenuSetupPage *
+mgMuggle::SetupMenu (void)
{
- s_resume_idx = index;
+ return new mgMenuSetup ();
}
-unsigned mgMuggle::getResumeIndex( )
+
+bool mgMuggle::SetupParse (const char *Name, const char *Value)
{
- return s_resume_idx;
+ if (!strcasecmp (Name, "InitLoopMode"))
+ the_setup.InitLoopMode = atoi (Value);
+ else if (!strcasecmp (Name, "InitShuffleMode"))
+ the_setup.InitShuffleMode = atoi (Value);
+ else if (!strcasecmp (Name, "AudioMode"))
+ the_setup.AudioMode = atoi (Value);
+ else if (!strcasecmp (Name, "DisplayMode"))
+ the_setup.DisplayMode = atoi (Value);
+ else if (!strcasecmp (Name, "BackgrMode"))
+ the_setup.BackgrMode = atoi (Value);
+ else if (!strcasecmp (Name, "TargetLevel"))
+ the_setup.TargetLevel = atoi (Value);
+ else if (!strcasecmp (Name, "LimiterLevel"))
+ the_setup.LimiterLevel = atoi (Value);
+ else if (!strcasecmp (Name, "Only48kHz"))
+ the_setup.Only48kHz = atoi (Value);
+ else
+ return false;
+
+ return true;
}
-VDRPLUGINCREATOR(mgMuggle); // Don't touch this!
+
+VDRPLUGINCREATOR (mgMuggle); // Don't touch this!