Changeset 10717


Ignore:
Timestamp:
Jun 3, 2010, 7:53:01 PM (13 years ago)
Author:
charles
Message:

(trunk) add "filename" arg to the dbus message when passing a .torrent from one instance of Transmission to another

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core-dbus.xml

    r8669 r10717  
    55      <arg type="b" name="handled" direction="out"/>
    66      <arg type="s" name="metainfo" direction="in"/>
     7      <arg type="s" name="filename" direction="in"/>
    78    </method>
    89    <method name="PresentWindow">
  • trunk/gtk/tr-core.c

    r10644 r10717  
    959959tr_core_add_metainfo( TrCore      * core,
    960960                      const char  * payload,
     961                      const char  * filename,
    961962                      gboolean    * setme_handled,
    962963                      GError     ** gerr UNUSED )
     
    973974        *setme_handled = TRUE;
    974975    }
    975     else /* base64-encoded metainfo */
    976     {
    977         int file_length;
     976    else
     977    {
    978978        tr_ctor * ctor;
    979         char * file_contents;
    980         gboolean do_prompt = pref_flag_get( PREF_KEY_OPTIONS_PROMPT );
    981 
     979        gboolean has_metainfo = FALSE;
     980        const gboolean do_prompt = pref_flag_get( PREF_KEY_OPTIONS_PROMPT );
     981
     982        /* create the constructor */
    982983        ctor = tr_ctorNew( session );
    983984        tr_core_apply_defaults( ctor );
    984985
    985         file_contents = tr_base64_decode( payload, -1, &file_length );
    986         tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
    987         add_ctor( core, ctor, do_prompt, TRUE );
    988 
    989         tr_free( file_contents );
    990         tr_core_torrents_added( core );
    991         *setme_handled = TRUE;
     986        if( !has_metainfo && g_file_test( filename, G_FILE_TEST_IS_REGULAR ) )
     987        {
     988            /* set the metainfo from a local file */
     989            has_metainfo = !tr_ctorSetMetainfoFromFile( ctor, filename );
     990        }
     991
     992        if( !has_metainfo )
     993        {
     994            /* base64-encoded metainfo */
     995            int file_length;
     996            char * file_contents = tr_base64_decode( payload, -1, &file_length );
     997            has_metainfo = !tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
     998            tr_free( file_contents );
     999        }
     1000
     1001        if( has_metainfo )
     1002        {
     1003            add_ctor( core, ctor, do_prompt, TRUE );
     1004            tr_core_torrents_added( core );
     1005        }
     1006
     1007        *setme_handled = has_metainfo;
    9921008    }
    9931009
  • trunk/gtk/tr-core.h

    r10550 r10717  
    134134/** @brief Add a torrent. */
    135135gboolean tr_core_add_metainfo( TrCore      * core,
    136                                const char  * base64_metainfo,
     136                               const char  * payload,
     137                               const char  * optional_filename,
    137138                               gboolean    * setme_success,
    138139                               GError     ** err );
  • trunk/gtk/util.c

    r10698 r10717  
    564564            dbus_g_proxy_call( proxy, "AddMetainfo", &err,
    565565                               G_TYPE_STRING, payload,
     566                               G_TYPE_STRING, filename,
    566567                               G_TYPE_INVALID,
    567568                               G_TYPE_BOOLEAN, &handled,
  • trunk/qt/dbus-adaptor.cc

    r10532 r10717  
    1111 */
    1212
     13#include <QFile>
    1314#include "app.h"
    1415#include "dbus-adaptor.h"
     
    2829
    2930bool
    30 TrDBusAdaptor :: AddMetainfo( const QString& str )
     31TrDBusAdaptor :: AddMetainfo( const QString& payload, const QString& filename )
    3132{
    32     myApp->addTorrent( str );
     33    myApp->addTorrent( QFile(filename).exists() ? filename : payload );
    3334    return true;
    3435}
  • trunk/qt/dbus-adaptor.h

    r10532 r10717  
    3232  public slots:
    3333    bool PresentWindow();
    34     bool AddMetainfo( const QString& );
     34    bool AddMetainfo( const QString& payload, const QString& filename );
    3535};
    3636
Note: See TracChangeset for help on using the changeset viewer.