grim/guifications3
Clone
Summary
Browse
Changes
Graph
removed some ENABLE_NLS wrappers
2011-05-17, Gary Kramlich
f31281edef1c
removed some ENABLE_NLS wrappers
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#
include
<config.h>
#endif
/* HAVE_CONFIG_H */
#include
<gf_lib.h>
#if 0
#include <mpris/mpris.h>
#endif
/******************************************************************************
* Globals
*****************************************************************************/
static
GfFeed
*
feed
=
NULL
,
*
session_feed
=
NULL
;
static
GfClientConnection
*
connection
=
NULL
;
static
gboolean
initialized
=
FALSE
;
static
guint
connect_id
=
0
;
/******************************************************************************
* Connection Stuff
*****************************************************************************/
/* forward declarations suck, but this can't be easily avoided */
static
void
gfd_mpris_connect
(
void
);
static
gboolean
gfd_mpris_reconnect_cb
(
gpointer
data
)
{
gf_log_info
(
"gfd-mpris"
,
"reconnect_cb
\n
"
);
gfd_mpris_connect
();
return
FALSE
;
}
static
void
gfd_mpris_schedule_reconnect
(
void
)
{
gf_log_info
(
"gfd-mpris"
,
"schedule_reconnect
\n
"
);
if
(
connect_id
!=
0
)
return
;
connect_id
=
g_timeout_add_seconds
(
30
,
gfd_mpris_reconnect_cb
,
NULL
);
}
static
void
gfd_mpris_connected_cb
(
GfConnection
*
connection
,
gpointer
data
)
{
GfFeedPool
*
pool
=
NULL
;
gf_log_info
(
"gfd-mpris"
,
"connected_cb
\n
"
);
pool
=
gf_connection_get_feed_pool
(
connection
);
gf_log_info
(
"gfd-mpris"
,
"got feed pool %p
\n
"
,
pool
);
g_return_if_fail
(
GF_IS_FEED_POOL
(
pool
));
gf_log_info
(
"gfd-mpris"
,
"registering feed %p
\n
"
,
feed
);
session_feed
=
gf_feed_pool_register_feed
(
pool
,
feed
);
gf_log_info
(
"gfd-mpris"
,
"registered feed %p
\n
"
,
session_feed
);
}
static
void
gfd_mpris_disconnecting_cb
(
GfConnection
*
connection
,
gpointer
data
)
{
GfFeedPool
*
pool
=
NULL
;
gf_log_info
(
"gfd-mpris"
,
"disconnecting_cb
\n
"
);
pool
=
gf_connection_get_feed_pool
(
connection
);
if
(
GF_IS_FEED_POOL
(
pool
))
gf_feed_pool_unregister_feed
(
pool
,
session_feed
);
g_object_unref
(
G_OBJECT
(
session_feed
));
}
static
void
gfd_mpris_connect
(
void
)
{
GError
*
error
=
NULL
;
gf_log_info
(
"gfd-mpris"
,
"connect
\n
"
);
if
(
!
GF_IS_CLIENT_CONNECTION
(
connection
))
{
connection
=
gf_connection_manager_get_default_client_connection
();
g_signal_connect
(
G_OBJECT
(
connection
),
"connected"
,
G_CALLBACK
(
gfd_mpris_connected_cb
),
NULL
);
g_signal_connect
(
G_OBJECT
(
connection
),
"disconnecting"
,
G_CALLBACK
(
gfd_mpris_disconnecting_cb
),
NULL
);
}
if
(
!
gf_client_connection_connect
(
connection
,
&
error
))
{
gf_log_info
(
"guifications-daemon-mpris"
,
"Failed to connect: %s"
,
(
error
)
?
error
->
message
:
"Unknown Error"
);
connect_id
=
0
;
gfd_mpris_schedule_reconnect
();
}
}
/******************************************************************************
* Feed Stuff
*****************************************************************************/
static
void
gfd_mpris_create_feed
(
void
)
{
GfImage
*
image
=
NULL
;
gchar
*
path
;
gf_log_info
(
"gfd-mpris"
,
"create_feed
\n
"
);
path
=
g_build_filename
(
DATADIR
,
"pixmaps"
,
"guifications-daemon"
,
"mpris"
,
"mpris.png"
,
NULL
);
image
=
gf_image_new_from_file
(
path
);
g_free
(
path
);
feed
=
gf_feed_new
(
"MPRIS"
,
image
,
_
(
"MPRIS"
),
_
(
"A feed for notifications for the "
"Media Player Remote Interface Specification."
));
g_object_unref
(
image
);
}
/******************************************************************************
* Plugin Stuff
*****************************************************************************/
G_MODULE_EXPORT
gboolean
gf_native_plugin_load
(
GfNativePlugin
*
plugin
)
{
GModule
*
gmodule
=
NULL
;
gf_log_info
(
"gfd-mpris"
,
"plugin_load
\n
"
);
if
(
initialized
)
return
;
#ifdef ENABLE_NLS
bindtextdomain
(
GETTEXT_PACKAGE
,
LOCALEDIR
);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset
(
GETTEXT_PACKAGE
,
"UTF-8"
);
# endif
/* HAVE_BIND_TEXTDOMAIN_CODESET */
#endif
/* ENABLE_NLS */
/* theres no way to uninitialize mpris, so we have to stay resident */
gmodule
=
gf_native_plugin_get_module
(
plugin
);
g_module_make_resident
(
gmodule
);
/* create our feed */
gfd_mpris_create_feed
();
/* initialize mpris */
mpris_client_init
();
/* connect to the daemon */
gfd_mpris_connect
();
initialized
=
TRUE
;
}
G_MODULE_EXPORT
gboolean
gf_native_plugin_unload
(
GfNativePlugin
*
plugin
)
{
gf_log_info
(
"gfd-mpris"
,
"plugin_unload
\n
"
);
/* we drop out because we can't uninitialize mpris */
return
FALSE
;
}
static
GfPluginInfo
info
=
{
GF_NATIVE_PLUGIN_ABI_VERSION
,
PACKAGE_NAME
,
PACKAGE_VERSION
,
N_
(
"MPRIS feed for Guifications"
),
N_
(
"This is a daemon side plugin for guifications-daemon that propagates "
"events from MPRIS."
),
"Gary Kramlich <grim@reaperworld.com>"
,
"http://www.guifications.org/"
,
};
G_MODULE_EXPORT
GfPluginInfo
*
gf_native_plugin_query
(
GfPlugin
*
plugin
)
{
gf_log_info
(
"gfd-mpris"
,
"plugin_query
\n
"
);
return
&
info
;
}