enjoy/src/bin/main.c

123 lines
2.8 KiB
C
Raw Normal View History

add basic enjoy code to svn. WARNING: there is not much to see here yet! I'm just adding to svn as people seems interested in help, and it is impossible to help without the base code. IF YOU DON'T WANT TO HELP WITH CODE, DON'T EVEN BOTHER COMPILING IT YET! Enjoy is (will be) a music player fully based on Enlightenment Foundation Libraries (EFL), the goal is to have a simple yet useful music player that works on desktop and mobiles with the minimum set of dependencies and maximum efficiency. It is based on LightMediaScanner (my code[1]) to scan directories for music and create a database and does so in a very and safe efficient way by having a scanner process with lower nice priority. It is also smart enough to hint to your kernel you'll not need the scanned files anymore (posix_fadvise()) and thus it will not pollute your RAM with useless file system cache. So far it is not creating the database on its own, neither have a a library manager to add/remove directories. In order to run Enjoy you must first create your own database using "test" program from lightmediascanner sources: {{{ cd lightmediascanner ./configure && make && make install mkdir -p $HOME/.config/enjoy/media.db ./src/bin/test -i 5000 -p id3 -s $HOME/Music $HOME/.config/enjoy/media.db }}} The GUI is pretty much ugly and needs huge work. It is almost fully done in Edje, so C part is quite lean, however I did no Edje work yet, just the basics to show something (uses r | g | b rectangles for actions, you have to guess what's what ;-)) = HOW TO HELP = Read TODO file. If you're more like a coder: * src/bin/db.c follow the propsed stubs and db_songs_get() example; * src/bin/page.c add recursive paging with "folder" pages; * src/bin/win.c start/stop ecore_thread with lms_process() + lms_check(); * src/bin/win.c write library manager: rescan collection (thread as above item), add directories, remove directories. If you're more like an edje guy: * data/themes: follow eve's style, focus on the bottom toolbar, then the list items, then the page/songs. Use dummy icons (copy from eve or efenniht), we'll provide proper icons soon * add nowplaying screen * add volume using dragable (copy from efenniht's slider) [1] download code from http://git.profusion.mobi/cgit.cgi/lightmediascanner.git/ or http://lms.garage.maemo.org/ SVN revision: 52658
2010-09-23 18:37:54 -07:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Elementary.h>
#ifndef ELM_LIB_QUICKLAUNCH
#include "private.h"
#include <Ecore_Getopt.h>
#include <Ecore_File.h>
#include <stdlib.h>
#include "gettext.h"
int _log_domain = -1;
static App app;
static const Ecore_Getopt options = {
PACKAGE_NAME,
"%prog [options] [url]",
PACKAGE_VERSION "Revision:" stringify(VREV),
"(C) 2010 ProFUSION embedded systems",
"LGPL-3",
"Music player for mobiles and desktops.",
EINA_TRUE,
{
ECORE_GETOPT_APPEND_METAVAR
('a', "add", "Add (recursively) directory to music library.",
"DIRECTORY", ECORE_GETOPT_TYPE_STR),
ECORE_GETOPT_APPEND_METAVAR
('d', "del", "Delete (recursively) directory from music library.",
"DIRECTORY", ECORE_GETOPT_TYPE_STR),
ECORE_GETOPT_VERSION('V', "version"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_HELP('h', "help"),
ECORE_GETOPT_SENTINEL
}
};
EAPI int
elm_main(int argc, char **argv)
{
int r = 0, args;
Eina_Bool quit_option = EINA_FALSE;
const char *home;
char *s;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_LIST(app.add_dirs),
ECORE_GETOPT_VALUE_LIST(app.del_dirs),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_NONE
};
#if ENABLE_NLS
setlocale(LC_ALL, "");
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
#endif
_log_domain = eina_log_domain_register("enjoy", NULL);
if (_log_domain < 0)
{
EINA_LOG_CRIT("could not create log domain 'enjoy'.");
return -1;
}
args = ecore_getopt_parse(&options, values, argc, argv);
if (args < 0)
{
ERR("Could not parse command line options.");
return -1;
}
if (quit_option)
{
DBG("Command lines option requires quit.");
return 0;
}
elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/default.edj");
home = getenv("HOME");
if (!home || !home[0])
{
CRITICAL("Could not get $HOME");
r = -1;
goto end;
}
snprintf(app.configdir, sizeof(app.configdir), "%s/.config/enjoy", home);
if (!ecore_file_mkpath(app.configdir))
{
ERR("Could not create %s", app.configdir);
r = -1;
goto end;
}
app.win = win_new(&app);
if (!app.win) goto end;
elm_run();
evas_object_del(app.win);
end:
EINA_LIST_FREE(app.add_dirs, s) free(s);
EINA_LIST_FREE(app.del_dirs, s) free(s);
eina_log_domain_unregister(_log_domain);
_log_domain = -1;
elm_shutdown();
return r;
}
#endif
ELM_MAIN()