2008-02-24 15:42:31 +00:00
|
|
|
/*
|
2011-01-19 13:48:47 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2008-02-24 15:42:31 +00:00
|
|
|
*
|
2010-12-27 19:18:17 +00:00
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
2008-02-24 15:42:31 +00:00
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
2008-09-23 19:11:04 +00:00
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
2008-02-24 15:42:31 +00:00
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
2008-09-23 19:11:04 +00:00
|
|
|
*
|
2008-03-02 16:14:46 +00:00
|
|
|
* $Id$
|
2008-02-24 15:42:31 +00:00
|
|
|
*/
|
|
|
|
|
2008-03-03 04:44:27 +00:00
|
|
|
#include <glib/gi18n.h>
|
2009-01-13 16:39:19 +00:00
|
|
|
#include "conf.h"
|
2008-02-24 15:42:31 +00:00
|
|
|
#include "notify.h"
|
2009-01-12 21:15:14 +00:00
|
|
|
#include "tr-prefs.h"
|
2008-02-24 15:42:31 +00:00
|
|
|
|
|
|
|
void
|
2011-03-03 01:59:25 +00:00
|
|
|
gtr_notify_torrent_completed( TrCore * core, int torrent_id )
|
2008-09-23 19:11:04 +00:00
|
|
|
{
|
2011-07-23 17:23:12 +00:00
|
|
|
if( gtr_pref_flag_get( PREF_KEY_TORRENT_COMPLETE_SOUND_ENABLED ) )
|
2009-11-22 18:55:24 +00:00
|
|
|
{
|
2011-07-23 17:23:12 +00:00
|
|
|
const char * cmd = gtr_pref_string_get( PREF_KEY_TORRENT_COMPLETE_SOUND_COMMAND );
|
|
|
|
g_spawn_command_line_async( cmd, NULL );
|
2009-11-22 18:55:24 +00:00
|
|
|
}
|
|
|
|
|
2011-07-23 17:23:12 +00:00
|
|
|
if( gtr_pref_flag_get( PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_ENABLED ) )
|
2009-01-12 18:48:20 +00:00
|
|
|
{
|
2011-07-23 17:23:12 +00:00
|
|
|
const tr_torrent * tor = gtr_core_find_torrent( core, torrent_id );
|
|
|
|
const char * fmt = gtr_pref_string_get( PREF_KEY_TORRENT_COMPLETE_NOTIFICATION_COMMAND );
|
|
|
|
char * cmd = g_strdup_printf( fmt, _( "Torrent Complete" ), ( tor ? tr_torrentName( tor ) : "" ) );
|
|
|
|
g_spawn_command_line_async( cmd, NULL );
|
|
|
|
g_free( cmd );
|
2009-01-12 18:48:20 +00:00
|
|
|
}
|
2008-02-24 15:42:31 +00:00
|
|
|
}
|
|
|
|
|
2009-06-11 16:17:48 +00:00
|
|
|
void
|
2011-03-03 01:59:25 +00:00
|
|
|
gtr_notify_torrent_added( const char * name )
|
2009-06-11 16:17:48 +00:00
|
|
|
{
|
2011-07-23 17:23:12 +00:00
|
|
|
if( gtr_pref_flag_get( PREF_KEY_TORRENT_ADDED_NOTIFICATION_ENABLED ) )
|
2009-06-11 16:17:48 +00:00
|
|
|
{
|
2011-07-23 17:23:12 +00:00
|
|
|
const char * fmt = gtr_pref_string_get( PREF_KEY_TORRENT_ADDED_NOTIFICATION_COMMAND );
|
|
|
|
char * cmd = g_strdup_printf( fmt, _( "Torrent Added" ), name );
|
|
|
|
g_spawn_command_line_async( cmd, NULL );
|
|
|
|
g_free( cmd );
|
2009-06-11 16:17:48 +00:00
|
|
|
}
|
|
|
|
}
|