enjoy: improve plugins build and installation.
- enjoy.m4 (similar to lightmediascanner/m4/ac-plugins.m4) - optional build of modules - each module in their own directory - install modules to $(libdir)/enjoy/ - load module from multiple "standard" places, such as - $(libdir)/enjoy/ - ~/.enjoy - ${ENJOY_LIB_DIR}/enjoy - $ENJOY_MODULES_DIR - each module have its own log stuff SVN revision: 63142
This commit is contained in:
parent
baf145dd8a
commit
41d8c6e5d1
27
configure.ac
27
configure.ac
|
@ -29,6 +29,7 @@ AC_ISC_POSIX
|
|||
|
||||
AM_INIT_AUTOMAKE(1.6 dist-bzip2)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
_XTERM_COLORS
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])
|
||||
|
@ -59,7 +60,7 @@ AC_SUBST(ALL_LINGUAS)
|
|||
AM_GNU_GETTEXT_VERSION([0.12.1])
|
||||
AM_GNU_GETTEXT([external])
|
||||
|
||||
PKG_CHECK_MODULES([EDBUS], [edbus])
|
||||
PKG_CHECK_MODULES([EDBUS], [edbus ecore])
|
||||
PKG_CHECK_MODULES([ELEMENTARY], [elementary ecore-file eina evas ecore ecore-evas edje ecore-con])
|
||||
PKG_CHECK_MODULES([EMOTION], [emotion])
|
||||
PKG_CHECK_MODULES([LMS], [lightmediascanner])
|
||||
|
@ -111,11 +112,17 @@ fi
|
|||
|
||||
AM_CONDITIONAL(BUILD_QUICKLAUNCH, test "x${want_quicklaunch}" = "xyes")
|
||||
|
||||
AC_ENJOY_OPTIONAL_MODULE([FSO], false)
|
||||
AC_ENJOY_OPTIONAL_MODULE([MPRIS], true)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
enjoy.spec
|
||||
src/Makefile
|
||||
src/bin/Makefile
|
||||
src/plugins/Makefile
|
||||
src/plugins/fso/Makefile
|
||||
src/plugins/mpris/Makefile
|
||||
data/Makefile
|
||||
data/desktop/Makefile
|
||||
data/themes/Makefile
|
||||
|
@ -146,6 +153,24 @@ cat << EOF_QL
|
|||
EOF_QL
|
||||
fi
|
||||
|
||||
txt_strip() {
|
||||
echo "[$]@" | sed -e 's/^[[ \t]]*\([[^ \t]]*\)[[ \t]]*$/\1/g'
|
||||
}
|
||||
MODS=""
|
||||
for mod in $OPTIONAL_MODULES; do
|
||||
MODS="$MODS ${COLOR_HGREEN}+$mod${COLOR_END}"
|
||||
done
|
||||
MODS=$(txt_strip $MODS)
|
||||
|
||||
UNUSED_MODS=""
|
||||
for mod in $UNUSED_OPTIONAL_MODULES; do
|
||||
UNUSED_MODS="$UNUSED_MODS ${COLOR_HRED}-$mod${COLOR_END}"
|
||||
done
|
||||
UNUSED_MODS=$(txt_strip $UNUSED_MODS)
|
||||
|
||||
echo
|
||||
echo -e "Modules: $MODS $UNUSED_MODS"
|
||||
|
||||
cat << EOF2
|
||||
|
||||
Now type 'make' ('gmake' on some systems) to compile enjoy, if it
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
dnl _XTERM_COLORS
|
||||
define([_XTERM_COLORS],
|
||||
[
|
||||
# Check for XTerm and define some colors
|
||||
if test "x$TERM" = "xxterm" -o "x$TERM" = "xrxvt-unicode" -o "x$TERM" = "xscreen"; then
|
||||
COLOR_PREF="\0033\0133"
|
||||
COLOR_H="${COLOR_PREF}1m"
|
||||
COLOR_HGREEN="${COLOR_PREF}1;32m"
|
||||
COLOR_HRED="${COLOR_PREF}1;31m"
|
||||
COLOR_GREEN="${COLOR_PREF}32m"
|
||||
COLOR_RED="${COLOR_PREF}31m"
|
||||
COLOR_YELLOW="${COLOR_PREF}1;33m"
|
||||
COLOR_END="${COLOR_PREF}0m"
|
||||
else
|
||||
COLOR_H=""
|
||||
COLOR_HGREEN=""
|
||||
COLOR_HRED=""
|
||||
COLOR_GREEN=""
|
||||
COLOR_RED=""
|
||||
COLOR_YELLOW=""
|
||||
COLOR_END=""
|
||||
fi
|
||||
])
|
||||
|
||||
dnl AC_ENJOY_CHECK_PKG(name, lib [>= version], [action-if, [action-not]])
|
||||
dnl improved version of PKG_CHECK_MODULES, it does the same checking
|
||||
dnl and defines HAVE_[name]=yes/no and also exports
|
||||
dnl [name]_CFLAGS and [name]_LIBS.
|
||||
dnl
|
||||
dnl if action-not isn't provided, AC_MSG_ERROR will be used.
|
||||
dnl
|
||||
dnl Checks:
|
||||
dnl lib >= version
|
||||
dnl
|
||||
dnl Provides:
|
||||
dnl - HAVE_[name]=yes|no
|
||||
dnl - [name]_CFLAGS: if HAVE_[name]=yes
|
||||
dnl - [name]_LIBS: if HAVE_[name]=yes
|
||||
dnl - [name]_VERSION: if HAVE_[name]=yes
|
||||
dnl
|
||||
AC_DEFUN([AC_ENJOY_CHECK_PKG],
|
||||
[
|
||||
# ----------------------------------------------------------------------
|
||||
# BEGIN: Check library with pkg-config: $1 (pkg-config=$2)
|
||||
#
|
||||
|
||||
PKG_CHECK_MODULES([$1], [$2],
|
||||
[
|
||||
HAVE_[$1]=yes
|
||||
[pkg_name]=$(echo "[$2]" | cut -d\ -f1)
|
||||
[$1]_VERSION=$($PKG_CONFIG --modversion $pkg_name)
|
||||
AC_SUBST([$1]_VERSION)
|
||||
AC_SUBST([$1]_CFLAGS)
|
||||
AC_SUBST([$1]_LIBS)
|
||||
ifelse([$3], , :, [$3])
|
||||
],
|
||||
[
|
||||
HAVE_[$1]=no
|
||||
ifelse([$4], , AC_MSG_ERROR(you need [$2] development installed!), AC_MSG_RESULT(no); [$4])
|
||||
])
|
||||
AM_CONDITIONAL(HAVE_[$1], test x$HAVE_[$1] = xyes)
|
||||
AC_SUBST(HAVE_[$1])
|
||||
if test x$HAVE_[$1] = xyes; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_[$1], 1, Package [$1] ($2) found.)
|
||||
fi
|
||||
|
||||
#
|
||||
# END: Check library with pkg-config: $1 (pkg-config=$2)
|
||||
# ----------------------------------------------------------------------
|
||||
])
|
||||
|
||||
dnl AC_ENJOY_OPTIONAL_MODULE(name, [initial-status, [check-if-enabled]])
|
||||
dnl Defines configure argument --<enable|disable>-[name] to enable an
|
||||
dnl optional module called 'name'.
|
||||
dnl
|
||||
dnl If initial-status is true, then it's enabled by default and option
|
||||
dnl will be called --disable-[name], otherwise it's disabled and option
|
||||
dnl is --enable-[name].
|
||||
dnl
|
||||
dnl If module is enabled, then check-if-enabled will be executed. This
|
||||
dnl may change the contents of shell variable NAME (uppercase version of
|
||||
dnl name, with underscores instead of dashed) to something different than
|
||||
dnl "true" to disable module.
|
||||
dnl
|
||||
dnl Parameters:
|
||||
dnl - name: module name to use. It will be converted to have dashes (-)
|
||||
dnl instead of underscores, and will be in lowercase.
|
||||
dnl - initial-status: true or false, states if module is enabled or
|
||||
dnl disabled by default.
|
||||
dnl - check-if-enabled: macro to be expanded inside check for enabled
|
||||
dnl module.
|
||||
dnl
|
||||
dnl Provides:
|
||||
dnl - USE_MODULE_[name]=true|false [make, shell]
|
||||
dnl - USE_MODULE_[name]=1 if enabled [config.h]
|
||||
dnl
|
||||
AC_DEFUN([AC_ENJOY_OPTIONAL_MODULE],
|
||||
[
|
||||
# ----------------------------------------------------------------------
|
||||
# BEGIN: Check for optional module: $1 (default: $2)
|
||||
#
|
||||
m4_pushdef([MODNAME], [m4_bpatsubst(m4_toupper([$1]), -, _)])dnl
|
||||
m4_pushdef([modname_opt], [m4_bpatsubst(m4_tolower([$1]), _, -)])
|
||||
m4_pushdef([INITVAL], [m4_default([$2], [false])])dnl
|
||||
m4_pushdef([ENABLE_HELP], AS_HELP_STRING([--enable-modname_opt],
|
||||
[enable optional module modname_opt. Default is disabled.])
|
||||
)dnl
|
||||
m4_pushdef([DISABLE_HELP], AS_HELP_STRING([--disable-modname_opt],
|
||||
[disable optional module modname_opt. Default is enabled.])
|
||||
)dnl
|
||||
m4_pushdef([HELP_STR], m4_if(INITVAL, [true], [DISABLE_HELP], [ENABLE_HELP]))dnl
|
||||
m4_pushdef([NOT_INITVAL], m4_if(INITVAL, [true], [false], [true]))dnl
|
||||
|
||||
USING_MODULES=1
|
||||
|
||||
MODNAME=INITVAL
|
||||
AC_ARG_ENABLE(modname_opt, HELP_STR, [MODNAME=${enableval:-NOT_INITVAL}])
|
||||
if test x[$]MODNAME = xyes || test x[$]MODNAME = x1; then
|
||||
MODNAME=true
|
||||
fi
|
||||
if test x[$]MODNAME = xno || test x[$]MODNAME = x0; then
|
||||
MODNAME=false
|
||||
fi
|
||||
|
||||
USE_MODULE_[]MODNAME=[$]MODNAME
|
||||
|
||||
_XTERM_COLORS
|
||||
|
||||
# Check list for optional module $1
|
||||
if test x[$]MODNAME = xtrue; then
|
||||
ifelse([$3], , , [
|
||||
echo
|
||||
echo "checking optional module modname_opt:"
|
||||
# BEGIN: User checks
|
||||
$3
|
||||
# END: User checks
|
||||
if test x[$]MODNAME = xfalse; then
|
||||
echo -e "optional module modname_opt ${COLOR_HRED}failed${COLOR_END} checks."
|
||||
else
|
||||
echo -e "optional module modname_opt passed checks."
|
||||
fi
|
||||
echo
|
||||
])
|
||||
|
||||
if test x[$]MODNAME = xfalse; then
|
||||
echo -e "${COLOR_YELLOW}Warning:${COLOR_END} optional module ${COLOR_H}modname_opt${COLOR_END} disabled by extra checks."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if user checks succeeded
|
||||
if test x[$]MODNAME = xtrue; then
|
||||
[OPTIONAL_MODULES]="$[OPTIONAL_MODULES] modname_opt"
|
||||
AC_DEFINE_UNQUOTED(USE_MODULE_[]MODNAME, 1, Use module modname_opt)
|
||||
else
|
||||
[UNUSED_OPTIONAL_MODULES]="$[UNUSED_OPTIONAL_MODULES] modname_opt"
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(USE_MODULE_[]MODNAME, test x[$]MODNAME = xtrue)
|
||||
AC_SUBST(USE_MODULE_[]MODNAME)
|
||||
|
||||
m4_popdef([HELP_STR])dnl
|
||||
m4_popdef([DISABLE_HELP])dnl
|
||||
m4_popdef([ENABLE_HELP])dnl
|
||||
m4_popdef([INITVAL])dnl
|
||||
m4_popdef([MODNAME])
|
||||
#
|
||||
# END: Check for optional module: $1 ($2)
|
||||
# ----------------------------------------------------------------------
|
||||
])
|
|
@ -1,2 +1,2 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
SUBDIRS = bin
|
||||
SUBDIRS = bin plugins
|
||||
|
|
|
@ -4,7 +4,7 @@ INCLUDES = \
|
|||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-DLIBRARY_DIR=\"$(libdir)\" \
|
||||
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
|
||||
-DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
@ELEMENTARY_CFLAGS@ \
|
||||
|
@ -43,8 +43,3 @@ endif
|
|||
|
||||
noinst_HEADERS = gettext.h private.h coverart-lastfm.h
|
||||
EXTRA_DIST = gettext.h private.h coverart-lastfm.h
|
||||
|
||||
lib_LTLIBRARIES = libenjoypluginfso.la libenjoypluginmpris.la
|
||||
|
||||
libenjoypluginfso_la_SOURCES = fso.c
|
||||
libenjoypluginmpris_la_SOURCES = mpris.c
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
#include <Eina.h>
|
||||
#include <E_DBus.h>
|
||||
#include "plugin.h"
|
||||
#include "log.h"
|
||||
|
||||
#define FSO_OUSAGED_SERVICE "org.freesmartphone.ousaged"
|
||||
#define FSO_OUSAGED_OBJECT_PATH "/org/freesmartphone/Usage"
|
||||
#define FSO_OUSAGED_INTERFACE "org.freesmartphone.Usage"
|
||||
|
||||
static E_DBus_Connection *sysconn = NULL;
|
||||
|
||||
/* callbacks */
|
||||
|
||||
static void
|
||||
fso_request_reource_cb(void *data, DBusMessage *replymsg, DBusError *error)
|
||||
{
|
||||
DBG("Request sent to fsousaged to enable resource.");
|
||||
|
||||
if (error && dbus_error_is_set(error))
|
||||
ERR("Error requesting FSO resource: %s - %s\n", error->name, error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
fso_release_reource_cb(void *data, DBusMessage *replymsg, DBusError *error)
|
||||
{
|
||||
DBG("Request sent to fsousaged to disable resource.");
|
||||
|
||||
if (error && dbus_error_is_set(error))
|
||||
ERR("Error releasing FSO resource: %s - %s", error->name, error->message);
|
||||
}
|
||||
|
||||
|
||||
/* methods */
|
||||
|
||||
static void
|
||||
fso_request_resource(const char *resource)
|
||||
{
|
||||
DBusMessage *msg;
|
||||
msg = dbus_message_new_method_call(
|
||||
FSO_OUSAGED_SERVICE,
|
||||
FSO_OUSAGED_OBJECT_PATH,
|
||||
FSO_OUSAGED_INTERFACE,
|
||||
"RequestResource");
|
||||
dbus_message_append_args(msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID);
|
||||
e_dbus_message_send(sysconn, msg, fso_request_reource_cb, -1, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fso_release_resource(const char *resource)
|
||||
{
|
||||
DBusMessage *msg;
|
||||
msg = dbus_message_new_method_call(
|
||||
FSO_OUSAGED_SERVICE,
|
||||
FSO_OUSAGED_OBJECT_PATH,
|
||||
FSO_OUSAGED_INTERFACE,
|
||||
"ReleaseResource");
|
||||
dbus_message_append_args(msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID);
|
||||
e_dbus_message_send(sysconn, msg, fso_release_reource_cb, -1, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
fso_init(void)
|
||||
{
|
||||
if (sysconn) return EINA_FALSE;
|
||||
e_dbus_init();
|
||||
sysconn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
|
||||
fso_request_resource("CPU");
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
fso_shutdown(void)
|
||||
{
|
||||
if (!sysconn) return;
|
||||
fso_release_resource("CPU");
|
||||
e_dbus_shutdown();
|
||||
sysconn = NULL;
|
||||
}
|
||||
|
||||
EINA_MODULE_INIT(fso_init);
|
||||
EINA_MODULE_SHUTDOWN(fso_shutdown);
|
|
@ -116,31 +116,50 @@ enjoy_event_id_shutdown()
|
|||
ecore_shutdown();
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
enjoy_module_load_one(Eina_Module *module, void *data)
|
||||
static void
|
||||
enjoy_module_load(void)
|
||||
{
|
||||
const char *filename = eina_module_file_get(module);
|
||||
const char *prefix = "libenjoyplugin";
|
||||
char *path;
|
||||
|
||||
if (!strstr(filename, prefix)) return EINA_FALSE;
|
||||
if (!eina_module_load(module))
|
||||
DBG("Loading modules from '%s'", PACKAGE_LIB_DIR "/enjoy/");
|
||||
app.modules = eina_module_list_get
|
||||
(NULL, PACKAGE_LIB_DIR "/enjoy/", 0, NULL, NULL);
|
||||
|
||||
path = eina_module_environment_path_get("HOME", "/.enjoy/");
|
||||
if (path)
|
||||
{
|
||||
WRN("Couldn't load module %s.", filename);
|
||||
return EINA_FALSE;
|
||||
DBG("Loading modules from '%s'", path);
|
||||
app.modules = eina_module_list_get(app.modules, path, 0, NULL, NULL);
|
||||
free(path);
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
path = eina_module_environment_path_get("ENJOY_LIB_DIR", "/enjoy/");
|
||||
if (path)
|
||||
{
|
||||
DBG("Loading modules from '%s'", path);
|
||||
app.modules = eina_module_list_get(app.modules, path, 0, NULL, NULL);
|
||||
free(path);
|
||||
}
|
||||
|
||||
path = eina_module_environment_path_get("ENJOY_MODULES_DIR", NULL);
|
||||
if (path)
|
||||
{
|
||||
DBG("Loading modules from '%s'", path);
|
||||
app.modules = eina_module_list_get(app.modules, path, 0, NULL, NULL);
|
||||
free(path);
|
||||
}
|
||||
|
||||
if (!app.modules)
|
||||
{
|
||||
INF("No module found!");
|
||||
return;
|
||||
}
|
||||
|
||||
eina_module_list_load(app.modules);
|
||||
}
|
||||
|
||||
static void
|
||||
enjoy_module_load()
|
||||
{
|
||||
puts("loading modules from " LIBRARY_DIR);
|
||||
app.modules = eina_module_list_get(NULL, LIBRARY_DIR, EINA_FALSE, enjoy_module_load_one, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
enjoy_module_unload()
|
||||
enjoy_module_unload(void)
|
||||
{
|
||||
while (eina_array_count_get(app.modules))
|
||||
eina_module_unload(eina_array_pop(app.modules));
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
SUBDIRS =
|
||||
|
||||
if USE_MODULE_FSO
|
||||
SUBDIRS += fso
|
||||
endif
|
||||
|
||||
if USE_MODULE_MPRIS
|
||||
SUBDIRS += mpris
|
||||
endif
|
|
@ -0,0 +1,17 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-DLIBRARY_DIR=\"$(libdir)\" \
|
||||
-DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
@EDBUS_CFLAGS@
|
||||
|
||||
pkgdir = $(libdir)/enjoy
|
||||
pkg_LTLIBRARIES = fso.la
|
||||
fso_la_SOURCES = fso.c
|
||||
fso_la_LIBADD = @EDBUS_LIBS@
|
||||
fso_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
fso_la_LIBTOOLFLAGS = --tag=disable-static
|
|
@ -0,0 +1,118 @@
|
|||
#include <Eina.h>
|
||||
#include <E_DBus.h>
|
||||
#include "plugin.h"
|
||||
|
||||
static int _fso_log_domain = -1;
|
||||
|
||||
#ifdef CRITICAL
|
||||
#undef CRITICAL
|
||||
#endif
|
||||
#ifdef ERR
|
||||
#undef ERR
|
||||
#endif
|
||||
#ifdef WRN
|
||||
#undef WRN
|
||||
#endif
|
||||
#ifdef INF
|
||||
#undef INF
|
||||
#endif
|
||||
#ifdef DBG
|
||||
#undef DBG
|
||||
#endif
|
||||
|
||||
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_fso_log_domain, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_fso_log_domain, __VA_ARGS__)
|
||||
#define WRN(...) EINA_LOG_DOM_WARN(_fso_log_domain, __VA_ARGS__)
|
||||
#define INF(...) EINA_LOG_DOM_INFO(_fso_log_domain, __VA_ARGS__)
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(_fso_log_domain, __VA_ARGS__)
|
||||
|
||||
#define FSO_OUSAGED_SERVICE "org.freesmartphone.ousaged"
|
||||
#define FSO_OUSAGED_OBJECT_PATH "/org/freesmartphone/Usage"
|
||||
#define FSO_OUSAGED_INTERFACE "org.freesmartphone.Usage"
|
||||
|
||||
static E_DBus_Connection *sysconn = NULL;
|
||||
|
||||
/* callbacks */
|
||||
|
||||
static void
|
||||
fso_request_reource_cb(void *data, DBusMessage *replymsg, DBusError *error)
|
||||
{
|
||||
DBG("Request sent to fsousaged to enable resource.");
|
||||
|
||||
if (error && dbus_error_is_set(error))
|
||||
ERR("Error requesting FSO resource: %s - %s", error->name, error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
fso_release_reource_cb(void *data, DBusMessage *replymsg, DBusError *error)
|
||||
{
|
||||
DBG("Request sent to fsousaged to disable resource.");
|
||||
|
||||
if (error && dbus_error_is_set(error))
|
||||
ERR("Error releasing FSO resource: %s - %s", error->name, error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
fso_request_resource(const char *resource)
|
||||
{
|
||||
DBusMessage *msg = dbus_message_new_method_call
|
||||
(FSO_OUSAGED_SERVICE, FSO_OUSAGED_OBJECT_PATH, FSO_OUSAGED_INTERFACE,
|
||||
"RequestResource");
|
||||
dbus_message_append_args
|
||||
(msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID);
|
||||
e_dbus_message_send(sysconn, msg, fso_request_reource_cb, -1, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
fso_release_resource(const char *resource)
|
||||
{
|
||||
DBusMessage *msg = dbus_message_new_method_call
|
||||
(FSO_OUSAGED_SERVICE, FSO_OUSAGED_OBJECT_PATH, FSO_OUSAGED_INTERFACE,
|
||||
"ReleaseResource");
|
||||
dbus_message_append_args
|
||||
(msg, DBUS_TYPE_STRING, &resource, DBUS_TYPE_INVALID);
|
||||
e_dbus_message_send(sysconn, msg, fso_release_reource_cb, -1, NULL);
|
||||
dbus_message_unref(msg);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
fso_init(void)
|
||||
{
|
||||
if (_fso_log_domain < 0)
|
||||
{
|
||||
_fso_log_domain = eina_log_domain_register
|
||||
("enjoy-fso", EINA_COLOR_LIGHTCYAN);
|
||||
if (_fso_log_domain < 0)
|
||||
{
|
||||
EINA_LOG_CRIT("Could not register log domain 'enjoy-fso'");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (sysconn) return EINA_TRUE;
|
||||
|
||||
e_dbus_init();
|
||||
sysconn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
|
||||
fso_request_resource("CPU");
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
fso_shutdown(void)
|
||||
{
|
||||
if (!sysconn) return;
|
||||
fso_release_resource("CPU");
|
||||
e_dbus_shutdown();
|
||||
sysconn = NULL;
|
||||
if (_fso_log_domain >= 0)
|
||||
{
|
||||
eina_log_domain_unregister(_fso_log_domain);
|
||||
_fso_log_domain = -1;
|
||||
}
|
||||
}
|
||||
|
||||
EINA_MODULE_INIT(fso_init);
|
||||
EINA_MODULE_SHUTDOWN(fso_shutdown);
|
|
@ -0,0 +1,17 @@
|
|||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-DLIBRARY_DIR=\"$(libdir)\" \
|
||||
-DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
|
||||
-DLOCALEDIR=\"$(localedir)\" \
|
||||
@EDBUS_CFLAGS@
|
||||
|
||||
pkgdir = $(libdir)/enjoy
|
||||
pkg_LTLIBRARIES = mpris.la
|
||||
mpris_la_SOURCES = mpris.c
|
||||
mpris_la_LIBADD = @EDBUS_LIBS@
|
||||
mpris_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
mpris_la_LIBTOOLFLAGS = --tag=disable-static
|
|
@ -8,6 +8,30 @@
|
|||
typedef struct _MPRIS_Method MPRIS_Method;
|
||||
typedef struct _MPRIS_Signal MPRIS_Signal;
|
||||
|
||||
static int _mpris_log_domain = -1;
|
||||
|
||||
#ifdef CRITICAL
|
||||
#undef CRITICAL
|
||||
#endif
|
||||
#ifdef ERR
|
||||
#undef ERR
|
||||
#endif
|
||||
#ifdef WRN
|
||||
#undef WRN
|
||||
#endif
|
||||
#ifdef INF
|
||||
#undef INF
|
||||
#endif
|
||||
#ifdef DBG
|
||||
#undef DBG
|
||||
#endif
|
||||
|
||||
#define CRITICAL(...) EINA_LOG_DOM_CRIT(_mpris_log_domain, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_mpris_log_domain, __VA_ARGS__)
|
||||
#define WRN(...) EINA_LOG_DOM_WARN(_mpris_log_domain, __VA_ARGS__)
|
||||
#define INF(...) EINA_LOG_DOM_INFO(_mpris_log_domain, __VA_ARGS__)
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(_mpris_log_domain, __VA_ARGS__)
|
||||
|
||||
|
||||
#define APPLICATION_NAME "org.mpris.enjoy"
|
||||
#define PLAYER_INTERFACE_NAME "org.freedesktop.MediaPlayer"
|
||||
|
@ -177,10 +201,21 @@ _cb_player_tracklist_change(void *data __UNUSED__, int type __UNUSED__, void *ev
|
|||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
static Eina_Bool
|
||||
mpris_init(void)
|
||||
{
|
||||
if (conn) return EINA_FALSE;
|
||||
if (_mpris_log_domain < 0)
|
||||
{
|
||||
_mpris_log_domain = eina_log_domain_register
|
||||
("enjoy-mpris", EINA_COLOR_LIGHTCYAN);
|
||||
if (_mpris_log_domain < 0)
|
||||
{
|
||||
EINA_LOG_CRIT("Could not register log domain 'enjoy-mpris'");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (conn) return EINA_TRUE;
|
||||
e_dbus_init();
|
||||
conn = e_dbus_bus_get(DBUS_BUS_SESSION);
|
||||
if (conn)
|
||||
|
@ -204,6 +239,12 @@ mpris_shutdown(void)
|
|||
e_dbus_shutdown();
|
||||
conn = NULL;
|
||||
interface_list = NULL;
|
||||
|
||||
if (_mpris_log_domain >= 0)
|
||||
{
|
||||
eina_log_domain_unregister(_mpris_log_domain);
|
||||
_mpris_log_domain = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
Loading…
Reference in New Issue