summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-11 18:18:36 +0000
committerLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-11 18:18:36 +0000
commit283a4201828edde1cf92e59ccbb0395a0f894538 (patch)
treea3126652556700dca24915d9b24b29e0616a2f84
parent37ee0c18279d0b328a874c4d058d7ae3b7d2c699 (diff)
downloadvdr-plugin-muggle-283a4201828edde1cf92e59ccbb0395a0f894538.tar.gz
vdr-plugin-muggle-283a4201828edde1cf92e59ccbb0395a0f894538.tar.bz2
Merged changes from 0.1.4-wr
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@565 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--HISTORY17
-rw-r--r--Makefile26
-rw-r--r--mg_mysql.c182
-rw-r--r--mg_mysql.h3
-rw-r--r--mg_sync.c4
-rw-r--r--muggle.c39
-rwxr-xr-xmugglei.c15
-rw-r--r--vdr_actions.c35
-rw-r--r--vdr_menu.c17
-rw-r--r--vdr_menu.h1
-rw-r--r--vdr_setup.c7
11 files changed, 215 insertions, 131 deletions
diff --git a/HISTORY b/HISTORY
index 687ff02..d5a168c 100644
--- a/HISTORY
+++ b/HISTORY
@@ -82,7 +82,6 @@ XXXXXXXXXX: Version 0.0.8-ALPHA
- GD compatibility added
- Many bugfixes and usability improvements
-2005-02-07: Version 0.1.2-BETA
- Die Organisation der Dateien kann nun vom Benutzer verändert werden.
Zudem können neue Bäume erstellt werden (zB mag ich
Decade > Genre > Track sehr gern).
@@ -162,3 +161,19 @@ XXXXXXXXXX: Version 0.0.8-ALPHA
exist (debian: Package iso-codes)
- add all genres listed by id3 -L. Fix spellings.
- lots of bug fixes, as usual
+
+2005-03-XX: Version 0.1.5-BETA
+- add include files like stdio.h, needed in some environments
+- fix genre import
+- if you have mysql embedded 4.1.11 or better, you can access embedded
+ and external data bases with the same binary. If you omit the -h
+ parameter, embedded is used. Without embedded support compiled in,
+ the default for -h is still localhost
+- renamed the Makefile conditional HAVE_SERVER to HAVE_ONLY_SERVER. This
+ better reflects the new functionality.
+- if you want to connect to the local server using sockets, you now
+ do that with -h localhost. Up to now you had to specify -s. This is
+ no longer needed. This better reflects the mysql C API. As a con-
+ sequence, up to now not giving any argument to muggle called the
+ server on localhost using TCP, now it uses the faster sockets. You
+ can still request TCP by using -h 127.0.0.1
diff --git a/Makefile b/Makefile
index 0b1c55c..1bc0296 100644
--- a/Makefile
+++ b/Makefile
@@ -14,10 +14,10 @@ PLUGIN = muggle
# HAVE_VORBISFILE=1
# HAVE_FLAC=1
-#if you want to use a dedicated Mysql server instead of the embedded code,
+#if you do not want to compile in code for embedded sql,
#define this in $VDRDIR/Make.config:
-# HAVE_SERVER=1
-#
+# HAVE_ONLY_SERVER=1
+
### The version number of this plugin (taken from the main source file):
VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).c | awk '{ print $$6 }' | sed -e 's/[";]//g')
@@ -51,24 +51,24 @@ PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
INCLUDES += -I$(VDRDIR) -I$(VDRDIR)/include -I$(DVBDIR)/include \
- -I/usr/include/mysql/ -I/usr/include/taglib
+ $(shell mysql_config --cflags) $(shell taglib-config --cflags)
-DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
+DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DMYSQLCLIENTVERSION='"$(shell mysql_config --version)"'
### The object files (add further files here):
OBJS = $(PLUGIN).o i18n.o mg_valmap.o mg_mysql.o mg_sync.o mg_order.o mg_content.o mg_selection.o vdr_actions.o vdr_menu.o mg_tools.o \
- vdr_decoder_mp3.o vdr_decoder_ogg.o vdr_decoder_flac.o vdr_stream.o vdr_decoder.o vdr_player.o \
+ vdr_decoder_mp3.o vdr_stream.o vdr_decoder.o vdr_player.o \
vdr_setup.o mg_setup.o
-LIBS = -lmad -ltag
-MILIBS = -ltag
+LIBS = -lmad $(shell taglib-config --libs)
+MILIBS = $(shell taglib-config --libs)
-ifdef HAVE_SERVER
-SQLLIBS = `mysql_config --libs`
-DEFINES += -DHAVE_SERVER
+ifdef HAVE_ONLY_SERVER
+SQLLIBS = $(shell mysql_config --libs)
+DEFINES += -DHAVE_ONLY_SERVER
else
-SQLLIBS = `mysql_config --libmysqld-libs` -L/lib
+SQLLIBS = $(shell mysql_config --libmysqld-libs) -L/lib
endif
ifdef HAVE_VORBISFILE
@@ -115,7 +115,7 @@ install:
@cp mugglei /usr/local/bin/
# @install -m 755 mugglei /usr/local/bin/
-dist: clean
+dist: clean mg_tables.h
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
diff --git a/mg_mysql.c b/mg_mysql.c
index 8c315f3..f50cafb 100644
--- a/mg_mysql.c
+++ b/mg_mysql.c
@@ -11,7 +11,9 @@
#include "mg_tools.h"
#include <assert.h>
+#include <stdio.h>
#include <stdarg.h>
+#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
@@ -20,6 +22,8 @@
bool needGenre2;
static bool needGenre2_set;
+bool NoHost();
+bool UsingEmbedded();
class mysqlhandle_t {
public:
@@ -27,22 +31,25 @@ class mysqlhandle_t {
~mysqlhandle_t();
};
-#ifndef HAVE_SERVER
+
static char *datadir;
-static char *server_args[] =
+static char *embedded_args[] =
{
"muggle",
"--datadir=/tmp", // stupid default
"--key_buffer_size=32M"
};
-static char *server_groups[] =
+
+#ifndef HAVE_ONLY_SERVER
+static char *embedded_groups[] =
{
"embedded",
"server",
"muggle_SERVER",
0
};
+#endif
void
set_datadir(char *dir)
@@ -50,7 +57,7 @@ set_datadir(char *dir)
mgDebug(1,"setting datadir to %s",dir);
struct stat stbuf;
datadir=strdup(dir);
- asprintf(&server_args[1],"--datadir=%s",datadir);
+ asprintf(&embedded_args[1],"--datadir=%s",datadir);
if (stat(datadir,&stbuf))
mkdir(datadir,0755);
if (stat(datadir,&stbuf))
@@ -58,21 +65,33 @@ set_datadir(char *dir)
mgError("Cannot access datadir %s: errno=%d",datadir,errno);
}
}
-#endif
+
mysqlhandle_t::mysqlhandle_t()
{
-#ifndef HAVE_SERVER
- mgDebug(1,"calling mysql_server_init");
- if (mysql_server_init(sizeof(server_args) / sizeof(char *),
- server_args, server_groups))
+#ifndef HAVE_ONLY_SERVER
+ int argv_size;
+ if (UsingEmbedded())
+ {
+ mgDebug(1,"calling mysql_server_init for embedded");
+ argv_size = sizeof(embedded_args) / sizeof(char *);
+ }
+ else
+ {
+ if (strcmp(MYSQLCLIENTVERSION,"4.1.11")<0)
+ mgError("You have embedded mysql. For accessing external servers "
+ "you need mysql 4.1.11 but you have only %s", MYSQLCLIENTVERSION);
+ mgDebug(1,"calling mysql_server_init for external");
+ argv_size = -1;
+ }
+ if (mysql_server_init(argv_size, embedded_args, embedded_groups))
mgDebug(3,"mysql_server_init failed");
#endif
}
mysqlhandle_t::~mysqlhandle_t()
{
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
mgDebug(3,"calling mysql_server_end");
mysql_server_end();
#endif
@@ -266,6 +285,12 @@ static char *db_cmds[] =
"TYPE=MyISAM;"
};
+bool
+mgmySql::sql_query(const char *sql)
+{
+ return mysql_query(m_db,sql);
+}
+
MYSQL_RES*
mgmySql::exec_sql( string query)
@@ -273,7 +298,7 @@ mgmySql::exec_sql( string query)
if (!m_db || query.empty())
return 0;
mgDebug(4,"exec_sql(%X,%s)",m_db,query.c_str());
- if (mysql_query (m_db, (query + ';').c_str ()))
+ if (sql_query (query.c_str ()))
{
mgError("SQL Error in %s: %s",query.c_str(),mysql_error (m_db));
std::cout<<"ERROR in " << query << ":" << mysql_error(m_db)<<std::endl;
@@ -376,34 +401,36 @@ void mgmySql::Create()
createtime=time(0);
// create database and tables
mgDebug(1,"Dropping and recreating database %s",the_setup.DbName);
- if (mysql_query(m_db,"DROP DATABASE IF EXISTS GiantDisc;"))
+ if (sql_query("DROP DATABASE IF EXISTS GiantDisc;"))
{
mgWarning("Cannot drop existing database:%s",mysql_error (m_db));
return;
}
- if (mysql_query(m_db,"CREATE DATABASE GiantDisc;"))
+ if (sql_query("CREATE DATABASE GiantDisc;"))
{
mgWarning("Cannot create database:%s",mysql_error (m_db));
return;
}
-#ifdef HAVE_SERVER
- mysql_query(m_db,"grant all privileges on GiantDisc.* to vdr@localhost;");
- // ignore error. If we can create the data base, we can do everything
- // with it anyway.
-#endif
- mysql_query(m_db,"use GiantDisc;");
+
+ if (!UsingEmbedded())
+ sql_query("grant all privileges on GiantDisc.* to vdr@localhost;");
+ // ignore error. If we can create the data base, we can do everything
+ // with it anyway.
+
+ if (mysql_select_db(m_db,the_setup.DbName))
+ mgError("mysql_select_db(%s) failed with %s",mysql_error(m_db));
+
int len = sizeof( db_cmds ) / sizeof( char* );
for( int i=0; i < len; i ++ )
{
- if (mysql_query (m_db, db_cmds[i]))
+ if (sql_query (db_cmds[i]))
{
mgWarning("%20s: %s",db_cmds[i],mysql_error (m_db));
- mysql_query(m_db, "DROP DATABASE IF EXISTS GiantDisc;"); // clean up
+ sql_query("DROP DATABASE IF EXISTS GiantDisc;"); // clean up
return;
}
}
m_database_found=true;
- Use();
FillTables();
}
@@ -459,79 +486,64 @@ mgmySql::Connected () const
return m_database_found;
}
+bool
+NoHost()
+{
+ return (!the_setup.DbHost
+ || strlen(the_setup.DbHost)==0);
+}
+
+bool
+UsingEmbedded()
+{
+#ifdef HAVE_ONLY_SERVER
+ return false;
+#else
+ return NoHost();
+#endif
+}
+
void
mgmySql::Connect ()
{
assert(!m_db);
-#ifdef HAVE_SERVER
- if (the_setup.DbHost == "") return;
-#endif
m_db = mysql_init (0);
if (!m_db)
return;
-#ifdef HAVE_SERVER
- bool success;
- if (the_setup.DbSocket != NULL)
+ if (UsingEmbedded())
{
- mgDebug(1,"Using socket %s for connecting to server as user %s.",
- the_setup.DbSocket,
- the_setup.DbUser);
- mgDebug(3,"DbPassword is: '%s'",the_setup.DbPass);
- success = (mysql_real_connect( m_db,
- "",
- the_setup.DbUser,
- the_setup.DbPass,
- 0,
- 0,
- the_setup.DbSocket, 0 ) != 0 );
+ if (!mysql_real_connect(m_db, 0, 0, 0, 0, 0, 0, 0))
+ mgWarning("Failed to connect to embedded mysql in %s:%s ",datadir,mysql_error(m_db));
+ else
+ mgDebug(1,"Connected to embedded mysql in %s",datadir);
}
else
{
- mgDebug(1,"Using TCP for connecting to server %s as user %s.",
- the_setup.DbHost,
- the_setup.DbUser);
- mgDebug(3,"DbPassword is: '%s'",the_setup.DbPass);
- success = ( mysql_real_connect( m_db,
- the_setup.DbHost,
- the_setup.DbUser,
- the_setup.DbPass,
- 0,
- the_setup.DbPort,
- 0, 0 ) != 0 );
+ if (NoHost() || !strcmp(the_setup.DbHost,"localhost"))
+ mgDebug(1,"Using socket %s for connecting to local system as user %s.",
+ the_setup.DbSocket, the_setup.DbUser);
+ else
+ mgDebug(1,"Using TCP for connecting to server %s as user %s.",
+ the_setup.DbHost, the_setup.DbUser);
+ if (!mysql_real_connect( m_db,
+ the_setup.DbHost, the_setup.DbUser, the_setup.DbPass, 0,
+ the_setup.DbPort, the_setup.DbSocket, 0 ) != 0 )
+ {
+ mgWarning("Failed to connect to server '%s' as User '%s', Password '%s': %s",
+ the_setup.DbHost,the_setup.DbUser,the_setup.DbPass,mysql_error(m_db));
+ mysql_close (m_db);
+ m_db = 0;
+ }
}
- if (!success)
- {
- mgWarning("Failed to connect to server '%s' as User '%s', Password '%s': %s",
- the_setup.DbHost,the_setup.DbUser,the_setup.DbPass,mysql_error(m_db));
- mysql_close (m_db);
- m_db = 0;
- }
-#else
- if (!mysql_real_connect(m_db, 0, 0, 0, 0, 0, 0, 0))
- mgWarning("Failed to connect to embedded mysql in %s:%s ",datadir,mysql_error(m_db));
- else
- mgDebug(1,"Connected to embedded mysql in %s",datadir);
-#endif
if (m_db)
{
- mysql_query(m_db,"SHOW DATABASES");
- MYSQL_RES * rows = mysql_store_result(m_db);
- if (rows)
+ m_database_found = mysql_select_db(m_db,the_setup.DbName)==0;
{
- MYSQL_ROW row;
- while ((row = mysql_fetch_row (rows)) != 0)
- if (!strcmp(row[0],the_setup.DbName))
- {
- m_database_found=true;
- break;
- }
- mysql_free_result(rows);
+ if (!Connected())
+ if (!createtime)
+ mgWarning("Database %s not found:%s",
+ the_setup.DbName,mysql_error(m_db));
}
- if (m_database_found)
- Use();
- else
- if (!createtime)
- mgWarning("Database %s does not exist",the_setup.DbName);
}
if (!needGenre2_set && Connected())
{
@@ -541,14 +553,6 @@ mgmySql::Connect ()
return;
}
-void
-mgmySql::Use()
-{
- char b[100];
- sprintf(b,"USE %s;",the_setup.DbName);
- mysql_query(m_db,b);
- mgDebug(1,"found database %s",the_setup.DbName);
-}
void
mgmySql::CreateFolderFields()
@@ -557,7 +561,7 @@ mgmySql::CreateFolderFields()
return;
if (HasFolderFields())
return;
- mysql_query(m_db,"DESCRIBE tracks folder1");
+ sql_query("DESCRIBE tracks folder1");
MYSQL_RES *rows = mysql_store_result(m_db);
if (rows)
{
@@ -565,7 +569,7 @@ mgmySql::CreateFolderFields()
mysql_free_result(rows);
if (!m_hasfolderfields)
{
- m_hasfolderfields = !mysql_query(m_db,
+ m_hasfolderfields = !sql_query(
"alter table tracks add column folder1 varchar(255),"
"add column folder2 varchar(255),"
"add column folder3 varchar(255),"
diff --git a/mg_mysql.h b/mg_mysql.h
index eddc34e..3c3fde1 100644
--- a/mg_mysql.h
+++ b/mg_mysql.h
@@ -62,16 +62,15 @@ class mgmySql
bool Connected() const;
bool HasFolderFields() const { return m_hasfolderfields;}
void Connect();
- void Use();
//! \brief create database and tables
void Create();
void FillTables();
void CreateFolderFields();
-
private:
MYSQL *m_db;
bool m_database_found;
bool m_hasfolderfields;
+ bool sql_query(const char *query);
};
#endif
diff --git a/mg_sync.c b/mg_sync.c
index 73f0bce..dff458f 100644
--- a/mg_sync.c
+++ b/mg_sync.c
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <stdio.h>
#include <fts.h>
#include <sys/time.h>
#include <time.h>
@@ -208,7 +209,8 @@ mgSync::GetFileInfo(const char *filename)
*slash='\'';
*(slash+1)=0;
}
- const char *genrename=tag->genre().toCString();
+ TagLib::String sgenre1=tag->genre();
+ const char *genrename=sgenre1.toCString();
const char *genreid=m_Genres[genrename].c_str();
sql_Cstring(genreid,c_genre1);
sql_Cstring(getlanguage(filename),c_lang);
diff --git a/muggle.c b/muggle.c
index 7259078..3137f78 100644
--- a/muggle.c
+++ b/muggle.c
@@ -49,15 +49,15 @@ mgMuggle::mgMuggle (void)
{
main = NULL;
// defaults for database arguments
- the_setup.DbHost = strdup ("localhost");
- the_setup.DbSocket = NULL;
+ the_setup.DbHost = 0;
+ the_setup.DbSocket = 0;
the_setup.DbPort = 0;
the_setup.DbName = strdup ("GiantDisc");
- the_setup.DbUser = strdup ("");
- the_setup.DbPass = strdup ("");
+ the_setup.DbUser = 0;
+ the_setup.DbPass = 0;
the_setup.GdCompatibility = false;
the_setup.ToplevelDir = strdup ("/mnt/music/");
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
char *buf;
asprintf(&buf,"%s/.muggle",getenv("HOME"));
set_datadir(buf);
@@ -85,25 +85,40 @@ mgMuggle::CommandLineHelp (void)
{
// Return a string that describes all known command line options.
return
+#ifdef HAVE_ONLY_SERVER
" -h HHHH, --host=HHHH specify database host (default is localhost)\n"
- " -s SSSS --socket=PATH specify database socket (default is TCP connection)\n"
+#else
+ " -h HHHH, --host=HHHH specify database host (default is mysql embedded)\n"
+#endif
+ " -s SSSS --socket=PATH specify database socket\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"
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
" -d DIRN, --datadir=DIRN specify directory for embedded sql data (default is $HOME/.muggle)\n"
#endif
" -g, --giantdisc enable full Giantdisc compatibility mode\n"
- " -v, --verbose specify debug level. The higher the more. Default is 1\n";
+ " -v, --verbose specify debug level. The higher the more. Default is 1\n"
+ "\n"
+ "if the specified host is localhost, sockets will be used if possible.\n"
+ "Otherwise the -s parameter will be ignored";
}
bool mgMuggle::ProcessArgs (int argc, char *argv[])
{
mgSetDebugLevel (1);
- mgDebug (1, "mgMuggle::ProcessArgs");
+ char b[1000];
+ sprintf(b,"mgMuggle::ProcessArgs ");
+ for (int i=1;i<argc;i++)
+ {
+ if (strlen(b)+strlen(argv[i]+2)>1000) break;;
+ strcat(b," ");
+ strcat(b,argv[i]);
+ }
+ mgDebug(1,b);
// Implement command line argument processing here if applicable.
static struct option
@@ -115,7 +130,7 @@ bool mgMuggle::ProcessArgs (int argc, char *argv[])
{"port", required_argument, NULL, 'p'},
{"user", required_argument, NULL, 'u'},
{"password", required_argument, NULL, 'w'},
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
{"datadir", required_argument, NULL, 'd'},
#endif
{"toplevel", required_argument, NULL, 't'},
@@ -127,7 +142,7 @@ bool mgMuggle::ProcessArgs (int argc, char *argv[])
c,
option_index = 0;
while ((c =
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
getopt_long (argc, argv, "gh:s:n:p:t:u:w:d:v:", long_options,
#else
getopt_long (argc, argv, "gh:s:n:p:t:u:w:v:", long_options,
@@ -166,7 +181,7 @@ bool mgMuggle::ProcessArgs (int argc, char *argv[])
the_setup.DbPass = strcpyrealloc (the_setup.DbPass, optarg);
}
break;
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
case 'd':
{
set_datadir(optarg);
diff --git a/mugglei.c b/mugglei.c
index 1e2f7ae..e5e7c21 100755
--- a/mugglei.c
+++ b/mugglei.c
@@ -71,7 +71,11 @@ int main( int argc, char *argv[] )
std::cout << "Only files ending in .flac, .mp3, .ogg (ignoring case) will be imported" << std::endl;
std::cout << "" << std::endl;
std::cout << "Options:" << std::endl;
+#ifdef HAVE_ONLY_SERVER
std::cout << " -h <hostname> - specify host of mySql database server (default is 'localhost')" << std::endl;
+#else
+ std::cout << " -h <hostname> - specify host of mySql database server (default is mysql embedded')" << std::endl;
+#endif
std::cout << " -s <socket> - specify a socket for mySQL communication (default is TCP)" << std::endl;
std::cout << " -n <database> - specify database name (default is 'GiantDisc')" << std::endl;
std::cout << " -u <username> - specify user of mySql database (default is empty)" << std::endl;
@@ -80,10 +84,13 @@ int main( int argc, char *argv[] )
std::cout << " -z - scan all database entries and delete entries for files not found" << std::endl;
std::cout << " -z is not yet implemented" << std::endl;
std::cout << " -c - delete the entire database and recreate a new empty one" << std::endl;
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
std::cout << " -d <datadir> - the data directory for the embedded mysql server. Defaults to ./.muggle" << std::endl;
#endif
std::cout << " -v - the wanted log level, the higher the more. Default is 1" << std::endl;
+ std::cout << std::endl << std::endl;
+ std::cout << "if the specified host is localhost, sockets will be used if possible." << std::endl;
+ std::cout << "Otherwise the -s parameter will be ignored" << std::endl;
exit( 1 );
}
@@ -92,7 +99,7 @@ int main( int argc, char *argv[] )
import_assorted = false;
delete_mode = false;
create_mode = false;
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
char *buf;
asprintf(&buf,"%s/.muggle",getenv("HOME"));
set_datadir(buf);
@@ -102,7 +109,7 @@ int main( int argc, char *argv[] )
// parse command line options
while( 1 )
{
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
int c = getopt(argc, argv, "h:s:n:u:p:t:zcv:d:");
#else
int c = getopt(argc, argv, "h:s:n:u:p:t:zcv:");
@@ -153,7 +160,7 @@ int main( int argc, char *argv[] )
{
mgSetDebugLevel(atol(optarg));
} break;
-#ifndef HAVE_SERVER
+#ifndef HAVE_ONLY_SERVER
case 'd':
{
set_datadir(optarg);
diff --git a/vdr_actions.c b/vdr_actions.c
index b389e38..4ab8483 100644
--- a/vdr_actions.c
+++ b/vdr_actions.c
@@ -29,6 +29,7 @@
#define DEBUG
#include "mg_tools.h"
#include "mg_order.h"
+#include "mg_sync.h"
static bool
IsEntry(mgActions i)
@@ -677,17 +678,39 @@ mgToggleSelection::Execute ()
osd()->newposition = selection ()->gotoPosition ();
}
-class mgSync : public mgCommand
+class mgCmdSync : public mgOsdItem
{
public:
+ bool Enabled(mgActions on) { return true; }
void Execute();
- const char *ButtonName() { return tr("Synchronize"); }
+ eOSState ProcessKey(eKeys key);
+ const char *ButtonName() { return tr("Synchronize database"); }
};
+
+static char *sync_args[] =
+{
+ ".",
+ 0
+};
+
+eOSState
+mgCmdSync::ProcessKey(eKeys key)
+{
+ if (key==kOk)
+ if (Interface->Confirm(tr("Synchronize database with track flles?")))
+ {
+ Execute();
+ return osContinue;
+ }
+ return osUnknown;
+}
+
void
-mgSync::Execute()
+mgCmdSync::Execute()
{
- // selection()->Sync(".");
+ mgSync s;
+ s.Sync(sync_args);
}
//! \brief sets the default collection selection
@@ -1228,7 +1251,7 @@ mgAction::Type()
if (t == typeid(mgCreateOrder)) return actCreateOrder;
if (t == typeid(mgDeleteOrder)) return actDeleteOrder;
if (t == typeid(mgEditOrder)) return actEditOrder;
- if (t == typeid(mgSync)) return actSync;
+ if (t == typeid(mgCmdSync)) return actSync;
if (t == typeid(mgExternal0)) return actExternal0;
if (t == typeid(mgExternal1)) return actExternal1;
if (t == typeid(mgExternal2)) return actExternal2;
@@ -1290,7 +1313,7 @@ actGenerate(const mgActions action)
case actSetButton: result = new mgSetButton;break;
case actShowList: result = new mgShowList;break;
case actShowCommands: result = new mgShowCommands;break;
- case actSync: result = new mgSync;break;
+ case actSync: result = new mgCmdSync;break;
case actSetDefaultCollection: result = new mgSetDefaultCollection;break;
case actOrder: result = new mgActOrder;break;
case actUnused6: break;
diff --git a/vdr_menu.c b/vdr_menu.c
index 6472ad6..8e26afd 100644
--- a/vdr_menu.c
+++ b/vdr_menu.c
@@ -608,9 +608,6 @@ mgSubmenu::BuildOsd ()
AddAction(actClearCollection,on);
AddAction(actChooseOrder,on);
AddAction(actExportTracklist,on);
-#if 0
- AddAction(actSync,on);
-#endif
cCommand *command;
if (osd()->external_commands)
{
@@ -687,6 +684,20 @@ mgMenu::Process (eKeys key)
return ExecuteButton(key);
}
+eOSState
+mgTree::Process (eKeys key)
+{
+ eOSState result = osUnknown;
+ if (key!=kNone)
+ mgDebug(1,"mgTree::Process(%d)",key);
+ switch (key)
+ {
+ case k0:mgDebug(1,"ich bin k0");break;
+ default: result = mgMenu::Process(key);
+ }
+ return result;
+}
+
void
mgTree::BuildOsd ()
{
diff --git a/vdr_menu.h b/vdr_menu.h
index 227931c..ede022b 100644
--- a/vdr_menu.h
+++ b/vdr_menu.h
@@ -343,6 +343,7 @@ class mgTree:public mgMenu
{
public:
mgTree();
+ virtual eOSState Process (eKeys Key);
protected:
void BuildOsd ();
};
diff --git a/vdr_setup.c b/vdr_setup.c
index 95d7df2..c2f442e 100644
--- a/vdr_setup.c
+++ b/vdr_setup.c
@@ -20,6 +20,7 @@
#include <cstring>
#include "vdr_setup.h"
+#include "vdr_actions.h"
#include "i18n.h"
@@ -55,6 +56,12 @@ mgMenuSetup::mgMenuSetup ()
Add (new
cMenuEditIntItem (tr ("Setup.Muggle$Limiter level"),
&m_data.LimiterLevel, MIN_LIMITER_LEVEL, 100));
+
+ mgAction *a = actGenerate(actSync);
+ const char *mn = a->MenuName();
+ a->SetText(mn);
+ free(const_cast<char*>(mn));
+ Add(dynamic_cast<cOsdItem*>(a));
}