add auto playlist manager module

attempts to auto add recently modified songs to end of playlist
This commit is contained in:
zmike 2014-11-09 18:08:36 -05:00
parent b9332485ad
commit 981af9cf4e
3 changed files with 134 additions and 9 deletions

View File

@ -185,6 +185,14 @@ AM_CONDITIONAL([MOD_GOOGLE_IMAGE], [test "x$want_google_image" = "xyes"])
########################################
want_auto_playlist_manager=yes
AC_ARG_ENABLE([module-auto-playlist-manager],
[AC_HELP_STRING([--disable-module-auto-playlist-manager], [disable auto playlist manager module. @<:@default=detect@:>@])],
[want_auto_playlist_manager=$enableval], [])
AM_CONDITIONAL([MOD_APL], [test "x$want_auto_playlist_manager" = "xyes"])
########################################
want_mpdule=maybe
AC_ARG_ENABLE([mpdule],
[AC_HELP_STRING([--disable-mpdule], [disable mpdule enlightenment module. @<:@default=detect@:>@])],
@ -266,16 +274,17 @@ echo
cat << MODULES_EOF
Modules:
* glyr_gmpc...........: $want_glyr_gmpc
* glyr................: $want_glyr
* google_image........: $want_google_image
* elyr................: $want_elyr
* eet_saver...........: $want_eet_saver
* eet_loader..........: $want_eet_loader
* filesystem_loader...: $want_filesystem_loader
* id3_loader..........: $want_id3_loader
* glyr_gmpc............: $want_glyr_gmpc
* glyr.................: $want_glyr
* google_image.........: $want_google_image
* elyr.................: $want_elyr
* eet_saver............: $want_eet_saver
* eet_loader...........: $want_eet_loader
* filesystem_loader....: $want_filesystem_loader
* id3_loader...........: $want_id3_loader
* auto_playlist_manager: $want_auto_playlist_manager
* mpdule..............: $want_mpdule
* mpdule...............: $want_mpdule
MODULES_EOF
echo

View File

@ -219,3 +219,26 @@ src_modules_id3_loader_la_LDFLAGS = -module -avoid-version
src_modules_id3_loader_la_LIBTOOLFLAGS = --tag=disable-static
endif
if MOD_APL
mod_LTLIBRARIES += src/modules/auto_playlist_manager.la
src_modules_auto_playlist_manager_la_SOURCES = \
src/modules/auto_playlist_manager.c \
$(ELDBUS_H) \
$(AZY_H)
src_modules_auto_playlist_manager_la_CPPFLAGS = \
$(AM_CFLAGS) \
$(mod_cppflags) \
@EFL_CFLAGS@ \
-I$(top_srcdir)/src/bin \
-I$(top_builddir)
src_modules_auto_playlist_manager_la_LIBADD = \
@EFL_LIBS@
src_modules_auto_playlist_manager_la_LDFLAGS = -module -avoid-version
src_modules_auto_playlist_manager_la_LIBTOOLFLAGS = --tag=disable-static
endif

View File

@ -0,0 +1,93 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#define EMPC_EXTERNS_ONLY
#include "empdd.h"
#include "empc.h"
#include <Ecore.h>
#include "eldbus_empd_empdd.h"
#include "Empd_Common_Azy.h"
static Ecore_Event_Handler *handler[2];
static long long dbtime = 0;
static void
find_cb(Eldbus_Proxy *proxy EINA_UNUSED, void *data EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED, Eldbus_Error_Info *error EINA_UNUSED, Eina_Value *args)
{
Eina_Value array;
unsigned int i;
eina_value_struct_value_get(args, "arg0", &array);
for (i = 0; i < eina_value_array_count(&array); i++)
{
Eina_Value struc, val, realval;
int type;
Empd_Empdd_File *f;
eina_value_array_value_get(&array, i, &struc);
eina_value_struct_get(&struc, "arg0", &type);
eina_value_struct_value_get(&struc, "arg1", &val);
eina_value_struct_value_get(&val, "arg0", &realval);
switch (type)
{
case MPD_ENTITY_TYPE_SONG:
azy_value_to_Empd_Empdd_File(&realval, &f);
empd_empdd_add_list_call(empd_proxy, f->uri);
Empd_Empdd_File_free(f);
break;
default: break;
}
eina_value_flush(&struc);
eina_value_flush(&val);
eina_value_flush(&realval);
}
eina_value_flush(&array);
}
static Eina_Bool
dbupdate_begin()
{
dbtime = lround(ecore_time_unix_get()) - 10;
return EINA_TRUE;
}
static Eina_Bool
dbupdate_end()
{
char buf[1024];
if (!dbtime) return ECORE_CALLBACK_RENEW;
snprintf(buf, sizeof(buf), "%lld", dbtime);
snprintf(buf, sizeof(buf), "%lld", dbtime);
empd_empdd_find_call(empd_proxy, find_cb, NULL, EMPD_SEARCH_TYPE_MODIFIED, buf);
dbtime = 0;
return ECORE_CALLBACK_RENEW;
}
EAPI Empc_Module_Type
empc_module_type(void)
{
return EMPC_MODULE_TYPE_PLAYLIST_MANAGER;
}
static Eina_Bool
auto_playlist_manager_init(void)
{
handler[0] = ecore_event_handler_add(EMPD_EMPDD_DATABASE_UPDATE_BEGIN_EVENT, dbupdate_begin, NULL);
handler[1] = ecore_event_handler_add(EMPD_EMPDD_DATABASE_UPDATE_END_EVENT, dbupdate_end, NULL);
return EINA_TRUE;
}
static void
auto_playlist_manager_shutdown(void)
{
E_FREE_FUNC(handler[0], ecore_event_handler_del);
E_FREE_FUNC(handler[1], ecore_event_handler_del);
}
EINA_MODULE_INIT(auto_playlist_manager_init);
EINA_MODULE_SHUTDOWN(auto_playlist_manager_shutdown);