#include <kdialog.h>
#include <tdelocale.h>

/****************************************************************************
** Form implementation generated from reading ui file 'hidsrvwizard.ui'
**
** Created by: The TQt user interface compiler (TQt 3.5.0)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/

#include "hidsrvwizard.h"

#include <ntqvariant.h>
#include <kurlrequester.h>
#include <kcombobox.h>
#include <kpushbutton.h>
#include <ntqpushbutton.h>
#include <ntqwidget.h>
#include <ntqbuttongroup.h>
#include <ntqradiobutton.h>
#include <ntqlabel.h>
#include <ntqlineedit.h>
#include <ntqspinbox.h>
#include <ntqlayout.h>
#include <ntqtooltip.h>
#include <ntqwhatsthis.h>
#include "hidsrvwizard.ui.h"

/*
 *  Constructs a HidSrvWizard as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 *  The qwizard will by default be modeless, unless you set 'modal' to
 *  true to construct a modal qwizard.
 */
HidSrvWizard::HidSrvWizard( TQWidget* parent, const char* name, bool modal, WFlags fl )
    : KWizard( parent, name, modal, fl )
{
    if ( !name )
	setName( "HidSrvWizard" );

    WizardPage = new TQWidget( this, "WizardPage" );
    WizardPageLayout = new TQGridLayout( WizardPage, 1, 1, 11, 6, "WizardPageLayout"); 

    buttonGroup1 = new TQButtonGroup( WizardPage, "buttonGroup1" );

    localWeb = new TQRadioButton( buttonGroup1, "localWeb" );
    localWeb->setGeometry( TQRect( 12, 55, 287, 19 ) );

    remote = new TQRadioButton( buttonGroup1, "remote" );
    remote->setGeometry( TQRect( 12, 30, 340, 19 ) );
    remote->setChecked( true );

    WizardPageLayout->addWidget( buttonGroup1, 1, 0 );

    textLabel1 = new TQLabel( WizardPage, "textLabel1" );

    WizardPageLayout->addWidget( textLabel1, 0, 0 );
    addPage( WizardPage, TQString("") );

    LocalWebService = new TQWidget( this, "LocalWebService" );
    LocalWebServiceLayout = new TQGridLayout( LocalWebService, 1, 1, 11, 6, "LocalWebServiceLayout"); 

    textLabel4 = new TQLabel( LocalWebService, "textLabel4" );

    LocalWebServiceLayout->addMultiCellWidget( textLabel4, 0, 0, 0, 2 );

    downloadThttpd = new TQPushButton( LocalWebService, "downloadThttpd" );

    LocalWebServiceLayout->addWidget( downloadThttpd, 1, 1 );
    spacer1 = new TQSpacerItem( 81, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    LocalWebServiceLayout->addItem( spacer1, 1, 0 );
    spacer2 = new TQSpacerItem( 71, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    LocalWebServiceLayout->addItem( spacer2, 1, 2 );
    addPage( LocalWebService, TQString("") );

    ServiceName = new TQWidget( this, "ServiceName" );
    ServiceNameLayout = new TQGridLayout( ServiceName, 1, 1, 11, 6, "ServiceNameLayout"); 

    textLabel5 = new TQLabel( ServiceName, "textLabel5" );

    ServiceNameLayout->addMultiCellWidget( textLabel5, 0, 0, 0, 2 );
    spacer3 = new TQSpacerItem( 20, 31, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
    ServiceNameLayout->addItem( spacer3, 3, 1 );
    spacer4 = new TQSpacerItem( 20, 21, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
    ServiceNameLayout->addItem( spacer4, 1, 1 );
    spacer5 = new TQSpacerItem( 31, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    ServiceNameLayout->addItem( spacer5, 2, 0 );
    spacer6 = new TQSpacerItem( 101, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    ServiceNameLayout->addItem( spacer6, 2, 2 );

    Nick = new TQLineEdit( ServiceName, "Nick" );
    Nick->setMinimumSize( TQSize( 180, 0 ) );

    ServiceNameLayout->addWidget( Nick, 2, 1 );
    addPage( ServiceName, TQString("") );

    RedirectService = new TQWidget( this, "RedirectService" );
    RedirectServiceLayout = new TQGridLayout( RedirectService, 1, 1, 11, 6, "RedirectServiceLayout"); 

    RedirectAddress = new TQLineEdit( RedirectService, "RedirectAddress" );

    RedirectServiceLayout->addWidget( RedirectAddress, 2, 0 );

    textLabel2 = new TQLabel( RedirectService, "textLabel2" );

    RedirectServiceLayout->addMultiCellWidget( textLabel2, 1, 1, 0, 2 );

    NonWebPort = new TQSpinBox( RedirectService, "NonWebPort" );
    NonWebPort->setMaxValue( 65535 );

    RedirectServiceLayout->addWidget( NonWebPort, 0, 2 );

    textLabel6 = new TQLabel( RedirectService, "textLabel6" );

    RedirectServiceLayout->addMultiCellWidget( textLabel6, 0, 0, 0, 1 );

    textLabel3 = new TQLabel( RedirectService, "textLabel3" );

    RedirectServiceLayout->addWidget( textLabel3, 3, 0 );

    RedirectPort = new TQSpinBox( RedirectService, "RedirectPort" );
    RedirectPort->setMaxValue( 65535 );

    RedirectServiceLayout->addWidget( RedirectPort, 2, 1 );

    textLabel4_2 = new TQLabel( RedirectService, "textLabel4_2" );

    RedirectServiceLayout->addMultiCellWidget( textLabel4_2, 3, 3, 1, 2 );
    addPage( RedirectService, TQString("") );

    LocalWebServiceFiles = new TQWidget( this, "LocalWebServiceFiles" );
    LocalWebServiceFilesLayout = new TQGridLayout( LocalWebServiceFiles, 1, 1, 11, 6, "LocalWebServiceFilesLayout"); 

    textLabel5_2 = new TQLabel( LocalWebServiceFiles, "textLabel5_2" );

    LocalWebServiceFilesLayout->addMultiCellWidget( textLabel5_2, 2, 2, 0, 1 );

    textLabel6_2 = new TQLabel( LocalWebServiceFiles, "textLabel6_2" );

    LocalWebServiceFilesLayout->addWidget( textLabel6_2, 0, 0 );

    textLabel6_2_2 = new TQLabel( LocalWebServiceFiles, "textLabel6_2_2" );

    LocalWebServiceFilesLayout->addWidget( textLabel6_2_2, 1, 0 );

    localWebPort = new TQSpinBox( LocalWebServiceFiles, "localWebPort" );
    localWebPort->setMaxValue( 65535 );
    localWebPort->setValue( 5222 );

    LocalWebServiceFilesLayout->addWidget( localWebPort, 1, 1 );

    WebPort = new TQSpinBox( LocalWebServiceFiles, "WebPort" );
    WebPort->setMaxValue( 65535 );
    WebPort->setValue( 80 );

    LocalWebServiceFilesLayout->addWidget( WebPort, 0, 1 );

    FilesToServe = new KURLComboRequester( LocalWebServiceFiles, "FilesToServe" );
    FilesToServe->setMode( 6 );

    LocalWebServiceFilesLayout->addMultiCellWidget( FilesToServe, 3, 3, 0, 1 );
    addPage( LocalWebServiceFiles, TQString("") );

    ServiceConfigured = new TQWidget( this, "ServiceConfigured" );

    textLabel6_3 = new TQLabel( ServiceConfigured, "textLabel6_3" );
    textLabel6_3->setGeometry( TQRect( 14, 8, 350, 90 ) );
    addPage( ServiceConfigured, TQString("") );

    GatherDetails = new TQWidget( this, "GatherDetails" );

    GatheringDetailsText = new TQLabel( GatherDetails, "GatheringDetailsText" );
    GatheringDetailsText->setGeometry( TQRect( 5, 15, 370, 130 ) );
    GatheringDetailsText->setTextFormat( TQLabel::RichText );
    GatheringDetailsText->setAlignment( int( TQLabel::WordBreak | TQLabel::AlignVCenter ) );
    addPage( GatherDetails, TQString("") );
    languageChange();
    resize( TQSize(406, 240).expandedTo(minimumSizeHint()) );
    clearWState( WState_Polished );

    // signals and slots connections
    connect( localWeb, TQ_SIGNAL( toggled(bool) ), this, TQ_SLOT( localWeb_toggled(bool) ) );
    connect( downloadThttpd, TQ_SIGNAL( clicked() ), this, TQ_SLOT( downloadThttpd_clicked() ) );

    // tab order
    setTabOrder( remote, downloadThttpd );
    setTabOrder( downloadThttpd, Nick );
    setTabOrder( Nick, NonWebPort );
    setTabOrder( NonWebPort, RedirectAddress );
    setTabOrder( RedirectAddress, RedirectPort );
    setTabOrder( RedirectPort, WebPort );
    setTabOrder( WebPort, localWebPort );
    setTabOrder( localWebPort, FilesToServe );
    init();
}

/*
 *  Destroys the object and frees any allocated resources
 */
HidSrvWizard::~HidSrvWizard()
{
    // no need to delete child widgets, TQt does it all for us
}

/*
 *  Sets the strings of the subwidgets using the current
 *  language.
 */
void HidSrvWizard::languageChange()
{
    setCaption( tr2i18n( "Form1" ) );
    buttonGroup1->setTitle( tr2i18n( "Service Types" ) );
    localWeb->setText( tr2i18n( "A local web service." ) );
    remote->setText( tr2i18n( "A redirect to a remote or local service, e.g. google.com" ) );
    textLabel1->setText( tr2i18n( "What kind of hidden service would you like to create?" ) );
    setTitle( WizardPage, tr2i18n( "Select Service Type" ) );
    textLabel4->setText( tr2i18n( "<blockquote>To run a local web service, the Tor people recommend thttpd. Would you like to download and install thttpd now? If not, you can just continue and set up the address and port of the service as normal.</blockquote>" ) );
    downloadThttpd->setText( tr2i18n( "Download thttpd" ) );
    setTitle( LocalWebService, tr2i18n( "Local Web Service" ) );
    textLabel5->setText( tr2i18n( "What name do you want to give to this service?" ) );
    setTitle( ServiceName, tr2i18n( "Service Name" ) );
    textLabel2->setText( tr2i18n( "Enter the address and port your service will redirect to:" ) );
    textLabel6->setText( tr2i18n( "Enter the port your hidden service will listen on:" ) );
    textLabel3->setText( tr2i18n( "e.g. www.google.com<br>or localhost" ) );
    textLabel4_2->setText( tr2i18n( "e.g. 80" ) );
    setTitle( RedirectService, tr2i18n( "Redirect Service" ) );
    textLabel5_2->setText( tr2i18n( "Select or accept the location of the files you will serve:" ) );
    textLabel6_2->setText( tr2i18n( "Enter the port your hidden service will listen on:" ) );
    textLabel6_2_2->setText( tr2i18n( "Enter the local port for your hidden service:" ) );
    setTitle( LocalWebServiceFiles, tr2i18n( "Local Web Service" ) );
    textLabel6_3->setText( tr2i18n( "OK. Your hidden service has been configured.<br>Now Tor needs to create it. Click 'Next' to create the service." ) );
    setTitle( ServiceConfigured, tr2i18n( "Service Configured." ) );
    GatheringDetailsText->setText( tr2i18n( "Please wait a moment while Tor creates the service details." ) );
    setTitle( GatherDetails, tr2i18n( "Gathering Service Details from Tor" ) );
}

/****************************************************************************
** HidSrvWizard meta object code from reading C++ file 'hidsrvwizard.h'
**
** Created by: The TQt Meta Object Compiler version 26 (TQt 3.5.0)
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#undef TQT_NO_COMPAT
#include "hidsrvwizard.h"
#include <ntqmetaobject.h>
#include <ntqapplication.h>

#include <private/qucomextra_p.h>
#if !defined(Q_MOC_OUTPUT_REVISION) || (Q_MOC_OUTPUT_REVISION != 26)
#error "This file was generated using the moc from 3.5.0. It"
#error "cannot be used with the include files from this version of TQt."
#error "(The moc has changed too much.)"
#endif

const char *HidSrvWizard::className() const
{
    return "HidSrvWizard";
}

TQMetaObject *HidSrvWizard::metaObj = 0;
static TQMetaObjectCleanUp cleanUp_HidSrvWizard( "HidSrvWizard", &HidSrvWizard::staticMetaObject );

#ifndef TQT_NO_TRANSLATION
TQString HidSrvWizard::tr( const char *s, const char *c )
{
    if ( tqApp )
	return tqApp->translate( "HidSrvWizard", s, c, TQApplication::DefaultCodec );
    else
	return TQString::fromLatin1( s );
}
#ifndef TQT_NO_TRANSLATION_UTF8
TQString HidSrvWizard::trUtf8( const char *s, const char *c )
{
    if ( tqApp )
	return tqApp->translate( "HidSrvWizard", s, c, TQApplication::UnicodeUTF8 );
    else
	return TQString::fromUtf8( s );
}
#endif // TQT_NO_TRANSLATION_UTF8

#endif // TQT_NO_TRANSLATION

TQMetaObject* HidSrvWizard::staticMetaObject()
{
    if ( metaObj ) {
	return metaObj;
}
#ifdef TQT_THREAD_SUPPORT
    if (tqt_sharedMetaObjectMutex) tqt_sharedMetaObjectMutex->lock();
    if ( metaObj ) {
	if (tqt_sharedMetaObjectMutex) tqt_sharedMetaObjectMutex->unlock();
	return metaObj;
    }
#endif // TQT_THREAD_SUPPORT
    TQMetaObject* parentObject = KWizard::staticMetaObject();
    static const TQUParameter param_slot_0[] = {
	{ "state", &static_QUType_bool, 0, TQUParameter::In }
    };
    static const TQUMethod slot_0 = {"localWeb_toggled", 1, param_slot_0 };
    static const TQUMethod slot_1 = {"downloadThttpd_clicked", 0, 0 };
    static const TQUParameter param_slot_2[] = {
	{ "w", &static_QUType_ptr, "TQWidget", TQUParameter::In }
    };
    static const TQUMethod slot_2 = {"showPage", 1, param_slot_2 };
    static const TQUMethod slot_3 = {"checkServiceDetails", 0, 0 };
    static const TQUMethod slot_4 = {"accept", 0, 0 };
    static const TQUMethod slot_5 = {"reject", 0, 0 };
    static const TQUMethod slot_6 = {"languageChange", 0, 0 };
    static const TQMetaData slot_tbl[] = {
	{ "localWeb_toggled(bool)", &slot_0, TQMetaData::Public },
	{ "downloadThttpd_clicked()", &slot_1, TQMetaData::Public },
	{ "showPage(TQWidget*)", &slot_2, TQMetaData::Public },
	{ "checkServiceDetails()", &slot_3, TQMetaData::Public },
	{ "accept()", &slot_4, TQMetaData::Public },
	{ "reject()", &slot_5, TQMetaData::Public },
	{ "languageChange()", &slot_6, TQMetaData::Protected }
    };
    static const TQUParameter param_signal_0[] = {
	{ 0, &static_QUType_TQString, 0, TQUParameter::In },
	{ 0, &static_QUType_TQString, 0, TQUParameter::In }
    };
    static const TQUMethod signal_0 = {"createService", 2, param_signal_0 };
    static const TQUParameter param_signal_1[] = {
	{ 0, &static_QUType_TQString, 0, TQUParameter::In },
	{ 0, &static_QUType_TQString, 0, TQUParameter::In },
	{ 0, &static_QUType_TQString, 0, TQUParameter::In },
	{ 0, &static_QUType_TQString, 0, TQUParameter::In },
	{ 0, &static_QUType_TQString, 0, TQUParameter::In },
	{ 0, &static_QUType_TQString, 0, TQUParameter::In }
    };
    static const TQUMethod signal_1 = {"addService", 6, param_signal_1 };
    static const TQMetaData signal_tbl[] = {
	{ "createService(const TQString&,const TQString&)", &signal_0, TQMetaData::Public },
	{ "addService(const TQString&,const TQString&,const TQString&,const TQString&,const TQString&,const TQString&)", &signal_1, TQMetaData::Public }
    };
    metaObj = TQMetaObject::new_metaobject(
	"HidSrvWizard", parentObject,
	slot_tbl, 7,
	signal_tbl, 2,
#ifndef TQT_NO_PROPERTIES
	0, 0,
	0, 0,
#endif // TQT_NO_PROPERTIES
	0, 0 );
    cleanUp_HidSrvWizard.setMetaObject( metaObj );
#ifdef TQT_THREAD_SUPPORT
    if (tqt_sharedMetaObjectMutex) tqt_sharedMetaObjectMutex->unlock();
#endif // TQT_THREAD_SUPPORT
    return metaObj;
}

void* HidSrvWizard::tqt_cast( const char* clname )
{
    if ( !qstrcmp( clname, "HidSrvWizard" ) )
	return this;
    return KWizard::tqt_cast( clname );
}

#include <ntqobjectdefs.h>
#include <ntqsignalslotimp.h>

// TQ_SIGNAL createService
void HidSrvWizard::createService( const TQString& t0, const TQString& t1 )
{
    if ( signalsBlocked() )
	return;
    TQConnectionList *clist = receivers( staticMetaObject()->signalOffset() + 0 );
    if ( !clist )
	return;
    TQUObject o[3];
    static_QUType_TQString.set(o+1,t0);
    static_QUType_TQString.set(o+2,t1);
    o[2].isLastObject = true;
    activate_signal( clist, o );
}

// TQ_SIGNAL addService
void HidSrvWizard::addService( const TQString& t0, const TQString& t1, const TQString& t2, const TQString& t3, const TQString& t4, const TQString& t5 )
{
    if ( signalsBlocked() )
	return;
    TQConnectionList *clist = receivers( staticMetaObject()->signalOffset() + 1 );
    if ( !clist )
	return;
    TQUObject o[7];
    static_QUType_TQString.set(o+1,t0);
    static_QUType_TQString.set(o+2,t1);
    static_QUType_TQString.set(o+3,t2);
    static_QUType_TQString.set(o+4,t3);
    static_QUType_TQString.set(o+5,t4);
    static_QUType_TQString.set(o+6,t5);
    o[6].isLastObject = true;
    activate_signal( clist, o );
}

bool HidSrvWizard::tqt_invoke( int _id, TQUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: localWeb_toggled((bool)static_QUType_bool.get(_o+1)); break;
    case 1: downloadThttpd_clicked(); break;
    case 2: showPage((TQWidget*)static_QUType_ptr.get(_o+1)); break;
    case 3: checkServiceDetails(); break;
    case 4: accept(); break;
    case 5: reject(); break;
    case 6: languageChange(); break;
    default:
	return KWizard::tqt_invoke( _id, _o );
    }
    return true;
}

bool HidSrvWizard::tqt_emit( int _id, TQUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: createService((const TQString&)static_QUType_TQString.get(_o+1),(const TQString&)static_QUType_TQString.get(_o+2)); break;
    case 1: addService((const TQString&)static_QUType_TQString.get(_o+1),(const TQString&)static_QUType_TQString.get(_o+2),(const TQString&)static_QUType_TQString.get(_o+3),(const TQString&)static_QUType_TQString.get(_o+4),(const TQString&)static_QUType_TQString.get(_o+5),(const TQString&)static_QUType_TQString.get(_o+6)); break;
    default:
	return KWizard::tqt_emit(_id,_o);
    }
    return true;
}
#ifndef TQT_NO_PROPERTIES

bool HidSrvWizard::tqt_property( int id, int f, TQVariant* v)
{
    return KWizard::tqt_property( id, f, v);
}

bool HidSrvWizard::tqt_static_property( TQObject* , int , int , TQVariant* ){ return false; }
#endif // TQT_NO_PROPERTIES
