@ -45,6 +45,7 @@ std::string programOptionsWriterCurrentSection;
MainWindow : : MainWindow ( std : : shared_ptr < std : : iostream > logStream_ , QWidget * parent ) :
MainWindow : : MainWindow ( std : : shared_ptr < std : : iostream > logStream_ , QWidget * parent ) :
QMainWindow ( parent )
QMainWindow ( parent )
, currentLocalDestinationB32 ( " " )
, logStream ( logStream_ )
, logStream ( logStream_ )
, delayedSaveManagerPtr ( new DelayedSaveManagerImpl ( ) )
, delayedSaveManagerPtr ( new DelayedSaveManagerImpl ( ) )
, dataSerial ( DelayedSaveManagerImpl : : INITIAL_DATA_SERIAL )
, dataSerial ( DelayedSaveManagerImpl : : INITIAL_DATA_SERIAL )
@ -135,6 +136,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
//childTextBrowser->setOpenExternalLinks(false);
//childTextBrowser->setOpenExternalLinks(false);
childTextBrowser - > setOpenLinks ( false ) ;
childTextBrowser - > setOpenLinks ( false ) ;
connect ( textBrowser , SIGNAL ( anchorClicked ( const QUrl & ) ) , this , SLOT ( anchorClickedHandler ( const QUrl & ) ) ) ;
connect ( textBrowser , SIGNAL ( anchorClicked ( const QUrl & ) ) , this , SLOT ( anchorClickedHandler ( const QUrl & ) ) ) ;
connect ( childTextBrowser , SIGNAL ( anchorClicked ( const QUrl & ) ) , this , SLOT ( anchorClickedHandler ( const QUrl & ) ) ) ;
pageWithBackButton = new PageWithBackButton ( this , childTextBrowser ) ;
pageWithBackButton = new PageWithBackButton ( this , childTextBrowser ) ;
ui - > verticalLayout_2 - > addWidget ( pageWithBackButton ) ;
ui - > verticalLayout_2 - > addWidget ( pageWithBackButton ) ;
pageWithBackButton - > hide ( ) ;
pageWithBackButton - > hide ( ) ;
@ -177,9 +179,9 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
# define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
# define OPTION(section,option,defaultValueGetter) ConfigOption(QString(section),QString(option))
initFileChooser ( OPTION ( " " , " conf " , [ ] ( ) { return " " ; } ) , uiSettings - > configFileLineEdit , uiSettings - > configFileBrowsePushButton ) ;
initFileChooser ( OPTION ( " " , " conf " , [ ] ( ) { return " " ; } ) , uiSettings - > configFileLineEdit , uiSettings - > configFileBrowsePushButton , false , true ) ;
initFileChooser ( OPTION ( " " , " tunconf " , [ ] ( ) { return " " ; } ) , uiSettings - > tunnelsConfigFileLineEdit , uiSettings - > tunnelsConfigFileBrowsePushButton ) ;
initFileChooser ( OPTION ( " " , " tunconf " , [ ] ( ) { return " " ; } ) , uiSettings - > tunnelsConfigFileLineEdit , uiSettings - > tunnelsConfigFileBrowsePushButton , false ) ;
initFileChooser ( OPTION ( " " , " pidfile " , [ ] { return " " ; } ) , uiSettings - > pidFileLineEdit , uiSettings - > pidFileBrowsePushButton ) ;
initFileChooser ( OPTION ( " " , " pidfile " , [ ] { return " " ; } ) , uiSettings - > pidFileLineEdit , uiSettings - > pidFileBrowsePushButton , false ) ;
uiSettings - > logDestinationComboBox - > clear ( ) ;
uiSettings - > logDestinationComboBox - > clear ( ) ;
uiSettings - > logDestinationComboBox - > insertItems ( 0 , QStringList ( )
uiSettings - > logDestinationComboBox - > insertItems ( 0 , QStringList ( )
@ -188,8 +190,11 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
< < QApplication : : translate ( " MainWindow " , " file " , 0 )
< < QApplication : : translate ( " MainWindow " , " file " , 0 )
) ;
) ;
initLogDestinationCombobox ( OPTION ( " " , " log " , [ ] { return " " ; } ) , uiSettings - > logDestinationComboBox ) ;
initLogDestinationCombobox ( OPTION ( " " , " log " , [ ] { return " " ; } ) , uiSettings - > logDestinationComboBox ) ;
# ifdef I2PD_QT_RELEASE
uiSettings - > logDestinationComboBox - > setEnabled ( false ) ; // #1593
# endif
logFileNameOption = initFileChooser ( OPTION ( " " , " logfile " , [ ] { return " " ; } ) , uiSettings - > logFileLineEdit , uiSettings - > logFileBrowsePushButton ) ;
logFileNameOption = initFileChooser ( OPTION ( " " , " logfile " , [ ] { return " " ; } ) , uiSettings - > logFileLineEdit , uiSettings - > logFileBrowsePushButton , false ) ;
initLogLevelCombobox ( OPTION ( " " , " loglevel " , [ ] { return " " ; } ) , uiSettings - > logLevelComboBox ) ;
initLogLevelCombobox ( OPTION ( " " , " loglevel " , [ ] { return " " ; } ) , uiSettings - > logLevelComboBox ) ;
initCheckBox ( OPTION ( " " , " logclftime " , [ ] { return " false " ; } ) , uiSettings - > logclftimeCheckBox ) ; //"Write full CLF-formatted date and time to log (default: write only time)"
initCheckBox ( OPTION ( " " , " logclftime " , [ ] { return " false " ; } ) , uiSettings - > logclftimeCheckBox ) ; //"Write full CLF-formatted date and time to log (default: write only time)"
initFolderChooser ( OPTION ( " " , " datadir " , [ ] { return " " ; } ) , uiSettings - > dataFolderLineEdit , uiSettings - > dataFolderBrowsePushButton ) ;
initFolderChooser ( OPTION ( " " , " datadir " , [ ] { return " " ; } ) , uiSettings - > dataFolderLineEdit , uiSettings - > dataFolderBrowsePushButton ) ;
@ -232,7 +237,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initIPAddressBox ( OPTION ( " httpproxy " , " address " , [ ] { return " " ; } ) , uiSettings - > httpProxyAddressLineEdit , tr ( " HTTP proxy -> IP address " ) ) ;
initIPAddressBox ( OPTION ( " httpproxy " , " address " , [ ] { return " " ; } ) , uiSettings - > httpProxyAddressLineEdit , tr ( " HTTP proxy -> IP address " ) ) ;
initTCPPortBox ( OPTION ( " httpproxy " , " port " , [ ] { return " 4444 " ; } ) , uiSettings - > httpProxyPortLineEdit , tr ( " HTTP proxy -> Port " ) ) ;
initTCPPortBox ( OPTION ( " httpproxy " , " port " , [ ] { return " 4444 " ; } ) , uiSettings - > httpProxyPortLineEdit , tr ( " HTTP proxy -> Port " ) ) ;
initCheckBox ( OPTION ( " httpproxy " , " addresshelper " , [ ] { return " true " ; } ) , uiSettings - > httpProxyAddressHelperCheckBox ) ; //Enable address helper (jump). true by default
initCheckBox ( OPTION ( " httpproxy " , " addresshelper " , [ ] { return " true " ; } ) , uiSettings - > httpProxyAddressHelperCheckBox ) ; //Enable address helper (jump). true by default
initFileChooser ( OPTION ( " httpproxy " , " keys " , [ ] { return " " ; } ) , uiSettings - > httpProxyKeyFileLineEdit , uiSettings - > httpProxyKeyFilePushButton ) ;
initFileChooser ( OPTION ( " httpproxy " , " keys " , [ ] { return " " ; } ) , uiSettings - > httpProxyKeyFileLineEdit , uiSettings - > httpProxyKeyFilePushButton , false ) ;
initSignatureTypeCombobox ( OPTION ( " httpproxy " , " signaturetype " , [ ] { return " 7 " ; } ) , uiSettings - > comboBox_httpPorxySignatureType ) ;
initSignatureTypeCombobox ( OPTION ( " httpproxy " , " signaturetype " , [ ] { return " 7 " ; } ) , uiSettings - > comboBox_httpPorxySignatureType ) ;
initStringBox ( OPTION ( " httpproxy " , " inbound.length " , [ ] { return " 3 " ; } ) , uiSettings - > httpProxyInboundTunnelsLenLineEdit ) ;
initStringBox ( OPTION ( " httpproxy " , " inbound.length " , [ ] { return " 3 " ; } ) , uiSettings - > httpProxyInboundTunnelsLenLineEdit ) ;
initStringBox ( OPTION ( " httpproxy " , " inbound.quantity " , [ ] { return " 5 " ; } ) , uiSettings - > httpProxyInboundTunnQuantityLineEdit ) ;
initStringBox ( OPTION ( " httpproxy " , " inbound.quantity " , [ ] { return " 5 " ; } ) , uiSettings - > httpProxyInboundTunnQuantityLineEdit ) ;
@ -245,7 +250,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initCheckBox ( OPTION ( " socksproxy " , " enabled " , [ ] { return " " ; } ) , uiSettings - > socksProxyEnabledCheckBox ) ;
initCheckBox ( OPTION ( " socksproxy " , " enabled " , [ ] { return " " ; } ) , uiSettings - > socksProxyEnabledCheckBox ) ;
initIPAddressBox ( OPTION ( " socksproxy " , " address " , [ ] { return " " ; } ) , uiSettings - > socksProxyAddressLineEdit , tr ( " Socks proxy -> IP address " ) ) ;
initIPAddressBox ( OPTION ( " socksproxy " , " address " , [ ] { return " " ; } ) , uiSettings - > socksProxyAddressLineEdit , tr ( " Socks proxy -> IP address " ) ) ;
initTCPPortBox ( OPTION ( " socksproxy " , " port " , [ ] { return " 4447 " ; } ) , uiSettings - > socksProxyPortLineEdit , tr ( " Socks proxy -> Port " ) ) ;
initTCPPortBox ( OPTION ( " socksproxy " , " port " , [ ] { return " 4447 " ; } ) , uiSettings - > socksProxyPortLineEdit , tr ( " Socks proxy -> Port " ) ) ;
initFileChooser ( OPTION ( " socksproxy " , " keys " , [ ] { return " " ; } ) , uiSettings - > socksProxyKeyFileLineEdit , uiSettings - > socksProxyKeyFilePushButton ) ;
initFileChooser ( OPTION ( " socksproxy " , " keys " , [ ] { return " " ; } ) , uiSettings - > socksProxyKeyFileLineEdit , uiSettings - > socksProxyKeyFilePushButton , false ) ;
initSignatureTypeCombobox ( OPTION ( " socksproxy " , " signaturetype " , [ ] { return " 7 " ; } ) , uiSettings - > comboBox_socksProxySignatureType ) ;
initSignatureTypeCombobox ( OPTION ( " socksproxy " , " signaturetype " , [ ] { return " 7 " ; } ) , uiSettings - > comboBox_socksProxySignatureType ) ;
initStringBox ( OPTION ( " socksproxy " , " inbound.length " , [ ] { return " " ; } ) , uiSettings - > socksProxyInboundTunnelsLenLineEdit ) ;
initStringBox ( OPTION ( " socksproxy " , " inbound.length " , [ ] { return " " ; } ) , uiSettings - > socksProxyInboundTunnelsLenLineEdit ) ;
initStringBox ( OPTION ( " socksproxy " , " inbound.quantity " , [ ] { return " " ; } ) , uiSettings - > socksProxyInboundTunnQuantityLineEdit ) ;
initStringBox ( OPTION ( " socksproxy " , " inbound.quantity " , [ ] { return " " ; } ) , uiSettings - > socksProxyInboundTunnQuantityLineEdit ) ;
@ -275,8 +280,8 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initIPAddressBox ( OPTION ( " i2pcontrol " , " address " , [ ] { return " " ; } ) , uiSettings - > i2pControlAddressLineEdit , tr ( " I2PControl -> IP address " ) ) ;
initIPAddressBox ( OPTION ( " i2pcontrol " , " address " , [ ] { return " " ; } ) , uiSettings - > i2pControlAddressLineEdit , tr ( " I2PControl -> IP address " ) ) ;
initTCPPortBox ( OPTION ( " i2pcontrol " , " port " , [ ] { return " 7650 " ; } ) , uiSettings - > i2pControlPortLineEdit , tr ( " I2PControl -> Port " ) ) ;
initTCPPortBox ( OPTION ( " i2pcontrol " , " port " , [ ] { return " 7650 " ; } ) , uiSettings - > i2pControlPortLineEdit , tr ( " I2PControl -> Port " ) ) ;
initStringBox ( OPTION ( " i2pcontrol " , " password " , [ ] { return " " ; } ) , uiSettings - > i2pControlPasswordLineEdit ) ;
initStringBox ( OPTION ( " i2pcontrol " , " password " , [ ] { return " " ; } ) , uiSettings - > i2pControlPasswordLineEdit ) ;
initFileChooser ( OPTION ( " i2pcontrol " , " cert " , [ ] { return " i2pcontrol.crt.pem " ; } ) , uiSettings - > i2pControlCertFileLineEdit , uiSettings - > i2pControlCertFileBrowsePushButton ) ;
initFileChooser ( OPTION ( " i2pcontrol " , " cert " , [ ] { return " i2pcontrol.crt.pem " ; } ) , uiSettings - > i2pControlCertFileLineEdit , uiSettings - > i2pControlCertFileBrowsePushButton , true ) ;
initFileChooser ( OPTION ( " i2pcontrol " , " key " , [ ] { return " i2pcontrol.key.pem " ; } ) , uiSettings - > i2pControlKeyFileLineEdit , uiSettings - > i2pControlKeyFileBrowsePushButton ) ;
initFileChooser ( OPTION ( " i2pcontrol " , " key " , [ ] { return " i2pcontrol.key.pem " ; } ) , uiSettings - > i2pControlKeyFileLineEdit , uiSettings - > i2pControlKeyFileBrowsePushButton , true ) ;
initCheckBox ( OPTION ( " upnp " , " enabled " , [ ] { return " true " ; } ) , uiSettings - > enableUPnPCheckBox ) ;
initCheckBox ( OPTION ( " upnp " , " enabled " , [ ] { return " true " ; } ) , uiSettings - > enableUPnPCheckBox ) ;
initStringBox ( OPTION ( " upnp " , " name " , [ ] { return " I2Pd " ; } ) , uiSettings - > upnpNameLineEdit ) ;
initStringBox ( OPTION ( " upnp " , " name " , [ ] { return " I2Pd " ; } ) , uiSettings - > upnpNameLineEdit ) ;
@ -284,9 +289,9 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initCheckBox ( OPTION ( " precomputation " , " elgamal " , [ ] { return " false " ; } ) , uiSettings - > useElGamalPrecomputedTablesCheckBox ) ;
initCheckBox ( OPTION ( " precomputation " , " elgamal " , [ ] { return " false " ; } ) , uiSettings - > useElGamalPrecomputedTablesCheckBox ) ;
initCheckBox ( OPTION ( " reseed " , " verify " , [ ] { return " " ; } ) , uiSettings - > reseedVerifyCheckBox ) ;
initCheckBox ( OPTION ( " reseed " , " verify " , [ ] { return " " ; } ) , uiSettings - > reseedVerifyCheckBox ) ;
initFileChooser ( OPTION ( " reseed " , " file " , [ ] { return " " ; } ) , uiSettings - > reseedFileLineEdit , uiSettings - > reseedFileBrowsePushButton ) ;
initFileChooser ( OPTION ( " reseed " , " file " , [ ] { return " " ; } ) , uiSettings - > reseedFileLineEdit , uiSettings - > reseedFileBrowsePushButton , true ) ;
initStringBox ( OPTION ( " reseed " , " urls " , [ ] { return " " ; } ) , uiSettings - > reseedURLsLineEdit ) ;
initStringBox ( OPTION ( " reseed " , " urls " , [ ] { return " " ; } ) , uiSettings - > reseedURLsLineEdit ) ;
initFileChooser ( OPTION ( " reseed " , " zipfile " , [ ] { return " " ; } ) , uiSettings - > reseedZipFileLineEdit , uiSettings - > reseedZipFileBrowsePushButton ) ; //Path to local .zip file to reseed from
initFileChooser ( OPTION ( " reseed " , " zipfile " , [ ] { return " " ; } ) , uiSettings - > reseedZipFileLineEdit , uiSettings - > reseedZipFileBrowsePushButton , true ) ; //Path to local .zip file to reseed from
initUInt16Box ( OPTION ( " reseed " , " threshold " , [ ] { return " 25 " ; } ) , uiSettings - > reseedThresholdNumberLineEdit , tr ( " reseedThreshold " ) ) ; //Minimum number of known routers before requesting reseed. 25 by default
initUInt16Box ( OPTION ( " reseed " , " threshold " , [ ] { return " 25 " ; } ) , uiSettings - > reseedThresholdNumberLineEdit , tr ( " reseedThreshold " ) ) ; //Minimum number of known routers before requesting reseed. 25 by default
initStringBox ( OPTION ( " reseed " , " proxy " , [ ] { return " " ; } ) , uiSettings - > reseedProxyLineEdit ) ; //URL for https/socks reseed proxy
initStringBox ( OPTION ( " reseed " , " proxy " , [ ] { return " " ; } ) , uiSettings - > reseedProxyLineEdit ) ; //URL for https/socks reseed proxy
@ -325,7 +330,15 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
# undef OPTION
# undef OPTION
//widgetlocks.add(new widgetlock(widget,lockbtn));
//widgetlocks.add(new widgetlock(widget,lockbtn));
// #1593
# ifdef I2PD_QT_RELEASE
uiSettings - > logDestComboEditPushButton - > setEnabled ( false ) ;
# else
widgetlocks . add ( new widgetlock ( uiSettings - > logDestinationComboBox , uiSettings - > logDestComboEditPushButton ) ) ;
widgetlocks . add ( new widgetlock ( uiSettings - > logDestinationComboBox , uiSettings - > logDestComboEditPushButton ) ) ;
# endif
widgetlocks . add ( new widgetlock ( uiSettings - > logLevelComboBox , uiSettings - > logLevelComboEditPushButton ) ) ;
widgetlocks . add ( new widgetlock ( uiSettings - > logLevelComboBox , uiSettings - > logLevelComboEditPushButton ) ) ;
widgetlocks . add ( new widgetlock ( uiSettings - > comboBox_httpPorxySignatureType , uiSettings - > httpProxySignTypeComboEditPushButton ) ) ;
widgetlocks . add ( new widgetlock ( uiSettings - > comboBox_httpPorxySignatureType , uiSettings - > httpProxySignTypeComboEditPushButton ) ) ;
widgetlocks . add ( new widgetlock ( uiSettings - > comboBox_socksProxySignatureType , uiSettings - > socksProxySignTypeComboEditPushButton ) ) ;
widgetlocks . add ( new widgetlock ( uiSettings - > comboBox_socksProxySignatureType , uiSettings - > socksProxySignTypeComboEditPushButton ) ) ;
@ -649,15 +662,15 @@ MainWindow::~MainWindow()
//QMessageBox::information(0, "Debug", "mw destructor 2");
//QMessageBox::information(0, "Debug", "mw destructor 2");
}
}
FileChooserItem * MainWindow : : initFileChooser ( ConfigOption option , QLineEdit * fileNameLineEdit , QPushButton * fileBrowsePushButton ) {
FileChooserItem * MainWindow : : initFileChooser ( ConfigOption option , QLineEdit * fileNameLineEdit , QPushButton * fileBrowsePushButton , bool requireExistingFile , bool readOnly ) {
FileChooserItem * retVal ;
FileChooserItem * retVal ;
retVal = new FileChooserItem ( option , fileNameLineEdit , fileBrowsePushButton , this ) ;
retVal = new FileChooserItem ( option , fileNameLineEdit , fileBrowsePushButton , this , requireExistingFile , readOnly ) ;
MainWindowItem * super = retVal ;
MainWindowItem * super = retVal ;
configItems . append ( super ) ;
configItems . append ( super ) ;
return retVal ;
return retVal ;
}
}
void MainWindow : : initFolderChooser ( ConfigOption option , QLineEdit * folderLineEdit , QPushButton * folderBrowsePushButton ) {
void MainWindow : : initFolderChooser ( ConfigOption option , QLineEdit * folderLineEdit , QPushButton * folderBrowsePushButton ) {
configItems . append ( new FolderChooserItem ( option , folderLineEdit , folderBrowsePushButton , this ) ) ;
configItems . append ( new FolderChooserItem ( option , folderLineEdit , folderBrowsePushButton , this , true ) ) ;
}
}
/*void MainWindow::initCombobox(ConfigOption option, QComboBox* comboBox){
/*void MainWindow::initCombobox(ConfigOption option, QComboBox* comboBox){
configItems . append ( new ComboBoxItem ( option , comboBox ) ) ;
configItems . append ( new ComboBoxItem ( option , comboBox ) ) ;
@ -783,7 +796,7 @@ void MainWindow::deleteTunnelFromUI(std::string tunnelName, TunnelConfig* cnf) {
}
}
/** returns false iff not valid items present and save was aborted */
/** returns false iff not valid items present and save was aborted */
bool MainWindow : : saveAllConfigs ( bool focusOnTunnel , std : : string tunnelNameToFocus ) {
bool MainWindow : : saveAllConfigs ( bool reloadAfterSave , FocusEnum focusOn , std : : string tunnelNameToFocus , QWidget * widget ToFocus ) {
QString cannotSaveSettings = QApplication : : tr ( " Cannot save settings. " ) ;
QString cannotSaveSettings = QApplication : : tr ( " Cannot save settings. " ) ;
programOptionsWriterCurrentSection = " " ;
programOptionsWriterCurrentSection = " " ;
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
@ -803,7 +816,7 @@ bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocu
return false ;
return false ;
}
}
}
}
delayedSaveManagerPtr - > delayedSave ( + + dataSerial , focusOnTunnel , tunnelNameToFocus ) ; //TODO does dataSerial work? //FIXME
delayedSaveManagerPtr - > delayedSave ( reloadAfterSave , + + dataSerial , focusOn , tunnelNameToFocus , widget ToFocus ) ; //TODO does dataSerial work? //FIXME
//onLoggingOptionsChange();
//onLoggingOptionsChange();
return true ;
return true ;
@ -811,11 +824,14 @@ bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocu
void FileChooserItem : : pushButtonReleased ( ) {
void FileChooserItem : : pushButtonReleased ( ) {
QString fileName = lineEdit - > text ( ) . trimmed ( ) ;
QString fileName = lineEdit - > text ( ) . trimmed ( ) ;
fileName = QFileDialog : : getOpenFileName ( nullptr , tr ( " Open File " ) , fileName , tr ( " All Files (*.*) " ) ) ;
fileName = requireExistingFile ?
QFileDialog : : getOpenFileName ( nullptr , tr ( " Open File " ) , fileName , tr ( " All Files (*.*) " ) ) :
QFileDialog : : getSaveFileName ( nullptr , tr ( " Open File " ) , fileName , tr ( " All Files (*.*) " ) ) ;
if ( fileName . length ( ) > 0 ) lineEdit - > setText ( fileName ) ;
if ( fileName . length ( ) > 0 ) lineEdit - > setText ( fileName ) ;
}
}
void FolderChooserItem : : pushButtonReleased ( ) {
void FolderChooserItem : : pushButtonReleased ( ) {
QString fileName = lineEdit - > text ( ) . trimmed ( ) ;
QString fileName = lineEdit - > text ( ) . trimmed ( ) ;
assert ( requireExistingFile ) ;
fileName = QFileDialog : : getExistingDirectory ( nullptr , tr ( " Open Folder " ) , fileName ) ;
fileName = QFileDialog : : getExistingDirectory ( nullptr , tr ( " Open Folder " ) , fileName ) ;
if ( fileName . length ( ) > 0 ) lineEdit - > setText ( fileName ) ;
if ( fileName . length ( ) > 0 ) lineEdit - > setText ( fileName ) ;
}
}
@ -841,7 +857,7 @@ void MainWindow::updated() {
bool correct = applyTunnelsUiToConfigs ( ) ;
bool correct = applyTunnelsUiToConfigs ( ) ;
if ( ! correct ) return ;
if ( ! correct ) return ;
saveAllConfigs ( false ) ;
saveAllConfigs ( false , FocusEnum : : noFocus ) ;
}
}
void MainWindowItem : : installListeners ( MainWindow * mainWindow ) { }
void MainWindowItem : : installListeners ( MainWindow * mainWindow ) { }
@ -916,11 +932,11 @@ bool MainWindow::applyTunnelsUiToConfigs() {
return true ;
return true ;
}
}
void MainWindow : : reloadTunnelsConfigAndUI_QString ( const QString tunnelNameToFocus ) {
void MainWindow : : reloadTunnelsConfigAndUI_QString ( QString tunnelNameToFocus ) {
reloadTunnelsConfigAndUI ( tunnelNameToFocus . toStdString ( ) ) ;
reloadTunnelsConfigAndUI ( tunnelNameToFocus . toStdString ( ) , nullptr ) ;
}
}
void MainWindow : : reloadTunnelsConfigAndUI ( std : : string tunnelNameToFocus ) {
void MainWindow : : reloadTunnelsConfigAndUI ( std : : string tunnelNameToFocus , QWidget * widgetToFocus ) {
deleteTunnelForms ( ) ;
deleteTunnelForms ( ) ;
for ( std : : map < std : : string , TunnelConfig * > : : iterator it = tunnelConfigs . begin ( ) ; it ! = tunnelConfigs . end ( ) ; + + it ) {
for ( std : : map < std : : string , TunnelConfig * > : : iterator it = tunnelConfigs . begin ( ) ; it ! = tunnelConfigs . end ( ) ; + + it ) {
TunnelConfig * tunconf = it - > second ;
TunnelConfig * tunconf = it - > second ;
@ -937,8 +953,10 @@ void MainWindow::TunnelsPageUpdateListenerMainWindowImpl::updated(std::string ol
std : : map < std : : string , TunnelConfig * > : : const_iterator it = mainWindow - > tunnelConfigs . find ( oldName ) ;
std : : map < std : : string , TunnelConfig * > : : const_iterator it = mainWindow - > tunnelConfigs . find ( oldName ) ;
if ( it ! = mainWindow - > tunnelConfigs . end ( ) ) mainWindow - > tunnelConfigs . erase ( it ) ;
if ( it ! = mainWindow - > tunnelConfigs . end ( ) ) mainWindow - > tunnelConfigs . erase ( it ) ;
mainWindow - > tunnelConfigs [ tunConf - > getName ( ) ] = tunConf ;
mainWindow - > tunnelConfigs [ tunConf - > getName ( ) ] = tunConf ;
mainWindow - > saveAllConfigs ( true , FocusEnum : : focusOnTunnelName , tunConf - > getName ( ) ) ;
}
}
mainWindow - > saveAllConfigs ( true , tunConf - > getName ( ) ) ;
else
mainWindow - > saveAllConfigs ( false , FocusEnum : : noFocus ) ;
}
}
void MainWindow : : TunnelsPageUpdateListenerMainWindowImpl : : needsDeleting ( std : : string oldName ) {
void MainWindow : : TunnelsPageUpdateListenerMainWindowImpl : : needsDeleting ( std : : string oldName ) {
@ -976,17 +994,68 @@ void MainWindow::anchorClickedHandler(const QUrl & link) {
qDebug ( ) < < debugStr ;
qDebug ( ) < < debugStr ;
//QMessageBox::information(this, "", debugStr);
//QMessageBox::information(this, "", debugStr);
/* /?page=local_destination&b32=xx...xx */
QString str = link . toString ( ) ;
QString str = link . toString ( ) ;
# define LOCAL_DEST_B32_PREFIX " / ?page=local_destination&b32="
std : : map < std : : string , std : : string > params ;
static size_t LOCAL_DEST_B32_PREFIX_SZ = QString ( LOCAL_DEST_B32_PREFIX ) . size ( ) ;
i2p : : http : : URL url ;
if ( str . startsWith ( LOCAL_DEST_B32_PREFIX ) ) {
url . parse ( str . toStdString ( ) ) ;
str = str . right ( str . size ( ) - LOCAL_DEST_B32_PREFIX_SZ ) ;
url . parse_query ( params ) ;
qDebug ( ) < < " b32: " < < str ;
const std : : string page = params [ " page " ] ;
const std : : string cmd = params [ " cmd " ] ;
if ( page = = " sam_session " ) {
pageWithBackButton - > show ( ) ;
textBrowser - > hide ( ) ;
std : : stringstream s ;
i2p : : http : : ShowSAMSession ( s , params [ " sam_id " ] ) ;
childTextBrowser - > setHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
} else if ( page = = " local_destination " ) {
std : : string b32 = params [ " b32 " ] ;
currentLocalDestinationB32 = b32 ;
pageWithBackButton - > show ( ) ;
pageWithBackButton - > show ( ) ;
textBrowser - > hide ( ) ;
textBrowser - > hide ( ) ;
std : : stringstream s ;
std : : stringstream s ;
std : : string strstd = str . toStdString ( ) ;
std : : string strstd = currentLocalDestinationB32 ;
i2p : : http : : ShowLocalDestination ( s , strstd , 0 ) ;
childTextBrowser - > setHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
} else if ( page = = " i2cp_local_destination " ) {
pageWithBackButton - > show ( ) ;
textBrowser - > hide ( ) ;
std : : stringstream s ;
i2p : : http : : ShowI2CPLocalDestination ( s , params [ " i2cp_id " ] ) ;
childTextBrowser - > setHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
} else if ( cmd = = " closestream " ) {
std : : string b32 = params [ " b32 " ] ;
uint32_t streamID = std : : stoul ( params [ " streamID " ] , nullptr ) ;
i2p : : data : : IdentHash ident ;
ident . FromBase32 ( b32 ) ;
auto dest = i2p : : client : : context . FindLocalDestination ( ident ) ;
if ( streamID ) {
if ( dest ) {
if ( dest - > DeleteStream ( streamID ) )
QMessageBox : : information (
this ,
QApplication : : tr ( " Success " ) ,
QApplication : : tr ( " <HTML><b>SUCCESS</b>: Stream closed " ) ) ;
else
QMessageBox : : critical (
this ,
QApplication : : tr ( " Error " ) ,
QApplication : : tr ( " <HTML><b>ERROR</b>: Stream not found or already was closed " ) ) ;
}
else
QMessageBox : : critical (
this ,
QApplication : : tr ( " Error " ) ,
QApplication : : tr ( " <HTML><b>ERROR</b>: Destination not found " ) ) ;
}
else
QMessageBox : : critical (
this ,
QApplication : : tr ( " Error " ) ,
QApplication : : tr ( " <HTML><b>ERROR</b>: StreamID is null " ) ) ;
std : : stringstream s ;
std : : string strstd = currentLocalDestinationB32 ;
i2p : : http : : ShowLocalDestination ( s , strstd , 0 ) ;
i2p : : http : : ShowLocalDestination ( s , strstd , 0 ) ;
childTextBrowser - > setHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
childTextBrowser - > setHtml ( QString : : fromStdString ( s . str ( ) ) ) ;
}
}