Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$
mpris-signals.c
Go to the documentation of this file.
00001 /*  Audacious - Cross-platform multimedia player
00002  *  Copyright (C) 2005-2011  Audacious development team.
00003  *
00004  *  Based on BMP:
00005  *  Copyright (C) 2003-2004  BMP development team.
00006  *
00007  *  Based on XMMS:
00008  *  Copyright (C) 1998-2003  XMMS development team.
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; under version 3 of the License.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program.  If not, see <http://www.gnu.org/licenses>.
00021  *
00022  *  The Audacious team does not consider modular code linking to
00023  *  Audacious or using our public API to be a derived work.
00024  */
00025 
00026 #ifdef USE_DBUS
00027 
00028 #include "dbus-service.h"
00029 #include "main.h"
00030 
00031 static void mpris_status_cb (void * hook_data, void * user_data)
00032 {
00033     mpris_emit_status_change (mpris, GPOINTER_TO_INT (user_data));
00034 }
00035 #endif
00036 
00037 void mpris_signals_init (void)
00038 {
00039 #ifdef USE_DBUS
00040     hook_associate ("playback begin", mpris_status_cb, GINT_TO_POINTER
00041      (MPRIS_STATUS_PLAY));
00042     hook_associate ("playback pause", mpris_status_cb, GINT_TO_POINTER
00043      (MPRIS_STATUS_PAUSE));
00044     hook_associate ("playback unpause", mpris_status_cb, GINT_TO_POINTER
00045      (MPRIS_STATUS_PLAY));
00046     hook_associate ("playback stop", mpris_status_cb, GINT_TO_POINTER
00047      (MPRIS_STATUS_STOP));
00048 
00049     hook_associate ("set shuffle", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_INVALID));
00050     hook_associate ("set repeat", mpris_status_cb, GINT_TO_POINTER (MPRIS_STATUS_INVALID));
00051     hook_associate ("set no_playlist_advance", mpris_status_cb, GINT_TO_POINTER
00052      (MPRIS_STATUS_INVALID));
00053 #endif
00054 }
00055 
00056 void mpris_signals_cleanup (void)
00057 {
00058 #ifdef USE_DBUS
00059     hook_dissociate ("playback begin", mpris_status_cb);
00060     hook_dissociate ("playback pause", mpris_status_cb);
00061     hook_dissociate ("playback unpause", mpris_status_cb);
00062     hook_dissociate ("playback stop", mpris_status_cb);
00063 
00064     hook_dissociate ("set shuffle", mpris_status_cb);
00065     hook_dissociate ("set repeat", mpris_status_cb);
00066     hook_dissociate ("set no_playlist_advance", mpris_status_cb);
00067 #endif
00068 }