Changeset 9245 for trunk/qt/app.cc


Ignore:
Timestamp:
Oct 5, 2009, 9:33:39 PM (13 years ago)
Author:
charles
Message:

(trunk Qt) add command-line arguments for connecting to a remote session

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/app.cc

    r9237 r9245  
    4444        { 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
    4545        { 'm', "minimized",  "Start minimized in system tray", "m", 0, NULL },
     46        { 'p', "port",  "Port to use when connecting to an existing session", "p", 1, "<port>" },
     47        { 'r', "remote",  "Connect to an existing session at the specified hostname", "r", 1, "<host>" },
     48        { 'u', "username", "Username to use when connecting to an existing session", "v", 1, "<username>" },
    4649        { 'v', "version", "Show version number and exit", "v", 0, NULL },
     50        { 'w', "password", "Password to use when connecting to an existing session", "w", 1, "<password>" },
    4751        { 0, NULL, NULL, NULL, 0, NULL }
    4852    };
     
    99103    bool minimized = false;
    100104    const char * optarg;
     105    const char * host = 0;
     106    const char * port = 0;
     107    const char * username = 0;
     108    const char * password = 0;
    101109    const char * configDir = 0;
    102110    QStringList filenames;
     
    104112        switch( c ) {
    105113            case 'g': configDir = optarg; break;
     114            case 'p': port = optarg; break;
     115            case 'r': host = optarg; break;
     116            case 'u': username = optarg; break;
     117            case 'w': password = optarg; break;
    106118            case 'm': minimized = true; break;
    107119            case 'v':        Utils::toStderr( QObject::tr( "transmission %1" ).arg( LONG_VERSION_STRING ) ); exit( 0 ); break;
     
    118130    const bool firstTime = !QFile(QDir(configDir).absoluteFilePath("settings.json")).exists();
    119131
     132    // initialize the prefs
    120133    myPrefs = new Prefs ( configDir );
     134    if( host != 0 )
     135        myPrefs->set( Prefs::SESSION_REMOTE_HOST, host );
     136    if( port != 0 )
     137        myPrefs->set( Prefs::SESSION_REMOTE_PORT, port );
     138    if( username != 0 )
     139        myPrefs->set( Prefs::SESSION_REMOTE_USERNAME, username );
     140    if( password != 0 )
     141        myPrefs->set( Prefs::SESSION_REMOTE_USERNAME, password );
     142    if( ( host != 0 ) || ( port != 0 ) || ( username != 0 ) || ( password != 0 ) )
     143        myPrefs->set( Prefs::SESSION_IS_REMOTE, true );
     144
    121145    mySession = new Session( configDir, *myPrefs );
    122146    myModel = new TorrentModel( *myPrefs );
Note: See TracChangeset for help on using the changeset viewer.