mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
(trunk) add "filename" arg to the dbus message when passing a .torrent from one instance of Transmission to another
This commit is contained in:
parent
60ce7e5263
commit
2f56196206
6 changed files with 34 additions and 14 deletions
|
@ -4,6 +4,7 @@
|
|||
<method name="AddMetainfo">
|
||||
<arg type="b" name="handled" direction="out"/>
|
||||
<arg type="s" name="metainfo" direction="in"/>
|
||||
<arg type="s" name="filename" direction="in"/>
|
||||
</method>
|
||||
<method name="PresentWindow">
|
||||
<arg type="b" name="handled" direction="out"/>
|
||||
|
|
|
@ -958,6 +958,7 @@ tr_core_add_ctor( TrCore * core, tr_ctor * ctor )
|
|||
gboolean
|
||||
tr_core_add_metainfo( TrCore * core,
|
||||
const char * payload,
|
||||
const char * filename,
|
||||
gboolean * setme_handled,
|
||||
GError ** gerr UNUSED )
|
||||
{
|
||||
|
@ -972,23 +973,38 @@ tr_core_add_metainfo( TrCore * core,
|
|||
tr_core_add_from_url( core, payload );
|
||||
*setme_handled = TRUE;
|
||||
}
|
||||
else /* base64-encoded metainfo */
|
||||
else
|
||||
{
|
||||
int file_length;
|
||||
tr_ctor * ctor;
|
||||
char * file_contents;
|
||||
gboolean do_prompt = pref_flag_get( PREF_KEY_OPTIONS_PROMPT );
|
||||
gboolean has_metainfo = FALSE;
|
||||
const gboolean do_prompt = pref_flag_get( PREF_KEY_OPTIONS_PROMPT );
|
||||
|
||||
/* create the constructor */
|
||||
ctor = tr_ctorNew( session );
|
||||
tr_core_apply_defaults( ctor );
|
||||
|
||||
file_contents = tr_base64_decode( payload, -1, &file_length );
|
||||
tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
|
||||
add_ctor( core, ctor, do_prompt, TRUE );
|
||||
if( !has_metainfo && g_file_test( filename, G_FILE_TEST_IS_REGULAR ) )
|
||||
{
|
||||
/* set the metainfo from a local file */
|
||||
has_metainfo = !tr_ctorSetMetainfoFromFile( ctor, filename );
|
||||
}
|
||||
|
||||
tr_free( file_contents );
|
||||
tr_core_torrents_added( core );
|
||||
*setme_handled = TRUE;
|
||||
if( !has_metainfo )
|
||||
{
|
||||
/* base64-encoded metainfo */
|
||||
int file_length;
|
||||
char * file_contents = tr_base64_decode( payload, -1, &file_length );
|
||||
has_metainfo = !tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
|
||||
tr_free( file_contents );
|
||||
}
|
||||
|
||||
if( has_metainfo )
|
||||
{
|
||||
add_ctor( core, ctor, do_prompt, TRUE );
|
||||
tr_core_torrents_added( core );
|
||||
}
|
||||
|
||||
*setme_handled = has_metainfo;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -133,7 +133,8 @@ void tr_core_add_list( TrCore * self,
|
|||
|
||||
/** @brief Add a torrent. */
|
||||
gboolean tr_core_add_metainfo( TrCore * core,
|
||||
const char * base64_metainfo,
|
||||
const char * payload,
|
||||
const char * optional_filename,
|
||||
gboolean * setme_success,
|
||||
GError ** err );
|
||||
|
||||
|
|
|
@ -563,6 +563,7 @@ gtr_dbus_add_torrent( const char * filename )
|
|||
if( proxy )
|
||||
dbus_g_proxy_call( proxy, "AddMetainfo", &err,
|
||||
G_TYPE_STRING, payload,
|
||||
G_TYPE_STRING, filename,
|
||||
G_TYPE_INVALID,
|
||||
G_TYPE_BOOLEAN, &handled,
|
||||
G_TYPE_INVALID );
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* $Id:$
|
||||
*/
|
||||
|
||||
#include <QFile>
|
||||
#include "app.h"
|
||||
#include "dbus-adaptor.h"
|
||||
|
||||
|
@ -27,8 +28,8 @@ TrDBusAdaptor :: PresentWindow( )
|
|||
}
|
||||
|
||||
bool
|
||||
TrDBusAdaptor :: AddMetainfo( const QString& str )
|
||||
TrDBusAdaptor :: AddMetainfo( const QString& payload, const QString& filename )
|
||||
{
|
||||
myApp->addTorrent( str );
|
||||
myApp->addTorrent( QFile(filename).exists() ? filename : payload );
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class TrDBusAdaptor: public QDBusAbstractAdaptor
|
|||
|
||||
public slots:
|
||||
bool PresentWindow();
|
||||
bool AddMetainfo( const QString& );
|
||||
bool AddMetainfo( const QString& payload, const QString& filename );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue